]> Cypherpunks repositories - gostls13.git/commitdiff
time: add RFC1123 with numeric timezone format
authorScott Lawrence <bytbox@gmail.com>
Mon, 31 Oct 2011 19:59:06 +0000 (12:59 -0700)
committerRob Pike <r@golang.org>
Mon, 31 Oct 2011 19:59:06 +0000 (12:59 -0700)
Fixes #841.

R=rsc, r
CC=golang-dev
https://golang.org/cl/5322058

src/pkg/time/format.go
src/pkg/time/time_test.go

index 50e96a5c2591b724f7d98d3a82e44c44ce260543..1a629c918853ca5d2e2e27c6f666e9aab4558efc 100644 (file)
@@ -45,12 +45,12 @@ const (
        UnixDate = "Mon Jan _2 15:04:05 MST 2006"
        RubyDate = "Mon Jan 02 15:04:05 -0700 2006"
        RFC822   = "02 Jan 06 1504 MST"
-       // RFC822 with Zulu time.
-       RFC822Z = "02 Jan 06 1504 -0700"
-       RFC850  = "Monday, 02-Jan-06 15:04:05 MST"
-       RFC1123 = "Mon, 02 Jan 2006 15:04:05 MST"
-       RFC3339 = "2006-01-02T15:04:05Z07:00"
-       Kitchen = "3:04PM"
+       RFC822Z  = "02 Jan 06 1504 -0700" // RFC822 with numeric zone
+       RFC850   = "Monday, 02-Jan-06 15:04:05 MST"
+       RFC1123  = "Mon, 02 Jan 2006 15:04:05 MST"
+       RFC1123Z = "Mon, 02 Jan 2006 15:04:05 -0700" // RFC1123 with numeric zone
+       RFC3339  = "2006-01-02T15:04:05Z07:00"
+       Kitchen  = "3:04PM"
        // Handy time stamps.
        Stamp      = "Jan _2 15:04:05"
        StampMilli = "Jan _2 15:04:05.000"
index 353976c96936f1e9d589e502eb5a9909a8193be0..e4cf51374cb877b60c96500db9313c058924c57a 100644 (file)
@@ -201,6 +201,7 @@ var formatTests = []FormatTest{
        {"RFC822", RFC822, "04 Feb 09 2100 PST"},
        {"RFC850", RFC850, "Wednesday, 04-Feb-09 21:00:57 PST"},
        {"RFC1123", RFC1123, "Wed, 04 Feb 2009 21:00:57 PST"},
+       {"RFC1123Z", RFC1123Z, "Wed, 04 Feb 2009 21:00:57 -0800"},
        {"RFC3339", RFC3339, "2009-02-04T21:00:57-08:00"},
        {"Kitchen", Kitchen, "9:00PM"},
        {"am/pm", "3pm", "9pm"},
@@ -240,6 +241,7 @@ var parseTests = []ParseTest{
        {"RubyDate", RubyDate, "Thu Feb 04 21:00:57 -0800 2010", true, true, 1, 0},
        {"RFC850", RFC850, "Thursday, 04-Feb-10 21:00:57 PST", true, true, 1, 0},
        {"RFC1123", RFC1123, "Thu, 04 Feb 2010 21:00:57 PST", true, true, 1, 0},
+       {"RFC1123Z", RFC1123Z, "Thu, 04 Feb 2010 21:00:57 -0800", true, true, 1, 0},
        {"RFC3339", RFC3339, "2010-02-04T21:00:57-08:00", true, false, 1, 0},
        {"custom: \"2006-01-02 15:04:05-07\"", "2006-01-02 15:04:05-07", "2010-02-04 21:00:57-08", true, false, 1, 0},
        // Optional fractional seconds.
@@ -248,6 +250,7 @@ var parseTests = []ParseTest{
        {"RubyDate", RubyDate, "Thu Feb 04 21:00:57.012 -0800 2010", true, true, 1, 3},
        {"RFC850", RFC850, "Thursday, 04-Feb-10 21:00:57.0123 PST", true, true, 1, 4},
        {"RFC1123", RFC1123, "Thu, 04 Feb 2010 21:00:57.01234 PST", true, true, 1, 5},
+       {"RFC1123Z", RFC1123Z, "Thu, 04 Feb 2010 21:00:57.01234 -0800", true, true, 1, 5},
        {"RFC3339", RFC3339, "2010-02-04T21:00:57.012345678-08:00", true, false, 1, 9},
        // Amount of white space should not matter.
        {"ANSIC", ANSIC, "Thu Feb 4 21:00:57 2010", false, true, 1, 0},