Skip to content

Commit 0659f6b

Browse files
authored
Merge pull request #5 from doolse/fix12Hour
Use 12 instead of 0, PM starts at 12, not 13
2 parents 158e590 + a7b63b8 commit 0659f6b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Data/Formatter/DateTime.purs

+3-2
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,10 @@ formatF cb dt@(DT.DateTime d t) = case _ of
186186
Hours24 a →
187187
show (fromEnum $ T.hour t) <> cb a
188188
Hours12 a →
189-
show ((fromEnum $ T.hour t) `mod` 12) <> cb a
189+
let fix12 h = if h == 0 then 12 else h
190+
in show (fix12 $ (fromEnum $ T.hour t) `mod` 12) <> cb a
190191
Meridiem a →
191-
(if (fromEnum $ T.hour t) > 12 then "PM" else "AM") <> cb a
192+
(if (fromEnum $ T.hour t) >= 12 then "PM" else "AM") <> cb a
192193
Minutes a →
193194
show (fromEnum $ T.minute t) <> cb a
194195
Seconds a →

0 commit comments

Comments
 (0)