#include <mailutils/datetime.h> 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. If no timezone information is available, tz should be NULL. 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:
- The abbreviated weekday name.
- The full weekday name.
- %b %h
- The abbreviated month name.
- The full month name.
- Equivalent to "%a %b %e %H:%M:%S %Y".
- The century number (year/100) as a 2-digit integer.
- The day of the month as a decimal number (range 01 to 31).
- Equivalent to "%m/%d/%y".
- Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space.
- 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.
- Equivalent to "%Y-%m-%d" (the ISO 8601 date format).
- 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.
- Like %G, but without century, that is, with a 2-digit year (00-99).
- The hour as a decimal number using a 24-hour clock (range 00 to 23).
- The hour as a decimal number using a 12-hour clock (range 01 to 12).
- The day of the year as a decimal number (range 001 to 366).
- The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank.
- The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank.
- The month as a decimal number (range 01 to 12).
- The minute as a decimal number (range 00 to 59).
- A newline character.
- 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).
- Either "AM" or "PM" according to the given time value. Noon is treated as "PM" and midnight as "AM".
- Like %p but in lowercase: "am" or "pm".
- The time in a.m. or p.m. notation, i.e. equivalent to "%I:%M:%S %p".
- The time in 24-hour notation: %H:%M
- The number of seconds since the Epoch.
- The second as a decimal number (range 00 to 60).
- A tab character.
- The time in 24-hour notation: "%H:%M:%S".
- The day of the week as a decimal, range 1 to 7, Monday being 1.
- 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.
- 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.
- 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.
- The preferred date representation without the time: equivalent to "%D".
- The preferred date representation without the date: "%H:%M:%S".
- The year as a decimal number without a century (range 00 to 99).
- The year as a decimal number including the century.
- The timezone name or abbreviation, if available. Otherwise equivalent to "%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.
- UNIX mailbox from line:
- "%a %b %e %H:%M:%S %Y"
- It is available as MU_DATETIME_FROM macro, defined in mailutils/datetime.h
- RFC-822 date/time format:
- "%a, %e %b %Y %H:%M:%S %z"
- It is available as MU_DATETIME_FORM_RFC822 macro.
- IMAP INTERNALDATE format:
- "%d-%b-%Y%$ %H:%M:%S %z"
- It is available as MU_DATETIME_IMAP and MU_DATETIME_INTERNALDATE macros.