Difference between revisions of "Mu c streamftime"

From Mailutils
Jump to navigationJump to search
Line 99: Line 99:
  
 
A percent sign followed by any character not listed above is written to the output stream verbatim.
 
A percent sign followed by any character not listed above is written to the output stream verbatim.
 +
 +
== See also ==
 +
[[mu_strftime]]
  
 
[[Category:Date/Time Functions]]
 
[[Category:Date/Time Functions]]
 
[[Category:C API]]
 
[[Category:C API]]

Revision as of 10:33, 17 December 2011

int mu_c_streamftime (mu_stream_t str, const char *fmt, struct tm *input_tm,
                      struct mu_timezone *tz)

The function mu_c_streamftime formats the broken-down time tm with optional timezone information tz according to the format specification format and writes the result to the stream str. The function returns 0 on success and error code on error.

The format string is similar to that of strftime(3). The function is designed to format timestamps for protocol exchange and therefore ignores locale settings (which is reflected by _c_ in its name). A detailed description of the format string follows.

Ordinary characters placed in the format string are copied to the output stream without conversion. Conversion specifications are introduced by a % character, and terminated by a conversion specifier character. They are replaced in s as follows:

%a
The abbreviated weekday name.
%A
The full weekday name.
%b %h
The abbreviated month name.
%B
The full month name.
%c
Equivalent to "%a %b %e %H:%M:%S %Y".
%C
The century number (year/100) as a 2-digit integer.
%d
The day of the month as a decimal number (range 01 to 31).
%D
Equivalent to "%m/%d/%y".
%e
Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space.
%E
A modifier. Actual conversion specifier must follow, e.g. %Ec. The Single Unix Specification mentions %Ec, %EC, %Ex, %EX, %Ey, and %EY, which are supposed to use a corresponding locale-dependent alternative representation. Since mu_c_streamftime explicitly operates in POSIX locale, this is a no-op.
%F
Equivalent to "%Y-%m-%d" (the ISO 8601 date format).
%G
The ISO 8601 year with century as a decimal number. The 4-digit year corresponding to the ISO week number (see %V below). This has the same format and value as %y, except that if the ISO week number belongs to the previous or next year, that year is used instead.
%g
Like %G, but without century, that is, with a 2-digit year (00-99).
%H
The hour as a decimal number using a 24-hour clock (range 00 to 23).
%I
The hour as a decimal number using a 12-hour clock (range 01 to 12).
%j
The day of the year as a decimal number (range 001 to 366).
%k
The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank.
%l
The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank.
%m
The month as a decimal number (range 01 to 12).
%M
The minute as a decimal number (range 00 to 59).
%n
A newline character.
%O
A no-op modifier. Actual conversion specifier must follow (The Single Unix Specification mentions %Od, %Oe, %OH, %OI, %Om, %OM, %OS, %Ou, %OU, %OV, %Ow, %OW, and %Oy, which are supposed to use alternative numeric symbols).
%p
Either "AM" or "PM" according to the given time value. Noon is treated as "PM" and midnight as "AM".
%P
Like %p but in lowercase: "am" or "pm".
%r
The time in a.m. or p.m. notation, i.e. equivalent to "%I:%M:%S %p".
%R
The time in 24-hour notation: %H:%M
%s
The number of seconds since the Epoch.
%S
The second as a decimal number (range 00 to 60).
%t
A tab character.
%T
The time in 24-hour notation: "%H:%M:%S".
%u
The day of the week as a decimal, range 1 to 7, Monday being 1.
%U
The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01.
%V
The ISO 8601:1988 week number of the current year as a decimal number range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week.;%w
The day of the week as a decimal, range 0 to 6, Sunday being 0.
%W
The week number of the current year as a decimal number, range 00 to 53, starting with the first Monday as the first day of week 01.
%x
The preferred date representation without the time: equivalent to "%D".
%X
The preferred date representation without the date: "%H:%M:%S".
%y
The year as a decimal number without a century (range 00 to 99).
%Y
The year as a decimal number including the century.
%Z
The timezone name or abbreviation, if available. Otherwise equivalent to "%z".
%z
The time-zone as hour offset from GMT.
%%
A literal '%' character.
%$
Ignored for compatibilty with mu_scan_datetime.

A percent sign followed by any character not listed above is written to the output stream verbatim.

See also

mu_strftime