Format time with an arbitrary formatting string. Other formatters in this module are implemented using timeF.
Modulefmt-0.6.3.0Haskell2010
Fmt.Time
Formatters for various time types. This module copies the structure of
Formatting.Time
from the formatting package.
Most of the time you'll want to use one of these formatters (all of the
examples below use "2018-02-14 16:20:45.5 CST"):
dateTimeF – full date and time:
Example1 expression dateTimeF t"Wed Feb 14 16:20:45 CST 2018"
hmF – hours and minutes:
Example1 expression hmF t"16:20"
hmsF – hours, minutes and seconds:
Example1 expression hmsF t"16:20:45"
dateDashF – date in ISO 8601 format:
Example1 expression dateDashF t"2018-02-14"
diffF – either a time period or a point in time, in a convenient for humans format:
Example2 expressions diffF False 130 -- time period (130 seconds)"2 minutes"diffF True 130 -- point in time (130 seconds in the future)"in 2 minutes"
Note that two formatters from Formatting.Time are called differently here:
pico -> picosecondF
decimals -> subsecondF
- 48 values
- Packagefmt-0.6.3.0
- Exports48
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceTime.hs
Custom
1 declarationTimezone offset on the format -HHMM.
t2018-02-14 16:20:45.5 CSTtzF t"-0600"
Timezone name.
tzNameF t"CST"
As dateTimeFmt locale (e.g. %a %b %e %H:%M:%S %Z %Y).
dateTimeF t"Wed Feb 14 16:20:45 CST 2018"
Same as %H:%M.
hmF t"16:20"
Same as %H:%M:%S.
hmsF t"16:20:45"
As timeFmt locale (e.g. %H:%M:%S).
hmsLF t"16:20:45"
As time12Fmt locale (e.g. %I:%M:%S %p).
hmsPLF t"04:20:45 PM"
Day half from (amPm locale), converted to lowercase, am, pm.
dayHalfF t"pm"
Day half from (amPm locale), AM, PM.
dayHalfUF t"PM"
Hour, 24-hour, leading 0 as needed, 00 - 23.
hour24F t"16"hour24F midnight"00"
Hour, 12-hour, leading 0 as needed, 01 - 12.
hour12F t"04"hour12F midnight"12"
Hour, 24-hour, leading space as needed, 0 - 23.
hour24SF t"16"hour24SF midnight" 0"
Hour, 12-hour, leading space as needed, 1 - 12.
hour12SF t" 4"hour12SF midnight"12"
Minute, 00 - 59.
minuteF t"20"
Second, without decimal part, 00 - 60.
secondF t"45"
Picosecond, including trailing zeros, 000000000000 - 999999999999.
picosecondF t"500000000000"
Decimal point of the second. Up to 12 digits, without trailing zeros. For a whole number of seconds, this produces an empty string.
subsecondF t".5"
Number of whole seconds since the Unix epoch. For times before the Unix
epoch, this is a negative number. Note that in %s.%q and %s%Q the
decimals are positive, not negative. For example, 0.9 seconds before the
Unix epoch is formatted as -1.1 with %s%Q.
epochF t"1518646845"
Same as %m/%d/%y.
dateSlashF t"02/14/18"
Same as %Y-%m-%d.
dateDashF t"2018-02-14"
As dateFmt locale (e.g. %m/%d/%y).
dateSlashLF t"02/14/18"
Year.
yearF t"2018"
Last two digits of year, 00 - 99.
yyF t"18"
Century (being the first two digits of the year), 00 - 99.
centuryF t"20"
Month of year, leading 0 as needed, 01 - 12.
monthF t"02"
Day of month, leading 0 as needed, 01 - 31.
dayOfMonthF t"14"
Day of month, 1st, 2nd, 25th, etc.
dayOfMonthOrdF t"14th"
Day of month, leading space as needed, 1 - 31.
Day of year for Ordinal Date format, 001 - 366.
dayF t"045"
Year for Week Date format e.g. 2013.
weekYearF t"2018"
Last two digits of year for Week Date format, 00 - 99.
weekYYF t"18"
Century (first two digits of year) for Week Date format, 00 - 99.
weekCenturyF t"20"
Week for Week Date format, 01 - 53.
weekF t"07"
Day for Week Date format, 1 - 7.
dayOfWeekF t"3"
Week number of year, where weeks start on Sunday (as
sundayStartWeek), 00 - 53.
weekFromZeroF t"06"
Day of week number, 0 (= Sunday) - 6 (= Saturday).
dayOfWeekFromZeroF t"3"
Week number of year, where weeks start on Monday (as
mondayStartWeek), 00 - 53.
weekOfYearMonF t"07"
Time spans, diffs, NominalDiffTime, DiffTime, etc.
6 declarationsdiffF Display a time span as one time relative to another. Input is assumed to be seconds. Typical inputs are NominalDiffTime and DiffTime.
diffF False 100"a minute"diffF True 100"in a minute"
Display the absolute value time span in years.
epochF t -- time passed since Jan 1, 1970"1518646845"yearsF 3 1518646845"48.156"
Display the absolute value time span in days.
daysF 3 1518646845"17576.931"
Display the absolute value time span in hours.
hoursF 3 3600"1.000"
Display the absolute value time span in minutes.
minutesF 3 150"2.500"
Display the absolute value time span in seconds.
secondsF 3 100"100.000"