Copyright | (C) 2018 Thomas Tuegel <ttuegel@mailbox.org> |
---|---|
License | GPL-3 |
Maintainer | Thomas Tuegel <ttuegel@mailbox.org> |
Safe Haskell | None |
Language | Haskell2010 |
This module provides quasi-quoters to parse dates and times according to ISO 8601 formats. By using quasi-quotes for literals, parse errors are found by the compiler.
To use quasi-quotes, place the LANGUAGE QuasiQuotes
pragma at the top of the
source file or use the GHC command-line option -XQuasiQuotes
. If using GHCi,
enter at the prompt
>>>
:set -XQuasiQuotes
Quasi-quoters are provided for each type that defines an ISO8601
instance.
Use the quasi-quoters to quote a literal date or time of the corresponding type;
for example
[utcTime| 2018-05-25T15:36:27.416462897Z |] -- :: UTCTime
All quasi-quoters accept optional whitespace before and after the quoted value. Refer to the list below for details about the expected format for each type.
Documentation
utcTime :: QuasiQuoter Source #
Quote a value of type UTCTime
in yyyy-mm-ddThh:mm:ss[.sss]Z
format.
>>>
[utcTime| 2018-05-25T15:36:27.416462897Z |]
2018-05-25 15:36:27.416462897 UTC
day :: QuasiQuoter Source #
Quote a value of type Day
in yyyy-mm-dd
format.
>>>
[day| 2018-05-25 |]
2018-05-25
timeOfDay :: QuasiQuoter Source #
Quote a value of type TimeOfDay
in hh:mm:ss[.sss]
format.
>>>
[timeOfDay| 15:36:27.416462897 |]
15:36:27.416462897
localTime :: QuasiQuoter Source #
Quote a value of type LocalTime
in yyyy-mm-ddThh:mm:ss[.sss]
format.
>>>
[localTime| 2018-05-25T10:36:27.416462897 |]
2018-05-25 10:36:27.416462897
timeZone :: QuasiQuoter Source #
Quote a value of type TimeZone
in ±hh:mm
format.
>>>
[timeZone| -05:00 |]
-0500
zonedTime :: QuasiQuoter Source #
Quote a value of type ZonedTime
in yyyy-mm-ddThh:mm:ss[.sss]±hh:mm
format.
>>>
[zonedTime| 2018-05-25T10:36:27.416462897-05:00 |]
2018-05-25 10:36:27.416462897 -0500
calendarDiffDays :: QuasiQuoter Source #
Quote a value of type CalendarDiffDays
in PyYmMdD
format.
>>>
[calendarDiffDays| P2018Y5M25D |]
P24221M25D
calendarDiffTime :: QuasiQuoter Source #
Quote a value of type CalendarDiffTime
in PyYmMdDThHmMs[.sss]S
format.
>>>
[calendarDiffTime| P2018Y5M25DT15H36M27.416462897S |]
P24221MT2216187.416462897S