aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/time
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2016-07-22 18:15:38 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2016-07-22 18:15:38 +0000
commit22b955cca564a9a3a5b8c9d9dd1e295b7943c128 (patch)
treeabdbd898676e1f853fca2d7e031d105d7ebcf676 /libgo/go/time
parent9d04a3af4c6491536badf6bde9707c907e4d196b (diff)
downloadgcc-22b955cca564a9a3a5b8c9d9dd1e295b7943c128.zip
gcc-22b955cca564a9a3a5b8c9d9dd1e295b7943c128.tar.gz
gcc-22b955cca564a9a3a5b8c9d9dd1e295b7943c128.tar.bz2
libgo: update to go1.7rc3
Reviewed-on: https://go-review.googlesource.com/25150 From-SVN: r238662
Diffstat (limited to 'libgo/go/time')
-rw-r--r--libgo/go/time/example_test.go2
-rw-r--r--libgo/go/time/format.go9
-rw-r--r--libgo/go/time/format_test.go2
-rw-r--r--libgo/go/time/genzabbrs.go2
-rw-r--r--libgo/go/time/sleep.go27
-rw-r--r--libgo/go/time/sys_plan9.go4
-rw-r--r--libgo/go/time/sys_unix.go4
-rw-r--r--libgo/go/time/sys_windows.go4
-rw-r--r--libgo/go/time/tick.go3
-rw-r--r--libgo/go/time/tick_test.go2
-rw-r--r--libgo/go/time/time.go58
-rw-r--r--libgo/go/time/time_test.go4
-rw-r--r--libgo/go/time/zoneinfo_abbrs_windows.go40
-rw-r--r--libgo/go/time/zoneinfo_read.go11
-rw-r--r--libgo/go/time/zoneinfo_test.go11
-rw-r--r--libgo/go/time/zoneinfo_unix.go8
-rw-r--r--libgo/go/time/zoneinfo_windows.go4
17 files changed, 127 insertions, 68 deletions
diff --git a/libgo/go/time/example_test.go b/libgo/go/time/example_test.go
index f76fdcd4..4170d51 100644
--- a/libgo/go/time/example_test.go
+++ b/libgo/go/time/example_test.go
@@ -1,4 +1,4 @@
-// Copyright 2011 The Go Authors. All rights reserved.
+// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/libgo/go/time/format.go b/libgo/go/time/format.go
index e616feb..c2ae793 100644
--- a/libgo/go/time/format.go
+++ b/libgo/go/time/format.go
@@ -23,7 +23,7 @@ import "errors"
// compatibility with fixed-width Unix time formats.
//
// A decimal point followed by one or more zeros represents a fractional
-// second, printed to the given number of decimal places. A decimal point
+// second, printed to the given number of decimal places. A decimal point
// followed by one or more nines represents a fractional second, printed to
// the given number of decimal places, with trailing zeros removed.
// When parsing (only), the input may contain a fractional second
@@ -37,7 +37,7 @@ import "errors"
// -07 ±hh
// Replacing the sign in the format with a Z triggers
// the ISO 8601 behavior of printing Z instead of an
-// offset for the UTC zone. Thus:
+// offset for the UTC zone. Thus:
// Z0700 Z or ±hhmm
// Z07:00 Z or ±hh:mm
// Z07 Z or ±hh
@@ -51,6 +51,9 @@ import "errors"
// use of "GMT" in that case.
// In general RFC1123Z should be used instead of RFC1123 for servers
// that insist on that format, and RFC3339 should be preferred for new protocols.
+// RFC822, RFC822Z, RFC1123, and RFC1123Z are useful for formatting;
+// when used with time.Parse they do not accept all the time formats
+// permitted by the RFCs.
const (
ANSIC = "Mon Jan _2 15:04:05 2006"
UnixDate = "Mon Jan _2 15:04:05 MST 2006"
@@ -551,7 +554,7 @@ func (t Time) AppendFormat(b []byte, layout string) []byte {
b = append(b, "am"...)
}
case stdISO8601TZ, stdISO8601ColonTZ, stdISO8601SecondsTZ, stdISO8601ShortTZ, stdISO8601ColonSecondsTZ, stdNumTZ, stdNumColonTZ, stdNumSecondsTz, stdNumShortTZ, stdNumColonSecondsTZ:
- // Ugly special case. We cheat and take the "Z" variants
+ // Ugly special case. We cheat and take the "Z" variants
// to mean "the time zone as formatted for ISO 8601".
if offset == 0 && (std == stdISO8601TZ || std == stdISO8601ColonTZ || std == stdISO8601SecondsTZ || std == stdISO8601ShortTZ || std == stdISO8601ColonSecondsTZ) {
b = append(b, 'Z')
diff --git a/libgo/go/time/format_test.go b/libgo/go/time/format_test.go
index a2592e2..ed5509b3 100644
--- a/libgo/go/time/format_test.go
+++ b/libgo/go/time/format_test.go
@@ -449,7 +449,7 @@ func TestParseErrors(t *testing.T) {
_, err := Parse(test.format, test.value)
if err == nil {
t.Errorf("expected error for %q %q", test.format, test.value)
- } else if strings.Index(err.Error(), test.expect) < 0 {
+ } else if !strings.Contains(err.Error(), test.expect) {
t.Errorf("expected error with %q for %q %q; got %s", test.expect, test.format, test.value, err)
}
}
diff --git a/libgo/go/time/genzabbrs.go b/libgo/go/time/genzabbrs.go
index 9eb0728..6281f73 100644
--- a/libgo/go/time/genzabbrs.go
+++ b/libgo/go/time/genzabbrs.go
@@ -30,7 +30,7 @@ var filename = flag.String("output", "zoneinfo_abbrs_windows.go", "output file n
// getAbbrs finds timezone abbreviations (standard and daylight saving time)
// for location l.
func getAbbrs(l *time.Location) (st, dt string) {
- t := time.Date(time.Now().Year(), 0, 0, 0, 0, 0, 0, l)
+ t := time.Date(time.Now().Year(), 0, 1, 0, 0, 0, 0, l)
abbr1, off1 := t.Zone()
for i := 0; i < 12; i++ {
t = t.AddDate(0, 1, 0)
diff --git a/libgo/go/time/sleep.go b/libgo/go/time/sleep.go
index e7a2ee2..73114f5 100644
--- a/libgo/go/time/sleep.go
+++ b/libgo/go/time/sleep.go
@@ -24,7 +24,7 @@ type runtimeTimer struct {
// when is a helper function for setting the 'when' field of a runtimeTimer.
// It returns what the time will be, in nanoseconds, Duration d in the future.
-// If d is negative, it is ignored. If the returned value would be less than
+// If d is negative, it is ignored. If the returned value would be less than
// zero because of an overflow, MaxInt64 is returned.
func when(d Duration) int64 {
if d <= 0 {
@@ -54,6 +54,14 @@ type Timer struct {
// expired or been stopped.
// Stop does not close the channel, to prevent a read from the channel succeeding
// incorrectly.
+//
+// To prevent the timer firing after a call to Stop,
+// check the return value and drain the channel. For example:
+// if !t.Stop() {
+// <-t.C
+// }
+// This cannot be done concurrent to other receives from the Timer's
+// channel.
func (t *Timer) Stop() bool {
if t.r.f == nil {
panic("time: Stop called on uninitialized Timer")
@@ -80,6 +88,20 @@ func NewTimer(d Duration) *Timer {
// Reset changes the timer to expire after duration d.
// It returns true if the timer had been active, false if the timer had
// expired or been stopped.
+//
+// To reuse an active timer, always call its Stop method first and—if it had
+// expired—drain the value from its channel. For example:
+// if !t.Stop() {
+// <-t.C
+// }
+// t.Reset(d)
+// This should not be done concurrent to other receives from the Timer's
+// channel.
+//
+// Note that it is not possible to use Reset's return value correctly, as there
+// is a race condition between draining the channel and the new timer expiring.
+// Reset should always be used in concert with Stop, as described above.
+// The return value exists to preserve compatibility with existing programs.
func (t *Timer) Reset(d Duration) bool {
if t.r.f == nil {
panic("time: Reset called on uninitialized Timer")
@@ -106,6 +128,9 @@ func sendTime(c interface{}, seq uintptr) {
// After waits for the duration to elapse and then sends the current time
// on the returned channel.
// It is equivalent to NewTimer(d).C.
+// The underlying Timer is not recovered by the garbage collector
+// until the timer fires. If efficiency is a concern, use NewTimer
+// instead and call Timer.Stop if the timer is no longer needed.
func After(d Duration) <-chan Time {
return NewTimer(d).C
}
diff --git a/libgo/go/time/sys_plan9.go b/libgo/go/time/sys_plan9.go
index 8484729..11365a7 100644
--- a/libgo/go/time/sys_plan9.go
+++ b/libgo/go/time/sys_plan9.go
@@ -55,9 +55,9 @@ func closefd(fd uintptr) {
}
func preadn(fd uintptr, buf []byte, off int) error {
- whence := 0
+ whence := seekStart
if off < 0 {
- whence = 2
+ whence = seekEnd
}
if _, err := syscall.Seek(int(fd), int64(off), whence); err != nil {
return err
diff --git a/libgo/go/time/sys_unix.go b/libgo/go/time/sys_unix.go
index e592415..91d54c9 100644
--- a/libgo/go/time/sys_unix.go
+++ b/libgo/go/time/sys_unix.go
@@ -55,9 +55,9 @@ func closefd(fd uintptr) {
}
func preadn(fd uintptr, buf []byte, off int) error {
- whence := 0
+ whence := seekStart
if off < 0 {
- whence = 2
+ whence = seekEnd
}
if _, err := syscall.Seek(int(fd), int64(off), whence); err != nil {
return err
diff --git a/libgo/go/time/sys_windows.go b/libgo/go/time/sys_windows.go
index de63b4b..a4a068f 100644
--- a/libgo/go/time/sys_windows.go
+++ b/libgo/go/time/sys_windows.go
@@ -52,9 +52,9 @@ func closefd(fd uintptr) {
}
func preadn(fd uintptr, buf []byte, off int) error {
- whence := 0
+ whence := seekStart
if off < 0 {
- whence = 2
+ whence = seekEnd
}
if _, err := syscall.Seek(syscall.Handle(fd), int64(off), whence); err != nil {
return err
diff --git a/libgo/go/time/tick.go b/libgo/go/time/tick.go
index 196e8ac..3d69320 100644
--- a/libgo/go/time/tick.go
+++ b/libgo/go/time/tick.go
@@ -39,7 +39,7 @@ func NewTicker(d Duration) *Ticker {
return t
}
-// Stop turns off a ticker. After Stop, no more ticks will be sent.
+// Stop turns off a ticker. After Stop, no more ticks will be sent.
// Stop does not close the channel, to prevent a read from the channel succeeding
// incorrectly.
func (t *Ticker) Stop() {
@@ -50,6 +50,7 @@ func (t *Ticker) Stop() {
// channel only. While Tick is useful for clients that have no need to shut down
// the Ticker, be aware that without a way to shut it down the underlying
// Ticker cannot be recovered by the garbage collector; it "leaks".
+// Unlike NewTicker, Tick will return nil if d <= 0.
func Tick(d Duration) <-chan Time {
if d <= 0 {
return nil
diff --git a/libgo/go/time/tick_test.go b/libgo/go/time/tick_test.go
index 32f4740..2ab77f6 100644
--- a/libgo/go/time/tick_test.go
+++ b/libgo/go/time/tick_test.go
@@ -35,7 +35,7 @@ func TestTicker(t *testing.T) {
}
}
-// Test that a bug tearing down a ticker has been fixed. This routine should not deadlock.
+// Test that a bug tearing down a ticker has been fixed. This routine should not deadlock.
func TestTeardown(t *testing.T) {
Delta := 100 * Millisecond
if testing.Short() {
diff --git a/libgo/go/time/time.go b/libgo/go/time/time.go
index ef4ba58..c31de35 100644
--- a/libgo/go/time/time.go
+++ b/libgo/go/time/time.go
@@ -12,8 +12,8 @@ import "errors"
// A Time represents an instant in time with nanosecond precision.
//
// Programs using times should typically store and pass them as values,
-// not pointers. That is, time variables and struct fields should be of
-// type time.Time, not *time.Time. A Time value can be used by
+// not pointers. That is, time variables and struct fields should be of
+// type time.Time, not *time.Time. A Time value can be used by
// multiple goroutines simultaneously.
//
// Time instants can be compared using the Before, After, and Equal methods.
@@ -146,7 +146,7 @@ func (d Weekday) String() string { return days[d] }
// 00:00:00 UTC, which would be 12-31-(-1) 19:00:00 in New York.
//
// The zero Time value does not force a specific epoch for the time
-// representation. For example, to use the Unix epoch internally, we
+// representation. For example, to use the Unix epoch internally, we
// could define that to distinguish a zero value from Jan 1 1970, that
// time would be represented by sec=-1, nsec=1e9. However, it does
// suggest a representation, namely using 1-1-1 00:00:00 UTC as the
@@ -155,17 +155,17 @@ func (d Weekday) String() string { return days[d] }
// The Add and Sub computations are oblivious to the choice of epoch.
//
// The presentation computations - year, month, minute, and so on - all
-// rely heavily on division and modulus by positive constants. For
+// rely heavily on division and modulus by positive constants. For
// calendrical calculations we want these divisions to round down, even
// for negative values, so that the remainder is always positive, but
// Go's division (like most hardware division instructions) rounds to
-// zero. We can still do those computations and then adjust the result
+// zero. We can still do those computations and then adjust the result
// for a negative numerator, but it's annoying to write the adjustment
-// over and over. Instead, we can change to a different epoch so long
+// over and over. Instead, we can change to a different epoch so long
// ago that all the times we care about will be positive, and then round
-// to zero and round down coincide. These presentation routines already
+// to zero and round down coincide. These presentation routines already
// have to add the zone offset, so adding the translation to the
-// alternate epoch is cheap. For example, having a non-negative time t
+// alternate epoch is cheap. For example, having a non-negative time t
// means that we can write
//
// sec = t % 60
@@ -181,9 +181,9 @@ func (d Weekday) String() string { return days[d] }
//
// The calendar runs on an exact 400 year cycle: a 400-year calendar
// printed for 1970-2469 will apply as well to 2370-2769. Even the days
-// of the week match up. It simplifies the computations to choose the
+// of the week match up. It simplifies the computations to choose the
// cycle boundaries so that the exceptional years are always delayed as
-// long as possible. That means choosing a year equal to 1 mod 400, so
+// long as possible. That means choosing a year equal to 1 mod 400, so
// that the first leap year is the 4th year, the first missed leap year
// is the 100th year, and the missed missed leap year is the 400th year.
// So we'd prefer instead to print a calendar for 2001-2400 and reuse it
@@ -209,7 +209,7 @@ func (d Weekday) String() string { return days[d] }
// routines would then be invalid when displaying the epoch in time zones
// west of UTC, since it is year 0. It doesn't seem tenable to say that
// printing the zero time correctly isn't supported in half the time
-// zones. By comparison, it's reasonable to mishandle some times in
+// zones. By comparison, it's reasonable to mishandle some times in
// the year -292277022399.
//
// All this is opaque to clients of the API and can be changed if a
@@ -225,9 +225,6 @@ const (
// Assumed by the unixToInternal computation below.
internalYear = 1
- // The year of the zero Unix time.
- unixYear = 1970
-
// Offsets to convert between internal and absolute or Unix times.
absoluteToInternal int64 = (absoluteZeroYear - internalYear) * 365.2425 * secondsPerDay
internalToAbsolute = -absoluteToInternal
@@ -425,7 +422,7 @@ func (t Time) YearDay() int {
}
// A Duration represents the elapsed time between two instants
-// as an int64 nanosecond count. The representation limits the
+// as an int64 nanosecond count. The representation limits the
// largest representable duration to approximately 290 years.
type Duration int64
@@ -434,7 +431,7 @@ const (
maxDuration Duration = 1<<63 - 1
)
-// Common durations. There is no definition for units of Day or larger
+// Common durations. There is no definition for units of Day or larger
// to avoid confusion across daylight savings time zone transitions.
//
// To count the number of units in a Duration, divide:
@@ -455,10 +452,9 @@ const (
)
// String returns a string representing the duration in the form "72h3m0.5s".
-// Leading zero units are omitted. As a special case, durations less than one
+// Leading zero units are omitted. As a special case, durations less than one
// second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure
-// that the leading digit is non-zero. The zero duration formats as 0,
-// with no unit.
+// that the leading digit is non-zero. The zero duration formats as 0s.
func (d Duration) String() string {
// Largest time is 2540400h10m10.000000000s
var buf [32]byte
@@ -479,7 +475,7 @@ func (d Duration) String() string {
w--
switch {
case u == 0:
- return "0"
+ return "0s"
case u < uint64(Microsecond):
// print nanoseconds
prec = 0
@@ -609,7 +605,7 @@ func (d Duration) Hours() float64 {
// Add returns the time t+d.
func (t Time) Add(d Duration) Time {
t.sec += int64(d / 1e9)
- nsec := int32(t.nsec) + int32(d%1e9)
+ nsec := t.nsec + int32(d%1e9)
if nsec >= 1e9 {
t.sec++
nsec -= 1e9
@@ -626,7 +622,7 @@ func (t Time) Add(d Duration) Time {
// will be returned.
// To compute t-d for a duration d, use t.Add(-d).
func (t Time) Sub(u Time) Duration {
- d := Duration(t.sec-u.sec)*Second + Duration(int32(t.nsec)-int32(u.nsec))
+ d := Duration(t.sec-u.sec)*Second + Duration(t.nsec-u.nsec)
// Check for overflow or underflow.
switch {
case u.Add(d).Equal(t):
@@ -749,7 +745,7 @@ func absDate(abs uint64, full bool) (year int, month Month, day int, yday int) {
}
// daysBefore[m] counts the number of days in a non-leap year
-// before month m begins. There is an entry for m=12, counting
+// before month m begins. There is an entry for m=12, counting
// the number of days before January of next year (365).
var daysBefore = [...]int32{
0,
@@ -945,10 +941,11 @@ func (t Time) MarshalJSON() ([]byte, error) {
// UnmarshalJSON implements the json.Unmarshaler interface.
// The time is expected to be a quoted string in RFC 3339 format.
-func (t *Time) UnmarshalJSON(data []byte) (err error) {
+func (t *Time) UnmarshalJSON(data []byte) error {
// Fractional seconds are handled implicitly by Parse.
+ var err error
*t, err = Parse(`"`+RFC3339+`"`, string(data))
- return
+ return err
}
// MarshalText implements the encoding.TextMarshaler interface.
@@ -964,10 +961,11 @@ func (t Time) MarshalText() ([]byte, error) {
// UnmarshalText implements the encoding.TextUnmarshaler interface.
// The time is expected to be in RFC 3339 format.
-func (t *Time) UnmarshalText(data []byte) (err error) {
+func (t *Time) UnmarshalText(data []byte) error {
// Fractional seconds are handled implicitly by Parse.
+ var err error
*t, err = Parse(RFC3339, string(data))
- return
+ return err
}
// Unix returns the local Time corresponding to the given Unix time,
@@ -1019,7 +1017,7 @@ func norm(hi, lo, base int) (nhi, nlo int) {
//
// A daylight savings time transition skips or repeats times.
// For example, in the United States, March 13, 2011 2:15am never occurred,
-// while November 6, 2011 1:15am occurred twice. In such cases, the
+// while November 6, 2011 1:15am occurred twice. In such cases, the
// choice of time zone, and therefore the time, is not well-defined.
// Date returns a time that is correct in one of the two zones involved
// in the transition, but it does not guarantee which.
@@ -1126,7 +1124,7 @@ func (t Time) Round(d Duration) Time {
// but it's still here in case we change our minds.
func div(t Time, d Duration) (qmod2 int, r Duration) {
neg := false
- nsec := int32(t.nsec)
+ nsec := t.nsec
if t.sec < 0 {
// Operate on absolute value.
neg = true
@@ -1160,7 +1158,7 @@ func div(t Time, d Duration) (qmod2 int, r Duration) {
tmp := (sec >> 32) * 1e9
u1 := tmp >> 32
u0 := tmp << 32
- tmp = uint64(sec&0xFFFFFFFF) * 1e9
+ tmp = (sec & 0xFFFFFFFF) * 1e9
u0x, u0 := u0, u0+tmp
if u0 < u0x {
u1++
diff --git a/libgo/go/time/time_test.go b/libgo/go/time/time_test.go
index a925e98..b7ebb37 100644
--- a/libgo/go/time/time_test.go
+++ b/libgo/go/time/time_test.go
@@ -22,7 +22,7 @@ import (
// the subsequent tests fail.
func TestZoneData(t *testing.T) {
lt := Now()
- // PST is 8 hours west, PDT is 7 hours west. We could use the name but it's not unique.
+ // PST is 8 hours west, PDT is 7 hours west. We could use the name but it's not unique.
if name, off := lt.Zone(); off != -8*60*60 && off != -7*60*60 {
t.Errorf("Unable to find US Pacific time zone data for testing; time zone is %q offset %d", name, off)
t.Error("Likely problem: the time zone files have not been installed.")
@@ -533,7 +533,7 @@ var durationTests = []struct {
str string
d Duration
}{
- {"0", 0},
+ {"0s", 0},
{"1ns", 1 * Nanosecond},
{"1.1µs", 1100 * Nanosecond},
{"2.2ms", 2200 * Microsecond},
diff --git a/libgo/go/time/zoneinfo_abbrs_windows.go b/libgo/go/time/zoneinfo_abbrs_windows.go
index 51a1a2f..344a891 100644
--- a/libgo/go/time/zoneinfo_abbrs_windows.go
+++ b/libgo/go/time/zoneinfo_abbrs_windows.go
@@ -22,9 +22,10 @@ var abbrs = map[string]abbr{
"Namibia Standard Time": {"WAT", "WAST"}, // Africa/Windhoek
"Alaskan Standard Time": {"AKST", "AKDT"}, // America/Anchorage
"Paraguay Standard Time": {"PYT", "PYST"}, // America/Asuncion
- "Bahia Standard Time": {"BRT", "BRST"}, // America/Bahia
+ "Bahia Standard Time": {"BRT", "BRT"}, // America/Bahia
"SA Pacific Standard Time": {"COT", "COT"}, // America/Bogota
"Argentina Standard Time": {"ART", "ART"}, // America/Buenos_Aires
+ "Eastern Standard Time (Mexico)": {"EST", "EST"}, // America/Cancun
"Venezuela Standard Time": {"VET", "VET"}, // America/Caracas
"SA Eastern Standard Time": {"GFT", "GFT"}, // America/Cayenne
"Central Standard Time": {"CST", "CDT"}, // America/Chicago
@@ -38,21 +39,22 @@ var abbrs = map[string]abbr{
"SA Western Standard Time": {"BOT", "BOT"}, // America/La_Paz
"Pacific Standard Time": {"PST", "PDT"}, // America/Los_Angeles
"Central Standard Time (Mexico)": {"CST", "CDT"}, // America/Mexico_City
- "Montevideo Standard Time": {"UYT", "UYST"}, // America/Montevideo
+ "Montevideo Standard Time": {"UYT", "UYT"}, // America/Montevideo
"Eastern Standard Time": {"EST", "EDT"}, // America/New_York
"US Mountain Standard Time": {"MST", "MST"}, // America/Phoenix
"Canada Central Standard Time": {"CST", "CST"}, // America/Regina
- "Pacific Standard Time (Mexico)": {"PST", "PDT"}, // America/Santa_Isabel
"Pacific SA Standard Time": {"CLT", "CLST"}, // America/Santiago
"E. South America Standard Time": {"BRT", "BRST"}, // America/Sao_Paulo
"Newfoundland Standard Time": {"NST", "NDT"}, // America/St_Johns
- "Central Asia Standard Time": {"ALMT", "ALMT"}, // Asia/Almaty
+ "Central Asia Standard Time": {"+06", "+06"}, // Asia/Almaty
"Jordan Standard Time": {"EET", "EEST"}, // Asia/Amman
"Arabic Standard Time": {"AST", "AST"}, // Asia/Baghdad
- "Azerbaijan Standard Time": {"AZT", "AZST"}, // Asia/Baku
+ "Azerbaijan Standard Time": {"AZT", "AZT"}, // Asia/Baku
"SE Asia Standard Time": {"ICT", "ICT"}, // Asia/Bangkok
+ "Altai Standard Time": {"+06", "+07"}, // Asia/Barnaul
"Middle East Standard Time": {"EET", "EEST"}, // Asia/Beirut
"India Standard Time": {"IST", "IST"}, // Asia/Calcutta
+ "Transbaikal Standard Time": {"IRKT", "YAKT"}, // Asia/Chita
"Sri Lanka Standard Time": {"IST", "IST"}, // Asia/Colombo
"Syria Standard Time": {"EET", "EEST"}, // Asia/Damascus
"Bangladesh Standard Time": {"BDT", "BDT"}, // Asia/Dhaka
@@ -60,22 +62,26 @@ var abbrs = map[string]abbr{
"North Asia East Standard Time": {"IRKT", "IRKT"}, // Asia/Irkutsk
"Israel Standard Time": {"IST", "IDT"}, // Asia/Jerusalem
"Afghanistan Standard Time": {"AFT", "AFT"}, // Asia/Kabul
+ "Russia Time Zone 11": {"PETT", "PETT"}, // Asia/Kamchatka
"Pakistan Standard Time": {"PKT", "PKT"}, // Asia/Karachi
"Nepal Standard Time": {"NPT", "NPT"}, // Asia/Katmandu
"North Asia Standard Time": {"KRAT", "KRAT"}, // Asia/Krasnoyarsk
"Magadan Standard Time": {"MAGT", "MAGT"}, // Asia/Magadan
"N. Central Asia Standard Time": {"NOVT", "NOVT"}, // Asia/Novosibirsk
+ "North Korea Standard Time": {"KST", "KST"}, // Asia/Pyongyang
"Myanmar Standard Time": {"MMT", "MMT"}, // Asia/Rangoon
"Arab Standard Time": {"AST", "AST"}, // Asia/Riyadh
+ "Sakhalin Standard Time": {"SAKT", "SAKT"}, // Asia/Sakhalin
"Korea Standard Time": {"KST", "KST"}, // Asia/Seoul
"China Standard Time": {"CST", "CST"}, // Asia/Shanghai
"Singapore Standard Time": {"SGT", "SGT"}, // Asia/Singapore
+ "Russia Time Zone 10": {"SRET", "SRET"}, // Asia/Srednekolymsk
"Taipei Standard Time": {"CST", "CST"}, // Asia/Taipei
"West Asia Standard Time": {"UZT", "UZT"}, // Asia/Tashkent
"Georgian Standard Time": {"GET", "GET"}, // Asia/Tbilisi
"Iran Standard Time": {"IRST", "IRDT"}, // Asia/Tehran
"Tokyo Standard Time": {"JST", "JST"}, // Asia/Tokyo
- "Ulaanbaatar Standard Time": {"ULAT", "ULAT"}, // Asia/Ulaanbaatar
+ "Ulaanbaatar Standard Time": {"ULAT", "ULAST"}, // Asia/Ulaanbaatar
"Vladivostok Standard Time": {"VLAT", "VLAT"}, // Asia/Vladivostok
"Yakutsk Standard Time": {"YAKT", "YAKT"}, // Asia/Yakutsk
"Ekaterinburg Standard Time": {"YEKT", "YEKT"}, // Asia/Yekaterinburg
@@ -83,31 +89,35 @@ var abbrs = map[string]abbr{
"Azores Standard Time": {"AZOT", "AZOST"}, // Atlantic/Azores
"Cape Verde Standard Time": {"CVT", "CVT"}, // Atlantic/Cape_Verde
"Greenwich Standard Time": {"GMT", "GMT"}, // Atlantic/Reykjavik
- "Cen. Australia Standard Time": {"CST", "CST"}, // Australia/Adelaide
- "E. Australia Standard Time": {"EST", "EST"}, // Australia/Brisbane
- "AUS Central Standard Time": {"CST", "CST"}, // Australia/Darwin
- "Tasmania Standard Time": {"EST", "EST"}, // Australia/Hobart
- "W. Australia Standard Time": {"WST", "WST"}, // Australia/Perth
- "AUS Eastern Standard Time": {"EST", "EST"}, // Australia/Sydney
+ "Cen. Australia Standard Time": {"ACST", "ACDT"}, // Australia/Adelaide
+ "E. Australia Standard Time": {"AEST", "AEST"}, // Australia/Brisbane
+ "AUS Central Standard Time": {"ACST", "ACST"}, // Australia/Darwin
+ "Tasmania Standard Time": {"AEST", "AEDT"}, // Australia/Hobart
+ "W. Australia Standard Time": {"AWST", "AWST"}, // Australia/Perth
+ "AUS Eastern Standard Time": {"AEST", "AEDT"}, // Australia/Sydney
"UTC": {"GMT", "GMT"}, // Etc/GMT
"UTC-11": {"GMT+11", "GMT+11"}, // Etc/GMT+11
"Dateline Standard Time": {"GMT+12", "GMT+12"}, // Etc/GMT+12
"UTC-02": {"GMT+2", "GMT+2"}, // Etc/GMT+2
"UTC+12": {"GMT-12", "GMT-12"}, // Etc/GMT-12
+ "Astrakhan Standard Time": {"+03", "+04"}, // Europe/Astrakhan
"W. Europe Standard Time": {"CET", "CEST"}, // Europe/Berlin
"GTB Standard Time": {"EET", "EEST"}, // Europe/Bucharest
"Central Europe Standard Time": {"CET", "CEST"}, // Europe/Budapest
+ "E. Europe Standard Time": {"EET", "EEST"}, // Europe/Chisinau
"Turkey Standard Time": {"EET", "EEST"}, // Europe/Istanbul
- "Kaliningrad Standard Time": {"FET", "FET"}, // Europe/Kaliningrad
+ "Kaliningrad Standard Time": {"EET", "EET"}, // Europe/Kaliningrad
"FLE Standard Time": {"EET", "EEST"}, // Europe/Kiev
"GMT Standard Time": {"GMT", "BST"}, // Europe/London
+ "Belarus Standard Time": {"MSK", "MSK"}, // Europe/Minsk
"Russian Standard Time": {"MSK", "MSK"}, // Europe/Moscow
"Romance Standard Time": {"CET", "CEST"}, // Europe/Paris
+ "Russia Time Zone 3": {"SAMT", "SAMT"}, // Europe/Samara
"Central European Standard Time": {"CET", "CEST"}, // Europe/Warsaw
"Mauritius Standard Time": {"MUT", "MUT"}, // Indian/Mauritius
- "Samoa Standard Time": {"WST", "WST"}, // Pacific/Apia
+ "Samoa Standard Time": {"WSST", "WSDT"}, // Pacific/Apia
"New Zealand Standard Time": {"NZST", "NZDT"}, // Pacific/Auckland
- "Fiji Standard Time": {"FJT", "FJT"}, // Pacific/Fiji
+ "Fiji Standard Time": {"FJT", "FJST"}, // Pacific/Fiji
"Central Pacific Standard Time": {"SBT", "SBT"}, // Pacific/Guadalcanal
"Hawaiian Standard Time": {"HST", "HST"}, // Pacific/Honolulu
"Line Islands Standard Time": {"LINT", "LINT"}, // Pacific/Kiritimati
diff --git a/libgo/go/time/zoneinfo_read.go b/libgo/go/time/zoneinfo_read.go
index de9ebb4..19cd40d 100644
--- a/libgo/go/time/zoneinfo_read.go
+++ b/libgo/go/time/zoneinfo_read.go
@@ -11,6 +11,13 @@ package time
import "errors"
+// Copies of io.Seek* constants to avoid importing "io":
+const (
+ seekStart = 0
+ seekCurrent = 1
+ seekEnd = 2
+)
+
// Simple I/O interface to binary blob of data.
type data struct {
p []byte
@@ -210,10 +217,10 @@ func loadZoneFile(dir, name string) (l *Location, err error) {
return loadZoneData(buf)
}
-// There are 500+ zoneinfo files. Rather than distribute them all
+// There are 500+ zoneinfo files. Rather than distribute them all
// individually, we ship them in an uncompressed zip file.
// Used this way, the zip file format serves as a commonly readable
-// container for the individual small files. We choose zip over tar
+// container for the individual small files. We choose zip over tar
// because zip files have a contiguous table of contents, making
// individual file lookups faster, and because the per-file overhead
// in a zip file is considerably less than tar's 512 bytes.
diff --git a/libgo/go/time/zoneinfo_test.go b/libgo/go/time/zoneinfo_test.go
index ede5330..5b6a4dc 100644
--- a/libgo/go/time/zoneinfo_test.go
+++ b/libgo/go/time/zoneinfo_test.go
@@ -20,7 +20,7 @@ func TestVersion3(t *testing.T) {
}
// Test that we get the correct results for times before the first
-// transition time. To do this we explicitly check early dates in a
+// transition time. To do this we explicitly check early dates in a
// couple of specific timezones.
func TestFirstZone(t *testing.T) {
t.Skip("gccgo does not use the zip file")
@@ -64,3 +64,12 @@ func TestFirstZone(t *testing.T) {
}
}
}
+
+func TestLocationNames(t *testing.T) {
+ if time.Local.String() != "Local" {
+ t.Errorf(`invalid Local location name: got %q want "Local"`, time.Local)
+ }
+ if time.UTC.String() != "UTC" {
+ t.Errorf(`invalid UTC location name: got %q want "UTC"`, time.UTC)
+ }
+}
diff --git a/libgo/go/time/zoneinfo_unix.go b/libgo/go/time/zoneinfo_unix.go
index 5fc669e..6c7aaff 100644
--- a/libgo/go/time/zoneinfo_unix.go
+++ b/libgo/go/time/zoneinfo_unix.go
@@ -18,8 +18,12 @@ import (
)
func initTestingZone() {
- syscall.Setenv("TZ", "America/Los_Angeles")
- initLocal()
+ z, err := loadLocation("America/Los_Angeles")
+ if err != nil {
+ panic("cannot load America/Los_Angeles for testing: " + err.Error())
+ }
+ z.name = "Local"
+ localLoc = *z
}
// Many systems use /usr/share/zoneinfo, Solaris 2 has
diff --git a/libgo/go/time/zoneinfo_windows.go b/libgo/go/time/zoneinfo_windows.go
index bcb8ccd..a6546f5 100644
--- a/libgo/go/time/zoneinfo_windows.go
+++ b/libgo/go/time/zoneinfo_windows.go
@@ -83,7 +83,7 @@ func extractCAPS(desc string) string {
var short []rune
for _, c := range desc {
if 'A' <= c && c <= 'Z' {
- short = append(short, rune(c))
+ short = append(short, c)
}
}
return string(short)
@@ -140,6 +140,8 @@ func pseudoUnix(year int, d *syscall.Systemtime) int64 {
func initLocalFromTZI(i *syscall.Timezoneinformation) {
l := &localLoc
+ l.name = "Local"
+
nzone := 1
if i.StandardDate.Month > 0 {
nzone++