首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::time_put::put

Defined in header <locale>

public: iter_type put( iter_type out, std::ios_base& str, char_type fill, const std::tm* t, const CharT* fmtbeg, const CharT* fmtend ) const;

(1)

public: iter_type put( iter_type out, std::ios_base& str, char_type fill, const std::tm* t, char format, char modifier = 0 ) const;

(2)

protected: virtual iter_type do_put( iter_type out, std::ios_base& str, char_type fill, const std::tm* t, char format, char modifier ) const;

(3)

中存储的日历日期和时间。std::tm对象所指向的t根据格式字符串转换为字符串。[fmtbeg, fmtend)格式字符串与std::srtftime,但是每个格式说明符都由一个单独的调用来处理。do_put(),它可以通过扩展这个方面来定制。

1%29步通过字符序列[fmtbeg, fmtend)检查人物。不属于格式序列一部分的每个字符都写入输出迭代器。out马上。若要识别格式序列,此函数将缩小下一个字符。c[fmtbeg, fmtend)好像std::ctype<char_type>(str.getloc()).narrow(c,0)如果它等于'%',接下来的一个或两个字符将与以下格式序列列表进行比较。std::strftime再加上此地区支持的任何其他实现定义格式。对于每个有效的格式序列,调用do_put(out, str, fill, t, format, modifier)是制造的,在哪里format是格式序列字符,并且modifier是可选格式序列修饰符%28'E''O'29%。价值'\0'如果没有修饰符,则使用。

2%29呼叫do_put大多数派生类的成员函数。

3%29转换存储在std::tm对象所指向的t根据级联形成的格式转换序列,转换成字符串。'%'的价值modifier如果不是'\0'的价值format格式的解释方式与函数相同。std::strftime,除非此区域设置定义了与区域设置相关的格式,而且其他格式说明符可能支持%28fill为使用%29的这些实现定义格式说明符提供参数。字符串被写入输出迭代器。out...

参数

out

-

output iterator where the result of the conversion is written

str

-

a stream object that this function uses to obtain locale facets when needed, e.g. std::ctype to narrow characters

t

-

pointer to the std::tm object from which the date/time values are obtained

fmtbeg

-

pointer to the first character of a sequence of char_type characters specifying the conversion format 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: Conversion specifier Explanation Used fields % writes literal %. The full conversion specification must be %%. n(C++11) writes newline character t(C++11) writes horizontal tab character Year Y writes year as a decimal number, e.g. 2017 tm_year EY(C++11) writes year in the alternative representation, e.g.平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale tm_year y writes last 2 digits of year as a decimal number (range 00,99) tm_year Oy(C++11) writes last 2 digits of year using the alternative numeric system, e.g. 十一 instead of 11 in ja_JP locale tm_year Ey(C++11) writes year as offset from locale's alternative calendar period %EC (locale-dependent) tm_year C(C++11) writes first 2 digits of year as a decimal number (range 00,99) tm_year EC(C++11) writes name of the base year (period) in the locale's alternative representation, e.g. 平成 (Heisei era) in ja_JP tm_year G(C++11) writes ISO 8601 week-based year, i.e. the year that contains the specified week. In IS0 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements: Includes January 4 Includes first Thursday of the year tm_year, tm_wday, tm_yday g(C++11) writes last 2 digits of ISO 8601 week-based year, i.e. the year that contains the specified week (range 00,99). In IS0 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements: Includes January 4 Includes first Thursday of the year tm_year, tm_wday, tm_yday Month b writes abbreviated month name, e.g. Oct (locale dependent) tm_mon h(C++11) synonym of 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(C++11) writes month using the alternative numeric system, e.g. 十二 instead of 12 in ja_JP locale 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(C++11) writes week of the year, as by %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(C++11) writes week of the year, as by %W, using the alternative numeric system, e.g. 五十二 instead of 52 in ja_JP locale tm_year, tm_wday, tm_yday V(C++11) writes ISO 8601 week of the year (range 01,53). In IS0 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements: Includes January 4 Includes first Thursday of the year tm_year, tm_wday, tm_yday OV(C++11) writes week of the year, as by %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(C++11) writes zero-based day of the month using the alternative numeric system, e.g 二十七 instead of 23 in ja_JP locale Single character is preceded by a space. tm_mday e(C++11) writes day of the month as a decimal number (range 1,31). Single digit is preceded by a space. tm_mday Oe(C++11) writes one-based day of the month using the alternative numeric system, e.g. 二十七 instead of 27 in ja_JP locale 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(C++11) writes weekday, where Sunday is 0, using the alternative numeric system, e.g. 二 instead of 2 in ja_JP locale tm_wday u(C++11) writes weekday as a decimal number, where Monday is 1 (ISO 8601 format) (range 1-7) tm_wday Ou(C++11) writes weekday, where Monday is 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(C++11) writes hour from 24-hour clock using the alternative numeric system, e.g. 十八 instead of 18 in ja_JP locale tm_hour I writes hour as a decimal number, 12 hour clock (range 01,12) tm_hour OI(C++11) writes hour from 12-hour clock using the alternative numeric system, e.g. 六 instead of 06 in ja_JP locale tm_hour M writes minute as a decimal number (range 00,59) tm_min OM(C++11) writes minute using the alternative numeric system, e.g. 二十五 instead of 25 in ja_JP locale tm_min S writes second as a decimal number (range 00,60) tm_sec OS(C++11) writes second using the alternative numeric system, e.g. 二十四 instead of 24 in ja_JP locale tm_sec Other c writes standard date and time string, e.g. Sun Oct 17 04:41:13 2010 (locale dependent) all Ec(C++11) writes alternative date and time string, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale all x writes localized date representation (locale dependent) all Ex(C++11) writes alternative date representation, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale all X writes localized time representation (locale dependent) all EX(C++11) writes alternative time representation (locale dependent) all D(C++11) equivalent to "%m/%d/%y" tm_mon, tm_mday, tm_year F(C++11) equivalent to "%Y-%m-%d" (the ISO 8601 date format) tm_mon, tm_mday, tm_year r(C++11) writes localized 12-hour clock time (locale dependent) tm_hour, tm_min, tm_sec R(C++11) equivalent to "%H:%M" tm_hour, tm_min T(C++11) equivalent to "%H:%M:%S" (the ISO 8601 time format) tm_hour, tm_min, tm_sec p writes localized a.m. or p.m. (locale dependent) tm_hour z(C++11) writes offset from UTC in the ISO 8601 format (e.g. -0430), or no characters if the time zone information is not available tm_isdst Z writes time zone name or abbreviation, or no characters if the time zone information is not available (locale dependent) tm_isdst

Conversion specifier

Explanation

Used fields

%

writes literal %. The full conversion specification must be %%.

n(C++11)

writes newline character

t(C++11)

writes horizontal tab character

Year

Y

writes year as a decimal number, e.g. 2017

tm_year

EY(C++11)

writes year in the alternative representation, e.g.平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale

tm_year

y

writes last 2 digits of year as a decimal number (range 00,99)

tm_year

Oy(C++11)

writes last 2 digits of year using the alternative numeric system, e.g. 十一 instead of 11 in ja_JP locale

tm_year

Ey(C++11)

writes year as offset from locale's alternative calendar period %EC (locale-dependent)

tm_year

C(C++11)

writes first 2 digits of year as a decimal number (range 00,99)

tm_year

EC(C++11)

writes name of the base year (period) in the locale's alternative representation, e.g. 平成 (Heisei era) in ja_JP

tm_year

G(C++11)

writes ISO 8601 week-based year, i.e. the year that contains the specified week. In IS0 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements: Includes January 4 Includes first Thursday of the year

tm_year, tm_wday, tm_yday

g(C++11)

writes last 2 digits of ISO 8601 week-based year, i.e. the year that contains the specified week (range 00,99). In IS0 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements: Includes January 4 Includes first Thursday of the year

tm_year, tm_wday, tm_yday

Month

b

writes abbreviated month name, e.g. Oct (locale dependent)

tm_mon

h(C++11)

synonym of 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(C++11)

writes month using the alternative numeric system, e.g. 十二 instead of 12 in ja_JP locale

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(C++11)

writes week of the year, as by %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(C++11)

writes week of the year, as by %W, using the alternative numeric system, e.g. 五十二 instead of 52 in ja_JP locale

tm_year, tm_wday, tm_yday

V(C++11)

writes ISO 8601 week of the year (range 01,53). In IS0 8601 weeks begin with Monday and the first week of the year must satisfy the following requirements: Includes January 4 Includes first Thursday of the year

tm_year, tm_wday, tm_yday

OV(C++11)

writes week of the year, as by %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(C++11)

writes zero-based day of the month using the alternative numeric system, e.g 二十七 instead of 23 in ja_JP locale Single character is preceded by a space.

tm_mday

e(C++11)

writes day of the month as a decimal number (range 1,31). Single digit is preceded by a space.

tm_mday

Oe(C++11)

writes one-based day of the month using the alternative numeric system, e.g. 二十七 instead of 27 in ja_JP locale 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(C++11)

writes weekday, where Sunday is 0, using the alternative numeric system, e.g. 二 instead of 2 in ja_JP locale

tm_wday

u(C++11)

writes weekday as a decimal number, where Monday is 1 (ISO 8601 format) (range 1-7)

tm_wday

Ou(C++11)

writes weekday, where Monday is 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(C++11)

writes hour from 24-hour clock using the alternative numeric system, e.g. 十八 instead of 18 in ja_JP locale

tm_hour

I

writes hour as a decimal number, 12 hour clock (range 01,12)

tm_hour

OI(C++11)

writes hour from 12-hour clock using the alternative numeric system, e.g. 六 instead of 06 in ja_JP locale

tm_hour

M

writes minute as a decimal number (range 00,59)

tm_min

OM(C++11)

writes minute using the alternative numeric system, e.g. 二十五 instead of 25 in ja_JP locale

tm_min

S

writes second as a decimal number (range 00,60)

tm_sec

OS(C++11)

writes second using the alternative numeric system, e.g. 二十四 instead of 24 in ja_JP locale

tm_sec

Other

c

writes standard date and time string, e.g. Sun Oct 17 04:41:13 2010 (locale dependent)

all

Ec(C++11)

writes alternative date and time string, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale

all

x

writes localized date representation (locale dependent)

all

Ex(C++11)

writes alternative date representation, e.g. using 平成23年 (year Heisei 23) instead of 2011年 (year 2011) in ja_JP locale

all

X

writes localized time representation (locale dependent)

all

EX(C++11)

writes alternative time representation (locale dependent)

all

D(C++11)

equivalent to "%m/%d/%y"

tm_mon, tm_mday, tm_year

F(C++11)

equivalent to "%Y-%m-%d" (the ISO 8601 date format)

tm_mon, tm_mday, tm_year

r(C++11)

writes localized 12-hour clock time (locale dependent)

tm_hour, tm_min, tm_sec

R(C++11)

equivalent to "%H:%M"

tm_hour, tm_min

T(C++11)

equivalent to "%H:%M:%S" (the ISO 8601 time format)

tm_hour, tm_min, tm_sec

p

writes localized a.m. or p.m. (locale dependent)

tm_hour

z(C++11)

writes offset from UTC in the ISO 8601 format (e.g. -0430), or no characters if the time zone information is not available

tm_isdst

Z

writes time zone name or abbreviation, or no characters if the time zone information is not available (locale dependent)

tm_isdst

Conversion specifier

Explanation

Used fields

%

writes literal %. The full conversion specification must be %%.

n(C++11)

writes newline character

t(C++11)

writes horizontal tab character

y将年份写成十进制数,例如2017 tm[医]年

EY%28C++11%29在替代表示中写入年份,例如平成23年%28 Heisei 23%29,而在ja中为2011年%28a 2011%29[医]JP地区tm[医]年

Y将年的最后2位数字写为十进制数%28范围0099%29 tm[医]年

Oy%28C++11%29使用替代的数字系统写入年的最后2位数字,例如十一而不是ja中的11位[医]JP地区tm[医]年

EY%28C++11%29写入年份,从地区%27s替代日历周期%EC%28地区相关%29 tm抵消[医]年

C%28C++11%29将年份的前2位数字写为十进制数%28范围0099%29 tm[医]年

EC%28C++11%29在地区%27s替代表示中写入基准年%28周期%29的名称,例如平成%28 Heisei era%29在ja[医]JP tm[医]年

G%28C++11%29写入ISO 8601基于周的年份,即包含指定周的年份。在IS0中,8601周从星期一开始,一年中的第一周必须满足以下要求:包括1月4日,包括年的第一个星期四。[医]年份,tm[医]WDAY,tm[医]日

G%28C++11%29写入iso 8601周基础年的最后2位数,即包含指定周%28范围的年份。009929%。在IS0中,8601周从星期一开始,一年中的第一周必须满足以下要求:包括1月4日,包括年的第一个星期四。[医]年份,tm[医]WDAY,tm[医]日

B写缩写的月份名称,例如oct%28依赖于%29 tm[医]蒙

h%28C++11%29[医]蒙

B写完整的月份名称,例如10月%28依赖于%29 tm[医]蒙

M将月份写入小数%28范围01,12%29 tm[医]蒙

OM%28C++11%29使用替代数字系统编写月份,例如十二而不是JA中的12[医]JP地区tm[医]蒙

你把一年中的每周写成十进制数%28星期日是一周的第一天%29%28范围0053%29 tm[医]年份,tm[医]WDAY,tm[医]日

Ou%28C++11%29使用替代的数字系统(例如五十二而不是ja中的52),以%U的形式写一年中的每周[医]JP地区tm[医]年份,tm[医]WDAY,tm[医]日

W将一年中的每周写成十进制数%28星期一是一周的第一天%29%28范围0053%29 tm[医]年份,tm[医]WDAY,tm[医]日

现在,%28C++11%29使用替代的数字系统(例如五十二而不是JA中的52),以%W的方式写一年中的每周一周。[医]JP地区tm[医]年份,tm[医]WDAY,tm[医]日

v%28C++11%29写入ISO 8601周01,5329%。在IS0中,8601周从星期一开始,一年中的第一周必须满足以下要求:包括1月4日,包括年的第一个星期四。[医]年份,tm[医]WDAY,tm[医]日

Ov%28C++11%29使用替代的数字系统(例如五十二而不是JA中的52)来编写一年中的周数,如%V[医]JP地区tm[医]年份,tm[医]WDAY,tm[医]日

年度/月份的日期

J将一年中的一天写为十进制数%28范围001366%29 tm[医]日

D将月份中的一天写为十进制数%28范围01,31%29 tm[医]马日

OD%28C++11%29使用可选的数字系统(例如二十七而不是ja中的23)写一个月的零日。[医]jp区域设置单个字符前面有一个空格。TM[医]马日

E%28C++11%29写入月份中的小数%28范围一千三十一29%。单数前面有一个空格。TM[医]马日

OE%28C++11%29使用替代的数字系统编写一个月中的一天,例如二十七而不是ja中的27。[医]jp区域设置单个字符前面有一个空格。TM[医]马日

一周中的一天

A写入缩短的工作日名称,例如Fri%28 locale依赖于%29 tm。[医]WDAY

A写入整个工作日名称,例如周五%28依赖于%29 tm。[医]WDAY

W将工作日写成十进制数,其中星期日为0%28范围。0-6%29 tm[医]WDAY

现在%28C++11%29在工作日使用替代的数字系统(例如二而不是ja中的2),周日为0。[医]JP地区tm[医]WDAY

U%28C++11%29在工作日以小数形式写入,其中星期一为1%28ISO 8601格式%29%28范围1-7%29 tm[医]WDAY

Ou%28C++11%29在工作日,星期一为1,使用可选的数字系统,例如二而不是ja中的2[医]JP地区tm[医]WDAY

小时,分钟,秒

h将小时写为十进制数,24小时时钟%28范围00-23%29 tm[医]小时

噢,%28C++11%29使用替代的数字系统从24小时时钟写入一个小时,例如十八而不是ja中的18。[医]JP地区tm[医]小时

我写小时为十进制数,12小时时钟%28范围01,12%29 tm[医]小时

Oi%28C++11%29使用替代的数字系统从12小时时钟写入小时,例如在ja中使用六而不是06。[医]JP地区tm[医]小时

M将分钟写成十进制数%28范围0059%29 tm[医]敏

OM%28C++11%29使用替代数字系统写入分钟,例如二十五而不是JA中的25[医]JP地区tm[医]敏

s作为十进制数%28范围写入第二位0060%29 tm[医]证交会

OS%28C++11%29使用替代的数字系统编写第二次,例如二十四而不是ja中的24[医]JP地区tm[医]证交会

其他

c写入标准日期和时间字符串,例如太阳10月17日上午04:41:13 2010%28 locale依赖%29 All

EC%28C++11%29写入替代日期和时间字符串,例如在ja中使用平成23年%28a Heisei 23%29而不是2011年%28a 2011%29[医]JP地区所有

写入本地化日期表示%28依赖于%29 ALL

EX%28C++11%29编写替代日期表示,例如在ja中使用平成23年%28a Heisei 23%29而不是2011年%28a 2011%29[医]JP地区所有

写入本地化时间表示%28区域依赖于%29 ALL

EX%28C++11%29写入替代时间表示%28地区依赖于%29 ALL

D%28C++11%29等于“%m/%d/%y”tm[医]星期一,tm[医]mday,tm[医]年

F%28C++11%29等效于“%Y-%m-%d”%28 iso 8601日期格式%29 tm[医]星期一,tm[医]mday,tm[医]年

r%28C++11%29写入本地化的12小时时钟时间%28地区依赖于%29 tm[医]小时,小时[医]min,tm[医]证交会

R%28C++11%29,相当于“%H:%M”tm[医]小时,小时[医]敏

T%28C++11%29相当于“%H:%M:%S”%28 ISO 8601时间格式%29 tm[医]小时,小时[医]min,tm[医]证交会

p写入本地化的上午或下午%28依赖于%29 tm[医]小时

Z%28C++11%29在ISO 8601格式中写入来自UTC的偏移量%28e.g。-0430%29,如果时区信息不可用,则为空字符。[医]isdst

如果时区信息不可用,则写入时区名称或缩写,或不写入字符。[医]isdst

指示字符序列的最后一个字符的指针。[医]指定转换格式的字符类型

填充字符%28通常为空格%29

格式-命名转换说明符的字符。

修饰符-在%和转换说明符之间可能出现的可选修饰符

  • 包括1月4日
  • 包括一年中的第一个星期四

tm_year,,,tm_wday,,,tm_ydayg

%28C++11%29写入最后2位数字8601周为基础的年份,即包含指定周%28范围的年份。[00,99]29%。在IS0中,8601周从星期一开始,一年中的第一周必须满足以下要求:

  • 包括1月4日
  • 包括一年中的第一个星期四

tm_year,,,tm_wday,,,tm_ydayb写字缩短月份名称,例如:Oct28%依赖于区域的%29tm_monh

%28C++11%29同义词btm_monB写字整月名称,例如:October28%依赖于区域的%29tm_monm写字作为十进制数%28的范围[01,12]%29tm_monOm

%28C++11%29写使用替代的数字系统,例如十二而不是JA中的12[医]JP地区tm_monU写字一年中的每周作为十进制数%28星期日是一周的第一天%29%28范围[00,53]%29tm_year,,,tm_wday,,,tm_ydayOU

%28C++11%29写一年中的每周,如%U,使用替代的数字系统,例如在ja中使用五十二而不是52[医]JP地区tm_year,,,tm_wday,,,tm_ydayW写字一年中的每周作为小数%28星期一是一周的第一天%29%28范围[00,53]%29tm_year,,,tm_wday,,,tm_ydayOW

%28C++11%29写一年中的每周,如%W,使用替代的数字系统,例如在ja中使用五十二而不是52[医]JP地区tm_year,,,tm_wday,,,tm_ydayV

%28C++11%29写一年中的8601周%28范围[01,53]29%。在IS0中,8601周从星期一开始,一年中的第一周必须满足以下要求:

  • 包括1月4日
  • 包括一年中的第一个星期四

tm_year,,,tm_wday,,,tm_ydayOV

%28C++11%29写一年中的每周,如%V,使用替代的数字系统,例如在ja中使用五十二而不是52[医]JP地区tm_year,,,tm_wday,,,tm_yday年度/月份的日期j写字一年中的一天作为十进制数%28的范围[001,366]%29tm_ydayd写字当月的一天作为十进制数%28的范围[01,31]%29tm_mdayOd

%28C++11%29写入基于零的当月的一天在ja中使用替代的数字系统,例如二十七而不是23[医]jp区域设置单个字符前面有一个空格。

tm_mdaye

%28C++11%29写当月的一天作为十进制数%28的范围[1,31]29%。单数前面有一个空格。

tm_mdayOe

%28C++11%29只写一个当月的一天使用替代的数字系统,例如在ja中使用二十七而不是27[医]jp区域设置单个字符前面有一个空格。

tm_mday一周中的一天a写字缩短工作日名称,例如:Fri28%依赖于区域的%29tm_wdayA写字全日工作日名称,例如:Friday28%依赖于区域的%29tm_wdayw写字平日作为十进制数,星期日是0%28范围[0-6]%29tm_wdayOw

%28C++11%29写平日,星期日在哪里0,使用替代的数字系统,例如在ja中使用二而不是2[医]JP地区tm_wdayu

%28C++11%29写平日作为十进制数,星期一是1%28 ISO 8601格式%29%28范围[1-7]%29tm_wdayOu

%28C++11%29写平日,星期一在哪里1,使用替代的数字系统,例如在ja中使用二而不是2[医]JP地区tm_wday小时,分钟,秒H写字小时作为十进制数,24小时时钟%28范围[00-23]%29tm_hourOH

%28C++11%29写小时从24小时时钟开始使用替代的数字系统,例如十八而不是ja中的18[医]JP地区tm_hourI写字小时作为十进制数,12小时时钟%28范围[01,12]%29tm_hourOI

%28C++11%29写小时从12小时时钟开始,使用替代的数字系统,例如,在ja中使用六而不是06。[医]JP地区tm_hourM写字分分钟作为十进制数%28的范围[00,59]%29tm_minOM

%28C++11%29写分分钟使用替代的数字系统,例如二十五而不是JA中的25[医]JP地区tm_minS写字第二作为十进制数%28的范围[00,60]%29tm_secOS

%28C++11%29写第二使用替代的数字系统,例如在ja中使用二十四而不是24[医]JP地区tm_sec其他c写字标准日期和时间字符串,G.Sun Oct 17 04:41:13 2010%28地区依赖于%29 ALLEc

%28C++11%29写可选日期和时间字符串,例如在日本使用平成23年%28a Heisei 23%29而不是2011年%28a 2011%29。[医]JP地区所有x写本地化日期表示%28地区依赖于%29 ALLEx

%28C++11%29写替代日期表示,例如在日本使用平成23年%28a Heisei 23%29而不是2011年%28a 2011%29。[医]JP地区所有X写本地化时间表示%28地区依赖于%29 ALLEX

%28C++11%29写替代时间表示%28地区依赖于%29 ALLD

%28C++11%29相当于“%m/%d/%y”tm_mon,,,tm_mday,,,tm_yearF

%28C++11%29相当于“%Y-%m-%d”%28 iso 8601日期格式%29tm_mon,,,tm_mday,,,tm_yearr

%28C++11%29写本地化12小时钟时间%28地区依赖于%29tm_hour,,,tm_min,,,tm_secR

%28C++11%29相当于“%H:%M”tm_hour,,,tm_minT

%28C++11%29相当于“%H:%M:%S”%28 iso 8601时间格式%29tm_hour,,,tm_min,,,tm_secp写本地化上午或下午。28%依赖于区域的%29tm_hourz

%28C++11%29写从世界协调时抵消在iso 8601格式中%28例如。-0430%29,如果时区信息不可用,则为空字符tm_isdstZ写字时区名称或缩写,如果时区信息不可用,则为%28依赖于%29。tm_isdst指示字符序列的最后一个字符的指针。[医]类型字符指定转换格式填充字符%28-通常为空格%29格式-指定转换说明修饰符的字符-可能出现在%和转换说明符

返回值

一名爱尔兰人指出了最后一个角色。

注记

不提供错误处理。

fill的实现定义格式说明符和用户定义的重写。do_put()使用填充和填充逻辑。这样的实现通常使用来自str...

二次

代码语言:javascript
复制
#include <iostream>
#include <sstream>
#include <iomanip>
#include <ctime>
 
void try_time_put(const std::tm* t, const std::string& fmt)
{
        std::cout.imbue(std::locale());
        std::cout << "In the locale '" << std::cout.getloc().name() << "' : '";
 
        std::use_facet<std::time_put<char>>(std::cout.getloc()).put(
                    std::ostreambuf_iterator<char>(std::cout),
                    std::cout, ' ', t, &fmt[0], &fmt[0] + fmt.size());
 
        std::cout << "'\n";
}
 
int main()
{
    std::time_t t = std::time(NULL);
    std::tm tm = *std::localtime(&t);
 
    std::string fmt = "%c";
    std::cout << "Using the format string '" << fmt
              << "' to format the time: " << std::ctime(&t) << '\n';
 
    std::locale::global(std::locale("de_DE.utf8"));
    try_time_put(&tm, fmt);
 
    std::locale::global(std::locale("el_GR.utf8"));
    try_time_put(&tm, fmt);
 
    std::locale::global(std::locale("ja_JP.utf8"));
    try_time_put(&tm, fmt);
}

二次

产出:

二次

代码语言:javascript
复制
Using the format string '%c' to format the time: Mon Feb 11 22:58:50 2013
 
In the locale 'de_DE.utf8' : 'Mo 11 Feb 2013 23:02:38 EST'
In the locale 'el_GR.utf8' : 'Δευ 11 Φεβ 2013 11:02:38 μμ EST'
In the locale 'ja_JP.utf8' : '2013年02月11日 23時02分38秒'

二次

另见

put_time (C++11)

formats and outputs a date/time value according to the specified format (function template)

do_get virtual

extracts date/time components from input stream, according to the specified format (virtual protected member function of std::time_get)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券