Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/time/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ func (t *Time) mono() int64 {
// IsZero reports whether t represents the zero time instant,
// January 1, year 1, 00:00:00 UTC.
func (t Time) IsZero() bool {
return t.sec() == 0 && t.nsec() == 0
// If hasMonotonic is set in t.wall, then the time can't be before 1885, so it can't be the year 1.
// If hasMonotonic is zero, then all the bits in wall other than the nanoseconds field should be 0.
// So if there are no nanoseconds then t.wall == 0, and if there are no seconds then t.ext == 0.
// This is equivalent to t.sec() == 0 && t.nsec() == 0, but is more efficient.
return t.wall == 0 && t.ext == 0
}

// After reports whether the time instant t is after u.
Expand Down