File: README.md

package info (click to toggle)
golang-github-araddon-dateparse 0.0~git20210429.6b43995-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 224 kB
  • sloc: makefile: 3
file content (172 lines) | stat: -rw-r--r-- 13,356 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
DateParse CLI
----------------------

Simple CLI to test out dateparse.


```sh

# Since this date string has no timezone/offset so is more effected by
# which method you use to parse

$ dateparse --timezone="America/Denver" "2017-07-19 03:21:00"

Your Current time.Local zone is PDT

Layout String: dateparse.ParseFormat() => 2006-01-02 15:04:05

Your Using time.Local set to location=America/Denver MDT 

+-------------+---------------------------+-------------------------------+-------------------------------------+
| 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 day=3 |
| ParseAny    | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC day=3 |
| ParseAny    | time.Local = time.UTC     | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC day=3 |
| 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       |
| ParseStrict | time.Local = nil          | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC       |
| ParseStrict | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC       |
| ParseStrict | 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

$ dateparse --timezone="America/Denver" "2017-07-19 03:21:51+00:00"

Your Current time.Local zone is PDT

Layout String: dateparse.ParseFormat() => 2006-01-02 15:04:05-07:00

Your Using time.Local set to location=America/Denver MDT 

+-------------+---------------------------+---------------------------------+-------------------------------------+
| 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 day=3 |
| ParseAny    | time.Local = timezone arg | 2017-07-19 03:21:51 +0000 +0000 | 2017-07-19 03:21:51 +0000 UTC day=3 |
| ParseAny    | time.Local = time.UTC     | 2017-07-19 03:21:51 +0000 UTC   | 2017-07-19 03:21:51 +0000 UTC day=3 |
| 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       |
| ParseStrict | time.Local = nil          | 2017-07-19 03:21:51 +0000 UTC   | 2017-07-19 03:21:51 +0000 UTC       |
| ParseStrict | time.Local = timezone arg | 2017-07-19 03:21:51 +0000 +0000 | 2017-07-19 03:21:51 +0000 UTC       |
| ParseStrict | 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

Layout String: dateparse.ParseFormat() => 02-Jan-06 15:04:05 MDT

Your Using time.Local set to location=America/Denver MDT 

+-------------+---------------------------+-------------------------------+-------------------------------------+
| method      | Zone Source               | Parsed                        | Parsed: t.In(time.UTC)              |
+-------------+---------------------------+-------------------------------+-------------------------------------+
| ParseStrict | time.Local = nil          | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC       |
| ParseStrict | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC       |
| ParseStrict | time.Local = time.UTC     | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC       |
| ParseAny    | time.Local = nil          | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC day=3 |
| ParseAny    | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC day=3 |
| ParseAny    | time.Local = time.UTC     | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC day=3 |
| 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       |
+-------------+---------------------------+-------------------------------+-------------------------------------+



# pass in a wrong timezone "MST" (should be MDT)
$ dateparse --timezone="America/Denver" "Monday, 19-Jul-17 03:21:00 MST"

Your Current time.Local zone is PDT

Layout String: dateparse.ParseFormat() => 02-Jan-06 15:04:05 MST

Your Using time.Local set to location=America/Denver MDT 

+-------------+---------------------------+-------------------------------+-------------------------------------+
| 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 day=3 |
| ParseAny    | time.Local = timezone arg | 2017-07-19 04:21:00 -0600 MDT | 2017-07-19 10:21:00 +0000 UTC day=3 |
| ParseAny    | time.Local = time.UTC     | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC day=3 |
| 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       |
| ParseStrict | time.Local = nil          | 2017-07-19 03:21:00 +0000 MST | 2017-07-19 03:21:00 +0000 UTC       |
| ParseStrict | time.Local = timezone arg | 2017-07-19 04:21:00 -0600 MDT | 2017-07-19 10:21:00 +0000 UTC       |
| ParseStrict | 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
$ dateparse --timezone="America/New_York" "Monday, 19-Jul-17 03:21:00 MDT"

Your Current time.Local zone is PDT

Layout String: dateparse.ParseFormat() => 02-Jan-06 15:04:05 MDT

Your Using time.Local set to location=America/New_York EDT 

+-------------+---------------------------+-------------------------------+-------------------------------------+
| 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 day=3 |
| ParseAny    | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC day=3 |
| ParseAny    | time.Local = time.UTC     | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC day=3 |
| 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 -0400 EDT | 2017-07-19 07: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 -0400 EDT | 2017-07-19 07: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       |
| ParseStrict | time.Local = nil          | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC       |
| ParseStrict | time.Local = timezone arg | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC       |
| ParseStrict | time.Local = time.UTC     | 2017-07-19 03:21:00 +0000 UTC | 2017-07-19 03:21:00 +0000 UTC       |
+-------------+---------------------------+-------------------------------+-------------------------------------+

$ dateparse --timezone="America/New_York" "03/03/2017"

Your Current time.Local zone is PDT

Layout String: dateparse.ParseFormat() => 01/02/2006

Your Using time.Local set to location=America/New_York EDT 

+-------------+---------------------------+----------------------------------------------------+----------------------------------------------------+
| method      | Zone Source               | Parsed                                             | Parsed: t.In(time.UTC)                             |
+-------------+---------------------------+----------------------------------------------------+----------------------------------------------------+
| ParseIn     | time.Local = nil          | 2017-03-03 00:00:00 +0000 UTC                      | 2017-03-03 00:00:00 +0000 UTC                      |
| ParseIn     | time.Local = timezone arg | 2017-03-03 00:00:00 -0500 EST                      | 2017-03-03 05:00:00 +0000 UTC                      |
| ParseIn     | time.Local = time.UTC     | 2017-03-03 00:00:00 +0000 UTC                      | 2017-03-03 00:00:00 +0000 UTC                      |
| ParseLocal  | time.Local = nil          | 2017-03-03 00:00:00 +0000 UTC                      | 2017-03-03 00:00:00 +0000 UTC                      |
| ParseLocal  | time.Local = timezone arg | 2017-03-03 00:00:00 -0500 EST                      | 2017-03-03 05:00:00 +0000 UTC                      |
| ParseLocal  | time.Local = time.UTC     | 2017-03-03 00:00:00 +0000 UTC                      | 2017-03-03 00:00:00 +0000 UTC                      |
| ParseStrict | time.Local = nil          | This date has ambiguous mm/dd vs dd/mm type format | This date has ambiguous mm/dd vs dd/mm type format |
| ParseStrict | time.Local = timezone arg | This date has ambiguous mm/dd vs dd/mm type format | This date has ambiguous mm/dd vs dd/mm type format |
| ParseStrict | time.Local = time.UTC     | This date has ambiguous mm/dd vs dd/mm type format | This date has ambiguous mm/dd vs dd/mm type format |
| ParseAny    | time.Local = nil          | 2017-03-03 00:00:00 +0000 UTC                      | 2017-03-03 00:00:00 +0000 UTC day=5                |
| ParseAny    | time.Local = timezone arg | 2017-03-03 00:00:00 +0000 UTC                      | 2017-03-03 00:00:00 +0000 UTC day=5                |
| ParseAny    | time.Local = time.UTC     | 2017-03-03 00:00:00 +0000 UTC                      | 2017-03-03 00:00:00 +0000 UTC day=5                |
+-------------+---------------------------+----------------------------------------------------+----------------------------------------------------+

```