1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <!DOCTYPE library PUBLIC
"-//Boost//DTD BoostBook XML V1.0//EN"
3 "../../../tools/boostbook/dtd/boostbook.dtd">
5 <!-- Copyright (c) 2005 CrystalClear Software, Inc.
6 Subject to the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
10 <section id=
"date_time.format_flags">
11 <title>Format Flags
</title>
13 <para>Many of the format flags this new system uses for output are those used by
<code>strftime(...)
</code>, but not all. Some new flags have been added, and others overridden. The input system supports only specific flags, therefore, not all flags that work for output will work with input (we are currently working to correct this situation).
</para>
15 <para>The following tables list the all the flags available for both date_time IO as well as strftime. Format flags marked with a single asterisk (*) have a behavior unique to date_time. Those flags marked with an exclamation point (!) are not usable for input (at this time). The flags marked with a hash sign (#) are implemented by system locale and are known to be missing on some platforms. The first table is for dates, and the second table is for times.
19 <anchor id=
"date_time_io.date_format_flags" />
20 Date Facet Format Flags
21 <informaltable frame=
"all">
25 <entry valign=
"top" morerows=
"1">Format Specifier
</entry>
26 <entry>Description
</entry>
29 <entry>Example
</entry>
34 <entry valign=
"top" morerows=
"1"><screen>%a
</screen></entry>
35 <entry>Abbreviated weekday name
</entry>
38 <entry><screen>"Mon" =
> Monday
</screen></entry>
42 <entry valign=
"top" morerows=
"1"><screen>%A
</screen></entry>
43 <entry>Long weekday name
</entry>
46 <entry><screen>"Monday"</screen></entry>
50 <entry valign=
"top" morerows=
"1"><screen>%b
</screen></entry>
51 <entry>Abbreviated month name
</entry>
54 <entry><screen>"Feb" =
> February
</screen></entry>
58 <entry valign=
"top" morerows=
"1"><screen>%B
</screen></entry>
59 <entry>Full month name
</entry>
62 <entry><screen>"February"</screen></entry>
66 <entry valign=
"top" morerows=
"1"><screen>%c !
</screen></entry>
67 <entry>The preferred date and time representation for the current locale.
</entry>
70 <entry><screen></screen></entry>
74 <entry valign=
"top" morerows=
"1"><screen>%C !#
</screen></entry>
75 <entry>The century number (year/
100) as a
2-digit integer.
</entry>
78 <entry><screen></screen></entry>
82 <entry valign=
"top" morerows=
"1"><screen>%d
</screen></entry>
84 Day of the month as decimal
01 to
31. When used to parse input, the leading zero is optional.
88 <entry><screen></screen></entry>
92 <entry valign=
"top" morerows=
"1"><screen>%D !#
</screen></entry>
93 <entry>Equivalent to %m/%d/%y
</entry>
96 <entry><screen></screen></entry>
100 <entry valign=
"top" morerows=
"1"><screen>%e #
</screen></entry>
102 Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space.
103 When used to parse input, the leading space is optional.
107 <entry><screen></screen></entry>
111 <entry valign=
"top" morerows=
"1"><screen>%G !
</screen></entry>
112 <entry>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.
</entry>
115 <entry><screen></screen></entry>
119 <entry valign=
"top" morerows=
"1"><screen>%g !
</screen></entry>
120 <entry>Like %G, but without century.
</entry>
123 <entry><screen></screen></entry>
127 <entry valign=
"top" morerows=
"1"><screen>%h !#
</screen></entry>
128 <entry> Equivalent to %b
</entry>
131 <entry><screen></screen></entry>
135 <entry valign=
"top" morerows=
"1"><screen>%j
</screen></entry>
136 <entry>Day of year as decimal from
001 to
366 for leap years,
001 -
365 for non-leap years.
</entry>
139 <entry><screen>"060" =
> Feb-
29</screen></entry>
143 <entry valign=
"top" morerows=
"1"><screen>%m
</screen></entry>
144 <entry>Month name as a decimal
01 to
12</entry>
147 <entry><screen>"01" =
> January
</screen></entry>
151 <entry valign=
"top" morerows=
"1"><screen>%u !
</screen></entry>
152 <entry>The day of the week as a decimal, range
1 to
7, Monday being
1.
</entry>
155 <entry><screen></screen></entry>
159 <entry valign=
"top" morerows=
"1"><screen>%U
</screen></entry>
160 <entry>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. In
2005, Jan
1st falls on a Saturday, so therefore it falls within week
00 of
2005 (week
00 spans
2004-Dec-
26 to
2005-Jan-
01. This also happens to be week
53 of
2004).
</entry>
163 <entry><screen>date d(
2005, Jan,
1); // Saturday
165 ss
<< d; //
"00"
166 d += day(
1); // Sunday
167 ss
<< d; //
"01" beginning of week
1</screen></entry>
171 <entry valign=
"top" morerows=
"1"><screen>%V !#
</screen></entry>
172 <entry>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.
</entry>
175 <entry><screen></screen></entry>
179 <entry valign=
"top" morerows=
"1"><screen>%w
</screen></entry>
180 <entry>Weekday as decimal number
0 to
6</entry>
183 <entry><screen>"0" =
> Sunday
</screen></entry>
187 <entry valign=
"top" morerows=
"1"><screen>%W
</screen></entry>
188 <entry>Week number
00 to
53 where Monday is first day of week
1</entry>
191 <entry><screen>date d(
2005, Jan,
2); // Sunday
193 ss
<< d; //
"00"
194 d += day(
1); // Monday
195 ss
<< d; //
"01" beginning of week
1</screen></entry>
199 <entry valign=
"top" morerows=
"1"><screen>%x
</screen></entry>
200 <entry>Implementation defined date format from the locale.
</entry>
203 <entry><screen>date d(
2005,Oct,
31);
204 date_facet* f = new date_facet(
"%x");
206 locale loc = locale(locale(
"en_US"), f);
208 cout
<< d; //
"10/31/2005"
210 loc = locale(locale(
"de_DE"), f);
212 cout
<< d; //
"31.10.2005"</screen></entry>
216 <entry valign=
"top" morerows=
"1"><screen>%y
</screen></entry>
217 <entry>Two digit year
</entry>
220 <entry><screen>"05" =
> 2005</screen></entry>
224 <entry valign=
"top" morerows=
"1"><screen>%Y
</screen></entry>
225 <entry>Four digit year
</entry>
228 <entry><screen>"2005"</screen></entry>
232 <entry valign=
"top" morerows=
"1"><screen>%Y-%b-%d
</screen></entry>
233 <entry>Default date format
</entry>
236 <entry><screen>"2005-Apr-01"</screen></entry>
240 <entry valign=
"top" morerows=
"1"><screen>%Y%m%d
</screen></entry>
241 <entry>ISO format
</entry>
244 <entry><screen>"20050401"</screen></entry>
248 <entry valign=
"top" morerows=
"1"><screen>%Y-%m-%d
</screen></entry>
249 <entry>ISO extended format
</entry>
252 <entry><screen>"2005-04-01"</screen></entry>
260 <anchor id=
"date_time_io.time_format_flags" />
261 Time Facet Format Flags
262 <informaltable frame=
"all">
266 <entry valign=
"top" morerows=
"1">Format Specifier
</entry>
267 <entry>Description
</entry>
270 <entry>Example
</entry>
275 <entry valign=
"top" morerows=
"1"><screen>%- *!
</screen></entry>
276 <entry>Placeholder for the sign of a duration. Only displays when the duration is negative.
</entry>
279 <entry><screen>"-13:15:16"</screen></entry>
283 <entry valign=
"top" morerows=
"1"><screen>%+ *!
</screen></entry>
284 <entry>Placeholder for the sign of a duration. Always displays for both positive and negative.
</entry>
287 <entry><screen>"+13:15:16"</screen></entry>
291 <entry valign=
"top" morerows=
"1"><screen>%f
</screen></entry>
292 <entry>Fractional seconds are always used, even when their value is zero
</entry>
295 <entry><screen>"13:15:16.000000"</screen></entry>
299 <entry valign=
"top" morerows=
"1"><screen>%F *
</screen></entry>
300 <entry>Fractional seconds are used only when their value is not zero.
</entry>
303 <entry><screen>"13:15:16"
304 "05:04:03.001234"</screen></entry>
308 <entry valign=
"top" morerows=
"1"><screen>%H
</screen></entry>
309 <entry>The hour as a decimal number using a
24-hour clock (range
00 to
23).
</entry>
316 <entry valign=
"top" morerows=
"1"><screen>%I !
</screen></entry>
317 <entry>The hour as a decimal number using a
12-hour clock (range
01 to
12).
</entry>
324 <entry valign=
"top" morerows=
"1"><screen>%k !
</screen></entry>
325 <entry>The hour (
24-hour clock) as a decimal number (range
0 to
23); single digits are preceded by a blank.
</entry>
332 <entry valign=
"top" morerows=
"1"><screen>%l !
</screen></entry>
333 <entry>The hour (
12-hour clock) as a decimal number (range
1 to
12); single digits are preceded by a blank.
</entry>
340 <entry valign=
"top" morerows=
"1"><screen>%M
</screen></entry>
341 <entry>The minute as a decimal number (range
00 to
59).
</entry>
348 <entry valign=
"top" morerows=
"1"><screen>%O
</screen></entry>
349 <entry>The number of hours in a time duration as a decimal number (range
0 to max. representable duration); single digits are preceded by a zero.
</entry>
356 <entry valign=
"top" morerows=
"1"><screen>%p !
</screen></entry>
357 <entry>Either `AM' or `PM' according to the given time value, or the corresponding strings for the current locale.
</entry>
364 <entry valign=
"top" morerows=
"1"><screen>%P !#
</screen></entry>
365 <entry>Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale.
</entry>
372 <entry valign=
"top" morerows=
"1"><screen>%r !#
</screen></entry>
373 <entry>The time in a.m. or p.m. notation. In the POSIX locale this is equivalent to `%I:%M:%S %p'
</entry>
380 <entry valign=
"top" morerows=
"1"><screen>%R !
</screen></entry>
381 <entry>The time in
24-hour notation (%H:%M)
</entry>
388 <entry valign=
"top" morerows=
"1"><screen>%s *
</screen></entry>
389 <entry>Seconds with fractional seconds.
</entry>
392 <entry><screen>"59.000000"</screen></entry>
396 <entry valign=
"top" morerows=
"1"><screen>%S
</screen></entry>
397 <entry>Seconds only
</entry>
400 <entry><screen>"59"</screen></entry>
404 <entry valign=
"top" morerows=
"1"><screen>%T !
</screen></entry>
405 <entry>The time in
24-hour notation (%H:%M:%S)
</entry>
412 <entry valign=
"top" morerows=
"1"><screen>%q
</screen></entry>
413 <entry>ISO time zone (output only). This flag is ignored when using the time_facet with a ptime.
</entry>
416 <entry><screen>"-0700" // Mountain Standard Time
</screen></entry>
420 <entry valign=
"top" morerows=
"1"><screen>%Q
</screen></entry>
421 <entry>ISO extended time zone (output only). This flag is ignored when using the time_facet with a ptime.
</entry>
424 <entry><screen>"-05:00" // Eastern Standard Time
</screen></entry>
428 <entry valign=
"top" morerows=
"1"><screen>%z *!
</screen></entry>
429 <entry>Abbreviated time zone (output only). This flag is ignored when using the time_facet with a ptime.
</entry>
432 <entry><screen>"MST" // Mountain Standard Time
</screen></entry>
436 <entry valign=
"top" morerows=
"1"><screen>%Z *!
</screen></entry>
437 <entry>Full time zone name (output only). This flag is ignored when using the time_facet with a ptime.
</entry>
440 <entry><screen>"EDT" // Eastern Daylight Time
</screen></entry>
444 <entry valign=
"top" morerows=
"1"><screen>%ZP *
</screen></entry>
445 <entry>Posix time zone string (available to both input and output). This flag is ignored when using the time_facet with a ptime. For complete details on posix time zone strings, see
<link linkend=
"date_time.local_time.posix_time_zone">posix_time_zone class
</link>.
</entry>
448 <entry><screen>"EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00"</screen></entry>
452 <entry valign=
"top" morerows=
"1"><screen>%x %X
</screen></entry>
453 <entry>Implementation defined date/time format from the locale.
</entry>
456 <entry><screen>date d(
2005,Oct,
31);
457 ptime pt(d, hours(
20));
458 time_facet* f = new time_facet(
"%x %X");
460 locale loc = locale(locale(
"en_US"), f);
462 cout
<< pt; //
"10/31/2005 08:00:00 PM"
464 loc = locale(locale(
"de_DE"), f);
466 cout
<< pt; //
"31.10.2005 20:00:00"</screen></entry>
470 <entry valign=
"top" morerows=
"1"><screen>%Y%m%dT%H%M%S%F%q
</screen></entry>
471 <entry>ISO format
</entry>
474 <entry><screen>"20051015T131211-0700" // Oct
15,
2005 13:
12:
11 MST
</screen></entry>
478 <entry valign=
"top" morerows=
"1"><screen>%Y-%m-%d %H:%M:%S%F%Q
</screen></entry>
479 <entry>Extended ISO format
</entry>
482 <entry><screen>"2005-10-15 13:12:11-07:00"</screen></entry>
486 <entry valign=
"top" morerows=
"1"><screen>%Y-%b-%d %H:%M:%S%F %z
</screen></entry>
487 <entry>Default format used when outputting ptime and local_date_time.
</entry>
490 <entry><screen>"2005-Oct-15 13:12:11 MST"</screen></entry>
494 <entry valign=
"top" morerows=
"1"><screen>%Y-%b-%d %H:%M:%S%F %ZP
</screen></entry>
495 <entry>Default format used when inputting ptime and local_date_time.
</entry>
498 <entry><screen>"2005-Oct-15 13:12:11 MST-07"</screen></entry>
502 <entry valign=
"top" morerows=
"1"><screen>%-%H:%M:%S%F !
</screen></entry>
503 <entry>Default time_duration format for output. Sign will only be displayed for negative durations.
</entry>
506 <entry><screen>"-13:14:15.003400"</screen></entry>
510 <entry valign=
"top" morerows=
"1"><screen>%H:%M:%S%F
</screen></entry>
511 <entry>Default time_duration format for input.
</entry>
514 <entry><screen>"13:14:15.003400"</screen></entry>
521 <para>* Signifies flags that have a behavior unique to
<code>date_time
</code>.
</para>
522 <para># Signifies flags that have a platform-dependent behavior. These may not be supported everywhere.
</para>
523 <para>! Signifies flags that currently do not work for input.
</para>