Skip to content

Commit

Permalink
Better ISO 8601 parsing (#26)
Browse files Browse the repository at this point in the history
Adds support for YYYY-MM
  • Loading branch information
jakozaur authored Sep 23, 2024
1 parent 85de632 commit 125e13f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions iso8601.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ parse:
Y = c
M = 1
d = 1
case month:
M = c
d = 1
case day:
d = c
case hour:
Expand Down
12 changes: 12 additions & 0 deletions iso8601_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,18 @@ var cases = []TestCase{
MilliSecond: 0,
Zone: 0,
},
{
Using: "2017-02",
Year: 2017, Month: 2, Day: 1, Hour: 0, Minute: 0, Second: 0,
MilliSecond: 0,
Zone: 0,
},
{
Using: "2017-02-16",
Year: 2017, Month: 2, Day: 16, Hour: 0, Minute: 0, Second: 0,
MilliSecond: 0,
Zone: 0,
},

// Invalid Parse Test Cases
{
Expand Down

0 comments on commit 125e13f

Please sign in to comment.