Skip to content

Commit

Permalink
add support date int format
Browse files Browse the repository at this point in the history
eg: "20221025", "20221025010203"
  • Loading branch information
shockerli committed Oct 27, 2022
1 parent 2c92f57 commit 950255e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions time.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ var timeFormats = []string{
"2006-01-02 15:04:05.999999999 -0700 MST", // Time.String()
"2006-01-02",
"02 Jan 2006",
"20060102", // date of int
"20060102150405", // datetime of int
"2006-01-02T15:04:05-0700", // RFC3339 without timezone hh:mm colon
"2006-01-02 15:04:05 -07:00",
"2006-01-02 15:04:05 -0700",
Expand Down
2 changes: 2 additions & 0 deletions time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ func TestTimeE(t *testing.T) {
{"2016-03-06 15:28:01-00:00", time.Date(2016, 3, 6, 15, 28, 1, 0, cvt.TimeLocation), false}, // RFC3339 without T
{"2016-03-06 15:28:01-0000", time.Date(2016, 3, 6, 15, 28, 1, 0, cvt.TimeLocation), false}, // RFC3339 without T or timezone hh:mm colon

{"20090213", time.Date(2009, 2, 13, 0, 0, 0, 0, cvt.TimeLocation), false},
{"20090213233130", time.Date(2009, 2, 13, 23, 31, 30, 0, cvt.TimeLocation), false},
{"Fri Sep 25 13:58:21 2016 -0400", time.Date(2016, 9, 25, 17, 58, 21, 0, cvt.TimeLocation), false},
{"13 Feb 2009", expect2, false},
{"2009-02-13", expect2, false},
Expand Down

1 comment on commit 950255e

@vercel
Copy link

@vercel vercel bot commented on 950255e Oct 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.