Data.Formatter.DateTime
- Package
- purescript-formatters
- Repository
- purescript-contrib/purescript-formatters
This is a subset of common format/parse strings currently supported.
YYYY- Full Year (1999)YY- 2 digit year (99)MMMM- Full Month (January)MMM- Short Month (Jan)M- Unpadded Month (1)DD- Padded Day (02)D- Day of month (2)X- Unix Timestamp (1506875681)d- Day of Week (2, Monday = 1, Sunday = 7)dddd- DOW Name (Monday)ddd- DOW Name Short (Mon)HH- 24 Hour (13)hh- 12 Hour (1)a- Meridiem (am/pm)A- Meridiem (AM/PM)mm- Minutes Padded (02)m- Minutes (2)ss- Seconds Padded (02)s- Seconds (2)S- MilliSeconds (4)SS- MilliSeconds (04)SSS- MilliSeconds (004)
Full list is defined here
#Formatter Source
type Formatter = List FormatterCommandA description of a string format for dates and times.
Functions such as format and unformat use a Formatter
such as (YearFull : MonthTwoDigits : DayOfMonthTwoDigits : Nil)
in place of a format string such as "YYYYMMDD".
#FormatterCommand Source
data FormatterCommandOne part of a DateTime Formatter. Use Placeholder for
any static portion of the format, such as whitespace or separators - or :.
Constructors
YearFullYearTwoDigitsYearAbsoluteMonthFullMonthShortMonthDigitMonthTwoDigitsDayOfMonthTwoDigitsDayOfMonthUnixTimestampDayOfWeekDayOfWeekNameDayOfWeekNameShortHours24Hours12MeridiemMeridiemLowerCaseMinutesMinutesTwoDigitsSecondsSecondsTwoDigitsMillisecondsMillisecondsShortMillisecondsTwoDigitsPlaceholder String
Instances
#printFormatter Source
printFormatter :: Formatter -> StringThe format string representation of a Formatter.
show (Hours24 : MinutesTwoDigits : Nil) = "(Hours24 : MinutesTwoDigits : Nil)"
while printFormatter (Hours24 : MinutesTwoDigits : Nil) = "HHmm".
#parseFormatString Source
parseFormatString :: String -> Either String FormatterAttempt to parse a String as a Formatter.
#formatDateTime Source
formatDateTime :: String -> DateTime -> Either String StringFormat a DateTime according to the format defined in the given format string.
If the format string is empty or contains a reserved character such as a single "H",
will return a Left value.
Note that any non-reserved Char is treated as a placeholder, so while "yyyy-MM-dd" might
not produce the format you want (since "yyyy" isn't a recognized format),
it will still return a Right value.