MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / MakeCompatibleDateFromDisk

Function MakeCompatibleDateFromDisk

pkg/util/timeutil/pgdate/pgdate.go:80–96  ·  view source on GitHub ↗

MakeCompatibleDateFromDisk creates a Date from the number of days since the Unix epoch. If it is out of range of LowDate and HighDate, positive or negative infinity dates are returned. This function should be used only by the on-disk decoder to maintain backward compatibility. It retains the origin

(unixDays int64)

Source from the content-addressed store, hash-verified

78// compatibility. It retains the origin days argument which is returned
79// by UnixEpochDaysWithOrig.
80func MakeCompatibleDateFromDisk(unixDays int64) Date {
81 date := Date{
82 hasOrig: true,
83 orig: unixDays,
84 }
85 if pgDays, ok := arith.SubWithOverflow(unixDays, unixEpochToPGEpoch); !ok {
86 // We overflowed converting from Unix to PG days.
87 date.days = math.MinInt32
88 } else if pgDays > highDays {
89 date.days = math.MaxInt32
90 } else if pgDays < lowDays {
91 date.days = math.MinInt32
92 } else {
93 date.days = int32(pgDays)
94 }
95 return date
96}
97
98// MakeDateFromTime creates a Date from the specified time. The
99// timezone-relative date is used.

Callers 1

SampleDatumFunction · 0.92

Calls 1

SubWithOverflowFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…