You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I realise that this library is really old (or rather grown-up) and wide-spread. This make my question awkward, but here it is.
Looking at the code, I've stumbled over the semantics of the End functions, which define the end of a period as 1ns before the start of the next period. That seems odd:
mathematically a time period would usually be described as half-open interval [start, end) where end is actually the beginning of the next period
1ns difference is a somewhat arbitrary choice, simply being the smallest time increment that Go can handle
A similar pattern can be found in the Between function. I would have expected that something between begin of, say, a day and end of day would be anything on the same date, but that's not what Between does:
// Between check time between the begin, end time or notfunc (now*Now) Between(begin, endstring) bool {
beginTime:=now.MustParse(begin)
endTime:=now.MustParse(end)
returnnow.After(beginTime) &&now.Before(endTime)
}
This excludes start of day in this example and it also excludes the last nanosecond of the day according to the End semantics. The imho "proper" way to write this would have been:
Your Question
I realise that this library is really old (or rather grown-up) and wide-spread. This make my question awkward, but here it is.
Looking at the code, I've stumbled over the semantics of the
End
functions, which define the end of a period as 1ns before the start of the next period. That seems odd:A similar pattern can be found in the
Between
function. I would have expected that something between begin of, say, a day and end of day would be anything on the same date, but that's not whatBetween
does:This excludes start of day in this example and it also excludes the last nanosecond of the day according to the
End
semantics. The imho "proper" way to write this would have been:So my question is: why has the
End
semantic been chosen that way?Expected answer
Enlightenment and saying thank you for a wonderful and elegant library!
The text was updated successfully, but these errors were encountered: