MCPcopy Create free account
hub / github.com/apache/fory / DateToEpochDay

Function DateToEpochDay

go/fory/time.go:100–115  ·  view source on GitHub ↗

DateToEpochDay converts a Date to its day offset from the Unix epoch.

(date Date)

Source from the content-addressed store, hash-verified

98
99// DateToEpochDay converts a Date to its day offset from the Unix epoch.
100func DateToEpochDay(date Date) (int64, error) {
101 year := int64(date.Year)
102 if date.Month < time.January || date.Month > time.December {
103 return 0, SerializationErrorf("invalid date month %d", date.Month)
104 }
105 maxDay := daysInMonth(year, date.Month)
106 if date.Day < 1 || date.Day > maxDay {
107 return 0, SerializationErrorf(
108 "invalid date day %d for %d-%02d",
109 date.Day,
110 date.Year,
111 int(date.Month),
112 )
113 }
114 return daysFromCivil(year, date.Month, int64(date.Day)), nil
115}
116
117// DateFromEpochDay converts a Unix-epoch day offset to a Date.
118func DateFromEpochDay(days int64) (Date, error) {

Callers 3

WriteDataMethod · 0.85

Calls 4

SerializationErrorfFunction · 0.85
daysInMonthFunction · 0.85
daysFromCivilFunction · 0.85
int64Function · 0.50