]> Cypherpunks repositories - gostls13.git/commit
time: show how to get midnight on the current day
authorKevin Burke <kev@inburke.com>
Tue, 27 Jun 2017 18:36:32 +0000 (11:36 -0700)
committerKevin Burke <kev@inburke.com>
Wed, 28 Jun 2017 18:12:46 +0000 (18:12 +0000)
commite1ced3219506938daf404bb2373333cd3352f350
tree3e9b45c19c95d338cfd050ea8ad995d535a39cb0
parent4e9c86ab8e9faf6da9864db6ad81d396f3f55379
time: show how to get midnight on the current day

A common task is trying to get today's date in the local time zone
with zero values for the hour, minute, second, and nanosecond fields.
I tried this recently and incorrectly used Truncate(24*time.Hour),
which truncates based on a UTC clock, and gave me 5pm Pacific time
instead of midnight Pacific.

I thought it would be helpful to show a "correct" way to do this.

Change-Id: I479e6b0cc56367068530981ca69882b34febf945
Reviewed-on: https://go-review.googlesource.com/46833
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/time/example_test.go