Skip to content

Commit 33bcdc8

Browse files
authored
Merge pull request #33 from tippenein/allow-timestamp-parsing
Allow timestamp parsing
2 parents bd4dfc1 + d25b046 commit 33bcdc8

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/Data/Formatter/DateTime.purs

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ formatterCommandParser = (PC.try <<< PS.string) `oneOfAs`
129129
, Tuple "DD" DayOfMonthTwoDigits
130130
, Tuple "D" DayOfMonth
131131
, Tuple "E" DayOfWeek
132+
, Tuple "X" UnixTimestamp
132133
, Tuple "dddd" DayOfWeekName
133134
, Tuple "ddd" DayOfWeekNameShort
134135
, Tuple "HH" Hours24

test/src/DateTime.purs

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ datetimeTest = describe "Data.Formatter.DateTime" do
4747
, { format: "hhmmssS", dateStr: "1112301", date: makeDateTime 2017 4 10 11 12 30 123 }
4848
, { format: "HHmmssSSS", dateStr: "134530123", date: makeDateTime 2017 4 10 13 45 30 123 }
4949
, { format: "HHmm", dateStr: "1345", date: makeDateTime 2017 4 10 13 45 30 123 }
50+
, { format: "X", dateStr: "1499779279", date: makeDateTime 2017 7 11 13 21 19 0 }
5051
]
5152
(\({ format, dateStr, date }) → do
5253
(format `FDT.formatDateTime` date) `shouldEqual` (Right dateStr)
@@ -92,6 +93,7 @@ datetimeTest = describe "Data.Formatter.DateTime" do
9293
, {date: "111230003", format: "hhmmssSSS"}
9394
, {date: "11123012", format: "hhmmssSS"}
9495
, {date: "1112301", format: "hhmmssS"}
96+
, {date: "1499779279", format: "X"}
9597

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

0 commit comments

Comments
 (0)