1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101
|
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
"../../../tools/boostbook/dtd/boostbook.dtd">
<!-- Copyright (c) 2005 CrystalClear Software, Inc.
Subject to the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
-->
<section id="date_time.io_objects"
xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Date Time Formatter/Parser Objects</title>
<!-- <using-namespace name="boost"/> -->
<using-namespace name="boost::date_time"/>
<bridgehead renderas="sect2">Date Time Formatter/Parser Objects</bridgehead>
<link linkend="io_objects.periods">Periods</link> |
<link linkend="io_objects.date_generators">Date Generators</link> |
<link linkend="io_objects.special_values">Special Values</link> |
<link linkend="io_objects.format_date_parser">Format Date Parser</link>
<anchor id="io_objects.periods" />
<bridgehead renderas="sect3">Periods</bridgehead>
<para>The period_formatter and period_parser provide a uniform interface for the input and output of date_periods, time_periods, and in a future release, local_date_time_periods. The user has control over the delimiters, formats of the date/time components, and the form the period takes. The format of the date/time components is controlled via the date_time input and output facets.</para>
<bridgehead renderas="sect4">Period Form</bridgehead>
<para>Periods are constructed with open ranged parameters. The first value is the starting point, and is included in the period. The end value is not included but immediately follows the last value: [begin/end). However, a period can be streamed as either an open range or a closed range.</para>
<screen>[2003-Jan-01/2003-Dec-31] <-- period holding 365 days
[2003-Jan-01/2004-Jan-01) <-- period holding 365 days</screen>
<bridgehead renderas="sect4">Delimiters</bridgehead>
<para>There are four delimiters. The default values are<simplelist type="vert" columns="1">
<member>"\" - separator</member>
<member>"[" - start delimiter</member>
<member>")" - open range end delimiter</member>
<member>"]" - closed range end delimiter</member>
</simplelist>A user can provide a custom set of delimiters. Custom delimiters may contain spaces.</para>
<bridgehead renderas="sect4">Customization</bridgehead>
<para>The period form and delimiters can be set as construction parameters or by means of accessor functions. A custom period parser/formatter can then be used as a construction parameter to a new facet, or can be set in an existing facet via an accessor function.</para>
<bridgehead renderas="sect4">Period Formatter/Parser Reference</bridgehead>
The complete class reference can be found here: <classname alt="boost::date_time::period_formatter">Period Formatter Doxygen Reference</classname> and here: <classname alt="boost::date_time::period_parser">Period Parser Doxygen Reference</classname>
<para>
<bridgehead renderas="sect4">Period Formatter Construction</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top">Syntax</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top"><screen>period_formatter(...)
Parameters:
range_display_options
char_type*
char_type*
char_type*
char_type*</screen></entry>
<entry>NOTE: All five construction parameters have default values so this constructor also doubles as the default constructor. The <code>range_display_options</code> is a public type enum of the <code>period_formatter</code> class. The possible choices are AS_OPEN_RANGE or AS_CLOSED_RANGE. The closed range is the default. A period has three significant points: the begining, the last, and the end. A closed range period takes the form [begin,end), where an open range period takes the form [begin,last]. The four char_type* parameters are: the period separator, the start delimiter, the open range end delimiter, and the closed range end delimiter.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<bridgehead renderas="sect4">Period Formatter Accessors</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top" morerows="1">Syntax</entry>
<entry>Description</entry>
</row>
<row>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top" morerows="1"><screen>range_display_options range_option()</screen></entry>
<entry>Returns the current setting for the range display (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void range_option(...)
Parameter:
range_display_options</screen></entry>
<entry>Sets the option for range display (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void delimiter_strings(...)
Parameters:
string_type
string_type
string_type
string_type</screen></entry>
<entry>Set new delimiter strings in the formatter.</entry>
</row>
<row>
<entry><screen>string beg("->| ");
string sep(" || ");
string opn(" ->|");
string clo(" |<-");
pf.delimiter_strings(beg, sep,
opn, clo);</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>put_period_start_delimeter(...)
Return Type:
OutItrT
Parameter:
OutItrT</screen></entry>
<entry>Puts the start delimiter into the stream at position pointed to by OutItrT parameter.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>put_period_sepatator(...)
Return Type:
OutItrT
Parameter:
OutItrT</screen></entry>
<entry>Puts the separator into the stream at position pointed to by OutItrT parameter.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>put_period_end_delimeter(...)
Return Type:
OutItrT
Parameter:
OutItrT</screen></entry>
<entry>Puts the end delimiter into the stream at position pointed to by OutItrT parameter.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>OutItrT put_period(...)
Parameters:
OutItrT
ios_base
char_type
period_type
facet_type</screen></entry>
<entry>Puts a period into the stream using the set values for delimiters, separator, and range display. The facet parameter is used to put the date (or time) objects of the period.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
<bridgehead renderas="sect4">Period Parser Construction</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top">Syntax</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top"><screen>period_parser(...)
Parameters:
period_range_option
char_type*
char_type*
char_type*
char_type*</screen></entry>
<entry>NOTE: All five construction parameters have default values so this constructor also doubles as the default constructor. The <code>period_range_option</code> is a public type enum of the <code>period_parser</code> class. The possible choices are AS_OPEN_RANGE or AS_CLOSED_RANGE. The closed range is the default. A period has three significant points: the begining, the last, and the end. A closed range period takes the form [begin,end), where an open range period takes the form [begin,last]. The four char_type* parameters are: the period separator, the start delimiter, the open range end delimiter, and the closed range end delimiter.</entry>
</row>
<row>
<entry valign="top"><screen>period_parser(period_parser)</screen></entry>
<entry>Copy constructor</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<bridgehead renderas="sect4">Period Parser Accessors</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top" morerows="1">Syntax</entry>
<entry>Description</entry>
</row>
<row>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top" morerows="1"><screen>period_range_option range_option()</screen></entry>
<entry>Returns the current setting for the period range (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void range_option(...)
Parameter:
period_range_option </screen></entry>
<entry>Sets the option for period range (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void delimiter_strings(...)
Parameters:
string_type
string_type
string_type
string_type</screen></entry>
<entry>Set new delimiter strings in the parser.</entry>
</row>
<row>
<entry><screen>string beg("->| ");
string sep(" || ");
string opn(" ->|");
string clo(" |<-");
pp.delimiter_strings(beg, sep,
opn, clo);</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>collection_type delimiter_strings()</screen></entry>
<entry>Returns the set of delimiter strings currently held in the parser.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>period_type get_period(...)
Parameters:
stream_itr_type
stream_itr_type
ios_base
period_type
duration_type
facet_type</screen></entry>
<entry>Parses a period from the stream. The iterator parameters point to the begining and end of the stream. The duration_type is relevant to the period type, for example: A <code>date_period</code> would use <code>days</code> as a duration_type. The period will be parsed according to the formats and strings found in the facet parameter.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>_____________________________________________________</para>
<anchor id="io_objects.date_generators" />
<bridgehead renderas="sect3">Date Generators</bridgehead>
<para>The date_generator formatter and parser provide flexibility by allowing the user to use custom "phrase elements". These phrase elements are the "in-between" words in the date_generators. For example, in the date_generator "Second Monday of March", "Second" and "of" are the phrase elements, where "Monday" and "March" are the date elements. Customization of the date elements is done with the facet. The order of the date and phrase elements cannot be changed. When parsing, all elements of the date_generator phrase must parse correctly or an ios_base::failure exception will be thrown.</para>
<bridgehead renderas="sect4">Customization</bridgehead>
<para>The default "phrase_strings" are:
<simplelist type="horiz" columns="9">
<member>"first"</member>
<member>"second"</member>
<member>"third"</member>
<member>"fourth"</member>
<member>"fifth"</member>
<member>"last"</member>
<member>"before"</member>
<member>"after"</member>
<member>"of"</member>
</simplelist>
A custom set of phrase_strings must maintain this order of occurance (Ex: "1st", "2nd", "3rd", "4th", "5th", "last", "prior", "past", "in").</para>
<para> Examples using default phrase_strings and default facet formats for weekday & month: <screen>"first Tue of Mar"</screen>And using custom phrase_strings: <screen>"1st Tue in Mar"</screen>
</para>
<para>The custom set of phrase elements can be set as construction parameters or through an accessor function.A custom date_generator parser/formatter can then be used as a construction parameter to a new facet, or can be set in an existing facet via an accessor function.</para>
<para>IMPORTANT NOTE: Prior to 1.33, partial_date was output as "1 Jan" with a single *or* double digit number for the day. The new behavior is to *always* place a double digit number for the day - "01 Jan".</para>
<bridgehead renderas="sect4">Date Generator Reference</bridgehead>
The complete class references can be found here: <classname alt="boost::date_time::date_generator_formatter">Date Generator Formatter Doxygen Reference</classname> and here: <classname alt="boost::date_time::date_generator_parser">Date Generator Parser Doxygen Reference</classname>
<para>
<bridgehead renderas="sect4">Date Generator Formatter Construction</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top">Syntax</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top"><screen>date_generator_formatter()</screen></entry>
<entry>Uses the default date generator elements.</entry>
</row>
<row>
<entry valign="top"><screen>date_generator_formatter(...)
Parameters:
string_type first_element
string_type second_element
string_type third_element
string_type fourth_element
string_type fifth_element
string_type last_element
string_type before_element
string_type after_element
string_type of_element</screen></entry>
<entry>Constructs a date_generator_formatter using the given element strings.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<bridgehead renderas="sect4">Date Generator Formatter Accessors</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top" morerows="1">Syntax</entry>
<entry>Description</entry>
</row>
<row>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top" morerows="1"><screen>void elements(...)
Parameters:
collection_type
phrase_elements</screen></entry>
<entry>Replace the current phrase elements with a collection of new ones. The <code>phrase_elements</code> parameter is an enum that indicates what the first element in the new collection is (defaults to first).</entry>
</row>
<row>
<entry><screen>// col is a collection holding
// "final", "prior", "following",
// and "in"
typedef date_generator_formatter dgf;
dgf formatter();
formatter.elements(col, dgf::last);
// complete elements in dgf are now:
"first", "second", "third",
"fourth", "fifth", "final",
"prior", "following", and "in"</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>put_partial_date(...)
Return Type:
facet_type::OutItrT
Parameters:
OutItrT next
ios_base
char_type fill
partial_date
facet_type</screen></entry>
<entry>A put function for partial_date. This is a templated function that takes a facet_type as a parameter.</entry>
</row>
<row>
<entry>Put a partial_date => "dd Month".</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>put_nth_kday(...)
Return Type:
facet_type::OutItrT
Parameters:
OutItrT next
ios_base
char_type fill
nth_kday_type
facet_type</screen></entry>
<entry>A put function for nth_kday_type. This is a templated function that takes a facet_type as a parameter.</entry>
</row>
<row>
<entry>Put an nth_day_of_the_week_in_month => "nth weekday of month".</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>put_first_kday(...)
Return Type:
facet_type::OutItrT
Parameters:
OutItrT next
ios_base
char_type fill
first_kday_type
facet_type</screen></entry>
<entry>A put function for first_kday_type. This is a templated function that takes a facet_type as a parameter.</entry>
</row>
<row>
<entry>Put a first_day_of_the_week_in_month => "first weekday of month".</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>put_last_kday(...)
Return Type:
facet_type::OutItrT
Parameters:
OutItrT next
ios_base
char_type fill
last_kday_type
facet_type</screen></entry>
<entry>A put function for last_kday_type. This is a templated function that takes a facet_type as a parameter.</entry>
</row>
<row>
<entry>Put a last_day_of_the_week_in_month => "last weekday of month".</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>put_kday_before(...)
Return Type:
facet_type::OutItrT
Parameters:
OutItrT next
ios_base
char_type fill
kday_before_type
facet_type</screen></entry>
<entry>A put function for kday_before_type. This is a templated function that takes a facet_type as a parameter.</entry>
</row>
<row>
<entry>Put a first_day_of_the_week_before => "weekday before"</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>put_kday_after(...)
Return Type:
facet_type::OutItrT
Parameters:
OutItrT next
ios_base
char_type fill
kday_after_type
facet_type</screen></entry>
<entry>A put function for kday_after_type. This is a templated function that takes a facet_type as a parameter.</entry>
</row>
<row>
<entry>Put a first_day_of_the_week_after => "weekday after".</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
<bridgehead renderas="sect4">Date Generator Parser Construction</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top">Syntax</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top"><screen>date_generator_parser()</screen></entry>
<entry>Uses the default date generator elements.</entry>
</row>
<row>
<entry valign="top"><screen>date_generator_parser(...)
Parameter:
date_generator_parser</screen></entry>
<entry>Copy Constructor</entry>
</row>
<row>
<entry valign="top"><screen>date_generator_parser(...)
Parameters:
string_type first_element
string_type second_element
string_type third_element
string_type fourth_element
string_type fifth_element
string_type last_element
string_type before_element
string_type after_element
string_type of_element</screen></entry>
<entry>Constructs a date_generator_parser using the given element strings.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<bridgehead renderas="sect4">Date Generator Parser Accessors</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top" morerows="1">Syntax</entry>
<entry>Description</entry>
</row>
<row>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top" morerows="1"><screen>void element_strings(...)
Parameter:
collection_type</screen></entry>
<entry>Replace the set of date generator element string with a new set.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void element_strings(...)
Parameters:
string_type first
string_type second
string_type third
string_type fourth
string_type fifth
string_type last
string_type before
string_type after
string_type of</screen></entry>
<entry>Replace the set of date generator elements with new values.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>get_partial_date_type(...)
Return Type:
facet_type::partial_date_type
Parameters:
stream_itr_type next
stream_itr_type str_end
ios_base
facet_type</screen></entry>
<entry>A templated function that parses a date_generator from the stream.</entry>
</row>
<row>
<entry>Parses a partial_date => "dd Month".</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>get_nth_kday_type(...)
Return Type:
facet_type::nth_kday_type
Parameters:
stream_itr_type next
stream_itr_type str_end
ios_base
facet_type</screen></entry>
<entry>A templated function that parses a date_generator from the stream.</entry>
</row>
<row>
<entry>Parses an nth_day_of_the_week_in_month => "nth weekday of month".</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>get_first_kday_type(...)
Return Type:
facet_type::firat_kday_type
Parameters:
stream_itr_type next
stream_itr_type str_end
ios_base
facet_type</screen></entry>
<entry>A templated function that parses a date_generator from the stream.</entry>
</row>
<row>
<entry>Parses a first_day_of_the_week_in_month => "first weekday of month".</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>get_last_kday_type(...)
Return Type:
facet_type::last_kday_type
Parameters:
stream_itr_type next
stream_itr_type str_end
ios_base
facet_type</screen></entry>
<entry>A templated function that parses a date_generator from the stream.</entry>
</row>
<row>
<entry>Parses a last_day_of_the_week_in_month => "last weekday of month".</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>get_kday_before_type(...)
Return Type:
facet_type::kday_before_type
Parameters:
stream_itr_type next
stream_itr_type str_end
ios_base
facet_type</screen></entry>
<entry>A templated function that parses a date_generator from the stream.</entry>
</row>
<row>
<entry>Parses a first_day_of_the_week_before => "weekday before"</entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>get_kday_after_type(...)
Return Type:
facet_type::kday_after_type
Parameters:
stream_itr_type next
stream_itr_type str_end
ios_base
facet_type</screen></entry>
<entry>A templated function that parses a date_generator from the stream.</entry>
</row>
<row>
<entry>Parses a first_day_of_the_week_after => "weekday after".</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>_____________________________________________________</para>
<anchor id="io_objects.special_values" />
<bridgehead renderas="sect3">Special Values</bridgehead>
<para>The date_time library uses five special_values. They are:
<simplelist type="horiz" columns="5">
<member>not_a_date_time</member>
<member>neg_infin</member>
<member>pos_infin</member>
<member>min_date_time</member>
<member>max_date_time</member>
</simplelist>
</para>
<para>The default set of strings used to represent these types are: "not-a-date-time", "-infinity", "+infinity", "minimum-date-time", "maximum-date-time". When output, the min_date-time and max_date_time appear as normal date/time representations: "1400-Jan-01" and "9999-Dec-31" repectively.</para>
<bridgehead renderas="sect4">Customization</bridgehead>
<para>The special values parser/formatter allows the user to set custom strings for these special values. These strings can be set as construction parameters to a new facet, or can be set in an existing facet via an accessor function.</para>
<bridgehead renderas="sect4">Special Values Formatter/Parser Reference</bridgehead>
The complete class references can be found here: <classname alt="boost::date_time::special_values_formatter">Special Values Formatter Doxygen Reference</classname> and here: <classname alt="boost::date_time::special_values_parser">Special Values Parser Doxygen Reference</classname>
<para>
<bridgehead renderas="sect4">Special Values Formatter Constructor</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top">Syntax</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top"><screen>special_values_formatter()</screen></entry>
<entry>Constructor uses defaults for special value strings.</entry>
</row>
<row>
<entry valign="top"><screen>special_values_formatter(...)
Parameters:
collection_type::iterator
collection_type::iterator</screen></entry>
<entry>Constructs using values in collection. NOTE: Only the first three strings of the collection will be used. Strings for minimum_date_time and maximum_date_time are ignored as those special values are output as normal dates/times.</entry>
</row>
<row>
<entry valign="top"><screen>special_values_formatter(...)
Parameters:
char_type*
char_type*</screen></entry>
<entry>Constructs special values formatter from an array of strings.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
<bridgehead renderas="sect4">Special Values Formatter Accessors</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top" morerows="1">Syntax</entry>
<entry>Description</entry>
</row>
<row>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top" morerows="1"><screen>OutItrT put_special(...)
Parameters:
OutItrT next
special_values value</screen></entry>
<entry>Puts the given special value into the stream.</entry>
</row>
<row>
<entry><screen>date d1(not_a_date_time);
date d2(minimum_date_time);
special_values_formatter formatter;
formatter.put_special(itr, d1);
// Puts: "not-a-date-time"
formatter.put_special(itr, d2);
// Puts: "1400-Jan-01"</screen></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
<bridgehead renderas="sect4">Special Values Parser Constructor</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top">Syntax</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top"><screen>special_values_parser()</screen></entry>
<entry></entry>
</row>
<row>
<entry valign="top"><screen>special_values_parser(...)
Parameters:
collection_type::iterator
collection_type::iterator</screen></entry>
<entry>Constructs a special values parser using the strings in the collection.</entry>
</row>
<row>
<entry valign="top"><screen>special_values_parser(...)
Parameter:
scpecial_values_parser</screen></entry>
<entry>Copy constructor.</entry>
</row>
<row>
<entry valign="top"><screen>special_values_parser(...)
Parameters:
string_type nadt_str
string_type neg_inf_str
string_type pos_inf_str
string_type min_dt_str
string_type max_dt_str</screen></entry>
<entry>Constructs a special values parser using the supplied strings.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
<bridgehead renderas="sect4">Special Values Parser Accessors</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top" morerows="1">Syntax</entry>
<entry>Description</entry>
</row>
<row>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top" morerows="1"><screen>void sv_strings(...)
Parameters:
string_type nadt_str
string_type neg_inf_str
string_type pos_inf_str
string_type min_dt_str
string_type max_dt_str</screen></entry>
<entry>Replace the set of special value strings with the given ones.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>bool match(...)
Parameters:
stream_itr_type beg
stream_itr_type end
match_results</screen></entry>
<entry>Returns true if parse was successful. Upon a successful parse, <code>mr.current_match</code> will be set an int values corresponding to the equivalent special_value.</entry>
</row>
<row>
<entry><screen>// stream holds "maximum_date_time"
typedef special_values_parser svp;
svp parser;
svp::match_results mr;
if(parser.match(itr, str_end, mr)) {
d = date(static_cast<special_values>(
mr.match_results))
} else {
// error, failed parse
}
// d == "9999-Dec-31"</screen></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>_____________________________________________________</para>
<anchor id="io_objects.format_date_parser" />
<bridgehead renderas="sect3">Format Date Parser</bridgehead>
<para>The format date parser is the object that holds the strings for months and weekday names, as well as their abbreviations. Custom sets of strings can be set at construction time, or, the strings in an existing format_date_parser can be replaced through accessor functions. Both the constructor and the accessor functions take a vector of strings as their arguments.</para>
<bridgehead renderas="sect4">Format Date Parser Reference</bridgehead>
The complete class reference can be found here: <classname alt="boost::date_time::format_date_parser">Doxygen Reference</classname>
<para>
<bridgehead renderas="sect4">Format Date Parser Constructor</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top">Syntax</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top"><screen>format_date_parser(...)
Parameters:
string_type format
std::locale</screen></entry>
<entry>Creates a parser that uses the given format for parsing dates (in those functions where there is no format parameter). The names and abbreviations used are extracted from the given locale.</entry>
</row>
<row>
<entry valign="top"><screen>format_date_parser(...)
Parameters:
string_type format
input_collection_type
input_collection_type
input_collection_type
input_collection_type</screen></entry>
<entry>Creates a parser from using the given components. The input_collection_type parameters are for: short month names, long month names, short weekday names, and long weekday names (in that order). These collections must contain values for every month and every weekday (begining with January and Sunday).</entry>
</row>
<row>
<entry valign="top"><screen>format_date_parser(...)
Parameters:
format_date_parser</screen></entry>
<entry>Copy Constructor</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
<para>
<bridgehead renderas="sect4">Format Date Parser Accessors</bridgehead>
<informaltable frame="all">
<tgroup cols="2">
<thead>
<row>
<entry valign="top" morerows="1">Syntax</entry>
<entry>Description</entry>
</row>
<row>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry valign="top" morerows="1"><screen>string_type format()</screen></entry>
<entry>Returns the format that will be used when parsing dates in those functions where there is no format parameter.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void format(string_type)</screen></entry>
<entry>Sets the format that will be used when parsing dates in those functions where there is no format parameter.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void short_month_names(...)
Parameter:
input_collection_type names</screen></entry>
<entry>Replace the short month names used by the parser. The collection must contain values for each month, starting with January.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void long_month_names(...)
Parameter:
input_collection_type names</screen></entry>
<entry>Replace the long month names used by the parser. The collection must contain values for each month, starting with January.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void short_weekday_names(...)
Parameter:
input_collection_type names</screen></entry>
<entry>Replace the short weekday names used by the parser. The collection must contain values for each weekday, starting with Sunday.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>void long_weekday_names(...)
Parameter:
input_collection_type names</screen></entry>
<entry>Replace the long weekday names used by the parser. The collection must contain values for each weekday, starting with Sunday.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>date_type parse_date(...)
Parameters:
string_type input
string_type format
special_values_parser</screen></entry>
<entry>Parse a date from the given input using the given format.</entry>
</row>
<row>
<entry><screen>string inp("2005-Apr-15");
string format("%Y-%b-%d");
date d;
d = parser.parse_date(inp,
format,
svp);
// d == 2005-Apr-15</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>date_type parse_date(...)
Parameters:
istreambuf_iterator input
istreambuf_iterator str_end
special_values_parser</screen></entry>
<entry>Parse a date from stream using the parser's format.</entry>
</row>
<row>
<entry><screen></screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>date_type parse_date(...)
Parameters:
istreambuf_iterator input
istreambuf_iterator str_end
string_type format
special_values_parser</screen></entry>
<entry>Parse a date from stream using the given format.</entry>
</row>
<row>
<entry><screen>// stream holds "2005-04-15"
string format("%Y-%m-%d");
date d;
d = parser.parse_date(itr,
str_end,
format,
svp);
// d == 2005-Apr-15</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>month_type parse_month(...)
Parameters:
istreambuf_iterator input
istreambuf_iterator str_end
string_type format</screen></entry>
<entry>Parses a month from stream using given format. Throws bad_month if unable to parse.</entry>
</row>
<row>
<entry><screen>// stream holds "March"
string format("%B");
greg_month m;
m = parser.parse_month(itr,
str_end,
format);
// m == March</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>day_type parse_day_of_month(...)
Parameters:
istreambuf_iterator input
istreambuf_iterator str_end</screen></entry>
<entry>Parses a day_of_month from stream. The day must appear as a two digit number (01-31), or a bad_day_of_month will be thrown.</entry>
</row>
<row>
<entry><screen>// stream holds "01"
greg_day d;
d = parser.parse_day_of_month(itr,
str_end);
// d == 1st</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>day_type parse_var_day_of_month(...)
Parameters:
istreambuf_iterator input
istreambuf_iterator str_end</screen></entry>
<entry>Parses a day_of_month from stream. The day must appear as a one or two digit number (1-31), or a bad_day_of_month will be thrown.</entry>
</row>
<row>
<entry><screen>// stream holds "1"
greg_day d;
d = parser.parse_var_day_of_month(itr,
str_end);
// d == 1st</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>day_of_week_type parse_weekday(...)
Parameters:
istreambuf_iterator input
istreambuf_iterator str_end
string_type format</screen></entry>
<entry>Parse a weekday from stream according to the given format. Throws a bad_weekday if unable to parse.</entry>
</row>
<row>
<entry><screen>// stream holds "Tue"
string format("%a");
greg_weekday wd;
wd = parser.parse_weekday(itr,
str_end,
format);
// wd == Tuesday</screen></entry>
</row>
<row>
<entry valign="top" morerows="1"><screen>year_type parse_year(...)
Parameters:
istreambuf_iterator input
istreambuf_iterator str_end
string_type format</screen></entry>
<entry>Parse a year from stream according to given format. Throws bad year if unable to parse.</entry>
</row>
<row>
<entry><screen>// stream holds "98"
string format("%y");
greg_year y;
y = parser.parse_year(itr,
str_end,
format);
// y == 1998</screen></entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</section>
|