Whoops, you're right. I got my Time and Duration mixed up. Your question 
still stands, though. The section on Monotonic Clocks at 
https://pkg.go.dev/time?tab=doc is a bit dense, but my best guess is that 
stripping the monotonic clock reading from the Expiry ensures that the 
comparison is made against the actual wall clock time (in the past) vs some 
unknown adjusted time, which might be earlier or later than the intended 
time and thus give incorrect results.

s


On Monday, April 20, 2020 at 7:16:30 AM UTC-7, ISE Development wrote:
>
> On Monday, 20 April 2020 15:04:54 UTC+1, crate...@gmail.com wrote:
>>
>> According to https://golang.org/pkg/time/#Duration.Round "If m <= 0, 
>> Round returns d unchanged". So now I'm really curious, why do the Round() 
>> at all?
>>
>
> But in this case, it's a time.Time value, so this applies (
> https://pkg.go.dev/time?tab=doc#Time.Round):
>
> Round returns the result of rounding t to the nearest multiple of d (since 
>> the zero time). The rounding behavior for halfway values is to round up. If 
>> d <= 0, Round returns t stripped of any monotonic clock reading but 
>> otherwise unchanged. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/f871298a-f06d-4e9f-ad20-ee145cdd8004%40googlegroups.com.

Reply via email to