The function time2str(t, f) converts the calendar
time specified by its first argument t, which must be a numeric
expression, to a character string (symbolic value). The conversion is
controlled by the specified format string f (the second argument),
which must be a symbolic expression.
The calendar time passed to time2str has the same meaning as
the value returned by the function gmtime (See Obtaining current calendar time). Note that time2str does not correct
the specified calendar time for the local timezone, i.e. the calendar
time 0 always corresponds to 00:00:00 on January 1, 1970.
For example, the model statements:
param s, symbolic, := time2str(gmtime(), "%FT%TZ"); display s;
may produce the following printout:
s = '2008-12-04T00:23:45Z'
which is a timestamp in the ISO format.
The format string passed to the function time2str consists of
conversion specifiers and ordinary characters. Each conversion specifier
begins with a ‘%’ character followed by a letter.
The following conversion specifiers may be used in the format string:
%aThe abbreviated (2-character) weekday name.
%AThe full weekday name.
%bThe abbreviated (3-character) month name.
%BThe full month name.
%CThe century of the year, that is the greatest integer not greater than the year divided by 100.
%dThe day of the month as a decimal number (range 01 to 31).
%DThe date using the format %m/%d/%y.
%eThe day of the month like with %d, but padded with blank rather
than zero.
%FThe date using the format %Y-%m-%d.
%gThe year corresponding to the ISO week number, but without the century
(range 00 to 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.
%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.
%hThe same as %b.
%HThe hour as a decimal number, using a 24-hour clock (range 00 to 23).
%IThe hour as a decimal number, using a 12-hour clock (range 01 to 12).
%jThe day of the year as a decimal number (range 001 to 366).
%kThe hour as a decimal number, using a 24-hour clock like %H, but
padded with blank rather than zero.
%lThe hour as a decimal number, using a 12-hour clock like %I, but
padded with blank rather than zero.
%mThe month as a decimal number (range 01 to 12).
%MThe minute as a decimal number (range 00 to 59).
%pEither ‘AM’ or ‘PM’, according to the given time value.
Midnight is treated as ‘AM’ and noon as ‘PM’.
%PEither ‘am’ or ‘pm’, according to the given time value.
Midnight is treated as ‘am’ and noon as ‘pm’.
%RThe hour and minute in decimal numbers using the format %H:%M.
%SThe second as a decimal number (range 00 to 59).
%TThe time of day in decimal numbers using the format %H:%M:%S.
%uThe day of the week as a decimal number (range 1 to 7), Monday being 1.
%UThe week number of the current year as a decimal number (range 00 to 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 week number as a decimal number (range 01 to 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 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. In other word, if 1 January is Monday, Tuesday, Wednesday or Thursday, it is in week 01; if 1 January is Friday, Saturday or Sunday, it is in week 52 or 53 of the previous year.
%wThe day of the week as a decimal number (range 0 to 6), Sunday being 0.
%WThe week number of the current year as a decimal number (range 00 to 53), starting with the first Monday as the first day of the first week. Days preceding the first Monday in the year are considered to be in week 00.
%yThe year without a century as a decimal number (range 00 to 99), that is the year modulo 100.
%YThe year as a decimal number, using the Gregorian calendar.
%%A literal ‘%’ character.
All other (ordinary) characters in the format string are simply copied to the resultant string.
The first argument (calendar time) passed to the function time2str
must be in the range from –62135596800 to +64092211199 that corresponds
to the period from 00:00:00 on January 1, 0001 to 23:59:59 on December
31, 4000 of the Gregorian calendar.