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)
| 78 | // compatibility. It retains the origin days argument which is returned |
| 79 | // by UnixEpochDaysWithOrig. |
| 80 | func 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. |
no test coverage detected
searching dependent graphs…