Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(288)

Issue 6903050: code review 6903050: time: add Round and Truncate (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 4 months ago by rsc
Modified:
11 years, 4 months ago
Reviewers:
iant, remyoudompheng
CC:
golang-dev, bradfitz, iant, remyoudompheng
Visibility:
Public.

Description

time: add Round and Truncate New in Go 1 will be nanosecond precision in the result of time.Now on Linux. This will break code that stores time in external formats at microsecond precision, reads it back, and expects to get exactly the same time. Code like that can be fixed by using time.Now().Round(time.Microsecond) instead of time.Now() in those contexts.

Patch Set 1 #

Patch Set 2 : diff -r 477b2e70b12d https://go.googlecode.com/hg/ #

Total comments: 13

Patch Set 3 : diff -r 6b602ab487d6 https://code.google.com/p/go/ #

Total comments: 1

Patch Set 4 : diff -r 6b602ab487d6 https://code.google.com/p/go/ #

Patch Set 5 : diff -r 6b602ab487d6 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+361 lines, -0 lines) Patch
M doc/go1.1.html View 1 1 chunk +14 lines, -0 lines 0 comments Download
M src/pkg/time/example_test.go View 1 2 1 chunk +55 lines, -0 lines 0 comments Download
M src/pkg/time/time.go View 1 2 1 chunk +113 lines, -0 lines 0 comments Download
M src/pkg/time/time_test.go View 1 2 3 4 2 chunks +179 lines, -0 lines 0 comments Download

Messages

Total messages: 12
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
11 years, 4 months ago (2012-12-07 18:35:19 UTC) #1
rsc
Rob signed off on the API but I'd like someone to review the code, especially ...
11 years, 4 months ago (2012-12-07 22:26:09 UTC) #2
bradfitz
s/precision/resolution/g? On Fri, Dec 7, 2012 at 10:35 AM, <rsc@golang.org> wrote: > Reviewers: golang-dev_googlegroups.com, > ...
11 years, 4 months ago (2012-12-07 22:36:00 UTC) #3
iant
LGTM
11 years, 4 months ago (2012-12-08 08:35:52 UTC) #4
remyoudompheng
https://codereview.appspot.com/6903050/diff/3/src/pkg/time/time.go File src/pkg/time/time.go (right): https://codereview.appspot.com/6903050/diff/3/src/pkg/time/time.go#newcode1037 src/pkg/time/time.go:1037: // Truncate returns the result of rounding t down ...
11 years, 4 months ago (2012-12-08 09:51:50 UTC) #5
remyoudompheng
https://codereview.appspot.com/6903050/diff/3/src/pkg/time/example_test.go File src/pkg/time/example_test.go (right): https://codereview.appspot.com/6903050/diff/3/src/pkg/time/example_test.go#newcode60 src/pkg/time/example_test.go:60: func ExampleTime_Round() { there should be a test demonstrating ...
11 years, 4 months ago (2012-12-08 09:56:07 UTC) #6
remyoudompheng
Another example of how "round-even" may have an unclear meaning. Suppose I am calling t.Round(time.Hour). ...
11 years, 4 months ago (2012-12-08 23:01:16 UTC) #7
rsc
On 2012/12/08 23:01:16, remyoudompheng wrote: > Another example of how "round-even" may have an unclear ...
11 years, 4 months ago (2012-12-09 06:58:34 UTC) #8
rsc
@bradfitz: we use precision elsewhere in the package instead of resolution https://codereview.appspot.com/6903050/diff/3/src/pkg/time/time.go File src/pkg/time/time.go (right): ...
11 years, 4 months ago (2012-12-09 06:59:09 UTC) #9
rsc
PTAL rémy
11 years, 4 months ago (2012-12-09 07:00:06 UTC) #10
remyoudompheng
LGTM after the test fix https://codereview.appspot.com/6903050/diff/4/src/pkg/time/time_test.go File src/pkg/time/time_test.go (right): https://codereview.appspot.com/6903050/diff/4/src/pkg/time/time_test.go#newcode340 src/pkg/time/time_test.go:340: for Second%d == 0 ...
11 years, 4 months ago (2012-12-09 08:24:07 UTC) #11
rsc
11 years, 4 months ago (2012-12-09 08:59:41 UTC) #12
*** Submitted as https://code.google.com/p/go/source/detail?r=ea15e7ed6d72 ***

time: add Round and Truncate

New in Go 1 will be nanosecond precision in the result of time.Now on Linux.
This will break code that stores time in external formats at microsecond
precision, reads it back, and expects to get exactly the same time.

Code like that can be fixed by using time.Now().Round(time.Microsecond)
instead of time.Now() in those contexts.

R=golang-dev, bradfitz, iant, remyoudompheng
CC=golang-dev
https://codereview.appspot.com/6903050
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b