strftime


Description:

[ CCode ( cname = "strftime" , instance_pos = -1 ) ]
public size_t strftime (char[] s, string format)

Converts the date and time information to a null-terminated multibyte character string str according to format string format. Up to count bytes are written.

Conversion specifier Explanation Fields
% writes literal %. The full conversion specification must be %%. -

Year:

Conversion specifier Explanation Fields
Y writes year as a 4 digit decimal number year
y writes last 2 digits of year as a decimal number (range [00,99]) GLib.Time.year

Month:

Conversion specifier Explanation Fields
b writes abbreviated month name, e.g. Oct (locale dependent) GLib.Time.month
B writes full month name, e.g. October (locale dependent) GLib.Time.month
m writes month as a decimal number (range [01,12]) GLib.Time.month

Week:

Conversion specifier Explanation Fields
U writes week of the year as a decimal number (Sunday is the first day of the week) (range [00,53]) GLib.Time.year, GLib.Time.weekday, GLib.Time.day_of_year
W writes week of the year as a decimal number (Monday is the first day of the week) (range [00,53]) GLib.Time.year, GLib.Time.weekday, GLib.Time.day_of_year

Day of the year/month:

Conversion specifier Explanation Fields
j writes day of the year as a decimal number (range [001,366]) GLib.Time.day_of_year
d writes day of the month as a decimal number (range [01,31]) GLib.Time.day

Day of the week

Conversion specifier Explanation Fields
a writes abbreviated weekday name, e.g. Fri (locale dependent) GLib.Time.weekday
A writes full weekday name, e.g. Friday (locale dependent) GLib.Time.weekday
w writes weekday as a decimal number, where Sunday is 0 (range [0-6]) GLib.Time.weekday

Hour, minute, second

Conversion specifier Explanation Fields
H writes hour as a decimal number, 24 hour clock (range [00-23]) GLib.Time.hour
I writes hour as a decimal number, 12 hour clock (range [01,12]) GLib.Time.hour
M writes minute as a decimal number (range [00,59]) GLib.Time.minute
S writes second as a decimal number (range [00,60]) GLib.Time.second

Other:

Conversion specifier Explanation Fields
c writes standard date and time string, e.g. Sun Oct 17 04:41:13 2010 (locale dependent) all
x writes localized date representation (locale dependent) all
X writes localized time representation (locale dependent) all
p writes localized a.m. or p.m. (locale dependent) GLib.Time.hour
Z writes time zone name or abbreviation, or no characters if the time zone information is not available (locale dependent) GLib.Time.isdst

Parameters:

format

A string specifying the format of conversion.

f

A byte buffer

Returns:

Number of bytes written into the character array pointed to by str not including the terminating '\0' on success. If count was reached before the entire string could be stored, ​0 is returned and the contents are undefined.

See also:

GLib.Time.strptime, GLib.Time.format