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

207 Commits

Author SHA1 Message Date
Rob Pike
727b2b6f7d time: handle GMT possibly with offset
Update #3790
Handle time zones like GMT-8.
The more general time zone-matching problem is not yet resolved.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12922043
2013-08-15 10:10:49 +10:00
Russ Cox
071e44e4e4 time: make Time implement encoding interfaces
See golang.org/s/go12encoding for design.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12706043
2013-08-14 00:34:00 -04:00
Rob Pike
af8426eebe time: match month and day names only when not followed immediately by a lower-case letter
Avoids seeing "Janet" as "Januaryet".

Fixes #6020.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12448044
2013-08-05 10:53:46 +10:00
Rob Pike
16c9d3616a various: deleted unused items
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12396043
2013-08-03 16:01:04 +10:00
Ulf Holm Nielsen
aa38aeaeaf time: Allow Parse and Format to handle time zone offsets with seconds
Adds layout cases with seconds for stdISO8601 and stdNumTZ with and without colons. Update time.Format to append seconds for those cases.

Fixes #4934.

R=golang-dev, r, bradfitz
CC=golang-dev
https://golang.org/cl/8132044
2013-07-31 16:11:02 +10:00
Alex Brainman
231dfd9049 time: find correct zone abbreviations even on non-English windows systems
Fixes #5783

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/10956043
2013-07-10 15:34:24 +10:00
Jeff R. Allen
0286b4738e time: prevent a panic from leaving the timer mutex held
When deleting a timer, a panic due to nil deref
would leave a lock held, possibly leading to a deadlock
in a defer. Instead return false on a nil timer.

Fixes #5745.

R=golang-dev, daniel.morsing, dvyukov, rsc, iant
CC=golang-dev
https://golang.org/cl/10373047
2013-07-01 21:42:29 -04:00
Russ Cox
f21bc7920d time: avoid garbage collector aliasing bug
Time is a tiny struct, so the compiler copies a Time by
copying each of the three fields.

The layout of a time on amd64 is [ptr int32 gap32 ptr].
Copying a Time onto a location that formerly held a pointer in the
second word changes only the low 32 bits, creating a different
but still plausible pointer. This confuses the garbage collector
when it appears in argument or result frames.

To avoid this problem, declare nsec as uintptr, so that there is
no gap on amd64 anymore, and therefore no partial pointers.

Note that rearranging the fields to put the int32 last still leaves
a gap - [ptr ptr int32 gap32] - because Time must have a total
size that is ptr-width aligned.

Update #5749

This CL is enough to fix the problem, but we should still do
the other actions listed in the initial report. We're not too far
from completely precise collection.

R=golang-dev, dvyukov, r
CC=golang-dev
https://golang.org/cl/10504043
2013-06-24 14:49:35 -04:00
Rick Arnold
fc0b5ef0fd time: handle integer overflow in Sub
If time.Sub results in a value that won't fit in a Duration (int64),
return either the min or max int64 value as appropriate.

Fixes #5011.

R=golang-dev, bradfitz, r, rsc
CC=golang-dev
https://golang.org/cl/10328043
2013-06-21 18:07:57 -07:00
Rob Pike
0bc7e79afd all: excise some warts found by vet -shadow
These are not erroneous, just poor or confusing.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/10448043
2013-06-20 16:14:40 -07:00
Alex Brainman
07ea243d50 time: provide timezone abbreviations on windows
Use http://unicode.org/cldr/data/common/supplemental/windowsZones.xml
to generate the map.

Fixes #4838.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/9997043
2013-06-06 16:30:25 +10:00
Brad Fitzpatrick
509a1173a3 time: remove Time.FormatAppend
undo CL 8478044 / 0d28fd55e721

Lack of consensus.

««« original CL description
time: add Time.FormatAppend

This is a version of Time.Format that doesn't require allocation.

Fixes #5192
Update #5195

R=r
CC=gobot, golang-dev
https://golang.org/cl/8478044
»»»

R=r
CC=golang-dev
https://golang.org/cl/9462049
2013-05-21 14:32:09 -07:00
Brad Fitzpatrick
0af302f507 time: add Time.FormatAppend
This is a version of Time.Format that doesn't require allocation.

Fixes #5192
Update #5195

R=r
CC=gobot, golang-dev
https://golang.org/cl/8478044
2013-05-15 17:23:40 -07:00
Dmitriy Vyukov
489addd250 time: stop 1ns timer in test
R=golang-dev, adg, r
CC=golang-dev
https://golang.org/cl/8819046
2013-04-26 11:08:50 +04:00
Christian Himpel
237cee7834 time: fix typo in comment
R=r
CC=golang-dev
https://golang.org/cl/8889045
2013-04-22 22:09:11 -07:00
Rob Pike
14234c23a8 time: fix typo in comment
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8915043
2013-04-22 15:41:06 -07:00
Rob Pike
c285789059 time: improve the explanation of the working of Format and Parse
Change the term 'standard time', which already means something,
to 'reference time', and add a couple of sentences and clarifications.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/8799047
2013-04-22 11:36:17 -07:00
Albert Strasheim
0a71a5b029 all: Skip AllocsPerRun tests if GOMAXPROCS>1.
Fixes #4974.

R=rsc, bradfitz, r
CC=golang-dev
https://golang.org/cl/7545043
2013-03-06 15:52:32 -08:00
Andrew Gerrand
89cf67eb20 time: handle very large sleep durations
Fixes #4903.

R=golang-dev, daniel.morsing, dave, r
CC=golang-dev
https://golang.org/cl/7388056
2013-02-26 09:23:58 +11:00
Russ Cox
1903ad7189 cmd/gc, reflect, runtime: switch to indirect func value representation
Step 1 of http://golang.org/s/go11func.

R=golang-dev, r, daniel.morsing, remyoudompheng
CC=golang-dev
https://golang.org/cl/7393045
2013-02-21 17:01:13 -05:00
Russ Cox
6b4cf2b367 time: fix error message from Parse
Was incorrectly discarding the offending text in some cases.

Fixes #4493.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7277050
2013-02-04 00:00:36 -05:00
Russ Cox
1d9f67daf0 time: deal a bit better with time zones in Parse
* Document Parse's zone interpretation.
* Add ParseInLocation (API change).
* Recognize "wrong" time zone names, like daylight savings time in winter.
* Disambiguate time zone names using offset (like winter EST vs summer EST in Sydney).

The final two are backwards-incompatible changes, but I believe
they are both buggy behavior in the Go 1.0 versions; the old results
were more wrong than the new ones.

Fixes #3604.
Fixes #3653.
Fixes #4001.

R=adg
CC=golang-dev
https://golang.org/cl/7288052
2013-02-03 23:02:12 -05:00
Russ Cox
6a003d7589 time: handle zone file with no transitions
Code fix by Alex Bramley.

Fixes #4064.

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/7289049
2013-02-03 22:41:00 -05:00
Kyle Lemons
9bfd3c3937 testing: add AllocsPerRun
This CL also replaces similar loops in other stdlib
package tests with calls to AllocsPerRun.

Fixes #4461.

R=minux.ma, rsc
CC=golang-dev
https://golang.org/cl/7002055
2013-02-02 22:52:29 -05:00
Brad Fitzpatrick
86a8d59a01 time: make TestReset more reliable
Fixes #4690

R=golang-dev, alex.brainman, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7181052
2013-01-22 17:25:58 -08:00
Caleb Spare
657168fb17 time: standard time doc fix and format example
This fixes the incorrect unix timestamp of the standard time and adds
an example for (Time) Format to clarify how timezones work in format strings.

Fixes #4364.

R=golang-dev, remyoudompheng, kevlar, rsc
CC=golang-dev
https://golang.org/cl/7069046
2013-01-22 14:44:49 -05:00
Shenghou Ma
e985d5464b time: add note about Parse()'s choice of default year
R=rsc
CC=golang-dev
https://golang.org/cl/7101046
2013-01-19 04:57:31 +08:00
Alex Brainman
e0aa26a427 time: Sleep does better job then runtime.Gosched in TestAfterStress
for slow windows-386 builder

R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/7128053
2013-01-18 15:31:01 +11:00
Volker Dobler
44ff17e664 time: add Timer.Reset
Fixes #4412.

R=adg, rsc, rogpeppe, andrewdg, bradfitz
CC=golang-dev
https://golang.org/cl/7086050
2013-01-17 14:41:53 +11:00
Brad Fitzpatrick
fd1abac71c time: fix race
Fixes #4622

R=golang-dev, dave, dvyukov
CC=golang-dev
https://golang.org/cl/7103046
2013-01-14 14:09:42 -08:00
Shenghou Ma
d1ef9b56fb all: fix typos
caught by https://github.com/lyda/misspell-check.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/6949072
2012-12-19 03:04:09 +08:00
Dave Cheney
2d3bdab0d6 time: fix panic with time.Parse(time.StampNano, ... )
Fixes #4502.

R=rsc
CC=golang-dev
https://golang.org/cl/6949058
2012-12-18 07:52:23 +11:00
Russ Cox
00cd6a3be3 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://golang.org/cl/6903050
2012-12-09 03:59:33 -05:00
Dave Cheney
1e9ab9e792 time: add Now()/UnixNano() malloc tests
The fix for issue 4403 may include more calls to time.Now().UnixNano(). I was concerned that if this function allocated it would cause additional garbage on the heap. It turns out that it doesn't, which is a nice surprise.

Also add benchmark for Now().UnixNano()

R=bradfitz, minux.ma
CC=golang-dev
https://golang.org/cl/6849097
2012-11-25 11:29:06 +11:00
Shenghou Ma
48b739caac time: clarify why timer.Stop and ticker.Stop don't close the channel
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6818106
2012-11-08 23:25:48 +08:00
Robert Griesemer
465b9c35e5 gofmt: apply gofmt -w src misc
Remove trailing whitespace in comments.
No other changes.

R=r
CC=golang-dev
https://golang.org/cl/6815053
2012-10-30 13:38:01 -07:00
David Symonds
f2045aadd9 time: accept numbers larger than 2^32 in ParseDuration.
Fixes #3374.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6683047
2012-10-15 07:50:13 +11:00
Rob Pike
06d42690b6 time: delete erroneous word from documentation.
Fixes #4236.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/6658051
2012-10-12 11:00:00 +11:00
Robert Griesemer
af79568fde gofmt: apply gofmt -w -s src misc
Preparation for forthcoming CL 6624051: Will make it
easier to see if/what changes are incurred by it.

The alignment changes in this CL are due to CL 6610051
(fix to alignment heuristic) where it appears that an
old version of gofmt was run (and thus the correct
alignment updates were not done).

R=r
CC=golang-dev
https://golang.org/cl/6639044
2012-10-09 17:01:28 -07:00
Russ Cox
edce634963 time: prepare for 64-bit ints
The code was trying to interpret a uint32 n as a signed quantity
and then store it in an int. For this, int(n) currently works, but when
int becomes 64 bits one must write int(int32(n)) instead, to get
the 32-bit sign extension.

Update #2188.

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/6551068
2012-09-23 23:04:28 -04:00
Rob Pike
6fd2febaef time: fix spacing in comment.
No semantic change.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6475050
2012-08-22 21:30:18 -07:00
Carlos Castillo
7802080962 time: add YearDay method for time.Time structs
YearDay provides the day in the year represented by a given time.Time
object. This value is normally computed as part of other date calculations,
but not exported.

Fixes #3932.

R=golang-dev, r, remyoudompheng
CC=golang-dev, rsc
https://golang.org/cl/6460069
2012-08-22 20:49:16 -07:00
Rob Pike
84a5a9b558 time: avoid data race in abs
Fixes #3967.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6460115
2012-08-22 14:36:23 -07:00
Russ Cox
dcc46388df time: accept .999 in Parse
The recent shuffle in parsing formats exposed probably unintentional
behavior in time.Parse, namely that it was mostly ignoring ".99999"
in the format, producing the following behavior:

fmt.Println(time.Parse("03:04:05.999 MST", "12:00:00.888 PDT")) // error (.888 unexpected)
fmt.Println(time.Parse("03:04:05.999", "12:00:00")) // error (input too short)
fmt.Println(time.Parse("03:04:05.999 MST", "12:00:00 PDT"))  // ok (extra bytes on input make it ok)

http://play.golang.org/p/ESJ1UYXzq2

API CHANGE:

This CL makes all three examples valid: ".999" can match an
empty string or else a fractional second with at most nine digits.

Fixes #3701.

R=r, r
CC=golang-dev
https://golang.org/cl/6267045
2012-06-04 13:09:19 -04:00
Russ Cox
a76c8b2430 time: make Format 2.7x faster
benchmark             old ns/op    new ns/op    delta
BenchmarkFormat            2495          937  -62.44%
BenchmarkFormatNow         2308          889  -61.48%

Update #3679.

R=r
CC=golang-dev
https://golang.org/cl/6278047
2012-06-03 11:08:17 -04:00
Dmitriy Vyukov
a0efca84e6 time: fix deadlock in Sleep(0)
See time/sleep_test.go for repro.

R=golang-dev, r, rsc
CC=golang-dev, patrick.allen.higgins
https://golang.org/cl/6250072
2012-05-29 22:30:56 +04:00
David Symonds
555ca36c1d time: doc fix.
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6127050
2012-04-26 11:28:35 +10:00
Ian Lance Taylor
426bf36131 time: change float expression to ensure it is an integer
When I increased the number of bits that gccgo uses for
untyped floats, the expression 0.52*1e9 was no longer
integral.  This patch fixes that.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6113043
2012-04-23 15:46:54 -07:00
Robert Hencke
c81705f13a time: parse fractional second with single digit
Fixes #3487.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6011050
2012-04-16 11:56:37 +10:00
Gustavo Niemeyer
e4389c1d30 time: panic if UnixNano is out of range
R=golang-dev, remyoudompheng, dsymonds, gustavo, dchest, r, rsc
CC=golang-dev
https://golang.org/cl/5985059
2012-04-12 22:16:31 -03:00