• Kevin Burke's avatar
    time: show how to get midnight on the current day · e1ced321
    Kevin Burke authored
    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/46833Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    e1ced321
Name
Last commit
Last update
..
example_test.go Loading commit data...
export_android_test.go Loading commit data...
export_test.go Loading commit data...
export_windows_test.go Loading commit data...
format.go Loading commit data...
format_test.go Loading commit data...
genzabbrs.go Loading commit data...
internal_test.go Loading commit data...
mono_test.go Loading commit data...
sleep.go Loading commit data...
sleep_test.go Loading commit data...
sys_plan9.go Loading commit data...
sys_unix.go Loading commit data...
sys_windows.go Loading commit data...
tick.go Loading commit data...
tick_test.go Loading commit data...
time.go Loading commit data...
time_test.go Loading commit data...
zoneinfo.go Loading commit data...
zoneinfo_abbrs_windows.go Loading commit data...
zoneinfo_android.go Loading commit data...
zoneinfo_android_test.go Loading commit data...
zoneinfo_ios.go Loading commit data...
zoneinfo_plan9.go Loading commit data...
zoneinfo_read.go Loading commit data...
zoneinfo_test.go Loading commit data...
zoneinfo_unix.go Loading commit data...
zoneinfo_windows.go Loading commit data...
zoneinfo_windows_test.go Loading commit data...