When used in an expression out << put_time(tmb, fmt), converts the date and time information from a given calendar time tmb to a character string according to format string fmt, as if by calling std::strftime, std::wcsftime, or analog (depending on CharT
), according to the std::time_put facet of the locale currently imbued in the output stream out.
The format string consists of zero or more conversion specifiers and ordinary characters (except %
). All ordinary characters, including the terminating null character, are copied to the output string without modification. Each conversion specification begins with %
character, optionally followed by E
or O
modifier (ignored if unsupported by the locale), followed by the character that determines the behavior of the specifier. The following format specifiers are available:
%
writes literal %
. The full conversion specification must be %%
. n
t
Y
writes year as a decimal number, e.g. 2017 tm_year
EY
tm_year
y
writes last 2 digits of year as a decimal number (range [00,99]
) tm_year
Oy
tm_year
Ey
%EC
(locale-dependent) tm_year
C
[00,99]
) tm_year
EC
tm_year
G
In ISO 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements:
tm_year
, tm_wday
, tm_yday
g
[00,99]
).
In ISO 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements:
tm_year
, tm_wday
, tm_yday
Month b
writes abbreviated month name, e.g. Oct
(locale dependent) tm_mon
h
b
tm_mon
B
writes full month name, e.g. October
(locale dependent) tm_mon
m
writes month as a decimal number (range [01,12]
) tm_mon
Om
tm_mon
Week U
writes week of the year as a decimal number (Sunday is the first day of the week) (range [00,53]
) tm_year
, tm_wday
, tm_yday
OU
%U
, using the alternative numeric system, e.g. äºåäº instead of 52 in ja_JP locale tm_year
, tm_wday
, tm_yday
W
writes week of the year as a decimal number (Monday is the first day of the week) (range [00,53]
) tm_year
, tm_wday
, tm_yday
OW
%W
, using the alternative numeric system, e.g. äºåäº instead of 52 in ja_JP locale tm_year
, tm_wday
, tm_yday
V
[01,53]
).
In ISO 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements:
tm_year
, tm_wday
, tm_yday
OV
%V
, using the alternative numeric system, e.g. äºåäº instead of 52 in ja_JP locale tm_year
, tm_wday
, tm_yday
Day of the year/month j
writes day of the year as a decimal number (range [001,366]
) tm_yday
d
writes day of the month as a decimal number (range [01,31]
) tm_mday
Od
Single character is preceded by a space.
tm_mday
e
[1,31]
).
Single digit is preceded by a space.
tm_mday
Oe
Single character is preceded by a space.
tm_mday
Day of the week a
writes abbreviated weekday name, e.g. Fri
(locale dependent) tm_wday
A
writes full weekday name, e.g. Friday
(locale dependent) tm_wday
w
writes weekday as a decimal number, where Sunday is 0
(range [0-6]
) tm_wday
Ow
0
, using the alternative numeric system, e.g. äº instead of 2 in ja_JP locale tm_wday
u
1
(ISO 8601 format) (range [1-7]
) tm_wday
Ou
1
, using the alternative numeric system, e.g. äº instead of 2 in ja_JP locale tm_wday
Hour, minute, second H
writes hour as a decimal number, 24 hour clock (range [00-23]
) tm_hour
OH
tm_hour
I
writes hour as a decimal number, 12 hour clock (range [01,12]
) tm_hour
OI
tm_hour
M
writes minute as a decimal number (range [00,59]
) tm_min
OM
tm_min
S
writes second as a decimal number (range [00,60]
) tm_sec
OS
tm_sec
Other c
writes standard date and time string, e.g. Sun Oct 17 04:41:13 2010
(locale dependent) all Ec
x
writes localized date representation (locale dependent) all Ex
X
writes localized time representation, e.g. 18:40:20 or 6:40:20 PM (locale dependent) all EX
D
tm_mon
, tm_mday
, tm_year
F
tm_mon
, tm_mday
, tm_year
r
tm_hour
, tm_min
, tm_sec
R
tm_hour
, tm_min
T
tm_hour
, tm_min
, tm_sec
p
writes localized a.m. or p.m. (locale dependent) tm_hour
z
-0430
), or no characters if the time zone information is not available tm_isdst
Z
writes locale-dependent time zone name or abbreviation, or no characters if the time zone information is not available tm_isdst
template<class CharT, class Traits> void f(std::basic_ios<CharT, Traits>& str, const std::tm* tmb, const CharT* fmt) { using Iter = std::ostreambuf_iterator<CharT, Traits>; using TimePut = std::time_put<CharT, Iter>; const TimePut& tp = std::use_facet<TimePut>(str.getloc()); const Iter end = tp.put(Iter(str.rdbuf()), str, str.fill(), tmb, fmt, fmt + Traits::length(fmt)); if (end.failed()) str.setstate(std::ios_base::badbit); }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4