Update dateparse helper cli doc

This commit is contained in:
Aaron Raddon 2017-07-26 22:18:40 -07:00
parent ec2a23bade
commit 56d24425b2
2 changed files with 69 additions and 70 deletions

View File

@ -13,19 +13,19 @@ $ dateparse --timezone="America/Denver" "2017-07-19 03:21:00"
Your Current time.Local zone is PDT
+------------+---------------------+---------------------------+-------------------------------+-------------------------------+
| method | Input | Zone Source | Parsed: %v | Parsed: t.In(time.UTC) |
+------------+---------------------+---------------------------+-------------------------------+-------------------------------+
| ParseAny | 2017-07-19 03:21:00 | time.Local = nil | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | 2017-07-19 03:21:00 | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | 2017-07-19 03:21:00 | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | 2017-07-19 03:21:00 | time.Local = nil | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | 2017-07-19 03:21:00 | time.Local = timezone arg | 2017-07-19 03:21:00 -0600 MDT | 2017-07-19 09:21:00 +0000 UTC |
| ParseIn | 2017-07-19 03:21:00 | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | 2017-07-19 03:21:00 | time.Local = nil | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | 2017-07-19 03:21:00 | time.Local = timezone arg | 2017-07-19 03:21:00 -0600 MDT | 2017-07-19 09:21:00 +0000 UTC |
| ParseLocal | 2017-07-19 03:21:00 | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
+------------+---------------------+---------------------------+-------------------------------+-------------------------------+
+------------+---------------------------+-------------------------------+-------------------------------+
| method | Zone Source | Parsed | Parsed: t.In(time.UTC) |
+------------+---------------------------+-------------------------------+-------------------------------+
| ParseAny | time.Local = nil | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | time.Local = nil | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | time.Local = timezone arg | 2017-07-19 03:21:00 -0600 MDT | 2017-07-19 09:21:00 +0000 UTC |
| ParseIn | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | time.Local = nil | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | time.Local = timezone arg | 2017-07-19 03:21:00 -0600 MDT | 2017-07-19 09:21:00 +0000 UTC |
| ParseLocal | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC |
+------------+---------------------------+-------------------------------+-------------------------------+
# Note on this one that the outputed zone is always UTC/0 offset as opposed to above
@ -33,38 +33,38 @@ $ dateparse --timezone="America/Denver" "2017-07-19 03:21:51+00:00"
Your Current time.Local zone is PDT
+------------+---------------------------+---------------------------+---------------------------------+-------------------------------+
| method | Input | Zone Source | Parsed: %v | Parsed: t.In(time.UTC) |
+------------+---------------------------+---------------------------+---------------------------------+-------------------------------+
| ParseAny | 2017-07-19 03:21:51+00:00 | time.Local = nil | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
| ParseAny | 2017-07-19 03:21:51+00:00 | time.Local = timezone arg | 2017-07-19 03:21:51 +0000 +0000 | 2017-07-19 03:21:51 +0000 UTC |
| ParseAny | 2017-07-19 03:21:51+00:00 | time.Local = time.UTC | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
| ParseIn | 2017-07-19 03:21:51+00:00 | time.Local = nil | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
| ParseIn | 2017-07-19 03:21:51+00:00 | time.Local = timezone arg | 2017-07-19 03:21:51 +0000 +0000 | 2017-07-19 03:21:51 +0000 UTC |
| ParseIn | 2017-07-19 03:21:51+00:00 | time.Local = time.UTC | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
| ParseLocal | 2017-07-19 03:21:51+00:00 | time.Local = nil | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
| ParseLocal | 2017-07-19 03:21:51+00:00 | time.Local = timezone arg | 2017-07-19 03:21:51 +0000 +0000 | 2017-07-19 03:21:51 +0000 UTC |
| ParseLocal | 2017-07-19 03:21:51+00:00 | time.Local = time.UTC | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
+------------+---------------------------+---------------------------+---------------------------------+-------------------------------+
+------------+---------------------------+---------------------------------+-------------------------------+
| method | Zone Source | Parsed | Parsed: t.In(time.UTC) |
+------------+---------------------------+---------------------------------+-------------------------------+
| ParseAny | time.Local = nil | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
| ParseAny | time.Local = timezone arg | 2017-07-19 03:21:51 +0000 +0000 | 2017-07-19 03:21:51 +0000 UTC |
| ParseAny | time.Local = time.UTC | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
| ParseIn | time.Local = nil | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
| ParseIn | time.Local = timezone arg | 2017-07-19 03:21:51 +0000 +0000 | 2017-07-19 03:21:51 +0000 UTC |
| ParseIn | time.Local = time.UTC | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
| ParseLocal | time.Local = nil | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
| ParseLocal | time.Local = timezone arg | 2017-07-19 03:21:51 +0000 +0000 | 2017-07-19 03:21:51 +0000 UTC |
| ParseLocal | time.Local = time.UTC | 2017-07-19 03:21:51 +0000 UTC | 2017-07-19 03:21:51 +0000 UTC |
+------------+---------------------------+---------------------------------+-------------------------------+
$ dateparse --timezone="America/Denver" "Monday, 19-Jul-17 03:21:00 MDT"
Your Current time.Local zone is PDT
+------------+--------------------------------+---------------------------+-------------------------------+-------------------------------+
| method | Input | Zone Source | Parsed: %v | Parsed: t.In(time.UTC) |
+------------+--------------------------------+---------------------------+-------------------------------+-------------------------------+
| ParseAny | Monday, 19-Jul-17 03:21:00 MDT | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | Monday, 19-Jul-17 03:21:00 MDT | time.Local = timezone arg | 2017-07-19 03:21:00 -0600 MDT | 2017-07-19 09:21:00 +0000 UTC |
| ParseAny | Monday, 19-Jul-17 03:21:00 MDT | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | Monday, 19-Jul-17 03:21:00 MDT | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | Monday, 19-Jul-17 03:21:00 MDT | time.Local = timezone arg | 2017-07-19 03:21:00 -0600 MDT | 2017-07-19 09:21:00 +0000 UTC |
| ParseIn | Monday, 19-Jul-17 03:21:00 MDT | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | Monday, 19-Jul-17 03:21:00 MDT | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | Monday, 19-Jul-17 03:21:00 MDT | time.Local = timezone arg | 2017-07-19 03:21:00 -0600 MDT | 2017-07-19 09:21:00 +0000 UTC |
| ParseLocal | Monday, 19-Jul-17 03:21:00 MDT | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
+------------+--------------------------------+---------------------------+-------------------------------+-------------------------------+
+------------+---------------------------+-------------------------------+-------------------------------+
| method | Zone Source | Parsed | Parsed: t.In(time.UTC) |
+------------+---------------------------+-------------------------------+-------------------------------+
| ParseAny | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | time.Local = timezone arg | 2017-07-19 03:21:00 -0600 MDT | 2017-07-19 09:21:00 +0000 UTC |
| ParseAny | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | time.Local = timezone arg | 2017-07-19 03:21:00 -0600 MDT | 2017-07-19 09:21:00 +0000 UTC |
| ParseIn | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | time.Local = timezone arg | 2017-07-19 03:21:00 -0600 MDT | 2017-07-19 09:21:00 +0000 UTC |
| ParseLocal | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
+------------+---------------------------+-------------------------------+-------------------------------+
# pass in a wrong timezone "MST" (should be MDT)
@ -72,19 +72,19 @@ $ dateparse --timezone="America/Denver" "Monday, 19-Jul-17 03:21:00 MST"
Your Current time.Local zone is PDT
+------------+--------------------------------+---------------------------+-------------------------------+-------------------------------+
| method | Input | Zone Source | Parsed: %v | Parsed: t.In(time.UTC) |
+------------+--------------------------------+---------------------------+-------------------------------+-------------------------------+
| ParseAny | Monday, 19-Jul-17 03:21:00 MST | time.Local = nil | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | Monday, 19-Jul-17 03:21:00 MST | time.Local = timezone arg | 2017-07-19 04:21:00 -0600 MDT | 2017-07-19 10:21:00 +0000 UTC |
| ParseAny | Monday, 19-Jul-17 03:21:00 MST | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | Monday, 19-Jul-17 03:21:00 MST | time.Local = nil | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | Monday, 19-Jul-17 03:21:00 MST | time.Local = timezone arg | 2017-07-19 04:21:00 -0600 MDT | 2017-07-19 10:21:00 +0000 UTC |
| ParseIn | Monday, 19-Jul-17 03:21:00 MST | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | Monday, 19-Jul-17 03:21:00 MST | time.Local = nil | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | Monday, 19-Jul-17 03:21:00 MST | time.Local = timezone arg | 2017-07-19 04:21:00 -0600 MDT | 2017-07-19 10:21:00 +0000 UTC |
| ParseLocal | Monday, 19-Jul-17 03:21:00 MST | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
+------------+--------------------------------+---------------------------+-------------------------------+-------------------------------+
+------------+---------------------------+-------------------------------+-------------------------------+
| method | Zone Source | Parsed | Parsed: t.In(time.UTC) |
+------------+---------------------------+-------------------------------+-------------------------------+
| ParseAny | time.Local = nil | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | time.Local = timezone arg | 2017-07-19 04:21:00 -0600 MDT | 2017-07-19 10:21:00 +0000 UTC |
| ParseAny | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | time.Local = nil | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | time.Local = timezone arg | 2017-07-19 04:21:00 -0600 MDT | 2017-07-19 10:21:00 +0000 UTC |
| ParseIn | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | time.Local = nil | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | time.Local = timezone arg | 2017-07-19 04:21:00 -0600 MDT | 2017-07-19 10:21:00 +0000 UTC |
| ParseLocal | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC |
+------------+---------------------------+-------------------------------+-------------------------------+
# note, we are using America/New_York which doesn't recognize MDT so essentially ignores it
@ -92,20 +92,19 @@ $ dateparse --timezone="America/New_York" "Monday, 19-Jul-17 03:21:00 MDT"
Your Current time.Local zone is PDT
+------------+--------------------------------+---------------------------+-------------------------------+-------------------------------+
| method | Input | Zone Source | Parsed: %v | Parsed: t.In(time.UTC) |
+------------+--------------------------------+---------------------------+-------------------------------+-------------------------------+
| ParseIn | Monday, 19-Jul-17 03:21:00 MDT | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | Monday, 19-Jul-17 03:21:00 MDT | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | Monday, 19-Jul-17 03:21:00 MDT | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | Monday, 19-Jul-17 03:21:00 MDT | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | Monday, 19-Jul-17 03:21:00 MDT | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | Monday, 19-Jul-17 03:21:00 MDT | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | Monday, 19-Jul-17 03:21:00 MDT | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | Monday, 19-Jul-17 03:21:00 MDT | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | Monday, 19-Jul-17 03:21:00 MDT | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
+------------+--------------------------------+---------------------------+-------------------------------+-------------------------------+
+------------+---------------------------+-------------------------------+-------------------------------+
| method | Zone Source | Parsed | Parsed: t.In(time.UTC) |
+------------+---------------------------+-------------------------------+-------------------------------+
| ParseAny | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseAny | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseIn | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | time.Local = nil | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
| ParseLocal | time.Local = time.UTC | 2017-07-19 03:21:00 +0000 MDT | 2017-07-19 03:21:00 +0000 UTC |
+------------+---------------------------+-------------------------------+-------------------------------+
```

View File

@ -46,7 +46,7 @@ func main() {
table := termtables.CreateTable()
table.AddHeaders("method", "Input", "Zone Source", "Parsed", "Parsed: t.In(time.UTC)")
table.AddHeaders("method", "Zone Source", "Parsed", "Parsed: t.In(time.UTC)")
parsers := map[string]parser{
"ParseAny": parseAny,
@ -56,13 +56,13 @@ func main() {
for name, parser := range parsers {
time.Local = nil
table.AddRow(name, datestr, "time.Local = nil", parser(datestr, nil), parser(datestr, nil).In(time.UTC))
table.AddRow(name, "time.Local = nil", parser(datestr, nil), parser(datestr, nil).In(time.UTC))
if timezone != "" {
time.Local = loc
table.AddRow(name, datestr, "time.Local = timezone arg", parser(datestr, loc), parser(datestr, loc).In(time.UTC))
table.AddRow(name, "time.Local = timezone arg", parser(datestr, loc), parser(datestr, loc).In(time.UTC))
}
time.Local = time.UTC
table.AddRow(name, datestr, "time.Local = time.UTC", parser(datestr, time.UTC), parser(datestr, time.UTC).In(time.UTC))
table.AddRow(name, "time.Local = time.UTC", parser(datestr, time.UTC), parser(datestr, time.UTC).In(time.UTC))
}
fmt.Println(table.Render())