1
0
mirror of https://github.com/golang/go synced 2024-10-03 17:21:21 -06:00
Commit Graph

70 Commits

Author SHA1 Message Date
Russ Cox
3345802e8a time: document that only Jan and January, Mon and Monday are recognized
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-11-03 16:04:14 +00:00
Ian Lance Taylor
2c5bce1cfa time: simplify: tell people to not use == with Time values
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>
2016-11-01 19:57:35 +00:00
Ian Lance Taylor
023556c071 time: clarify Equal docs
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>
2016-10-28 22:31:09 +00:00
Russ Cox
c999108723 time: revise Timer comments for Stop, Reset
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>
2016-10-18 12:55:24 +00:00
Russ Cox
5fbf35dc3f time: be consistent about representation of UTC location in Time struct
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-10-18 12:42:46 +00:00
Russ Cox
f444b48fe4 encoding/json: fix decoding of null into Unmarshaler, TextUnmarshaler
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>
2016-10-17 15:21:33 +00:00
Brad Fitzpatrick
1c09b4dde6 time: document that calendrical calculations are with no leap seconds
Fixes #15247

Change-Id: I942fb2eacd1b54bab66cc147a6b047a3ffce0b84
Reviewed-on: https://go-review.googlesource.com/30595
Reviewed-by: Russ Cox <rsc@golang.org>
2016-10-06 19:43:14 +00:00
Simon Rawet
b4f3c9339e time: fix AddDate with nil location
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>
2016-10-06 18:41:23 +00:00
Mike Appleby
d1f4e0413f time: update comment to reflect correct file path.
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>
2016-10-01 01:09:32 +00:00
Alberto Donizetti
c5434f2973 time: update test for tzdata-2016g
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>
2016-09-29 16:26:28 +00:00
Rob Pike
3cca069220 time: allow long fractions in ParseDuration
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-09-19 19:46:09 +00:00
Joe Tsai
b78108d5dc time: document in UnixNano when the value is valid
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>
2016-09-14 21:07:35 +00:00
Quentin Smith
e42ae65a85 time: improve Truncate and Round documentation
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>
2016-09-12 22:07:17 +00:00
Sam Whited
67ea710792 time: Add Until helper function
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>
2016-08-30 00:10:47 +00:00
Alex Brainman
e2e2d10b9a time: always use $GOROOT/lib/time/zoneinfo.zip with genzabbrs.go
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>
2016-08-28 02:51:07 +00:00
Gabriel Russell
eb29ac7a7c time: fix optional fractional seconds range err
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-08-23 15:58:08 +00:00
Elias Naur
80b31c05e6 time: load time zones from the system tzdata file on Android
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>
2016-08-23 06:15:35 +00:00
Josh Bleecher Snyder
40cf4ad0ef all: fix "result not used" vet warnings
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>
2016-08-16 14:15:10 +00:00
Rob Pike
2834526fd9 time: update documentation for Duration.String regarding the zero value
It was out of date; in 1.7 the format changes to 0s.

Change-Id: I2013a1b0951afc5607828f313641b51c74433257
Reviewed-on: https://go-review.googlesource.com/24421
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-24 19:41:45 +00:00
Ian Lance Taylor
894803c11e time: document that RFC822/1123 don't parse all RFC formats
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-06-09 15:32:48 +00:00
Kenny Grant
e2a30b8ffb time: genzabbrs.go skips Feb when checking months
getAbbrs looks like it is checking each month looking for a change
in the time zone abbreviation, but starts in Dec of the previous year
and skips the month of February because of the overflow rules for
AddDate. Changing the day to 1 starts at Jan 1 and tries all months
in the current year. This isn't very important or likely to change
output as zones usually span several months. Discovered when
looking into time.AddDate behavior when adding months.

Change-Id: I685254c8d21c402ba82cc4176e9a86b64ce8f7f7
Reviewed-on: https://go-review.googlesource.com/23322
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-09 15:31:08 +00:00
Andrew Gerrand
a71af25401 time: warn about correct use of a Timer's Stop/Reset methods
Updates #14038
Fixes #14383

Change-Id: Icf6acb7c5d13ff1d3145084544c030a778482a38
Reviewed-on: https://go-review.googlesource.com/23575
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-06 21:15:35 +00:00
Kenny Grant
65adb6ab9a time: run genzabbrs.go with new source data
The source xml data has changed, so running genzabbrs.go
regenerates a new time zone file in zoneinfo_abbrs_windows.go
which adds some zones and adjusts others.

Now set export ZONEINFO=$GOROOT/lib/time/zoneinfo.zip to use zoneinfo.zip in go tip.

Change-Id: I19f72359cc808094e5dcb420e480a00c6b2205d7
Reviewed-on: https://go-review.googlesource.com/23321
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-23 18:14:21 +00:00
Brad Fitzpatrick
7ab698b022 time: document that After uses memory until duration times out
Fixes #15698

Change-Id: I616fc06dcf04092bafdaf56fb1afba2a998a6d83
Reviewed-on: https://go-review.googlesource.com/23304
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-05-20 22:51:51 +00:00
Alex Brainman
2699da1809 time: set Local.name on windows
Local.String() returns "Local" on every OS, but windows.
Change windows code to do like others.

Updates #15568

Change-Id: I7a4d2713d940e2a01cff9d7f5cefc89def07546a
Reviewed-on: https://go-review.googlesource.com/23078
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-14 17:30:16 +00:00
Brad Fitzpatrick
d88261fb65 time: don't depend on the io package
The time package has never depended on the io package until
a recent change during Go 1.7 to use the io.Seek* constants.

The go/build dependency check didn't catch this because "time" was
allowed to depend on meta package group "L0", which included "io".

Adding the "io" package broke one of Dmitry's tools. The tool is
fixable, but it's also not necessary for us to depend on "io" at all
for some constants. Mirror the constants instead, and change
deps_test.go to prevent an io dependency in the future.

Change-Id: I74325228565279a74fa4a2f419643f5710e3e09f
Reviewed-on: https://go-review.googlesource.com/22960
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-05-09 20:31:47 +00:00
Joe Tsai
acc757f678 all: use SeekStart, SeekCurrent, SeekEnd
CL/19862 (f79b50b8d5) recently introduced the constants
SeekStart, SeekCurrent, and SeekEnd to the io package. We should use these constants
consistently throughout the code base.

Updates #15269

Change-Id: If7fcaca7676e4a51f588528f5ced28220d9639a2
Reviewed-on: https://go-review.googlesource.com/22097
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-06 00:10:41 +00:00
Rob Pike
9c4295b574 time: print zero duration as 0s, not 0
There should be a unit, and s is the SI unit name, so use that.
The other obvious possibility is ns (nanosecond), but the fact
that durations are measured in nanoseconds is an internal detail.

Fixes #14058.

Change-Id: Id1f8f3c77088224d9f7cd643778713d5cc3be5d9
Reviewed-on: https://go-review.googlesource.com/22357
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-04-21 22:07:59 +00:00
Matthew Dempsky
0da4dbe232 all: remove unnecessary type conversions
cmd and runtime were handled separately, and I'm intentionally skipped
syscall. This is the rest of the standard library.

CL generated mechanically with github.com/mdempsky/unconvert.

Change-Id: I9e0eff886974dedc37adb93f602064b83e469122
Reviewed-on: https://go-review.googlesource.com/22104
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-15 07:31:45 +00:00
Dominik Honnef
fdba5a7544 all: delete dead non-test code
This change removes a lot of dead code. Some of the code has never been
used, not even when it was first commited. The rest shouldn't have
survived refactors.

This change doesn't remove unused routines helpful for debugging, nor
does it remove code that's used in commented out blocks of code that are
only unused temporarily. Furthermore, unused constants weren't removed
when they were part of a set of constants from specifications.

One noteworthy omission from this CL are about 1000 lines of unused code
in cmd/fix, 700 lines of which are the typechecker, which hasn't been
used ever since the pre-Go 1 fixes have been removed. I wasn't sure if
this code should stick around for future uses of cmd/fix or be culled as
well.

Change-Id: Ib714bc7e487edc11ad23ba1c3222d1fd02e4a549
Reviewed-on: https://go-review.googlesource.com/20926
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-25 06:28:13 +00:00
Brad Fitzpatrick
5fea2ccc77 all: single space after period.
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-03-02 00:13:47 +00:00
Brad Fitzpatrick
519474451a all: make copyright headers consistent with one space after period
This is a subset of https://golang.org/cl/20022 with only the copyright
header lines, so the next CL will be smaller and more reviewable.

Go policy has been single space after periods in comments for some time.

The copyright header template at:

    https://golang.org/doc/contribute.html#copyright

also uses a single space.

Make them all consistent.

Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0
Reviewed-on: https://go-review.googlesource.com/20111
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 23:34:33 +00:00
Brad Fitzpatrick
351c15f1ce all: remove public named return values when useless
Named returned values should only be used on public funcs and methods
when it contributes to the documentation.

Named return values should not be used if they're only saving the
programmer a few lines of code inside the body of the function,
especially if that means there's stutter in the documentation or it
was only there so the programmer could use a naked return
statement. (Naked returns should not be used except in very small
functions)

This change is a manual audit & cleanup of public func signatures.

Signatures were not changed if:

* the func was private (wouldn't be in public godoc)
* the documentation referenced it
* the named return value was an interesting name. (i.e. it wasn't
  simply stutter, repeating the name of the type)

There should be no changes in behavior. (At least: none intended)

Change-Id: I3472ef49619678fe786e5e0994bdf2d9de76d109
Reviewed-on: https://go-review.googlesource.com/20024
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-02-29 03:31:19 +00:00
Shenghou Ma
28ce6f3600 time: document Tick will return nil if d <= 0
Fixes #14557.

Change-Id: I9610b79aafe9c15f9c998739b586fd0b41b90d70
Reviewed-on: https://go-review.googlesource.com/20031
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-29 02:33:26 +00:00
Nathan VanBenschoten
b04f3b06ec all: replace strings.Index with strings.Contains where possible
Change-Id: Ia613f1c37bfce800ece0533a5326fca91d99a66a
Reviewed-on: https://go-review.googlesource.com/18120
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
2016-02-19 01:06:05 +00:00
Ian Lance Taylor
830143fa3d time: fix comment about use of Location.cacheEnd
Fixes #14099.

Change-Id: I122e918bdc55fb185f4a4a797489b160219542d2
Reviewed-on: https://go-review.googlesource.com/18943
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-26 15:16:47 +00:00
Russ Cox
e84dad3f6e time: restore old error text for day out of range
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-08 03:15:20 +00:00
Russ Cox
39c3e0f642 time: document that RFC1123 is wrong for times in UTC
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>
2016-01-06 17:59:15 +00:00
Rob Pike
5ef899111e time: reject invalid day of month in Parse
There was back-and-forth on this but it has been decided to fix the original
complaint, which was easy.

Fixes #7268.

Change-Id: I6b607c49ad44579086aba2c4f4c5424b97fbed64
Reviewed-on: https://go-review.googlesource.com/17710
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-10 19:12:13 +00:00
Ian Lance Taylor
3b3f422afe time: fix handling of -07, handle Z07
The existing code has partial support for -07 (just the hours of a time
zone offset).  Complete the support, add support for Z07, and add a few
tests.

Fixes #13426.

Change-Id: Ic6377bbf3e65b4bb761b9779f7e80c07ce4f57e8
Reviewed-on: https://go-review.googlesource.com/17260
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-02 01:35:09 +00:00
Edward Muller
f4b4d2f4d9 time: _2006 is a literal _, followed by 2006
Otherwise _2006 is treated as _2 and then an error.

Fixes #11334

Change-Id: I40a385b45e279e9f4538bf419baab72781cdb215
Reviewed-on: https://go-review.googlesource.com/16311
Reviewed-by: Rob Pike <r@golang.org>
2015-11-18 00:06:39 +00:00
Rob Pike
8b96be15f6 time: allow any one- or two-digit day of the month when parsing.
In Parse, one can now say Feb 31 or even Feb 99. This is easy
to explain, consistent with time.Date, and even maybe useful.

Fixes #12333.
Fixes #7268. (By disagreeing with it.)

Change-Id: I7b95c842528bed66933681c8b9cc00640fccfcb4
Reviewed-on: https://go-review.googlesource.com/14123
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-10 20:27:53 +00:00
Marvin Stenger
c12e38aa04 time: fixed handling of "5" in Format's layout string
Fixes #12440

Change-Id: Iead77fe34d986cfd5c16bac671fe13c8d012a754
Reviewed-on: https://go-review.googlesource.com/14178
Reviewed-by: Rob Pike <r@golang.org>
2015-09-09 18:41:34 +00:00
Ian Lance Taylor
d93f3b5e31 time: fix 400 year offset in comment
Change-Id: I33c2c222ea884d9ff57800ea5185644b5d8e591a
Reviewed-on: https://go-review.googlesource.com/14034
Reviewed-by: Minux Ma <minux@golang.org>
2015-08-29 01:03:42 +00:00
Daniel Johansson
cba1528ceb time: handle localized time zone names
The existing implementation fails to determine the correct time zone
abbreviations when the display language is non-English. This change adds
support for localized time zone names (standard- and daylightname)
by using the function RegLoadMUIString.

Fixes #12015

Change-Id: Ic0dc89c50993af8f292b199c20bc5932903e7e87
Reviewed-on: https://go-review.googlesource.com/13854
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-26 04:40:59 +00:00
Justin Nuß
5f859ba83d time: Use AppendFormat in Marshal[Text|JSON]
The current implementations of MarshalJSON and MarshalText use
time.Format which returns a string (converted from a byte slice),
only to convert it back to a byte slice.

Avoid the conversion (and thus an allocation) by directly appending
the formatted time to a preallocated byte slice, using the new
AppendFormat function, introduced in golang.org/cl/1760.

This reduces the allocations done in Marshal[Text|JSON] by 50%.

benchmark                old ns/op     new ns/op     delta
BenchmarkMarshalJSON     626           507           -19.01%
BenchmarkMarshalText     598           511           -14.55%

benchmark                old allocs     new allocs     delta
BenchmarkMarshalJSON     2              1              -50.00%
BenchmarkMarshalText     2              1              -50.00%

benchmark                old bytes     new bytes     delta
BenchmarkMarshalJSON     96            48            -50.00%
BenchmarkMarshalText     96            48            -50.00%

Fixes #11025

Change-Id: I468f78d075a6ecc1cdc839df7fb407fbc6ff2e70
Reviewed-on: https://go-review.googlesource.com/10555
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-22 11:31:58 +00:00
Rob Pike
47f22ab775 time: make it clearer how to format a fractional second
Fixes #10963.

Change-Id: I8d769b4d25b306f2df41f882ec01d97bbd63171d
Reviewed-on: https://go-review.googlesource.com/12221
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-07-15 05:13:05 +00:00
Rob Pike
a3985e400f time: document that time.Tick creates an unrecoverable resource
Fixes #11662.

Change-Id: I8839b48a1cd3da4c29b6def03cb0c74c1c12942e
Reviewed-on: https://go-review.googlesource.com/12066
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-13 01:35:36 +00:00
Brad Fitzpatrick
2ae77376f7 all: link to https instead of http
The one in misc/makerelease/makerelease.go is particularly bad and
probably warrants rotating our keys.

I didn't update old weekly notes, and reverted some changes involving
test code for now, since we're late in the Go 1.5 freeze. Otherwise,
the rest are all auto-generated changes, and all manually reviewed.

Change-Id: Ia2753576ab5d64826a167d259f48a2f50508792d
Reviewed-on: https://go-review.googlesource.com/12048
Reviewed-by: Rob Pike <r@golang.org>
2015-07-11 14:36:33 +00:00
Shenghou Ma
526b501713 time: correct unrepresentable Unix time comment
It's easy for someone who wants a time bigger than any
valid time to reach for time.Unix(1<<63-1, 0), so it
makes sense to explicit say such value is not valid.

Fixes #10906 (again).

Change-Id: If71e32472ae40d86c30e629b982406040a73c4c7
Reviewed-on: https://go-review.googlesource.com/10266
Reviewed-by: Russ Cox <rsc@golang.org>
2015-06-18 18:21:59 +00:00