aboutsummaryrefslogtreecommitdiff
path: root/src/time/format.go
AgeCommit message (Collapse)Author
2022-04-27time: document hhmmss formatscuiweixie
Fixes #52516 Change-Id: I173fdb09c245563e09be4e1aacfd374c3a764d74 GitHub-Last-Rev: 14a81e50616e0f268fee9323d0621de861885475 GitHub-Pull-Request: golang/go#52538 Reviewed-on: https://go-review.googlesource.com/c/go/+/402058 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-11all: gofmt main repoRuss Cox
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-01all: remove trailing blank doc comment linesRuss Cox
A future change to gofmt will rewrite // Doc comment. // func f() to // Doc comment. func f() Apply that change preemptively to all doc comments. For #51082. Change-Id: I4023e16cfb0729b64a8590f071cd92f17343081d Reviewed-on: https://go-review.googlesource.com/c/go/+/384259 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-02-15time: document that Parse truncates to nanosecond precisionIan Lance Taylor
For #48685 Fixes #50806 Change-Id: Ie8be40e5794c0998538890a651ef8ec92cb72d3a Reviewed-on: https://go-review.googlesource.com/c/go/+/381155 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Paul Jolly <paul@myitcv.org.uk> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-10-08time: allow minimum int64 in ParseDurationMeng Zhuo
ParseDuration should handle minimum int64 (-1<<63) nanosecond since type Duration is alias of int64 name old time/op new time/op delta ParseDuration 91.4ns ± 0% 86.4ns ± 1% -5.49% (p=0.000 n=9+8) Fixes: #48629 Change-Id: I81b7035b25cefb4c1e5b7801c20f2d335e29358a Reviewed-on: https://go-review.googlesource.com/c/go/+/352269 Trust: Meng Zhuo <mzh@golangcn.org> Run-TryBot: Meng Zhuo <mzh@golangcn.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-06time: truncate fractional seconds longer than 9 digitsAlexander Yastrebov
Fixes #48685 Change-Id: Id246708878c2902b407ab759537f6b545a1f459f GitHub-Last-Rev: 4d985192c5a66ae8891539f166ef88b53cd1cbea GitHub-Pull-Request: golang/go#48750 Reviewed-on: https://go-review.googlesource.com/c/go/+/353713 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-09-17time: re-add space-padded day of year to docsRiley Avron
CL 320252 reworked the time docs, but accidentally deleted the format __2 from the sentence describing the three-character day of year component. Change-Id: I3f583733028657c2a677358a25e062ea81835ce8 GitHub-Last-Rev: 2fa98324191500fd6a37097a9712ae23cc509269 GitHub-Pull-Request: golang/go#48387 Reviewed-on: https://go-review.googlesource.com/c/go/+/349929 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Carlos Amedee <carlos@golang.org>
2021-09-09time: propagate "," separator for fractional seconds into Formatkorzhao
In CL 300996 that fixed issue #6189, we made Parse recognize "," as a separator for fractional seconds. However, we didn't modify Format to propagate the separator verbatim from Parse. Without this change, we break prior functionality that relied on a comma being used in Format. Fixes #48037 Change-Id: I6565a25e8657ca3747a58b25acba58f27cdcddc0 Reviewed-on: https://go-review.googlesource.com/c/go/+/345438 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Cherry Mui <cherryyz@google.com>
2021-08-25time/format: avoid growslice in time.String()/time.GoString()korzhao
Pre-allocate the slice of buf with enough capacity to avoid growslice calls. benchmark old ns/op new ns/op delta BenchmarkTimeString-4 493 409 -17.12% BenchmarkTimeGoString-4 309 182 -41.30% benchmark old allocs new allocs delta BenchmarkTimeString-4 5 3 -40.00% BenchmarkTimeGoString-4 4 1 -75.00% benchmark old bytes new bytes delta BenchmarkTimeString-4 152 128 -15.79% BenchmarkTimeGoString-4 248 80 -67.74% Change-Id: I64eabe2ab0b3d4a846453c2e8e548a831d720b8c Reviewed-on: https://go-review.googlesource.com/c/go/+/343971 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Alexander Rakoczy <alex@golang.org>
2021-08-12time: fix docs for new comma layoutsRuss Cox
The current text is slightly inaccurate. Make it more correct. Change-Id: Iebe0051b74649d13982d7eefe3697f9e69c9b75d Reviewed-on: https://go-review.googlesource.com/c/go/+/340449 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-06-24time: handle invalid UTF-8 byte sequences in quote to prevent panicAndy Pan
Fixes #46883 Updates CL 267017 Change-Id: I15c307bfb0aaa2877a148d32527681f79df1a650 Reviewed-on: https://go-review.googlesource.com/c/go/+/330289 Reviewed-by: Kevin Burke <kev@inburke.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2021-05-18time: rewrite the documentation for layout stringsRob Pike
People continue to be confused by how these work. Address that by some rejiggering. Introduce a constant called Layout that both defines the time and provides a reference point for Parse and Format to refer to. We can then delete much redundancy, especially for Format's comments, but Parse tightens a bit too. Then change the way the concept of the layout string is introduced, and provide a clearer catalog of what its elements are. Fixes #38871 Change-Id: Ib967ae70c7d5798a97b865cdda1fda4daed8a99a Reviewed-on: https://go-review.googlesource.com/c/go/+/320252 Trust: Rob Pike <r@golang.org> Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-05-02time: make time.Time print a valid Go string with %#vKevin Burke
Previously calling fmt.Sprintf("%#v", t) on a time.Time value would yield a result like: time.Time{wall:0x0, ext:63724924180, loc:(*time.Location)(nil)} which does not compile when embedded in a Go program, and does not tell you what value is represented at a glance. This change adds a GoString method that returns much more legible output: "time.Date(2009, time.February, 5, 5, 0, 57, 12345600, time.UTC)" which gives you more information about the time.Time and also can be usefully embedded in a Go program without additional work. Update Quote() to hex escape non-ASCII characters (copying logic from strconv), which makes it safer to embed them in the output of GoString(). Fixes #39034. Change-Id: Ic985bafe4e556f64e82223c643f65143c9a45c3b Reviewed-on: https://go-review.googlesource.com/c/go/+/267017 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
2021-04-06time: properly quote strings containing quotes and backslashesAhmet Aktürk
Fixes #45391 Change-Id: I43ea597f6a9596a621ae7b63eb05440d5b9e2d8f Reviewed-on: https://go-review.googlesource.com/c/go/+/307192 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-03-16time: support "," as separator for fractional secondsEmmanuel T Odeke
Accepts comma "," as a separator for fractional seconds hence we now accept: * 2006-01-02 15:04:05,999999999 -0700 MST * Mon Jan _2 15:04:05,120007 2006 * Mon Jan 2 15:04:05,120007 2006 This change follows the recommendations of ISO 8601 per https://en.wikipedia.org/wiki/ISO_8601#cite_note-26 which states ISO 8601:2004(E), ISO, 2004-12-01, "4.2.2.4 ... the decimal fraction shall be divided from the integer part by the decimal sign specified in ISO 31-0, i.e. the comma [,] or full stop [.]. Of these, the comma is the preferred sign." Unfortunately, I couldn't directly access the ISO 8601 document because suddenly it is behind a paywall on the ISO website, charging CHF 158 (USD 179) for 38 pages :-( However, this follows publicly available cited literature, as well as the recommendations from the proposal approval. Fixes #6189 Updates #27746 Updates #26002 Updates #36145 Updates #43813 Fixes #43823 Change-Id: Ibe96064e8ee27c239be78c880fa561a1a41e190c Reviewed-on: https://go-review.googlesource.com/c/go/+/300996 Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-03-15time: add Time.IsDST() to check if its Location is in Daylight Savings TimeJoel Courtney
Fixes #42102 Change-Id: I2cd2fdf67c794c3e99ed1c24786f7f779da73962 GitHub-Last-Rev: bbfa92135734cbd55895012fa492e51686a7b58b GitHub-Pull-Request: golang/go#42103 Reviewed-on: https://go-review.googlesource.com/c/go/+/264077 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Rob Pike <r@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-06-02time: note that formats may parse invalid stringsDavid Golden
The existing documentation for time format constants doesn't mention that they may parse technically-invalid strings, such as single-digit hours when a two-digit hour is required by a specification. This commit adds a short warning note to that effect. Fixes #37616 Change-Id: I6e5e12bd42dc368f8ca542b4c0527a2b7d30acaf Reviewed-on: https://go-review.googlesource.com/c/go/+/229460 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-14time: quote original value in errors returned by ParseDurationObeyda Djeffal
Quote original values passed as substring of ParseError.Message. Improves the user experience of ParseDuration by making it quote its original argument, for example: _, err := time.ParseDuration("for breakfast") will now produce an error, which when printed out is: time: invalid duration "for breakfast" instead of: time: invalid duration for breakfast Adapt test cases for format.Parse and format.ParseDuration. Fixes #38295 Change-Id: Ife322c8f3c859e1e4e8dd546d4cf0d519b4bfa81 Reviewed-on: https://go-review.googlesource.com/c/go/+/227878 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-02-23time: don't get confused about day 31 when parsing 002Ian Lance Taylor
The 002 parsing code had a bug that mishandled day 31. Fixes #37387 Change-Id: Ia5a492a4ddd09a4bc232ce9582aead42d5099bdd Reviewed-on: https://go-review.googlesource.com/c/go/+/220637 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2020-01-23time: document how Parse handles two-digit yearsKirill Tatchihin
Fixes #36549 Change-Id: Ia803330fc046d5807bbefd67acb419cb81640a13 GitHub-Last-Rev: bd354319083bf80c250e1915f2be6860d2f7d14b GitHub-Pull-Request: golang/go#36584 Reviewed-on: https://go-review.googlesource.com/c/go/+/214980 Reviewed-by: Rob Pike <r@golang.org>
2019-04-26time: fix misleading error with the leading zero formatLE Manh Cuong
When the leading zero format is used, we currently don't handle the month and year properly. For the month, we were reporting an out of range error when getnum returns zero of its own, as it also returns the month 0. That's confusing, so only check the range when getnum returns a nil error. For the year, we don't restore the value when parsing error occurs. For example, with the incorrect input "111-01", "01" will be used to report an error. So restore the value when an error occurs fix the problem. Fixes #29918 Fixes #29916 Change-Id: I3145f8c46813a0457766b7c302482e6b56f94ed6 Reviewed-on: https://go-review.googlesource.com/c/go/+/160338 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-08time: add support for day-of-year in Format and ParseRuss Cox
Day of year is 002 or __2, in contrast to day-in-month 2 or 02 or _2. This means there is no way to print a variable-width day-of-year, but that's probably OK. Fixes #25689. Change-Id: I1425d412cb7d2d360e9b3bf74e89566714e2477a Reviewed-on: https://go-review.googlesource.com/c/go/+/122876 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2018-08-24time: allow +00 as numeric timezone name and GMT offsetAlberto Donizetti
A timezone with a zero offset from UTC and without a three-letter abbreviation will have a numeric name in timestamps: "+00". There are currently two of them: $ zdump Atlantic/Azores America/Scoresbysund Atlantic/Azores Wed Aug 22 09:01:05 2018 +00 America/Scoresbysund Wed Aug 22 09:01:05 2018 +00 These two timestamp are rejected by Parse, since it doesn't allow for zero offsets: parsing time "Wed Aug 22 09:01:05 2018 +00": extra text: +00 This change modifies Parse to accept a +00 offset in numeric timezone names. As side effect of this change, Parse also now accepts "GMT+00". It was explicitely disallowed (with a unit test ensuring it got rejected), but the restriction seems incorrect. DATE(1), for example, allows it: $ date --debug --date="2009-01-02 03:04:05 GMT+00" date: parsed date part: (Y-M-D) 2009-01-02 date: parsed time part: 03:04:05 date: parsed zone part: UTC+00 date: input timezone: parsed date/time string (+00) date: using specified time as starting value: '03:04:05' date: starting date/time: '(Y-M-D) 2009-01-02 03:04:05 TZ=+00' date: '(Y-M-D) 2009-01-02 03:04:05 TZ=+00' = 1230865445 epoch-seconds date: timezone: system default date: final: 1230865445.000000000 (epoch-seconds) date: final: (Y-M-D) 2009-01-02 03:04:05 (UTC) date: final: (Y-M-D) 2009-01-02 04:04:05 (UTC+01) Fri 2 Jan 04:04:05 CET 2009 This fixes 2 of 17 time.Parse() failures listed in Issue #26032. Updates #26032 Change-Id: I01cd067044371322b7bb1dae452fb3c758ed3cc2 Reviewed-on: https://go-review.googlesource.com/130696 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-21time: accept anything between -23 and 23 as offset namezone nameAlberto Donizetti
time.Parse currently rejects numeric timezones names with UTC offsets bigger than +12, but this is incorrect: there's a +13 timezone and a +14 timezone: $ zdump Pacific/Kiritimati Pacific/Kiritimati Mon Jun 25 02:15:03 2018 +14 For convenience, this cl changes the ranges of accepted offsets from -14..+12 to -23..+23 (zero still excluded), i.e. every possible offset that makes sense. We don't validate three-letter abbreviations for the timezones names, so there's no need to be too strict on numeric names. This change also fixes a bug in the parseTimeZone, that is currently unconditionally returning true (i.e. valid timezone), without checking the value returned by parseSignedOffset. This fixes 5 of 17 time.Parse() failures listed in Issue #26032. Updates #26032 Change-Id: I2f08ca9aa41ea4c6149ed35ed2dd8f23eeb42bff Reviewed-on: https://go-review.googlesource.com/120558 Reviewed-by: Rob Pike <r@golang.org>
2018-03-24all: remove some unused return parametersDaniel Martí
As found by unparam. Picked the low-hanging fruit, consisting only of errors that were always nil and results that were never used. Left out those that were useful for consistency with other func signatures. Change-Id: I06b52bbd3541f8a5d66659c909bd93cb3e172018 Reviewed-on: https://go-review.googlesource.com/102418 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-08time: add support for parsing timezones denoted by sign and offsetMichael Kasch
IANA Zoneinfo does not provide names for all timezones. Some are denoted by a sign and an offset only. E.g: Europe/Turkey is currently +03 or America/La_Paz which is -04 (https://data.iana.org/time-zones/releases/tzdata2018c.tar.gz) Fixes #24071 Change-Id: I9c230a719945e1263c5b52bab82084d22861be3e Reviewed-on: https://go-review.googlesource.com/98157 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-01-03time: revert CL 78735 (was: space padding using underscore)Ian Lance Taylor
CL 78735 description: time: add space padding layout strings(using underscore) for not only day but others As mentioned in #22802, only day component of layout string has space padding(represented by one underscore before its placeholder). This commit expands the rule for month, hour, minute and second. Updates #22802 (maybe fixes it) Revert this CL because it breaks currently working formats that happen to use underscores. Fixes #23259 Change-Id: I64acaaca9b5b74785ee0f0be7910574e87daa649 Reviewed-on: https://go-review.googlesource.com/85998 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2017-12-13time: add space padding layout strings(using underscore) for not only day ↵Hanjun Kim
but others As mentioned in #22802, only day component of layout string has space padding(represented by one underscore before its placeholder). This commit expands the rule for month, hour, minute and second. Updates #22802 (maybe fixes it) Change-Id: I886998380489862ab9a324a6774f2e4cf7124122 Reviewed-on: https://go-review.googlesource.com/78735 Run-TryBot: Rob Pike <r@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2017-11-02time: fix incorrect "zero padding" commentsKenny Grant
The comment on invalid time values in Constants and example refers to _ zero padding when it should refer to space padding. Change-Id: I5784356e389d324703e20eec6203f147db92880f Reviewed-on: https://go-review.googlesource.com/75410 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-01time: improve comments about valid layouts being invalid Parse valuesIan Lance Taylor
Updates #9346 Updates #22135 Change-Id: I7039c9f7d49600e877e35b7255c341fea35890e2 Reviewed-on: https://go-review.googlesource.com/74890 Reviewed-by: Rob Pike <r@golang.org>
2017-10-31time: document that valid layouts are not valid Parse valuesKenny Grant
For #9346 #22135 explicitly state under layout constants that they are not valid time values for Parse. Also add examples of parsing valid RFC3339 values and the layout to the example for time.Parse. Fix capitalisation of time.Parse and Time.Format. For #20869 include RFC3339 in the list of layouts that do not accept all the time formats allowed by RFCs (lowercase z). This does not fully address #20869. Fixes #9346 Fixes #22135 Change-Id: Ia4c13e5745de583db5ef7d5b1688d7768bc42c1b Reviewed-on: https://go-review.googlesource.com/74231 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-08time: don't match '---' month in time.ParseCholerae Hu
The existing implementation will panic when month in date string is '---'. Fixed #21113 Change-Id: I8058ae7a4102e882f8b7e9c65d80936b563265e4 Reviewed-on: https://go-review.googlesource.com/51010 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-14time: remove unused parameterKevin Burke
lookupName is only called in one location, and one of the return values is unused, so let's remove it. Change-Id: I35e22c7ec611e8eb349deb4f0561e212f7d9de0b Reviewed-on: https://go-review.googlesource.com/55232 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
2017-08-10time: remove extra space in docstringKevin Burke
Probably went unnoticed because HTML normalizes multiple space characters into one, unless you explicitly ask for them with &nbsp;. Change-Id: I3f97b24a111da3f0f28894f1246388018beb084e Reviewed-on: https://go-review.googlesource.com/54570 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Rob Pike <r@golang.org>
2017-07-06time: document the Time.String is meant for debuggingBrad Fitzpatrick
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>
2017-06-29time: warn that RFC3339Nano does not guarantee a natural orderingBrad Fitzpatrick
Fixes #19635 Change-Id: I85e725dbc85843afd0f4d82f5127fecacc1cb524 Reviewed-on: https://go-review.googlesource.com/47090 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-02-09time: format negative monotonic times correctly in Time.StringCaleb Spare
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>
2017-02-07time: delete incorrect docs about day-of-month checks.Sameer Ajmani
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>
2017-02-05time: Fix typo in Time.String() description.Alexey Palazhchenko
Refs #12914. Change-Id: Iadac4cbef70db6a95b47f86eaffcfc63bfdb8e90 Reviewed-on: https://go-review.googlesource.com/36334 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-02-03time: record monotonic clock reading in time.Now, for more accurate comparisonsRuss Cox
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>
2016-12-12time: parse WITA timezone correctlyMax Riveiro
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>
2016-11-22time: make Parse validate day's lower bound in addition to upper boundBrad Fitzpatrick
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>
2016-11-03time: document that only Jan and January, Mon and Monday are recognizedRuss Cox
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>
2016-10-18time: be consistent about representation of UTC location in Time structRuss Cox
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>
2016-09-19time: allow long fractions in ParseDurationRob Pike
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>
2016-08-23time: fix optional fractional seconds range errGabriel Russell
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>
2016-06-09time: document that RFC822/1123 don't parse all RFC formatsIan Lance Taylor
Fixes #14505. Change-Id: I46196b26c9339609e6e3ef9159de38c5b50c2a1b Reviewed-on: https://go-review.googlesource.com/23922 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-02all: single space after period.Brad Fitzpatrick
The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-08time: restore old error text for day out of rangeRuss Cox
Go 1.5 and earlier said "day out of range". As part of working on this code it morphed into "day of month out of range". To avoid churn in the output restore the old text. This fixes some tests reported privately. Change-Id: If179676cd49f9a471a9441fec2f5220c85eb0799 Reviewed-on: https://go-review.googlesource.com/18386 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-01-06time: document that RFC1123 is wrong for times in UTCRuss Cox
Fixes #13781. Change-Id: Icfac8f2bfc3a4106f646409cfdc053df1e0cd76a Reviewed-on: https://go-review.googlesource.com/18314 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>