Truncate(0) is not supposed to remove the nanoseconds part; it removes the 
monotonic time part. It just happens that the nanoseconds are zero on the 
"clock" on play:

https://play.golang.org/p/Kdq_SDTi664

To remove the subsecond part use .Truncate(time.Second) (or the corresponding 
Round of course)

//jb

On 14 May 2018, at 08:55, Jens Hausherr 
<[email protected]<mailto:[email protected]>> wrote:

Hi, here is something I have been puzzled for a few days now.

On my OSX machine rounding/truncating of time.Time values apparently does not 
remove the nanoseconds component as documented when calling 
Truncate(0)/Round(0).


On play.golang.org<http://play.golang.org> it works as expected: 
https://play.golang.org/p/NXyhK5v9Rwe (Although it might be misleading as it 
seems to be stuck in 2009 still).

The same code run on my local machine (OSX, go 1.10.2) outputs:

2018-05-14 08:50:02.291049227 +0200 CEST m=+0.000501271
2018-04-14 06:50:02.291049227 +0000 UTC
2018-04-29 06:50:02.291049227 +0000 UTC
2018-05-13 06:50:02.291049227 +0000 UTC

So the nanoseconds persist through UTC conversion and truncating the ns value.

Regards,
Jens




--
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 
[email protected]<mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to