Comparison
Ordering and equality for Date values.
func (d Date) Before(other Date) boolReports whether d is chronologically before other. Compares fields directly and does not require either date to be valid.
func (d Date) After(other Date) boolReports whether d is chronologically after other. Same validity note as Before.
func (d Date) Equal(other Date) boolReports whether d and other represent the same calendar date.
func Compare(a, b Date) intCompares two dates: -1 if a is before b, 0 if they're equal, 1 if a is after b. Same
field-only comparison as Before/After.
Example
a, _ := bs.NewDate(2083, 6, 6)
b, _ := bs.NewDate(2083, 6, 7)
a.Before(b) // true
b.After(a) // true
a.Equal(a) // true
bs.Compare(a, b) // -1
bs.Compare(a, a) // 0Since Date is a plain comparable struct, a == b also works directly (that's exactly what
Equal does) — the named methods exist for readability and so a Date slice can be sorted with
slices.SortFunc using Compare.