[%CFEngine_function_prototype(mode, template, time)%]
Description: Interprets a time and date format string at a particular point in GMT or local time using Unix epoch time.
[%CFEngine_function_attributes(mode, template, time)%]
The mode is either gmtime (to get GMT times and dates) or
localtime (to get times and dates according to the local
timezone, usually specified by the TZ environment variable).
The conversion specifications that can appear in the format template
are specialized for printing components of the date and time according to the system locale.
Example:
[%CFEngine_include_snippet(strftime.cf, #+begin_src cfengine3, .*end_src)%]
Output:
[%CFEngine_include_snippet(strftime.cf, #+begin_src\s+example_output\s, .end_src)%]
Notes: Note that strftime is a standard C function and you should
consult its reference to be sure of the specifiers it allows. The below
is from the documentation of the standard strftime implementation
in the glibc manual at
http://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html#Formatting-Calendar-Time
Ordinary characters appearing in the template are copied to the
output. Conversion specifiers are introduced by a % character
and end with a format specifier taken from the following list. The
whole % sequence is replaced in the output string as follows:
%aThe abbreviated weekday name according to the current locale.
%AThe full weekday name according to the current locale.
%bThe abbreviated month name according to the current locale.
%BThe full month name according to the current locale.
Using %B together with %d produces grammatically
incorrect results for some locales.
%cThe preferred calendar time representation for the current locale.
%CThe century of the year. This is equivalent to the greatest integer not greater than the year divided by 100.
This format was first standardized by POSIX.2-1992 and by ISO C99.
%dThe day of the month as a decimal number (range 01 through 31).
%DThe date using the format %m/%d/%y.
This format was first standardized by POSIX.2-1992 and by ISO C99.
%eThe day of the month like with %d, but padded with blank (range
` 1 through 31`).
This format was first standardized by POSIX.2-1992 and by ISO C99.
%FThe date using the format %Y-%m-%d. This is the form specified
in the ISO 8601 standard and is the preferred form for all uses.
This format was first standardized by ISO C99 and by POSIX.1-2001.
%gThe year corresponding to the ISO week number, but without the century
(range 00 through 99). This has the same format and value
as %y, except that if the ISO week number (see %V) belongs
to the previous or next year, that year is used instead.
This format was first standardized by ISO C99 and by POSIX.1-2001.
%GThe year corresponding to the ISO week number. This has the same format
and value as %Y, except that if the ISO week number (see
%V) belongs to the previous or next year, that year is used
instead.
This format was first standardized by ISO C99 and by POSIX.1-2001 but was previously available as a GNU extension.
%hThe abbreviated month name according to the current locale. The action
is the same as for %b.
This format was first standardized by POSIX.2-1992 and by ISO C99.
%HThe hour as a decimal number, using a 24-hour clock (range 00 through
23).
%IThe hour as a decimal number, using a 12-hour clock (range 01 through
12).
%jThe day of the year as a decimal number (range 001 through 366).
%kThe hour as a decimal number, using a 24-hour clock like %H, but
padded with blank (range ` 0 through 23`).
This format is a GNU extension.
%lThe hour as a decimal number, using a 12-hour clock like %I, but
padded with blank (range ` 1 through 12`).
This format is a GNU extension.
%mThe month as a decimal number (range 01 through 12).
%MThe minute as a decimal number (range 00 through 59).
%nA single \n (newline) character.
This format was first standardized by POSIX.2-1992 and by ISO C99.
%pEither AM or PM, according to the given time value; or the
corresponding strings for the current locale. Noon is treated as
PM and midnight as AM. In most locales
AM/PM format is not supported, in such cases %p
yields an empty string.
%PEither am or pm, according to the given time value; or the
corresponding strings for the current locale, printed in lowercase
characters. Noon is treated as pm and midnight as am. In
most locales AM/PM format is not supported, in such cases
%P yields an empty string.
This format is a GNU extension.
%rThe complete calendar time using the AM/PM format of the current locale.
This format was first standardized by POSIX.2-1992 and by ISO C99.
In the POSIX locale, this format is equivalent to %I:%M:%S %p.
%RThe hour and minute in decimal numbers using the format %H:%M.
This format was first standardized by ISO C99 and by POSIX.1-2001 but was previously available as a GNU extension.
%sThe number of seconds since the epoch, i.e., since 1970-01-01 00:00:00 UTC. Leap seconds are not counted unless leap second support is available.
This format is a GNU extension.
%SThe seconds as a decimal number (range 00 through 60).
%tA single \t (tabulator) character.
This format was first standardized by POSIX.2-1992 and by ISO C99.
%TThe time of day using decimal numbers using the format %H:%M:%S.
This format was first standardized by POSIX.2-1992 and by ISO C99.
%uThe day of the week as a decimal number (range 1 through
7), Monday being 1.
This format was first standardized by POSIX.2-1992 and by ISO C99.
%UThe week number of the current year as a decimal number (range 00
through 53), starting with the first Sunday as the first day of
the first week. Days preceding the first Sunday in the year are
considered to be in week 00.
%VThe ISO 8601:1988 week number as a decimal number (range 01
through 53). ISO weeks start with Monday and end with Sunday.
Week 01 of a year is the first week which has the majority of its
days in that year; this is equivalent to the week containing the year’s
first Thursday, and it is also equivalent to the week containing January
4. Week 01 of a year can contain days from the previous year.
The week before week 01 of a year is the last week (52 or
53) of the previous year even if it contains days from the new
year.
This format was first standardized by POSIX.2-1992 and by ISO C99.
%wThe day of the week as a decimal number (range 0 through
6), Sunday being 0.
%WThe week number of the current year as a decimal number (range 00
through 53), starting with the first Monday as the first day of
the first week. All days preceding the first Monday in the year are
considered to be in week 00.
%xThe preferred date representation for the current locale.
%XThe preferred time of day representation for the current locale.
%yThe year without a century as a decimal number (range 00 through
99). This is equivalent to the year modulo 100.
%YThe year as a decimal number, using the Gregorian calendar. Years
before the year 1 are numbered 0, -1, and so on.
%zRFC 822/ISO 8601:1988 style numeric time zone (e.g.,
-0600 or +0100), or nothing if no time zone is
determinable.
This format was first standardized by ISO C99 and by POSIX.1-2001 but was previously available as a GNU extension.
In the POSIX locale, a full RFC 822 timestamp is generated by the format
%a, %d %b %Y %H:%M:%S %z (or the equivalent
%a, %d %b %Y %T %z).
%ZThe time zone abbreviation (empty if the time zone can’t be determined).
%%A literal % character.
According to POSIX.1 every call to strftime checks the contents
of the environment variable TZ before any output is produced.