summaryrefslogtreecommitdiff
path: root/src/time
Commit message (Collapse)AuthorAgeFilesLines
* time: fix 400 years offset in commentAlberto Donizetti2017-07-171-1/+1
| | | | | | | | Fixes #21043 Change-Id: I12db4f67ddee80500ff323f84e8fa34511650e63 Reviewed-on: https://go-review.googlesource.com/49230 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* time: clarify documentation for Location.StringPat Moroney2017-07-151-1/+1
| | | | | | | Change-Id: I5c32a968303848304cbd6fe1e83bed0af11f6440 Reviewed-on: https://go-review.googlesource.com/48960 Reviewed-by: Caleb Spare <cespare@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* time: document the Time.String is meant for debuggingBrad Fitzpatrick2017-07-061-0/+4
| | | | | | | | | Fixes #20876 Change-Id: Ic62c4f59e3ddcae891aa9526f9693d233dd524fc Reviewed-on: https://go-review.googlesource.com/47552 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
* time: warn that RFC3339Nano does not guarantee a natural orderingBrad Fitzpatrick2017-06-291-0/+2
| | | | | | | | Fixes #19635 Change-Id: I85e725dbc85843afd0f4d82f5127fecacc1cb524 Reviewed-on: https://go-review.googlesource.com/47090 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* time: show how to get midnight on the current dayKevin Burke2017-06-281-0/+3
| | | | | | | | | | | | | | | | 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>
* time: fix example in monotonic time commentRuss Cox2017-06-281-3/+3
| | | | | | | | | | | | | t.Sub(u) would be -20 milliseconds. The right computation is u.Sub(t), but rewrite to be even clearer. Thanks to Karsten Weiss for catching this. Change-Id: I6e274d69b0301840d57c5c65bf4114da0d33bf10 Reviewed-on: https://go-review.googlesource.com/46971 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* time: remove some redundant equality comparison documentationBrad Fitzpatrick2017-06-141-9/+4
| | | | | | | | | | Updates to CL 45698 Updates #19510 Change-Id: Iec7a455b6c4d5f96d0b674459bf1455c99102d62 Reviewed-on: https://go-review.googlesource.com/45779 Reviewed-by: Rob Pike <r@golang.org>
* time: unify the Time.Equals vs == pitfall documentationBrad Fitzpatrick2017-06-141-13/+19
| | | | | | | | Fixes #19510 (good details therein) Change-Id: Id28b66d91435d839fd79eeed486527cc77257c12 Reviewed-on: https://go-review.googlesource.com/45698 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* time: run genzabbrs.go to update zoneinfo_abbrs_windows.goAlex Brainman2017-06-132-88/+92
| | | | | | | | | Last time zoneinfo_abbrs_windows.go was updated in CL 27832. Time for another update. Change-Id: I8dc3a1de6f22e90e634b2176188f257a260b6463 Reviewed-on: https://go-review.googlesource.com/45450 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* all: single space after periodBrad Fitzpatrick2017-06-091-8/+8
| | | | | | | | | | | Done with grep & interactive search & replace, to double-check replacements. Not many remained after CL 20022. Fixes #18572 Change-Id: Idbe90ba3b584f9b9661d2bbd141607daaadfa41a Reviewed-on: https://go-review.googlesource.com/45270 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
* time: vendor tzdata-2017b and update testAlberto Donizetti2017-06-071-2/+2
| | | | | | | | | | | | | | | | | | This change updates the vendored tzdata database to version 2017b (released 2017-03-20). The TestFirstZone test (which always uses the vendored database) is updated to make it work with the new timezones database. (The Tokelau abbreviation was changed from 'TKT' to the numeric abbreviation in tzdata-2017a) Fixes #19376 Change-Id: I0dea93e8703992de5c92c7840b8bacad9d02c50d Reviewed-on: https://go-review.googlesource.com/44832 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* time: strip monotonic clock reading in t.UTC, t.Local, t.InRuss Cox2017-06-062-6/+8
| | | | | | | | | | Fixes #18991. Change-Id: I46ded007b0c6a6e1173a55f3938007ab3a928dd9 Reviewed-on: https://go-review.googlesource.com/44858 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
* time: update docs to clarify goroutine-safety expectations of TimeNicholas Maniscalco2017-05-241-2/+5
| | | | | | | | Fixes #19935 Change-Id: I28e4cd6924f1b965a429a6a5ebfc4c0f952e8ae6 Reviewed-on: https://go-review.googlesource.com/40390 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* all: remove some unused parameters in test codeDaniel Martí2017-04-251-2/+2
| | | | | | | | | | | | Mostly unnecessary *testing.T arguments. Found with github.com/mvdan/unparam. Change-Id: Ifb955cb88f2ce8784ee4172f4f94d860fa36ae9a Reviewed-on: https://go-review.googlesource.com/41691 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* testing/quick: generate all possible int64, uint64 valuesRuss Cox2017-04-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | When generating a random int8, uint8, int16, uint16, int32, uint32, quick.Value chooses among all possible values. But when generating a random int64 or uint64, it only chooses values in the range [-2⁶², 2⁶²) (even for uint64). It should, like for all the other integers, use the full range. If it had, this would have caught #19807 earlier. Instead it let us discover the presence of #19809. While we are here, also make the default source of randomness not completely deterministic. Fixes #19808. Change-Id: I070f852531c92b3670bd76523326c9132bfc9416 Reviewed-on: https://go-review.googlesource.com/39152 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* time: test and fix Time.Round, Duration.Round for d > 2⁶²Russ Cox2017-03-312-3/+11
| | | | | | | | | | | | | | | | | | | Round uses r+r < d to decide whether the remainder is above or below half of d (to decide whether to round up or down). This is wrong when r+r wraps negative, because it looks < d but is really > d. No one will ever care about rounding to a multiple of d > 2⁶² (about 146 years), but might as well get it right. Fixes #19807. Change-Id: I1b55a742dc36e02a7465bc778bf5dd74fe71f7c0 Reviewed-on: https://go-review.googlesource.com/39151 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* time: make the ParseInLocation test more robustAlberto Donizetti2017-03-091-10/+31
| | | | | | | | | | | | | | | | | The tzdata 2017a update (2017-02-28) changed the abbreviation of the Asia/Baghdad time zone (used in TestParseInLocation) from 'AST' to the numeric '+03'. Update the test so that it skips the checks if we're using a recent tzdata release. Fixes #19457 Change-Id: I45d705a5520743a611bdd194dc8f8d618679980c Reviewed-on: https://go-review.googlesource.com/37964 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* time: strip monotonic time in t.Round, t.TruncateRuss Cox2017-03-022-12/+19
| | | | | | | | | | | | | | | | The original analysis of the Go corpus assumed that these stripped monotonic time. During the design discussion we decided to try not stripping monotonic time here, but existing code works better if we do. See the discussion on golang.org/issue/18991 for more details. For #18991. Change-Id: I04d355ffe56ca0317acdd2ca76cb3033c277f6d1 Reviewed-on: https://go-review.googlesource.com/37542 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* time: add Duration.Truncate and Duration.RoundCaleb Spare2017-02-142-0/+98
| | | | | | | | | | Fixes #18996 Change-Id: I0b0f7270960b368ce97ad4456f60bcc1fc2a8313 Reviewed-on: https://go-review.googlesource.com/36615 Run-TryBot: Caleb Spare <cespare@gmail.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* time: optimize Now on darwin, windowsRuss Cox2017-02-092-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fetch both monotonic and wall time together when possible. Avoids skew and is cheaper. Also shave a few ns off in conversion in package time. Compared to current implementation (after monotonic changes): name old time/op new time/op delta Now 19.6ns ± 1% 9.7ns ± 1% -50.63% (p=0.000 n=41+49) darwin/amd64 Now 23.5ns ± 4% 10.6ns ± 5% -54.61% (p=0.000 n=30+28) windows/amd64 Now 54.5ns ± 5% 29.8ns ± 9% -45.40% (p=0.000 n=27+29) windows/386 More importantly, compared to Go 1.8: name old time/op new time/op delta Now 9.5ns ± 1% 9.7ns ± 1% +1.94% (p=0.000 n=41+49) darwin/amd64 Now 12.9ns ± 5% 10.6ns ± 5% -17.73% (p=0.000 n=30+28) windows/amd64 Now 15.3ns ± 5% 29.8ns ± 9% +94.36% (p=0.000 n=30+29) windows/386 This brings time.Now back in line with Go 1.8 on darwin/amd64 and windows/amd64. It's not obvious why windows/386 is still noticeably worse than Go 1.8, but it's better than before this CL. The windows/386 speed is not too important; the changes just keep the two architectures similar. Change-Id: If69b94970c8a1a57910a371ee91e0d4e82e46c5d Reviewed-on: https://go-review.googlesource.com/36428 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* time: format negative monotonic times correctly in Time.StringCaleb Spare2017-02-092-25/+27
| | | | | | | | | | | Fixes #18993 Change-Id: Ia1fa20b6d82384b07e9ba5512b909439e0bec2a5 Reviewed-on: https://go-review.googlesource.com/36611 Run-TryBot: Caleb Spare <cespare@gmail.com> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* time: bound file reads and validate LoadLocation argumentBrad Fitzpatrick2017-02-088-2/+81
| | | | | | | | Fixes #18985 Change-Id: I956117f47d1d2b453b4786c7b78c1c944defeca0 Reviewed-on: https://go-review.googlesource.com/36551 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* time: delete incorrect docs about day-of-month checks.Sameer Ajmani2017-02-071-5/+0
| | | | | | | | | | | | Documentation was introduced by CL https://golang.org/cl/14123 but that behavior was changed later by CL https://golang.org/cl/17710. This CL deletes the stale paragraph. Fixes #18980 Change-Id: Ib434f1eac6fc814fde1be112a8f52afe6e3e0fcc Reviewed-on: https://go-review.googlesource.com/36532 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* time: Fix typo in Time.String() description.Alexey Palazhchenko2017-02-051-2/+2
| | | | | | | | Refs #12914. Change-Id: Iadac4cbef70db6a95b47f86eaffcfc63bfdb8e90 Reviewed-on: https://go-review.googlesource.com/36334 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* time: record monotonic clock reading in time.Now, for more accurate comparisonsRuss Cox2017-02-037-60/+550
| | | | | | | | | | | | | See https://golang.org/design/12914-monotonic for details. Fixes #12914. Change-Id: I80edc2e6c012b4ace7161c84cf067d444381a009 Reviewed-on: https://go-review.googlesource.com/36255 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Caleb Spare <cespare@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* time: defer loading ZONEINFO until first time.LoadLocation callJeff Johnson2017-02-013-3/+43
| | | | | | | | | | | | | A user application can now use os.Setenv("ZONEINFO", ..) becase the value is no longer read on init of the time package. Fixes #18619 Change-Id: Id8e303d67e6fb9c5d6ea9f969d8c94f6fff1bee3 Reviewed-on: https://go-review.googlesource.com/35639 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* time: parse WITA timezone correctlyMax Riveiro2016-12-122-2/+4
| | | | | | | | | | | | | WITA stands for Asia/Makassar IANA timezone https://en.wikipedia.org/wiki/Asia/Makassar Fixes #18251 Change-Id: I5896efb8052593afb4e51ae4a34b574a8206d4dc Reviewed-on: https://go-review.googlesource.com/34253 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* time: make Parse validate day's lower bound in addition to upper boundBrad Fitzpatrick2016-11-222-1/+2
| | | | | | | | | | | | Day 0 is as invalid as day 32. Fixes #17874 Change-Id: I52109d12bafd6d957d00c44d540cb88389fff0a7 Reviewed-on: https://go-review.googlesource.com/33429 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* time: simplify stringification of MonthMartin Möhrmann2016-11-121-7/+3
| | | | | | | | | | | Simplifies https://golang.org/cl/33145 which fixed #17720. Change-Id: Ib922d493cdc5920832dc95b55094796baca7243e Reviewed-on: https://go-review.googlesource.com/33194 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* time: use 1e9 rather than 1e-9 in Duration calculationsIan Lance Taylor2016-11-122-3/+20
| | | | | | | | | | | 1e-9 has a 1 in the last place, causing some Duration calculations to have unnecessary rounding errors. 1e9 does not, so use that instead. Change-Id: I96334a2c47e7a014b532eb4b8a3ef9550e7ed057 Reviewed-on: https://go-review.googlesource.com/33116 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* time: don't panic stringifying the zero MonthBrad Fitzpatrick2016-11-112-3/+21
| | | | | | | | | | | Fixes #17720 Change-Id: Ib95c230deef3934db729856c17908f8e5a1e2b7f Reviewed-on: https://go-review.googlesource.com/33145 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* time: update Timer.Stop doc to account for AfterFuncRuss Cox2016-11-111-1/+7
| | | | | | | | | | Fixes #17600. Change-Id: I7aa0eb0dd959da031b6039b51f07db668d4fb468 Reviewed-on: https://go-review.googlesource.com/33131 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Gudger <igudger@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* time: document that only Jan and January, Mon and Monday are recognizedRuss Cox2016-11-031-0/+7
| | | | | | | | | | | | | Not "J", not "JAN", not "jan", etc. Fixes #17523. Change-Id: I16b5da97e73d88c6680c36401d30f8a195061527 Reviewed-on: https://go-review.googlesource.com/32636 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Rob Pike <r@golang.org>
* time: simplify: tell people to not use == with Time valuesIan Lance Taylor2016-11-011-1/+1
| | | | | | | Change-Id: I49952f89b04f41109bb6591c6f025971d9880123 Reviewed-on: https://go-review.googlesource.com/32411 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: David Symonds <dsymonds@golang.org>
* time: clarify Equal docsIan Lance Taylor2016-10-281-2/+1
| | | | | | | | | | The docs used to imply that using == would compare Locations, but of course it just compares Location pointers, which will have unpredictable results depending on how the pointers are loaded. Change-Id: I783c1309e476a9616a1c1c290eac713aba3b0b57 Reviewed-on: https://go-review.googlesource.com/32332 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* time: revise Timer comments for Stop, ResetRuss Cox2016-10-181-4/+14
| | | | | | | | | | | | | The comments added for Go 1.7 are very close. Make explicit that they only apply if the timer is not known to have expired already. Fixes #14038. Change-Id: I6a38be7b2015e1571fc477e18444a8cee38aab29 Reviewed-on: https://go-review.googlesource.com/31350 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* time: be consistent about representation of UTC location in Time structRuss Cox2016-10-183-15/+41
| | | | | | | | | | | | | | | | | In the zero Time, the (not user visible) nil *Location indicates UTC. In the result of t.UTC() and other ways to create times in specific zones, UTC is indicated by a non-nil *Location, specifically &utcLoc. This creates a representation ambiguity exposed by comparison with == or reflect.DeepEqual or the like. Change time.Time representation to use only nil, never &utcLoc, to represent UTC. This eliminates the ambiguity. Fixes #15716. Change-Id: I7dcc2c20ce6b073e1daae323d3e49d17d1d52802 Reviewed-on: https://go-review.googlesource.com/31144 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* encoding/json: fix decoding of null into Unmarshaler, TextUnmarshalerRuss Cox2016-10-171-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Define behavior for Unmarshal of JSON null into Unmarshaler and TextUnmarshaler. Specifically, an Unmarshaler will be given the literal null and can decide what to do (because otherwise json.RawMessage is impossible to implement), and a TextUnmarshaler will be skipped over (because there is no text to unmarshal), like most other inappropriate types. Document this in Unmarshal, with a reminder in UnmarshalJSON about handling null. 2. Test all this. 3. Fix the TextUnmarshaler case, which was returning an unmarshalling error, to match the definition. 4. Fix the error that had been used for the TextUnmarshaler, since it was claiming that there was a JSON string when in fact the problem was NOT having a string. 5. Adjust time.Time and big.Int's UnmarshalJSON to ignore null, as is conventional. Fixes #9037. Change-Id: If78350414eb8dda712867dc8f4ca35a9db041b0c Reviewed-on: https://go-review.googlesource.com/30944 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* time: document that calendrical calculations are with no leap secondsBrad Fitzpatrick2016-10-061-1/+2
| | | | | | | | Fixes #15247 Change-Id: I942fb2eacd1b54bab66cc147a6b047a3ffce0b84 Reviewed-on: https://go-review.googlesource.com/30595 Reviewed-by: Russ Cox <rsc@golang.org>
* time: fix AddDate with nil locationSimon Rawet2016-10-062-1/+93
| | | | | | | | | | | | | | AddDate now retrieves location from t.Location() to ensure that it never calls Date with a nil location. Added test for this bug on all Time's methods Fixes #15852 Change-Id: Id2a222af56993f741ad0b802a2c3b89e8e463926 Reviewed-on: https://go-review.googlesource.com/23561 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
* time: update comment to reflect correct file path.Mike Appleby2016-10-011-1/+1
| | | | | | | | | Update cross-reference in the comment for runtimeTimer to point to the new go file instead of the old .h file. Change-Id: Iddb3614c41e1989096d6caf77d6c0d5781005181 Reviewed-on: https://go-review.googlesource.com/30157 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* time: update test for tzdata-2016gAlberto Donizetti2016-09-291-2/+5
| | | | | | | | | | Fixes #17276 Change-Id: I0188cf9bc5fdb48c71ad929cc54206d03e0b96e4 Reviewed-on: https://go-review.googlesource.com/29995 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* time: allow long fractions in ParseDurationRob Pike2016-09-192-7/+36
| | | | | | | | | | | | | | | | | | | | | The code scanned for an integer after a decimal point, which meant things could overflow if the number was very precise (0.1234123412341234123412342134s). This fix changes the parser to stop adding precision once we run out of bits, rather than trigger an erroneous overflow. We could parse durations using floating-point arithmetic, but since the type is int64 and float64 has only has 53 bits of precision, that would be imprecise. Fixes #15011. Change-Id: If85e22b8f6cef12475e221169bb8f493bb9eb590 Reviewed-on: https://go-review.googlesource.com/29338 Reviewed-by: Costin Chirvasuta <costinc@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* time: document in UnixNano when the value is validJoe Tsai2016-09-141-2/+3
| | | | | | | | | | | | | | | It is unlikely that the value of UnixNano overflow in most use cases. However, the max date of 2262 is also within the range where it may be of concern to some users. Rather than have each person recompute when this overflows to validate if its okay for their use case, we just document it as within the years 1678 and 2262, for user's convenience. Fixes #16977 Change-Id: I4988738c147f4a6d30f8b8735c3941b75113bb16 Reviewed-on: https://go-review.googlesource.com/28478 Reviewed-by: Andrew Gerrand <adg@golang.org>
* time: improve Truncate and Round documentationQuentin Smith2016-09-122-10/+18
| | | | | | | | | | | | | Truncate and Round operate on absolute time, which means that Truncate(Hour) may return a time with non-zero Minute(). Document that more clearly, and remove the misleading example which suggests it is safe. Updates #16647 Change-Id: I930584ca030dd12849195d45e49ed2fb74e0c9ac Reviewed-on: https://go-review.googlesource.com/28730 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* time: Add Until helper functionSam Whited2016-08-301-0/+6
| | | | | | | | | | | | | | | | Adds an Until() function that returns the duration until the given time. This compliments the existing Since() function and makes writing expressions that have expiration times more readable; for example: <-After(time.Until(connExpires)): Fixes #14595 Change-Id: I87998a924b11d4dad5512e010b29d2da6b123456 Reviewed-on: https://go-review.googlesource.com/20118 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
* time: always use $GOROOT/lib/time/zoneinfo.zip with genzabbrs.goAlex Brainman2016-08-283-84/+103
| | | | | | | | | | | | | | | | | | genzabbrs.go uses whatever zoneinfo database available on the system. This makes genzabbrs.go output change from system to system. Adjust go:generate line to always use $GOROOT/lib/time/zoneinfo.zip, so it does not matter who runs the command. Also move go:generate line into zoneinfo.go, so it can be run on Unix (see #16368 for details). Fixes #15802. Change-Id: I8ae4818aaf40795364e180d7bb4326ad7c07c370 Reviewed-on: https://go-review.googlesource.com/27832 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* time: fix optional fractional seconds range errGabriel Russell2016-08-232-0/+3
| | | | | | | | | | | | The optional fractional seconds overrides any range error from the second parsing. Instead don't look for optional fractional seconds if a range error has occured. Change-Id: I27e0a2432740f6753668bd8833e48b9495bc4036 Reviewed-on: https://go-review.googlesource.com/27590 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* time: load time zones from the system tzdata file on AndroidElias Naur2016-08-234-1/+150
| | | | | | | | | | | | | | | Android timezones are in a packed format, different from the separate files of a regular Unix system. This CL contain the necessary code to parse the packed tzdata file and extract time zones from it. It also adds a basic test to ensure the new parser works. Fixes #13581 Change-Id: Idebe73726c3d4c2de89dd6ae1d7d19f975207500 Reviewed-on: https://go-review.googlesource.com/24494 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: David Crawshaw <crawshaw@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* all: fix "result not used" vet warningsJosh Bleecher Snyder2016-08-161-1/+1
| | | | | | | | | | | | | For tests, assign to _. For benchmarks, assign to a sink. Updates #11041 Change-Id: I87c5543245c7bc74dceb38902f4551768dd37948 Reviewed-on: https://go-review.googlesource.com/27116 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>