MCPcopy Create free account
hub / github.com/dolthub/doltgresql / MakeCompatibleDateFromDisk

Function MakeCompatibleDateFromDisk

postgres/parser/pgdate/pgdate.go:93–109  ·  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

91// compatibility. It retains the origin days argument which is returned
92// by UnixEpochDaysWithOrig.
93func MakeCompatibleDateFromDisk(unixDays int64) Date {
94 date := Date{
95 hasOrig: true,
96 orig: unixDays,
97 }
98 if pgDays, ok := utils.SubWithOverflow(unixDays, unixEpochToPGEpoch); !ok {
99 // We overflowed converting from Unix to PG days.
100 date.days = math.MinInt32
101 } else if pgDays > highDays {
102 date.days = math.MaxInt32
103 } else if pgDays < lowDays {
104 date.days = math.MinInt32
105 } else {
106 date.days = int32(pgDays)
107 }
108 return date
109}
110
111// MakeDateFromTime creates a Date from the specified time. The
112// timezone-relative date is used.

Callers 1

SampleDatumFunction · 0.92

Calls 1

SubWithOverflowFunction · 0.92

Tested by

no test coverage detected