Ah, so I misunderstood the documentation.

Thanks for the answer.

I suspect the behaviour of play.golang.org is due to the fake time as part 
of the sandboxing

//Jens 

Am Montag, 14. Mai 2018 11:12:07 UTC+2 schrieb Jakob Borg:
>
> 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 <jabb...@gmail.com <javascript:>> 
> 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 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 golang-nuts...@googlegroups.com <javascript:>.
> 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 golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to