Skip to content

Allow timestamp parsing #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Data/Formatter/DateTime.purs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ formatterCommandParser = (PC.try <<< PS.string) `oneOfAs`
, Tuple "DD" DayOfMonthTwoDigits
, Tuple "D" DayOfMonth
, Tuple "E" DayOfWeek
, Tuple "X" UnixTimestamp
, Tuple "dddd" DayOfWeekName
, Tuple "ddd" DayOfWeekNameShort
, Tuple "HH" Hours24
Expand Down
2 changes: 2 additions & 0 deletions test/src/DateTime.purs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ datetimeTest = describe "Data.Formatter.DateTime" do
, { format: "hhmmssS", dateStr: "1112301", date: makeDateTime 2017 4 10 11 12 30 123 }
, { format: "HHmmssSSS", dateStr: "134530123", date: makeDateTime 2017 4 10 13 45 30 123 }
, { format: "HHmm", dateStr: "1345", date: makeDateTime 2017 4 10 13 45 30 123 }
, { format: "X", dateStr: "1499779279", date: makeDateTime 2017 7 11 13 21 19 0 }
]
(\({ format, dateStr, date }) → do
(format `FDT.formatDateTime` date) `shouldEqual` (Right dateStr)
Expand Down Expand Up @@ -91,6 +92,7 @@ datetimeTest = describe "Data.Formatter.DateTime" do
, {date: "111230003", format: "hhmmssSSS"}
, {date: "11123012", format: "hhmmssSS"}
, {date: "1112301", format: "hhmmssS"}
, {date: "1499779279", format: "X"}

]
(\({date, format}) → (FDT.unformatDateTime format date >>= FDT.formatDateTime format) `shouldEqual` (Right date))
Expand Down