View Source Timex.Format.DateTime.Formatters.Strftime (timex v3.7.9)
Date formatting language defined by the strftime
function from the Standard
C Library.
This implementation in Elixir is mostly compatible with strftime
. The
exception is the absence of locale-depended results. All directives that imply
textual result will produce English names and abbreviations.
A complete reference of the directives implemented here is given below.
directive-format
Directive format
A directive is marked by the percent sign (%
) followed by one character
(<directive>
). In addition, a few optional specifiers can be inserted
in-between:
%<flag><width><modifier><directive>
Supported flags:
-
- don't pad numerical results (overrides default padding if any)0
- use zeros for padding_
- use spaces for padding:
,::
- used only in combination with%z
; see description of%:z
and `%::z` below
<width>
is a non-negative decimal number specifying the minimum field
width.
<modifier>
can be E
or O
. These are locale-sensitive modifiers, and as
such they are currently ignored by this implementation.
list-of-all-directives
List of all directives
%%
- produces a single%
in the output
years-and-centuries
Years and centuries
%Y
- full year number (0..9999)%y
- the last two digits of the year number (0..99)%C
- century number (00..99)%G
- year number corresponding to the date's ISO week (0..9999)%g
- year number (2 digits) corresponding to the date's ISO week (0..99)
months
Months
%m
- month number (1..12)%b
- abbreviated month name (Jan..Dec, no padding)%h
- same is%b
%B
- full month name (January..December, no padding)
days-and-days-of-week
Days, and days of week
%d
- day number (1..31)%e
- same as%d
, but padded with spaces ( 1..31)%j
- ordinal day of the year (001..366)%u
- weekday, Monday first (1..7)%w
- weekday, Sunday first (0..6)%a
- abbreviated weekday name (Mon..Sun, no padding)%A
- full weekday name (Monday..Sunday, no padding)
weeks
Weeks
%V
- ISO week number (01..53)%W
- week number of the year, Monday first (00..52)%U
- week number of the year, Sunday first (00..52)
time
Time
%H
- hour of the day (00..23)%k
- same as%H
, but padded with spaces ( 0..23)%I
- hour of the day (1..12)%l
- same as%I
, but padded with spaces ( 1..12)%M
- minutes of the hour (00..59)%S
- seconds of the minute (00..60)%f
- microseconds in zero padded decimal form, i.e. 025000%L
- milliseconds (000..999)%s
- number of seconds since UNIX epoch%P
- lowercase am or pm (no padding)%p
- uppercase AM or PM (no padding)
time-zones
Time zones
%Z
- time zone name, e.g.UTC
(no padding)%z
- time zone offset in the form+0230
(no padding)%:z
- time zone offset in the form-07:30
(no padding)%::z
- time zone offset in the form-07:30:00
(no padding)
compound-directives
Compound directives
%D
- same as%m/%d/%y
%F
- same as%Y-%m-%d
%R
- same as%H:%M
%r
- same as%I:%M:%S %p
%T
- same as%H:%M:%S
%v
- same as%e-%b-%Y
Link to this section Summary
Functions
Callback implementation for Timex.Format.DateTime.Formatter.format!/2
.
Callback implementation for Timex.Format.DateTime.Formatter.format/2
.
Callback implementation for Timex.Format.DateTime.Formatter.lformat!/3
.
Callback implementation for Timex.Format.DateTime.Formatter.lformat/3
.
Callback implementation for Timex.Format.DateTime.Formatter.tokenize/1
.
Link to this section Functions
Callback implementation for Timex.Format.DateTime.Formatter.format!/2
.
Callback implementation for Timex.Format.DateTime.Formatter.format/2
.
@spec lformat!(Timex.Types.calendar_types(), String.t(), String.t()) :: String.t() | no_return()
Callback implementation for Timex.Format.DateTime.Formatter.lformat!/3
.
@spec lformat(Timex.Types.calendar_types(), String.t(), String.t()) :: {:ok, String.t()} | {:error, term()}
Callback implementation for Timex.Format.DateTime.Formatter.lformat/3
.
@spec tokenize(String.t()) :: {:ok, [Timex.Parse.DateTime.Tokenizers.Directive.t()]} | {:error, term()}
Callback implementation for Timex.Format.DateTime.Formatter.tokenize/1
.