xsd-0.5.0.0: XML Schema data structures

Safe HaskellNone

Text.XML.XSD.DateTime

Description

XSD dateTime data structure http://www.w3.org/TR/xmlschema-2/#dateTime

Synopsis

Documentation

data DateTime Source

XSD dateTime data structure http://www.w3.org/TR/xmlschema-2/#dateTime. Briefly, a dateTime uses the Gregorian calendar and may or may not have an associated timezone. If it has a timezone, then the canonical representation of that date time is in UTC.

Note, it is not possible to establish a total order on dateTime since non-timezoned are considered to belong to some unspecified timezone.

isoEither :: Iso' (Either UTCTime LocalTime) DateTimeSource

The isomorphism between a DateTime and Either UTCTime LocalTime

isoEither' :: Iso' (Either LocalTime UTCTime) DateTimeSource

The isomorphism between a DateTime and Either LocalTime UTCTime

fold :: (LocalTime -> a) -> (UTCTime -> a) -> DateTime -> aSource

Reduction on a DateTime.

pUTCTime :: Prism' DateTime UTCTimeSource

A prism that views the UTCTime component of a DateTime.

pLocalTime :: Prism' DateTime LocalTimeSource

A prism that views the LocalTime component of a DateTime.

dateTime :: Prism' Text DateTimeSource

A prism that parses the string into a DateTime and converts the DateTime into a string.

Just (DtZoned t) == (dateTime # fromUTCTime t) ^? dateTime
Just (DtUnzoned t) == (dateTime # fromLocalTime t) ^? dateTime
>>> "2009-10-10T03:10:10-05:00" ^? dateTime
Just 2009-10-10T08:10:10Z
>>> "2119-10-10T03:10:10.4-13:26" ^? dateTime
Just 2119-10-10T16:36:10.4Z
>>> "0009-10-10T03:10:10.783952+14:00" ^? dateTime
Just 0009-10-09T13:10:10.783952Z
>>> "2009-10-10T03:10:10Z" ^? dateTime
Just 2009-10-10T03:10:10Z
>>> "-2009-05-10T21:08:59+05:00" ^? dateTime
Just -2009-05-10T16:08:59Z
>>> "-19399-12-31T13:10:10-14:00" ^? dateTime
Just -19398-01-01T03:10:10Z
>>> "2009-12-31T13:10:10" ^? dateTime
Just 2009-12-31T13:10:10
>>> "2012-10-15T24:00:00" ^? dateTime
Just 2012-10-16T00:00:00
>>> "2002-10-10T12:00:00+05:00" ^? dateTime
Just 2002-10-10T07:00:00Z
>>> "2002-10-10T00:00:00+05:00" ^? dateTime
Just 2002-10-09T19:00:00Z
>>> "-0001-10-10T00:00:00" ^? dateTime
Just 000-1-10-10T00:00:00
>>> "0001-10-10T00:00:00" ^? dateTime
Just 0001-10-10T00:00:00
>>> "2009-10-10T03:10:10-05" ^? dateTime
Nothing
>>> "2009-10-10T03:10:10+14:50" ^? dateTime
Nothing
>>> "2009-10-10T03:10:1" ^? dateTime
Nothing
>>> "2009-10-10T03:1:10" ^? dateTime
Nothing
>>> "2009-10-10T0:10:10" ^? dateTime
Nothing
>>> "2009-10-1T10:10:10" ^? dateTime
Nothing
>>> "2009-1-10T10:10:10" ^? dateTime
Nothing
>>> "209-10-10T03:10:10" ^? dateTime
Nothing
>>> "2009-10-10T24:10:10" ^? dateTime
Nothing
>>> "0000-01-01T00:00:00" ^? dateTime
Nothing
>>> "2009-13-01T00:00:00" ^? dateTime
Nothing
>>> "+2009-10-01T04:20:40" ^? dateTime
Nothing
>>> "002009-10-01T04:20:40" ^? dateTime
Nothing
>>> dateTime # fromUTCTime (mkUTC 2119 10 10 16 36 10.4)
"2119-10-10T16:36:10.4Z"
>>> dateTime # fromZonedTime (mkZoned 2010 04 07 13 47 20.001 2 0)
"2010-04-07T11:47:20.001Z"
>>> dateTime # fromLocalTime (mkLocal 13 2 4 20 20 20)
"0013-02-04T20:20:20"
>>> (dateTime #) `fmap` ("2010-04-07T13:47:20.001+02:00" ^? dateTime) --  issue 2
Just "2010-04-07T11:47:20.001Z"

dateTime' :: Text -> Either String DateTimeSource

Parses the string into a dateTime or may fail with a parse error.

isZoned :: DateTime -> BoolSource

Whether the given dateTime is timezoned.

isUnzoned :: DateTime -> BoolSource

Whether the given dateTime is non-timezoned.

fromZonedTime :: ZonedTime -> DateTimeSource

Converts a zoned time to a dateTime.

toUTCTime :: DateTime -> Maybe UTCTimeSource

Attempts to convert a dateTime to a UTC time. The attempt fails if the given dateTime is non-timezoned.

fromUTCTime :: UTCTime -> DateTimeSource

Converts a UTC time to a timezoned dateTime.

toLocalTime :: DateTime -> Maybe LocalTimeSource

Attempts to convert a dateTime to a local time. The attempt fails if the given dateTime is timezoned.

fromLocalTime :: LocalTime -> DateTimeSource

Converts a local time to a non-timezoned dateTime.

utcTime' :: Text -> Either String UTCTimeSource

Parses the string in a dateTime then converts to a UTC time and may fail with a parse error.

utcTime :: Text -> Maybe UTCTimeSource

Parses the string in a dateTime then converts to a UTC time and may fail.

localTime' :: Text -> Either String LocalTimeSource

Parses the string in a dateTime then converts to a local time and may fail with a parse error.

localTime :: Text -> Maybe LocalTimeSource

Parses the string in a dateTime then converts to a local time time and may fail.