From a6ec750f4a18415e1c798ff8ec867157d2cd903e Mon Sep 17 00:00:00 2001 From: Mark McGranaghan Date: Fri, 2 Nov 2012 09:34:36 -0700 Subject: [PATCH] fix kitchen times, show an example of constants --- .../time-formatting-parsing.go | 8 ++++++-- .../time-formatting-parsing.sh | 13 +++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/examples/time-formatting-parsing/time-formatting-parsing.go b/examples/time-formatting-parsing/time-formatting-parsing.go index a6ebe80..88e0afc 100644 --- a/examples/time-formatting-parsing/time-formatting-parsing.go +++ b/examples/time-formatting-parsing/time-formatting-parsing.go @@ -20,7 +20,7 @@ func main() { // general pattern with which to format the given // time. Here are a few more examples of time // formatting. - p(t.Format("4:05PM")) + p(t.Format("3:04PM")) p(t.Format("Mon Jan _2 15:04:05 2006")) p(t.Format("2006-01-02T15:04:05.999999-07:00")) @@ -39,7 +39,7 @@ func main() { withNanos, "2012-11-01T22:08:41.117442+00:00") p(t1) - kitchen := "4:05PM" + kitchen := "3:04PM" t2, e := time.Parse(kitchen, "8:41PM") p(t2) @@ -48,4 +48,8 @@ func main() { ansic := "Mon Jan _2 15:04:05 2006" _, e = time.Parse(ansic, "8:41PM") p(e) + + // There are several predefined formats that you can + // use for both formatting and parsing. + p(t.Format(time.Kitchen)) } diff --git a/examples/time-formatting-parsing/time-formatting-parsing.sh b/examples/time-formatting-parsing/time-formatting-parsing.sh index a205ea6..e307e4e 100644 --- a/examples/time-formatting-parsing/time-formatting-parsing.sh +++ b/examples/time-formatting-parsing/time-formatting-parsing.sh @@ -1,9 +1,10 @@ $ go run time-formatting-parsing.go -2012-11-01T15:17:41-07:00 -17:41PM -Thu Nov 1 15:17:41 2012 -2012-11-01T15:17:41.256589-07:00 -2012-11-01T15:17:41-00:00 +2012-11-02T09:35:03-07:00 +9:35AM +Fri Nov 2 09:35:03 2012 +2012-11-02T09:35:03.982519-07:00 +2012-11-02T09:35:03-00:00 0001-01-01 00:00:00 +0000 UTC -0000-01-01 12:08:41 +0000 UTC +0000-01-01 20:41:00 +0000 UTC parsing time "8:41PM" as "Mon Jan _2 15:04:05 2006": ... +9:35AM