From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/boost/libs/date_time/Jamfile | 11 + src/boost/libs/date_time/LICENSE | 23 + src/boost/libs/date_time/README.md | 38 + src/boost/libs/date_time/build/Jamfile.v2 | 24 + .../libs/date_time/data/README.zone_spec_csv_file | 92 + .../libs/date_time/data/date_time_zonespec.csv | 520 +++ src/boost/libs/date_time/example/Jamfile | 47 + .../libs/date_time/example/gregorian/Jamfile.v2 | 20 + .../example/gregorian/date_serialization_demo.cpp | 127 + .../example/gregorian/dates_as_strings.cpp | 63 + .../date_time/example/gregorian/days_alive.cpp | 47 + .../example/gregorian/days_between_new_years.cpp | 38 + .../example/gregorian/days_since_year_start.cpp | 25 + .../example/gregorian/days_till_new_year.cpp | 26 + .../example/gregorian/end_of_month_day.cpp | 46 + .../example/gregorian/find_last_day_of_months.cpp | 54 + .../date_time/example/gregorian/localization.cpp | 100 + .../libs/date_time/example/gregorian/month_add.cpp | 58 + .../date_time/example/gregorian/period_calc.cpp | 86 + .../date_time/example/gregorian/print_holidays.cpp | 83 + .../date_time/example/gregorian/print_month.cpp | 64 + .../date_time/example/local_time/calc_rules.cpp | 47 + .../libs/date_time/example/local_time/flight.cpp | 60 + .../example/local_time/local_date_time.cpp | 45 + .../example/local_time/seconds_since_epoch.cpp | 65 + .../example/local_time/simple_time_zone.cpp | 86 + .../libs/date_time/example/posix_time/Jamfile.v2 | 13 + .../example/posix_time/local_utc_conversion.cpp | 90 + .../date_time/example/posix_time/print_hours.cpp | 53 + .../date_time/example/posix_time/time_math.cpp | 36 + .../date_time/example/posix_time/time_periods.cpp | 58 + .../date_time/example/tutorial/io_tutorial.cpp | 194 + src/boost/libs/date_time/index.html | 13 + src/boost/libs/date_time/meta/libraries.json | 16 + src/boost/libs/date_time/src/date_time.doc | 72 + .../date_time/src/gregorian/date_generators.cpp | 38 + .../libs/date_time/src/gregorian/greg_month.cpp | 31 + .../libs/date_time/src/gregorian/greg_names.hpp | 43 + .../libs/date_time/src/gregorian/greg_weekday.cpp | 50 + .../date_time/src/gregorian/gregorian_types.cpp | 62 + .../date_time/src/posix_time/posix_time_types.cpp | 35 + src/boost/libs/date_time/test/Jamfile.v2 | 168 + .../date_time/test/gregorian/testcurrent_day.cpp | 37 + .../libs/date_time/test/gregorian/testdate.cpp | 319 ++ .../date_time/test/gregorian/testdate_duration.cpp | 77 + .../test/gregorian/testdate_facet_new.cpp | 388 ++ .../test/gregorian/testdate_input_facet.cpp | 582 +++ .../date_time/test/gregorian/testdate_iterator.cpp | 367 ++ .../libs/date_time/test/gregorian/testfacet.cpp | 342 ++ .../test/gregorian/testformat_date_parser.cpp | 363 ++ .../date_time/test/gregorian/testformatters.cpp | 62 + .../date_time/test/gregorian/testgenerators.cpp | 175 + .../libs/date_time/test/gregorian/testgreg_cal.cpp | 135 + .../libs/date_time/test/gregorian/testgreg_day.cpp | 91 + .../test/gregorian/testgreg_durations.cpp | 241 ++ .../date_time/test/gregorian/testgreg_month.cpp | 67 + .../test/gregorian/testgreg_serialize.cpp | 190 + .../date_time/test/gregorian/testgreg_wstream.cpp | 178 + .../date_time/test/gregorian/testgreg_year.cpp | 45 + .../date_time/test/gregorian/testparse_date.cpp | 368 ++ .../libs/date_time/test/gregorian/testperiod.cpp | 153 + .../test/local_time/README.poorly_formed_zonespec | 4 + .../test/local_time/poorly_formed_zonespec.csv | 2 + .../libs/date_time/test/local_time/testclocks.cpp | 40 + .../test/local_time/testcustom_time_zone.cpp | 88 + .../local_time/testdst_transition_day_rule.cpp | 65 + .../date_time/test/local_time/testlocal_time.cpp | 370 ++ .../test/local_time/testlocal_time_facet.cpp | 188 + .../test/local_time/testlocal_time_input_facet.cpp | 239 ++ .../test/local_time/testlocal_time_iterator.cpp | 95 + .../test/local_time/testlocal_time_period.cpp | 82 + .../test/local_time/testposix_time_zone.cpp | 221 + .../date_time/test/local_time/testtz_database.cpp | 116 + .../test/local_time/testwcustom_time_zone.cpp | 89 + .../test/local_time/testwposix_time_zone.cpp | 224 + .../compile_fail/hours_special_value.cpp | 19 + .../compile_fail/millisec_special_value.cpp | 19 + .../compile_fail/minutes_special_value.cpp | 19 + .../compile_fail/seconds_special_value.cpp | 19 + .../test/posix_time/testc_local_adjustor.cpp | 131 + .../libs/date_time/test/posix_time/testclock.cpp | 42 + .../date_time/test/posix_time/testdst_rules.cpp | 451 ++ .../date_time/test/posix_time/testduration.cpp | 282 ++ .../test/posix_time/testfiletime_functions.cpp | 90 + .../date_time/test/posix_time/testformatters.cpp | 18 + .../posix_time/testgreg_duration_operators.cpp | 85 + .../date_time/test/posix_time/testiterator.cpp | 135 + .../test/posix_time/testlocal_adjustor.cpp | 175 + .../test/posix_time/testmicrosec_time_clock.cpp | 139 + .../date_time/test/posix_time/testparse_time.cpp | 280 ++ .../libs/date_time/test/posix_time/testperiod.cpp | 22 + .../libs/date_time/test/posix_time/teststreams.cpp | 179 + .../libs/date_time/test/posix_time/testtime.cpp | 336 ++ .../date_time/test/posix_time/testtime_facet.cpp | 458 +++ .../test/posix_time/testtime_formatters.cpp | 116 + .../test/posix_time/testtime_input_facet.cpp | 453 ++ .../date_time/test/posix_time/testtime_period.cpp | 77 + .../test/posix_time/testtime_serialize.cpp | 125 + .../posix_time/testtime_serialize_versioning.cpp | 64 + .../date_time/test/posix_time/testtime_wstream.cpp | 89 + .../libs/date_time/test/self_contained_header.cpp | 22 + .../libs/date_time/test/testconstrained_value.cpp | 74 + src/boost/libs/date_time/test/testfrmwk.hpp | 113 + src/boost/libs/date_time/test/testfrom_facet.cpp | 50 + .../libs/date_time/test/testgeneric_period.cpp | 273 ++ .../libs/date_time/test/testgregorian_calendar.cpp | 253 ++ src/boost/libs/date_time/test/testint64_range.cpp | 95 + src/boost/libs/date_time/test/testint_adapter.cpp | 158 + src/boost/libs/date_time/test/testmisc.cpp | 59 + .../date_time/test/testtime_resolution_traits.cpp | 72 + src/boost/libs/date_time/test/testwrapping_int.cpp | 138 + src/boost/libs/date_time/xmldoc/Jamfile.v2 | 90 + src/boost/libs/date_time/xmldoc/README | 38 + .../libs/date_time/xmldoc/acknowledgements.xml | 16 + src/boost/libs/date_time/xmldoc/buildinfo.xml | 153 + src/boost/libs/date_time/xmldoc/calculations.xml | 96 + src/boost/libs/date_time/xmldoc/changes.xml | 863 ++++ src/boost/libs/date_time/xmldoc/conceptual.xml | 19 + .../libs/date_time/xmldoc/custom_time_zone.xml | 376 ++ .../libs/date_time/xmldoc/date_algorithms.xml | 208 + src/boost/libs/date_time/xmldoc/date_class.xml | 524 +++ src/boost/libs/date_time/xmldoc/date_duration.xml | 250 ++ src/boost/libs/date_time/xmldoc/date_facet.xml | 319 ++ .../libs/date_time/xmldoc/date_input_facet.xml | 340 ++ src/boost/libs/date_time/xmldoc/date_iterators.xml | 113 + src/boost/libs/date_time/xmldoc/date_period.xml | 434 ++ src/boost/libs/date_time/xmldoc/date_time.xml | 70 + .../libs/date_time/xmldoc/date_time_autodoc.xml | 4344 ++++++++++++++++++++ .../date_time/xmldoc/date_time_docs_howto.html | 82 + .../date_time/xmldoc/date_time_fo_stylesheet.xsl | 180 + src/boost/libs/date_time/xmldoc/date_time_io.xml | 133 + .../libs/date_time/xmldoc/design_concepts.xml | 22 + src/boost/libs/date_time/xmldoc/design_goals.xml | 126 + src/boost/libs/date_time/xmldoc/details.xml | 22 + .../libs/date_time/xmldoc/domain_concepts.xml | 61 + src/boost/libs/date_time/xmldoc/doxy.xml | 22 + src/boost/libs/date_time/xmldoc/ex_calc_rules.xml | 59 + .../libs/date_time/xmldoc/ex_date_period_calc.xml | 96 + .../libs/date_time/xmldoc/ex_dates_as_strings.xml | 77 + src/boost/libs/date_time/xmldoc/ex_days_alive.xml | 59 + .../date_time/xmldoc/ex_days_between_new_years.xml | 49 + .../libs/date_time/xmldoc/ex_end_of_month_day.xml | 59 + .../xmldoc/ex_find_last_day_of_months.xml | 66 + src/boost/libs/date_time/xmldoc/ex_flight.xml | 60 + .../date_time/xmldoc/ex_local_utc_conversion.xml | 103 + .../libs/date_time/xmldoc/ex_localization.xml | 115 + .../libs/date_time/xmldoc/ex_meeting_planner.xml | 187 + src/boost/libs/date_time/xmldoc/ex_month_add.xml | 44 + .../libs/date_time/xmldoc/ex_print_holidays.xml | 97 + src/boost/libs/date_time/xmldoc/ex_print_hours.xml | 66 + src/boost/libs/date_time/xmldoc/ex_print_month.xml | 74 + .../date_time/xmldoc/ex_seconds_since_epoch.xml | 77 + .../libs/date_time/xmldoc/ex_simple_time_zone.xml | 100 + src/boost/libs/date_time/xmldoc/ex_time_math.xml | 48 + .../libs/date_time/xmldoc/ex_time_periods.xml | 74 + src/boost/libs/date_time/xmldoc/examples.xml | 34 + .../libs/date_time/xmldoc/exclusive_date_time.xml | 15 + src/boost/libs/date_time/xmldoc/format_flags.xml | 524 +++ src/boost/libs/date_time/xmldoc/gregorian.xml | 76 + .../libs/date_time/xmldoc/gregorian_autodoc.xml | 1676 ++++++++ .../libs/date_time/xmldoc/gregorian_calendar.xml | 96 + src/boost/libs/date_time/xmldoc/io_objects.xml | 1101 +++++ src/boost/libs/date_time/xmldoc/io_tutorial.xml | 306 ++ src/boost/libs/date_time/xmldoc/license.xml | 40 + .../libs/date_time/xmldoc/local_date_time.xml | 463 +++ src/boost/libs/date_time/xmldoc/local_time.xml | 77 + .../libs/date_time/xmldoc/local_time_autodoc.xml | 371 ++ .../libs/date_time/xmldoc/local_time_period.xml | 383 ++ src/boost/libs/date_time/xmldoc/motivation.xml | 20 + src/boost/libs/date_time/xmldoc/posix_time.xml | 65 + .../libs/date_time/xmldoc/posix_time_autodoc.xml | 864 ++++ .../libs/date_time/xmldoc/posix_time_zone.xml | 224 + src/boost/libs/date_time/xmldoc/ptime_class.xml | 574 +++ src/boost/libs/date_time/xmldoc/ref_tag_fix.pl | 114 + src/boost/libs/date_time/xmldoc/references.xml | 124 + src/boost/libs/date_time/xmldoc/serialization.xml | 116 + .../libs/date_time/xmldoc/snap_to_details.xml | 54 + src/boost/libs/date_time/xmldoc/table_template.xml | 32 + src/boost/libs/date_time/xmldoc/terminology.xml | 60 + src/boost/libs/date_time/xmldoc/tests.xml | 23 + src/boost/libs/date_time/xmldoc/time_duration.xml | 621 +++ src/boost/libs/date_time/xmldoc/time_facet.xml | 147 + .../libs/date_time/xmldoc/time_input_facet.xml | 163 + src/boost/libs/date_time/xmldoc/time_iterators.xml | 152 + src/boost/libs/date_time/xmldoc/time_period.xml | 396 ++ src/boost/libs/date_time/xmldoc/time_zone_base.xml | 113 + src/boost/libs/date_time/xmldoc/tradeoffs.xml | 127 + src/boost/libs/date_time/xmldoc/tz_database.xml | 233 ++ src/boost/libs/date_time/xmldoc/usage_examples.xml | 103 + 189 files changed, 33898 insertions(+) create mode 100644 src/boost/libs/date_time/Jamfile create mode 100644 src/boost/libs/date_time/LICENSE create mode 100644 src/boost/libs/date_time/README.md create mode 100644 src/boost/libs/date_time/build/Jamfile.v2 create mode 100644 src/boost/libs/date_time/data/README.zone_spec_csv_file create mode 100644 src/boost/libs/date_time/data/date_time_zonespec.csv create mode 100644 src/boost/libs/date_time/example/Jamfile create mode 100644 src/boost/libs/date_time/example/gregorian/Jamfile.v2 create mode 100644 src/boost/libs/date_time/example/gregorian/date_serialization_demo.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/dates_as_strings.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/days_alive.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/days_between_new_years.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/days_since_year_start.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/days_till_new_year.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/end_of_month_day.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/find_last_day_of_months.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/localization.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/month_add.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/period_calc.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/print_holidays.cpp create mode 100644 src/boost/libs/date_time/example/gregorian/print_month.cpp create mode 100644 src/boost/libs/date_time/example/local_time/calc_rules.cpp create mode 100644 src/boost/libs/date_time/example/local_time/flight.cpp create mode 100644 src/boost/libs/date_time/example/local_time/local_date_time.cpp create mode 100644 src/boost/libs/date_time/example/local_time/seconds_since_epoch.cpp create mode 100644 src/boost/libs/date_time/example/local_time/simple_time_zone.cpp create mode 100644 src/boost/libs/date_time/example/posix_time/Jamfile.v2 create mode 100644 src/boost/libs/date_time/example/posix_time/local_utc_conversion.cpp create mode 100644 src/boost/libs/date_time/example/posix_time/print_hours.cpp create mode 100644 src/boost/libs/date_time/example/posix_time/time_math.cpp create mode 100644 src/boost/libs/date_time/example/posix_time/time_periods.cpp create mode 100644 src/boost/libs/date_time/example/tutorial/io_tutorial.cpp create mode 100644 src/boost/libs/date_time/index.html create mode 100644 src/boost/libs/date_time/meta/libraries.json create mode 100644 src/boost/libs/date_time/src/date_time.doc create mode 100644 src/boost/libs/date_time/src/gregorian/date_generators.cpp create mode 100644 src/boost/libs/date_time/src/gregorian/greg_month.cpp create mode 100644 src/boost/libs/date_time/src/gregorian/greg_names.hpp create mode 100644 src/boost/libs/date_time/src/gregorian/greg_weekday.cpp create mode 100644 src/boost/libs/date_time/src/gregorian/gregorian_types.cpp create mode 100644 src/boost/libs/date_time/src/posix_time/posix_time_types.cpp create mode 100644 src/boost/libs/date_time/test/Jamfile.v2 create mode 100644 src/boost/libs/date_time/test/gregorian/testcurrent_day.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testdate.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testdate_duration.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testdate_facet_new.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testdate_input_facet.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testdate_iterator.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testfacet.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testformat_date_parser.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testformatters.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testgenerators.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testgreg_cal.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testgreg_day.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testgreg_durations.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testgreg_month.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testgreg_serialize.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testgreg_wstream.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testgreg_year.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testparse_date.cpp create mode 100644 src/boost/libs/date_time/test/gregorian/testperiod.cpp create mode 100644 src/boost/libs/date_time/test/local_time/README.poorly_formed_zonespec create mode 100644 src/boost/libs/date_time/test/local_time/poorly_formed_zonespec.csv create mode 100644 src/boost/libs/date_time/test/local_time/testclocks.cpp create mode 100644 src/boost/libs/date_time/test/local_time/testcustom_time_zone.cpp create mode 100644 src/boost/libs/date_time/test/local_time/testdst_transition_day_rule.cpp create mode 100644 src/boost/libs/date_time/test/local_time/testlocal_time.cpp create mode 100644 src/boost/libs/date_time/test/local_time/testlocal_time_facet.cpp create mode 100644 src/boost/libs/date_time/test/local_time/testlocal_time_input_facet.cpp create mode 100644 src/boost/libs/date_time/test/local_time/testlocal_time_iterator.cpp create mode 100644 src/boost/libs/date_time/test/local_time/testlocal_time_period.cpp create mode 100644 src/boost/libs/date_time/test/local_time/testposix_time_zone.cpp create mode 100644 src/boost/libs/date_time/test/local_time/testtz_database.cpp create mode 100644 src/boost/libs/date_time/test/local_time/testwcustom_time_zone.cpp create mode 100644 src/boost/libs/date_time/test/local_time/testwposix_time_zone.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/compile_fail/hours_special_value.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/compile_fail/millisec_special_value.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/compile_fail/minutes_special_value.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/compile_fail/seconds_special_value.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testc_local_adjustor.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testclock.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testdst_rules.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testduration.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testfiletime_functions.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testformatters.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testgreg_duration_operators.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testiterator.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testlocal_adjustor.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testparse_time.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testperiod.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/teststreams.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testtime.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testtime_facet.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testtime_formatters.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testtime_input_facet.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testtime_period.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testtime_serialize.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testtime_serialize_versioning.cpp create mode 100644 src/boost/libs/date_time/test/posix_time/testtime_wstream.cpp create mode 100644 src/boost/libs/date_time/test/self_contained_header.cpp create mode 100644 src/boost/libs/date_time/test/testconstrained_value.cpp create mode 100644 src/boost/libs/date_time/test/testfrmwk.hpp create mode 100644 src/boost/libs/date_time/test/testfrom_facet.cpp create mode 100644 src/boost/libs/date_time/test/testgeneric_period.cpp create mode 100644 src/boost/libs/date_time/test/testgregorian_calendar.cpp create mode 100644 src/boost/libs/date_time/test/testint64_range.cpp create mode 100644 src/boost/libs/date_time/test/testint_adapter.cpp create mode 100644 src/boost/libs/date_time/test/testmisc.cpp create mode 100644 src/boost/libs/date_time/test/testtime_resolution_traits.cpp create mode 100644 src/boost/libs/date_time/test/testwrapping_int.cpp create mode 100644 src/boost/libs/date_time/xmldoc/Jamfile.v2 create mode 100644 src/boost/libs/date_time/xmldoc/README create mode 100644 src/boost/libs/date_time/xmldoc/acknowledgements.xml create mode 100644 src/boost/libs/date_time/xmldoc/buildinfo.xml create mode 100644 src/boost/libs/date_time/xmldoc/calculations.xml create mode 100644 src/boost/libs/date_time/xmldoc/changes.xml create mode 100644 src/boost/libs/date_time/xmldoc/conceptual.xml create mode 100644 src/boost/libs/date_time/xmldoc/custom_time_zone.xml create mode 100644 src/boost/libs/date_time/xmldoc/date_algorithms.xml create mode 100644 src/boost/libs/date_time/xmldoc/date_class.xml create mode 100644 src/boost/libs/date_time/xmldoc/date_duration.xml create mode 100644 src/boost/libs/date_time/xmldoc/date_facet.xml create mode 100644 src/boost/libs/date_time/xmldoc/date_input_facet.xml create mode 100644 src/boost/libs/date_time/xmldoc/date_iterators.xml create mode 100644 src/boost/libs/date_time/xmldoc/date_period.xml create mode 100644 src/boost/libs/date_time/xmldoc/date_time.xml create mode 100644 src/boost/libs/date_time/xmldoc/date_time_autodoc.xml create mode 100644 src/boost/libs/date_time/xmldoc/date_time_docs_howto.html create mode 100644 src/boost/libs/date_time/xmldoc/date_time_fo_stylesheet.xsl create mode 100644 src/boost/libs/date_time/xmldoc/date_time_io.xml create mode 100644 src/boost/libs/date_time/xmldoc/design_concepts.xml create mode 100644 src/boost/libs/date_time/xmldoc/design_goals.xml create mode 100644 src/boost/libs/date_time/xmldoc/details.xml create mode 100644 src/boost/libs/date_time/xmldoc/domain_concepts.xml create mode 100644 src/boost/libs/date_time/xmldoc/doxy.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_calc_rules.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_date_period_calc.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_dates_as_strings.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_days_alive.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_days_between_new_years.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_end_of_month_day.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_find_last_day_of_months.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_flight.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_local_utc_conversion.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_localization.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_meeting_planner.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_month_add.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_print_holidays.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_print_hours.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_print_month.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_seconds_since_epoch.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_simple_time_zone.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_time_math.xml create mode 100644 src/boost/libs/date_time/xmldoc/ex_time_periods.xml create mode 100644 src/boost/libs/date_time/xmldoc/examples.xml create mode 100644 src/boost/libs/date_time/xmldoc/exclusive_date_time.xml create mode 100644 src/boost/libs/date_time/xmldoc/format_flags.xml create mode 100644 src/boost/libs/date_time/xmldoc/gregorian.xml create mode 100644 src/boost/libs/date_time/xmldoc/gregorian_autodoc.xml create mode 100644 src/boost/libs/date_time/xmldoc/gregorian_calendar.xml create mode 100644 src/boost/libs/date_time/xmldoc/io_objects.xml create mode 100644 src/boost/libs/date_time/xmldoc/io_tutorial.xml create mode 100644 src/boost/libs/date_time/xmldoc/license.xml create mode 100644 src/boost/libs/date_time/xmldoc/local_date_time.xml create mode 100644 src/boost/libs/date_time/xmldoc/local_time.xml create mode 100644 src/boost/libs/date_time/xmldoc/local_time_autodoc.xml create mode 100644 src/boost/libs/date_time/xmldoc/local_time_period.xml create mode 100644 src/boost/libs/date_time/xmldoc/motivation.xml create mode 100644 src/boost/libs/date_time/xmldoc/posix_time.xml create mode 100644 src/boost/libs/date_time/xmldoc/posix_time_autodoc.xml create mode 100644 src/boost/libs/date_time/xmldoc/posix_time_zone.xml create mode 100644 src/boost/libs/date_time/xmldoc/ptime_class.xml create mode 100644 src/boost/libs/date_time/xmldoc/ref_tag_fix.pl create mode 100644 src/boost/libs/date_time/xmldoc/references.xml create mode 100644 src/boost/libs/date_time/xmldoc/serialization.xml create mode 100644 src/boost/libs/date_time/xmldoc/snap_to_details.xml create mode 100644 src/boost/libs/date_time/xmldoc/table_template.xml create mode 100644 src/boost/libs/date_time/xmldoc/terminology.xml create mode 100644 src/boost/libs/date_time/xmldoc/tests.xml create mode 100644 src/boost/libs/date_time/xmldoc/time_duration.xml create mode 100644 src/boost/libs/date_time/xmldoc/time_facet.xml create mode 100644 src/boost/libs/date_time/xmldoc/time_input_facet.xml create mode 100644 src/boost/libs/date_time/xmldoc/time_iterators.xml create mode 100644 src/boost/libs/date_time/xmldoc/time_period.xml create mode 100644 src/boost/libs/date_time/xmldoc/time_zone_base.xml create mode 100644 src/boost/libs/date_time/xmldoc/tradeoffs.xml create mode 100644 src/boost/libs/date_time/xmldoc/tz_database.xml create mode 100644 src/boost/libs/date_time/xmldoc/usage_examples.xml (limited to 'src/boost/libs/date_time') diff --git a/src/boost/libs/date_time/Jamfile b/src/boost/libs/date_time/Jamfile new file mode 100644 index 000000000..c8fe54779 --- /dev/null +++ b/src/boost/libs/date_time/Jamfile @@ -0,0 +1,11 @@ +# Boost.DateTime Library Jamfile +# +# Copyright (c) 2018 James E. King III +# +# Use, modification, and distribution are subject to the +# Boost Software License, Version 1.0. (See accompanying file +# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +# please order by name to ease maintenance +build-project example ; +build-project test ; diff --git a/src/boost/libs/date_time/LICENSE b/src/boost/libs/date_time/LICENSE new file mode 100644 index 000000000..36b7cd93c --- /dev/null +++ b/src/boost/libs/date_time/LICENSE @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/boost/libs/date_time/README.md b/src/boost/libs/date_time/README.md new file mode 100644 index 000000000..c3479a2a3 --- /dev/null +++ b/src/boost/libs/date_time/README.md @@ -0,0 +1,38 @@ +DateTime, part of the collection of [Boost C++ Libraries](http://github.com/boostorg), makes programming with dates and times as simple and natural as programming with strings and integers. + +### License + +Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). + +### Properties + +* C++03 +* Requires Linking + +### Build Status + +Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests | +:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- | +[`master`](https://github.com/boostorg/date_time/tree/master) | [![Build Status](https://travis-ci.org/boostorg/date_time.svg?branch=master)](https://travis-ci.org/boostorg/date_time) | [![Build status](https://ci.appveyor.com/api/projects/status/upf5c528fy09fudk?svg=true)](https://ci.appveyor.com/project/jeking3/date-time-1evbf) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/14908/badge.svg)](https://scan.coverity.com/projects/boostorg-date_time) | [![codecov](https://codecov.io/gh/boostorg/date_time/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/date_time/branch/master) | [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/date_time.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/date_time.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/date_time.html) +[`develop`](https://github.com/boostorg/date_time/tree/develop) | [![Build Status](https://travis-ci.org/boostorg/date_time.svg?branch=develop)](https://travis-ci.org/boostorg/date_time) | [![Build status](https://ci.appveyor.com/api/projects/status/upf5c528fy09fudk/branch/develop?svg=true)](https://ci.appveyor.com/project/boostorg/date_time/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/14908/badge.svg)](https://scan.coverity.com/projects/boostorg-date_time) | [![codecov](https://codecov.io/gh/boostorg/date_time/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/date_time/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/date_time.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/date_time.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/date_time.html) + +### Directories + +| Name | Purpose | +| --------- | ------------------------------ | +| `build` | build script for link library | +| `data` | timezone database | +| `doc` | documentation | +| `example` | use case examples | +| `include` | headers | +| `src` | source code for link library | +| `test` | unit tests | +| `xmldoc` | additional documentation | + +### More information + +* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-date_time): Be sure to read the documentation first to see if it answers your question. +* [Report bugs](https://github.com/boostorg/date_time/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well. +* [Submit Pull Requests](https://github.com/boostorg/date_time/pulls) against the **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). Be sure to include tests proving your changes work properly. +* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[date_time]` tag at the beginning of the subject line. + diff --git a/src/boost/libs/date_time/build/Jamfile.v2 b/src/boost/libs/date_time/build/Jamfile.v2 new file mode 100644 index 000000000..a8cf24f7d --- /dev/null +++ b/src/boost/libs/date_time/build/Jamfile.v2 @@ -0,0 +1,24 @@ +# Copyright (c) 2002-2005 CrystalClear Software, Inc. +# Use, modification and distribution is 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) +# +# date_time is now header only -- this file provides a stub for backward compatibility +# + + +project boost/date_time + : requirements + DATE_TIME_INLINE + shared:BOOST_ALL_DYN_LINK=1 + : usage-requirements + DATE_TIME_INLINE + shared:BOOST_DATE_TIME_DYN_LINK=1 + : source-location ../src + ; + +# greg_month.cpp is now just a stub so that there is +# still a boost_date_time library to link for backward compatibility +lib boost_date_time : gregorian/greg_month.cpp ; + +boost-install boost_date_time ; diff --git a/src/boost/libs/date_time/data/README.zone_spec_csv_file b/src/boost/libs/date_time/data/README.zone_spec_csv_file new file mode 100644 index 000000000..069cac219 --- /dev/null +++ b/src/boost/libs/date_time/data/README.zone_spec_csv_file @@ -0,0 +1,92 @@ + +The csv file containing the zone_specs used by the +boost::local_time::tz_database is intended to be customized by the +library user. When customizing this file (or creating your own) the +file must follow a specific format. + +This first line is expected to contain column headings and is therefore +not processed by the tz_database. + +Each record (line) must have eleven fields. Some of those fields can +be empty. Every field (even empty ones) must be enclosed in double-quotes. +Ex: + "America/Phoenix" <- string enclosed in quotes + "" <- empty field + +Some fields represent a length of time. The format of these fields must be: + "{+|-}hh:mm[:ss]" <- length-of-time format +Where the plus or minus is mandatory and the seconds are optional. + +Since some time zones do not use daylight savings it is not always necessary +for every field in a zone_spec to contain a value. All zone_specs must have +at least ID and GMT offset. Zones that use daylight savings must have all +fields filled except: STD ABBR, STD NAME, DST NAME. You should take note +that DST ABBR is mandatory for zones that use daylight savings (see field +descriptions for further details). + + +********* Fields and their description/details ********* + +* ID + Contains the identifying string for the zone_spec. Any string will + do as long as it's unique. No two ID's can be the same. + +* STD ABBR +* STD NAME +* DST ABBR +* DST NAME + These four are all the names and abbreviations used by the time + zone being described. While any string will do in these fields, + care should be taken. These fields hold the strings that will be + used in the output of many of the local_time classes. + Ex: + time_zone nyc = tz_db.time_zone_from_region("America/New_York"); + local_time ny_time(date(2004, Aug, 30), IS_DST, nyc); + cout << ny_time.to_long_string() << endl; + // 2004-Aug-30 00:00:00 Eastern Daylight Time + cout << ny_time.to_short_string() << endl; + // 2004-Aug-30 00:00:00 EDT + + NOTE: The exact format/function names may vary - see local_time + documentation for further details. + +* GMT offset + This is the number of hours added to utc to get the local time + before any daylight savings adjustments are made. Some examples + are: America/New_York offset -5 hours, & Africa/Cairo offset +2 hours. + The format must follow the length-of-time format described above. + +* DST adjustment + The amount of time added to gmt_offset when daylight savings is in + effect. The format must follow the length-of-time format described + above. + +##################################################################### +##### TODO: more rule capabilities are needed - this portion of ##### +##### the tz_database is incomplete ##### +##################################################################### +* DST Start Date rule + This is a specially formatted string that describes the day of year + in which the transition take place. It holds three fields of it's own, + separated by semicolons. + * The first field indicates the "nth" weekday of the month. The + possible values are: 1 (first), 2 (second), 3 (third), + 4 (fourth), 5 (fifth), and -1 (last). + * The second field indicates the day-of-week from 0-6 (Sun=0). + * The third field indicates the month from 1-12 (Jan=1). + + Examples are: "-1;5;9"="Last Friday of September", + "2;1;3"="Second Monday of March" + +* Start time + Start time is the number of hours past midnight, on the day of the + start transition, the transition takes place. More simply put, the + time of day the transition is made (in 24 hours format). The format + must follow the length-of-time format described above with the + exception that it must always be positive. + +* DST End date rule + See DST Start date rule. The difference here is this is the day + daylight savings ends (transition to STD). +* End time + Same as Start time. diff --git a/src/boost/libs/date_time/data/date_time_zonespec.csv b/src/boost/libs/date_time/data/date_time_zonespec.csv new file mode 100644 index 000000000..c528d57d1 --- /dev/null +++ b/src/boost/libs/date_time/data/date_time_zonespec.csv @@ -0,0 +1,520 @@ +"ID","STD ABBR","STD NAME","DST ABBR","DST NAME","GMT offset","DST adjustment","DST Start Date rule","Start time","DST End date rule","End time" +"Africa/Abidjan","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Accra","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Addis_Ababa","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Africa/Algiers","CET","CET","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Asmara","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Africa/Asmera","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Africa/Bamako","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Bangui","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Banjul","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Bissau","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Blantyre","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Brazzaville","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Bujumbura","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Cairo","EET","EET","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Casablanca","WET","WET","WEST","WEST","+00:00:00","+01:00:00","2;0;7","+02:00:00","-1;0;10","+03:00:00" +"Africa/Ceuta","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Africa/Conakry","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Dakar","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Dar_es_Salaam","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Africa/Djibouti","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Africa/Douala","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/El_Aaiun","WET","WET","WEST","WEST","+00:00:00","+01:00:00","2;0;7","+02:00:00","-1;0;10","+03:00:00" +"Africa/Freetown","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Gaborone","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Harare","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Johannesburg","SAST","SAST","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Juba","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Africa/Kampala","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Africa/Khartoum","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Africa/Kigali","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Kinshasa","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Lagos","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Libreville","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Lome","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Luanda","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Lubumbashi","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Lusaka","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Malabo","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Maputo","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Maseru","SAST","SAST","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Mbabane","SAST","SAST","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Mogadishu","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Africa/Monrovia","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Nairobi","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Africa/Ndjamena","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Niamey","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Nouakchott","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Ouagadougou","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Porto-Novo","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Porto_Novo","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Sao_Tome","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Timbuktu","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Africa/Tripoli","EET","EET","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Africa/Tunis","CET","CET","","","+01:00:00","+00:00:00","","","","+00:00:00" +"Africa/Windhoek","WAT","WAT","WAST","WAST","+01:00:00","+01:00:00","1;0;9","+02:00:00","1;0;4","+02:00:00" +"America/Adak","HST","HST","HDT","HDT","-10:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Anchorage","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Anguilla","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Antigua","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Araguaina","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/Buenos_Aires","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/Catamarca","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/ComodRivadavia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/Cordoba","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/Jujuy","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/La_Rioja","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/Mendoza","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/Rio_Gallegos","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/Salta","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/San_Juan","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/San_Luis","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/Tucuman","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Argentina/Ushuaia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Aruba","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Asuncion","PYT","PYT","PYST","PYST","-04:00:00","+01:00:00","1;0;10","+00:00:00","-1;0;3","+00:00:00" +"America/Atikokan","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Atka","HST","HST","HDT","HDT","-10:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Bahia","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Bahia_Banderas","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00" +"America/Barbados","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Belem","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Belize","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00" +"America/Beulah","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Blanc-Sablon","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Blanc_Sablon","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Boa_Vista","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Bogota","COT","COT","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Boise","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Buenos_Aires","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Cambridge_Bay","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Campo_Grande","AMT","AMT","AMST","AMST","-04:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00" +"America/Cancun","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Caracas","VET","VET","","","-04:30:00","+00:00:00","","","","+00:00:00" +"America/Catamarca","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Cayenne","GFT","GFT","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Cayman","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Center","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Chicago","CST","Central Standard Time","CDT","Central Daylight Time","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Chihuahua","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00" +"America/ComodRivadavia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Coral_Harbour","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Cordoba","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Costa_Rica","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00" +"America/Creston","MST","MST","","","-07:00:00","+00:00:00","","","","+00:00:00" +"America/Cuiaba","AMT","AMT","AMST","AMST","-04:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00" +"America/Curacao","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Danmarkshavn","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"America/Dawson","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Dawson_Creek","MST","MST","","","-07:00:00","+00:00:00","","","","+00:00:00" +"America/Denver","MST","Mountain Standard Time","MDT","Mountain Daylight Time","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Detroit","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Dominica","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Edmonton","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Eirunepe","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/El_Salvador","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00" +"America/Ensenada","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Fortaleza","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Fort_Wayne","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Glace_Bay","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Godthab","WGT","WGT","WGST","WGST","-03:00:00","+01:00:00","-1;6;3","+22:00:00","-1;6;10","+23:00:00" +"America/Goose_Bay","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Grand_Turk","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Grenada","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Guadeloupe","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Guatemala","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00" +"America/Guayaquil","ECT","ECT","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Guyana","GYT","GYT","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Halifax","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Havana","CST","CST","CDT","CDT","-05:00:00","+01:00:00","2;0;3","+00:00:00","1;0;11","+01:00:00" +"America/Hermosillo","MST","MST","","","-07:00:00","+00:00:00","","","","+00:00:00" +"America/Indiana/Indianapolis","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Indiana/Knox","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Indiana/Marengo","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Indiana/Petersburg","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Indiana/Tell_City","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Indiana/Vevay","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Indiana/Vincennes","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Indiana/Winamac","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Indianapolis","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Inuvik","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Iqaluit","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Jamaica","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Jujuy","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Juneau","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Kentucky/Louisville","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Kentucky/Monticello","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Knox","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Knox_IN","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Kralendijk","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/La_Paz","BOT","BOT","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/La_Rioja","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Lima","PET","PET","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Los_Angeles","PST","Pacific Standard Time","PDT","Pacific Daylight Time","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Louisville","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Lower_Princes","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Maceio","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Managua","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00" +"America/Manaus","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Marengo","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Marigot","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Martinique","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Matamoros","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Mazatlan","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00" +"America/Mendoza","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Menominee","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Merida","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00" +"America/Metlakatla","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Mexico_City","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00" +"America/Miquelon","PMST","PMST","PMDT","PMDT","-03:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Moncton","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Monterrey","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00" +"America/Montevideo","UYT","UYT","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Monticello","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Montreal","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Montserrat","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Nassau","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/New_Salem","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/New_York","EST","Eastern Standard Time","EDT","Eastern Daylight Time","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Nipigon","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Nome","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Noronha","FNT","FNT","","","-02:00:00","+00:00:00","","","","+00:00:00" +"America/North_Dakota/Beulah","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/North_Dakota/Center","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/North_Dakota/New_Salem","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Ojinaga","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Panama","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Pangnirtung","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Paramaribo","SRT","SRT","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Petersburg","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Phoenix","MST","Mountain Standard Time","","","-07:00:00","+00:00:00","","","","+00:00:00" +"America/Port-au-Prince","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Porto_Acre","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Porto_Velho","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Port_au_Prince","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Port_of_Spain","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Puerto_Rico","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Rainy_River","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Rankin_Inlet","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Recife","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Regina","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00" +"America/Resolute","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Rio_Branco","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00" +"America/Rio_Gallegos","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Rosario","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Salta","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Santarem","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Santa_Isabel","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Santiago","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;8","+00:00:00","3;0;5","+00:00:00" +"America/Santo_Domingo","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/San_Juan","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/San_Luis","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Sao_Paulo","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00" +"America/Scoresbysund","EGT","EGT","EGST","EGST","-01:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+01:00:00" +"America/Shiprock","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Sitka","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/St_Barthelemy","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/St_Johns","NST","NST","NDT","NDT","-03:30:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/St_Kitts","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/St_Lucia","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/St_Thomas","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/St_Vincent","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Swift_Current","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00" +"America/Tegucigalpa","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00" +"America/Tell_City","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Thule","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Thunder_Bay","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Tijuana","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Toronto","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Tortola","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Tucuman","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Ushuaia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00" +"America/Vancouver","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Vevay","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Vincennes","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Virgin","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00" +"America/Whitehorse","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Winamac","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Winnipeg","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Yakutat","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"America/Yellowknife","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"Antarctica/Casey","AWST","AWST","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Antarctica/Davis","DAVT","DAVT","","","+07:00:00","+00:00:00","","","","+00:00:00" +"Antarctica/DumontDUrville","DDUT","DDUT","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Antarctica/Macquarie","MIST","MIST","","","+11:00:00","+00:00:00","","","","+00:00:00" +"Antarctica/Mawson","MAWT","MAWT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Antarctica/McMurdo","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00" +"Antarctica/Palmer","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;8","+00:00:00","3;0;5","+00:00:00" +"Antarctica/Rothera","ROTT","ROTT","","","-03:00:00","+00:00:00","","","","+00:00:00" +"Antarctica/South_Pole","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00" +"Antarctica/Syowa","SYOT","SYOT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Antarctica/Troll","UTC","UTC","CEST","CEST","+00:00:00","+02:00:00","-1;0;3","+01:00:00","-1;0;10","+03:00:00" +"Antarctica/Vostok","VOST","VOST","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Arctic/Longyearbyen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Asia/Aden","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Asia/Almaty","ALMT","ALMT","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Asia/Amman","EET","EET","EEST","EEST","+02:00:00","+01:00:00","1;5;4","+00:00:00","-1;5;10","+01:00:00" +"Asia/Anadyr","ANAT","ANAT","","","+12:00:00","+00:00:00","","","","+00:00:00" +"Asia/Aqtau","AQTT","AQTT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Asia/Aqtobe","AQTT","AQTT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Asia/Ashgabat","TMT","TMT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Asia/Ashkhabad","TMT","TMT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Asia/Baghdad","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Asia/Bahrain","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Asia/Baku","AZT","AZT","","","+04:00:00","+00:00:00","","","","+00:00:00" +"Asia/Bangkok","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00" +"Asia/Beirut","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+00:00:00" +"Asia/Bishkek","KGT","KGT","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Asia/Brunei","BNT","BNT","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Calcutta","IST","IST","","","+05:30:00","+00:00:00","","","","+00:00:00" +"Asia/Chita","YAKT","YAKT","","","+09:00:00","+00:00:00","","","","+00:00:00" +"Asia/Choibalsan","CHOT","CHOT","CHOST","CHOST","+08:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00" +"Asia/Chongqing","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Chungking","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Colombo","IST","IST","","","+05:30:00","+00:00:00","","","","+00:00:00" +"Asia/Dacca","BDT","BDT","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Asia/Damascus","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;5;3","+00:00:00","-1;5;10","+00:00:00" +"Asia/Dhaka","BDT","BDT","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Asia/Dili","TLT","TLT","","","+09:00:00","+00:00:00","","","","+00:00:00" +"Asia/Dubai","GST","GST","","","+04:00:00","+00:00:00","","","","+00:00:00" +"Asia/Dushanbe","TJT","TJT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Asia/Gaza","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;6;3","+01:00:00","3;5;10","+00:00:00" +"Asia/Harbin","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Hebron","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;6;3","+01:00:00","3;5;10","+00:00:00" +"Asia/Hong_Kong","HKT","HKT","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Hovd","HOVT","HOVT","HOVST","HOVST","+07:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00" +"Asia/Ho_Chi_Minh","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00" +"Asia/Irkutsk","IRKT","IRKT","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Istanbul","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Asia/Jakarta","WIB","WIB","","","+07:00:00","+00:00:00","","","","+00:00:00" +"Asia/Jayapura","WIT","WIT","","","+09:00:00","+00:00:00","","","","+00:00:00" +"Asia/Jerusalem","IST","IST","IDT","IDT","+02:00:00","+01:00:00","-1;5;3","+02:00:00","-1;0;10","+02:00:00" +"Asia/Kabul","AFT","AFT","","","+04:30:00","+00:00:00","","","","+00:00:00" +"Asia/Kamchatka","PETT","PETT","","","+12:00:00","+00:00:00","","","","+00:00:00" +"Asia/Karachi","PKT","PKT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Asia/Kashgar","XJT","XJT","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Asia/Kathmandu","NPT","NPT","","","+05:45:00","+00:00:00","","","","+00:00:00" +"Asia/Katmandu","NPT","NPT","","","+05:45:00","+00:00:00","","","","+00:00:00" +"Asia/Khandyga","YAKT","YAKT","","","+09:00:00","+00:00:00","","","","+00:00:00" +"Asia/Kolkata","IST","IST","","","+05:30:00","+00:00:00","","","","+00:00:00" +"Asia/Krasnoyarsk","KRAT","KRAT","","","+07:00:00","+00:00:00","","","","+00:00:00" +"Asia/Kuala_Lumpur","MYT","MYT","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Kuching","MYT","MYT","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Kuwait","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Asia/Macao","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Macau","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Magadan","MAGT","MAGT","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Asia/Makassar","WITA","WITA","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Manila","PHT","PHT","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Muscat","GST","GST","","","+04:00:00","+00:00:00","","","","+00:00:00" +"Asia/Nicosia","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Asia/Novokuznetsk","KRAT","KRAT","","","+07:00:00","+00:00:00","","","","+00:00:00" +"Asia/Novosibirsk","NOVT","NOVT","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Asia/Omsk","OMST","OMST","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Asia/Oral","ORAT","ORAT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Asia/Phnom_Penh","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00" +"Asia/Pontianak","WIB","WIB","","","+07:00:00","+00:00:00","","","","+00:00:00" +"Asia/Pyongyang","KST","KST","","","+08:30:00","+00:00:00","","","","+00:00:00" +"Asia/Qatar","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Asia/Qyzylorda","QYZT","QYZT","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Asia/Rangoon","MMT","MMT","","","+06:30:00","+00:00:00","","","","+00:00:00" +"Asia/Riyadh","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Asia/Saigon","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00" +"Asia/Sakhalin","SAKT","SAKT","","","+11:00:00","+00:00:00","","","","+00:00:00" +"Asia/Samarkand","UZT","UZT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Asia/Seoul","KST","KST","","","+09:00:00","+00:00:00","","","","+00:00:00" +"Asia/Shanghai","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Singapore","SGT","SGT","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Srednekolymsk","SRET","SRET","","","+11:00:00","+00:00:00","","","","+00:00:00" +"Asia/Taipei","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Tashkent","UZT","UZT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Asia/Tbilisi","GET","GET","","","+04:00:00","+00:00:00","","","","+00:00:00" +"Asia/Tehran","IRST","IRST","IRDT","IRDT","+03:30:00","+01:00:00","3;1;3","+00:00:00","3;3;9","+00:00:00" +"Asia/Tel_Aviv","IST","IST","IDT","IDT","+02:00:00","+01:00:00","-1;5;3","+02:00:00","-1;0;10","+02:00:00" +"Asia/Thimbu","BTT","BTT","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Asia/Thimphu","BTT","BTT","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Asia/Tokyo","JST","JST","","","+09:00:00","+00:00:00","","","","+00:00:00" +"Asia/Ujung_Pandang","WITA","WITA","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Asia/Ulaanbaatar","ULAT","ULAT","ULAST","ULAST","+08:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00" +"Asia/Ulan_Bator","ULAT","ULAT","ULAST","ULAST","+08:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00" +"Asia/Urumqi","XJT","XJT","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Asia/Ust-Nera","VLAT","VLAT","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Asia/Ust_Nera","VLAT","VLAT","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Asia/Vientiane","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00" +"Asia/Vladivostok","VLAT","VLAT","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Asia/Yakutsk","YAKT","YAKT","","","+09:00:00","+00:00:00","","","","+00:00:00" +"Asia/Yekaterinburg","YEKT","YEKT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Asia/Yerevan","AMT","AMT","","","+04:00:00","+00:00:00","","","","+00:00:00" +"Atlantic/Azores","AZOT","AZOT","AZOST","AZOST","-01:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+01:00:00" +"Atlantic/Bermuda","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"Atlantic/Canary","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00" +"Atlantic/Cape_Verde","CVT","CVT","","","-01:00:00","+00:00:00","","","","+00:00:00" +"Atlantic/Faeroe","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00" +"Atlantic/Faroe","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00" +"Atlantic/Jan_Mayen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Atlantic/Madeira","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00" +"Atlantic/Reykjavik","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Atlantic/South_Georgia","GST","GST","","","-02:00:00","+00:00:00","","","","+00:00:00" +"Atlantic/Stanley","FKST","FKST","","","-03:00:00","+00:00:00","","","","+00:00:00" +"Atlantic/St_Helena","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Australia/ACT","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/Adelaide","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/Brisbane","AEST","AEST","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Australia/Broken_Hill","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/Canberra","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/Currie","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/Darwin","ACST","ACST","","","+09:30:00","+00:00:00","","","","+00:00:00" +"Australia/Eucla","ACWST","ACWST","","","+08:45:00","+00:00:00","","","","+00:00:00" +"Australia/Hobart","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/LHI","LHST","LHST","LHDT","LHDT","+10:30:00","+00:30:00","1;0;10","+02:00:00","1;0;4","+02:00:00" +"Australia/Lindeman","AEST","AEST","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Australia/Lord_Howe","LHST","LHST","LHDT","LHDT","+10:30:00","+00:30:00","1;0;10","+02:00:00","1;0;4","+02:00:00" +"Australia/Melbourne","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/North","ACST","ACST","","","+09:30:00","+00:00:00","","","","+00:00:00" +"Australia/NSW","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/Perth","AWST","AWST","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Australia/Queensland","AEST","AEST","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Australia/South","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/Sydney","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/Tasmania","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/Victoria","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Australia/West","AWST","AWST","","","+08:00:00","+00:00:00","","","","+00:00:00" +"Australia/Yancowinna","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00" +"Brazil/Acre","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00" +"Brazil/DeNoronha","FNT","FNT","","","-02:00:00","+00:00:00","","","","+00:00:00" +"Brazil/East","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00" +"Brazil/West","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00" +"Canada/Atlantic","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"Canada/Central","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"Canada/East-Saskatchewan","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00" +"Canada/Eastern","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"Canada/East_Saskatchewan","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00" +"Canada/Mountain","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"Canada/Newfoundland","NST","NST","NDT","NDT","-03:30:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"Canada/Pacific","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"Canada/Saskatchewan","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00" +"Canada/Yukon","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"Chile/Continental","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;8","+00:00:00","3;0;5","+00:00:00" +"Chile/EasterIsland","EAST","EAST","EASST","EASST","-06:00:00","+01:00:00","2;6;8","+22:00:00","2;6;5","+22:00:00" +"Etc/GMT","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Etc/Greenwich","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Etc/UCT","UCT","UCT","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Etc/Universal","UTC","UTC","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Etc/UTC","UTC","UTC","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Etc/Zulu","UTC","UTC","","","+00:00:00","+00:00:00","","","","+00:00:00" +"Europe/Amsterdam","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Andorra","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Athens","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Belfast","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00" +"Europe/Belgrade","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Berlin","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Bratislava","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Brussels","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Bucharest","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Budapest","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Busingen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Chisinau","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Copenhagen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Dublin","GMT","GMT","IST","IST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00" +"Europe/Gibraltar","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Guernsey","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00" +"Europe/Helsinki","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Isle_of_Man","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00" +"Europe/Istanbul","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Jersey","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00" +"Europe/Kaliningrad","EET","EET","","","+02:00:00","+00:00:00","","","","+00:00:00" +"Europe/Kiev","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Lisbon","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00" +"Europe/Ljubljana","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/London","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00" +"Europe/Luxembourg","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Madrid","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Malta","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Mariehamn","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Minsk","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Europe/Monaco","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Moscow","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Europe/Nicosia","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Oslo","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Paris","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Podgorica","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Prague","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Riga","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Rome","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Samara","SAMT","SAMT","","","+04:00:00","+00:00:00","","","","+00:00:00" +"Europe/San_Marino","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Sarajevo","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Simferopol","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Europe/Skopje","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Sofia","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Stockholm","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Tallinn","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Tirane","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Tiraspol","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Uzhgorod","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Vaduz","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Vatican","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Vienna","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Vilnius","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Volgograd","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Europe/Warsaw","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Zagreb","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Europe/Zaporozhye","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00" +"Europe/Zurich","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00" +"Indian/Antananarivo","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Indian/Chagos","IOT","IOT","","","+06:00:00","+00:00:00","","","","+00:00:00" +"Indian/Christmas","CXT","CXT","","","+07:00:00","+00:00:00","","","","+00:00:00" +"Indian/Cocos","CCT","CCT","","","+06:30:00","+00:00:00","","","","+00:00:00" +"Indian/Comoro","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Indian/Kerguelen","TFT","TFT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Indian/Mahe","SCT","SCT","","","+04:00:00","+00:00:00","","","","+00:00:00" +"Indian/Maldives","MVT","MVT","","","+05:00:00","+00:00:00","","","","+00:00:00" +"Indian/Mauritius","MUT","MUT","","","+04:00:00","+00:00:00","","","","+00:00:00" +"Indian/Mayotte","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00" +"Indian/Reunion","RET","RET","","","+04:00:00","+00:00:00","","","","+00:00:00" +"Mexico/BajaNorte","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00" +"Mexico/BajaSur","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00" +"Mexico/General","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00" +"Pacific/Apia","WSST","WSST","WSDT","WSDT","+13:00:00","+01:00:00","-1;0;9","+03:00:00","1;0;4","+04:00:00" +"Pacific/Auckland","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00" +"Pacific/Chatham","CHAST","CHAST","CHADT","CHADT","+12:45:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00" +"Pacific/Chuuk","CHUT","CHUT","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Easter","EAST","EAST","EASST","EASST","-06:00:00","+01:00:00","2;6;8","+22:00:00","2;6;5","+22:00:00" +"Pacific/Efate","VUT","VUT","","","+11:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Enderbury","PHOT","PHOT","","","+13:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Fakaofo","TKT","TKT","","","+13:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Fiji","FJT","FJT","FJST","FJST","+12:00:00","+01:00:00","1;0;11","+02:00:00","3;0;1","+03:00:00" +"Pacific/Funafuti","TVT","TVT","","","+12:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Galapagos","GALT","GALT","","","-06:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Gambier","GAMT","GAMT","","","-09:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Guadalcanal","SBT","SBT","","","+11:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Guam","ChST","ChST","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Honolulu","HST","HST","","","-10:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Johnston","HST","HST","","","-10:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Kiritimati","LINT","LINT","","","+14:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Kosrae","KOST","KOST","","","+11:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Kwajalein","MHT","MHT","","","+12:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Majuro","MHT","MHT","","","+12:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Marquesas","MART","MART","","","-09:30:00","+00:00:00","","","","+00:00:00" +"Pacific/Midway","SST","SST","","","-11:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Nauru","NRT","NRT","","","+12:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Niue","NUT","NUT","","","-11:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Norfolk","NFT","NFT","","","+11:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Noumea","NCT","NCT","","","+11:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Pago_Pago","SST","SST","","","-11:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Palau","PWT","PWT","","","+09:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Pitcairn","PST","PST","","","-08:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Pohnpei","PONT","PONT","","","+11:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Ponape","PONT","PONT","","","+11:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Port_Moresby","PGT","PGT","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Rarotonga","CKT","CKT","","","-10:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Saipan","ChST","ChST","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Samoa","SST","SST","","","-11:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Tahiti","TAHT","TAHT","","","-10:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Tarawa","GILT","GILT","","","+12:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Tongatapu","TOT","TOT","","","+13:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Truk","CHUT","CHUT","","","+10:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Wake","WAKT","WAKT","","","+12:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Wallis","WFT","WFT","","","+12:00:00","+00:00:00","","","","+00:00:00" +"Pacific/Yap","CHUT","CHUT","","","+10:00:00","+00:00:00","","","","+00:00:00" diff --git a/src/boost/libs/date_time/example/Jamfile b/src/boost/libs/date_time/example/Jamfile new file mode 100644 index 000000000..89e0ad166 --- /dev/null +++ b/src/boost/libs/date_time/example/Jamfile @@ -0,0 +1,47 @@ +project libs/date_time/example ; + +exe dates_as_strings : gregorian/dates_as_strings.cpp ; +exe days_alive : gregorian/days_alive.cpp ; +exe days_till_new_year : gregorian/days_till_new_year.cpp ; + +exe days_between_new_years : gregorian/days_between_new_years.cpp ; +exe find_last_day_of_months : gregorian/find_last_day_of_months.cpp ; + +exe month_add : gregorian/month_add.cpp ; + +exe localization : gregorian/localization.cpp ; +exe print_holidays : gregorian/print_holidays.cpp ; +exe print_month : gregorian/print_month.cpp ; +exe period_calc : gregorian/period_calc.cpp ; + +exe days_since_year_start : gregorian/days_since_year_start.cpp ; + + +exe local_utc_conversion : posix_time/local_utc_conversion.cpp + : BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + ; + +exe print_hours : posix_time/print_hours.cpp + : BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + ; + +exe time_math : posix_time/time_math.cpp + : BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + ; + +exe time_periods : posix_time/time_periods.cpp + : BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + ; + +exe simple_time_zone : local_time/simple_time_zone.cpp ; +exe calc_rules : local_time/calc_rules.cpp ; +exe seconds_since_epoch : local_time/seconds_since_epoch.cpp ; +exe flight : local_time/flight.cpp ; +exe io_tutorial : tutorial/io_tutorial.cpp ; + +# Copyright (c) 2002-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) + diff --git a/src/boost/libs/date_time/example/gregorian/Jamfile.v2 b/src/boost/libs/date_time/example/gregorian/Jamfile.v2 new file mode 100644 index 000000000..39a6c219f --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/Jamfile.v2 @@ -0,0 +1,20 @@ +# Copyright (c) 2002-2006 CrystalClear Software, Inc. +# Use, modification and distribution is 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) +# + +project + : requirements ../../build/boost_date_time + ; + +exe dates_as_strings : dates_as_strings.cpp ; +exe end_of_month_day : end_of_month_day.cpp ; +exe period_calc : period_calc.cpp ; +exe days_alive : days_alive.cpp ; +exe print_holidays : print_holidays.cpp ; +exe days_since_year_start : days_since_year_start.cpp ; +exe print_month : print_month.cpp ; +exe days_till_new_year : days_till_new_year.cpp ; +exe date_localization : localization.cpp ; + \ No newline at end of file diff --git a/src/boost/libs/date_time/example/gregorian/date_serialization_demo.cpp b/src/boost/libs/date_time/example/gregorian/date_serialization_demo.cpp new file mode 100644 index 000000000..3c22129c4 --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/date_serialization_demo.cpp @@ -0,0 +1,127 @@ + + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "boost/date_time/gregorian/greg_serialize.hpp" +#include "boost/serialization/set.hpp" +#include "boost/serialization/list.hpp" +#include "boost/archive/text_oarchive.hpp" +#include "boost/archive/text_iarchive.hpp" +#include +#include + +using namespace boost::gregorian; +typedef std::set date_set; +typedef std::list date_list; + +void print(std::ostream& os, const date_set& ds) +{ + os << "******** Date Set *********" << std::endl; + date_set::const_iterator itr = ds.begin(); + while (itr != ds.end()) + { + os << (*itr) << " "; + itr++; + } + os << "\n***************************" << std::endl; +} + +class foo { + public: + foo(date d = date(not_a_date_time), + int i = 0) : + my_date(d), + my_int(i) + {} + void insert_date(date d) + { + my_dates.push_back(d); + } + void print(std::ostream& os) const + { + os << "foo= my_date is: " << my_date + << " my_int is: " << my_int; + date_list::const_iterator i = my_dates.begin(); + os << " Important dates: "; + while (i != my_dates.end()) { + os << (*i) << " "; + i++; + } + os << std::endl; + } + private: + friend class boost::serialization::access; + + // is a type of input archive the & operator is defined similar to >>. + template + void serialize(Archive & ar, const unsigned int version) + { + ar & my_date; + ar & my_int; + ar & my_dates; + } + + date my_date; + int my_int; + date_list my_dates; +}; + + +int +main() +{ + try { + date d(2004, Apr, 5); + std::cout << "Date: " << to_iso_string(d) << std::endl; + std::cout << "Date: " << d << std::endl; + std::ofstream ofs("date_demo.txt"); + boost::archive::text_oarchive oa(ofs); + oa << d; + + std::cout << "Construct a foo" << std::endl; + foo f(d, 1); + f.insert_date(d+days(1)); + f.insert_date(d+days(2)); + f.insert_date(d+days(3)); + f.print(std::cout); + oa << f; + + date_set dates; + dates.insert(date(2004, Apr,1)); + dates.insert(date(2004, Apr,10)); + dates.insert(date(2004, Apr,15)); + print(std::cout, dates); + + oa << dates; + ofs.close(); + + std::cout << "Now do the input streaming" << std::endl; + date d2(not_a_date_time); + std::ifstream ifs("date_demo.txt"); + boost::archive::text_iarchive ia(ifs); + ia >> d2; + + std::cout << "New date is: " << d2 << std::endl; + + foo f2; + ia >> f2; + f2.print(std::cout); + + date_set dates2; + ia >> dates2; //exception here + print(std::cout, dates2); + + } + catch(std::exception& e) { + std::cout << "Caught Exception: " << e.what() << std::endl; + } + +} + + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/gregorian/dates_as_strings.cpp b/src/boost/libs/date_time/example/gregorian/dates_as_strings.cpp new file mode 100644 index 000000000..097fffbc8 --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/dates_as_strings.cpp @@ -0,0 +1,63 @@ +/* The following is a simple example that shows conversion of dates + * to and from a std::string. + * + * Expected output: + * 2001-Oct-09 + * 2001-10-09 + * Tuesday October 9, 2001 + * An expected exception is next: + * Exception: Month number is out of range 1..12 + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include +#include + +int +main() +{ + + using namespace boost::gregorian; + + try { + // The following date is in ISO 8601 extended format (CCYY-MM-DD) + std::string s("2001-10-9"); //2001-October-09 + date d(from_simple_string(s)); + std::cout << to_simple_string(d) << std::endl; + + //Read ISO Standard(CCYYMMDD) and output ISO Extended + std::string ud("20011009"); //2001-Oct-09 + date d1(from_undelimited_string(ud)); + std::cout << to_iso_extended_string(d1) << std::endl; + + //Output the parts of the date - Tuesday October 9, 2001 + date::ymd_type ymd = d1.year_month_day(); + greg_weekday wd = d1.day_of_week(); + std::cout << wd.as_long_string() << " " + << ymd.month.as_long_string() << " " + << ymd.day << ", " << ymd.year + << std::endl; + + //Let's send in month 25 by accident and create an exception + std::string bad_date("20012509"); //2001-??-09 + std::cout << "An expected exception is next: " << std::endl; + date wont_construct(from_undelimited_string(bad_date)); + //use wont_construct so compiler doesn't complain, but you wont get here! + std::cout << "oh oh, you shouldn't reach this line: " + << to_iso_string(wont_construct) << std::endl; + } + catch(std::exception& e) { + std::cout << " Exception: " << e.what() << std::endl; + } + + + return 0; +} + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/gregorian/days_alive.cpp b/src/boost/libs/date_time/example/gregorian/days_alive.cpp new file mode 100644 index 000000000..83068ecfd --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/days_alive.cpp @@ -0,0 +1,47 @@ +/* Short example that calculates the number of days since user was born. + * Demonstrates comparisons of durations, use of the day_clock, + * and parsing a date from a string. + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include + +int +main() +{ + + using namespace boost::gregorian; + std::string s; + std::cout << "Enter birth day YYYY-MM-DD (eg: 2002-02-01): "; + std::cin >> s; + try { + date birthday(from_simple_string(s)); + date today = day_clock::local_day(); + days days_alive = today - birthday; + days one_day(1); + if (days_alive == one_day) { + std::cout << "Born yesterday, very funny" << std::endl; + } + else if (days_alive < days(0)) { + std::cout << "Not born yet, hmm: " << days_alive.days() + << " days" < + +int +main() +{ + + using namespace boost::gregorian; + + date today = day_clock::local_day(); + partial_date new_years_day(1,Jan); + //Subtract two dates to get a duration + days days_since_year_start = today - new_years_day.get_date(today.year()); + std::cout << "Days since Jan 1: " << days_since_year_start.days() + << std::endl; + + days days_until_year_start = new_years_day.get_date(today.year()+1) - today; + std::cout << "Days until next Jan 1: " << days_until_year_start.days() + << std::endl; + return 0; +} + + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/gregorian/days_since_year_start.cpp b/src/boost/libs/date_time/example/gregorian/days_since_year_start.cpp new file mode 100644 index 000000000..50e08d0fc --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/days_since_year_start.cpp @@ -0,0 +1,25 @@ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include + +int +main() +{ + + using namespace boost::gregorian; + + date today = day_clock::local_day(); + //Subtract two dates to get a duration + date_duration days_since_year_start = today - date(today.year(),Jan,1); + std::cout << "Days since Jan 1: " << days_since_year_start.days() + << std::endl; + return 0; +} + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/gregorian/days_till_new_year.cpp b/src/boost/libs/date_time/example/gregorian/days_till_new_year.cpp new file mode 100644 index 000000000..96dacbd5d --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/days_till_new_year.cpp @@ -0,0 +1,26 @@ +// This example displays the amount of time until new year's in days + +#include "boost/date_time/gregorian/gregorian.hpp" +#include + +int +main() +{ + + using namespace boost::gregorian; + + date::ymd_type today = day_clock::local_day_ymd(); + date new_years_day(today.year + 1,1,1); + date_duration dd = new_years_day - date(today); + + std::cout << "Days till new year: " << dd.days() << std::endl; + return 0; +} + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/gregorian/end_of_month_day.cpp b/src/boost/libs/date_time/example/gregorian/end_of_month_day.cpp new file mode 100644 index 000000000..ecb3919a6 --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/end_of_month_day.cpp @@ -0,0 +1,46 @@ +/* Simple program that uses the gregorian calendar to find the last + * day of the month and then display the last day of every month left + * in the year. + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include + +int +main() +{ + using namespace boost::gregorian; + + std::cout << " Enter Year(ex: 2002): "; + int year, month; + std::cin >> year; + std::cout << " Enter Month(1..12): "; + std::cin >> month; + try { + int day = gregorian_calendar::end_of_month_day(year,month); + date end_of_month(year,month,day); + + //Iterate thru by months -- + month_iterator mitr(end_of_month,1); + date start_of_next_year(year+1, Jan, 1); + //loop thru the days and print each one + while (mitr < start_of_next_year){ + std::cout << to_simple_string(*mitr) << std::endl; + ++mitr; + } + + } + catch(...) { + std::cout << "Invalid Date Entered" << std::endl; + } + return 0; + +} + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/gregorian/find_last_day_of_months.cpp b/src/boost/libs/date_time/example/gregorian/find_last_day_of_months.cpp new file mode 100644 index 000000000..b0c3640be --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/find_last_day_of_months.cpp @@ -0,0 +1,54 @@ +/* Simple program that finds the last day of the given month, + * then displays the last day of every month left in the given year. + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include + +int +main() +{ + using namespace boost::gregorian; + + greg_year year(1400); + greg_month month(1); + + // get a month and a year from the user + try { + greg_year::value_type y; + greg_month::value_type m; + std::cout << " Enter Year(ex: 2002): "; + std::cin >> y; + year = greg_year(y); + std::cout << " Enter Month(1..12): "; + std::cin >> m; + month = greg_month(m); + } + catch(const bad_year& by) { + std::cout << "Invalid Year Entered: " << by.what() << '\n' + << "Using minimum values for month and year." << std::endl; + } + catch(const bad_month& bm) { + std::cout << "Invalid Month Entered" << bm.what() << '\n' + << "Using minimum value for month. " << std::endl; + } + + date start_of_next_year(year+1, Jan, 1); + date d(year, month, 1); + + // add another month to d until we enter the next year. + while (d < start_of_next_year){ + std::cout << to_simple_string(d.end_of_month()) << std::endl; + d += months(1); + } + + return 0; +} + +/* Copyright 2001-2005: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/gregorian/localization.cpp b/src/boost/libs/date_time/example/gregorian/localization.cpp new file mode 100644 index 000000000..25856f638 --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/localization.cpp @@ -0,0 +1,100 @@ +/* The following shows the creation of a facet for the output of + * dates in German (please forgive me for any errors in my German -- + * I'm not a native speaker). + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include +#include + +/* Define a series of char arrays for short and long name strings + * to be associated with German date output (US names will be + * retrieved from the locale). */ +const char* const de_short_month_names[] = +{ + "Jan", "Feb", "Mar", "Apr", "Mai", "Jun", + "Jul", "Aug", "Sep", "Okt", "Nov", "Dez", "NAM" +}; +const char* const de_long_month_names[] = +{ + "Januar", "Februar", "Marz", "April", "Mai", + "Juni", "Juli", "August", "September", "Oktober", + "November", "Dezember", "NichtDerMonat" +}; +const char* const de_long_weekday_names[] = +{ + "Sonntag", "Montag", "Dienstag", "Mittwoch", + "Donnerstag", "Freitag", "Samstag" +}; +const char* const de_short_weekday_names[] = +{ + "Son", "Mon", "Die","Mit", "Don", "Fre", "Sam" +}; + + +int main() +{ + using namespace boost::gregorian; + + // create some gregorian objects to output + date d1(2002, Oct, 1); + greg_month m = d1.month(); + greg_weekday wd = d1.day_of_week(); + + // create a facet and a locale for German dates + date_facet* german_facet = new date_facet(); + std::cout.imbue(std::locale(std::locale::classic(), german_facet)); + + // create the German name collections + date_facet::input_collection_type short_months, long_months, + short_weekdays, long_weekdays; + std::copy(&de_short_month_names[0], &de_short_month_names[11], + std::back_inserter(short_months)); + std::copy(&de_long_month_names[0], &de_long_month_names[11], + std::back_inserter(long_months)); + std::copy(&de_short_weekday_names[0], &de_short_weekday_names[6], + std::back_inserter(short_weekdays)); + std::copy(&de_long_weekday_names[0], &de_long_weekday_names[6], + std::back_inserter(long_weekdays)); + + // replace the default names with ours + // NOTE: date_generators and special_values were not replaced as + // they are not used in this example + german_facet->short_month_names(short_months); + german_facet->long_month_names(long_months); + german_facet->short_weekday_names(short_weekdays); + german_facet->long_weekday_names(long_weekdays); + + // output the date in German using short month names + german_facet->format("%d.%m.%Y"); + std::cout << d1 << std::endl; //01.10.2002 + + german_facet->month_format("%B"); + std::cout << m << std::endl; //Oktober + + german_facet->weekday_format("%A"); + std::cout << wd << std::endl; //Dienstag + + + // Output the same gregorian objects using US names + date_facet* us_facet = new date_facet(); + std::cout.imbue(std::locale(std::locale::classic(), us_facet)); + + us_facet->format("%m/%d/%Y"); + std::cout << d1 << std::endl; // 10/01/2002 + + // English names, iso order (year-month-day), '-' separator + us_facet->format("%Y-%b-%d"); + std::cout << d1 << std::endl; // 2002-Oct-01 + + return 0; + +} + +/* Copyright 2001-2005: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/gregorian/month_add.cpp b/src/boost/libs/date_time/example/gregorian/month_add.cpp new file mode 100644 index 000000000..ee3f05ef8 --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/month_add.cpp @@ -0,0 +1,58 @@ +/* Simple program that uses the gregorian calendar to progress by exactly + * one month, regardless of how many days are in that month. + * + * This method can be used as an alternative to iterators + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include + +int +main() +{ + + using namespace boost::gregorian; + + date d = day_clock::local_day(); + date d2 = d + months(1); + date d3 = d - months(1); + std::cout << "Today is: " << to_simple_string(d) << ".\n" + << "One month from today will be: " << to_simple_string(d2) << ".\n" + << "One month ago was: " << to_simple_string(d3) + << std::endl; + std::cout << "******** Warning read this ***********************\n"; + std::cout << "Be aware that adding a month is not exactly like regular numeric math.\n" + << "Addition/Subtraction of months will 'snap to the end' of a month that\n" + << "is shorter than the current month. For example consider " + << "Jan 31, 2004 + (1 month)\n"; + date d4(2004, Jan, 31); + date d5 = d4 + months(1); + std::cout << "Result is: " << to_simple_string(d5) + << std::endl; + + std::cout << "\nSo what does this mean? It means the result of adding months is order\n" + << "dependent, non-commutative, and may create problems for applications.\n" + << "Consider: \n" + << "Jan 30, 2004 + (1 month) + (1 month) != Jan 30, 2004 + (2 months)\n" + << "Why not? Because Jan 30, 2004 + 1 month is Feb 29 + 1 month is Mar 31st.\n" + << "while Jan 30, 2004 + 2 months is Mar 30th.\n" + << "All of this clears up as long as all the starting dates before the 28th of\n" + << "the month -- then all the behavior follows classical mathematical rules.\n"; + + date d6(2004, Jan, 30); + date d7 = d6 + months(1) + months(1); + date d8 = d6 + months(2); + std::cout << "2004-01-30 + (1 month) + (1 month) is: " << to_simple_string(d7) << ".\n" + << "2004-01-30 + (2 months) is: " << to_simple_string(d8) + << std::endl; + + return 0; +} + +/* Copyright 2001-2005: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/gregorian/period_calc.cpp b/src/boost/libs/date_time/example/gregorian/period_calc.cpp new file mode 100644 index 000000000..31875fe95 --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/period_calc.cpp @@ -0,0 +1,86 @@ +/* +This example demonstrates a simple use of periods for the calculation +of date information. + +The example calculates if a given date is a weekend or holiday +given an exclusion set. That is, each weekend or holiday is +entered into the set as a time interval. Then if a given date +is contained within any of the intervals it is considered to +be within the exclusion set and hence is a offtime. + +Output: +Number Excluded Periods: 5 +20020202/20020203 +20020209/20020210 +20020212/20020212 +20020216/20020217 +In Exclusion Period: 20020216 --> 20020216/20020217 +20020223/20020224 + +*/ + + +#include "boost/date_time/gregorian/gregorian.hpp" +#include +#include +#include + +typedef std::set date_period_set; + +//Simple population of the exclusion set +date_period_set +generateExclusion() +{ + using namespace boost::gregorian; + date_period periods_array[] = + { date_period(date(2002,Feb,2), date(2002,Feb,4)),//weekend of 2nd-3rd + date_period(date(2002,Feb,9), date(2002,Feb,11)), + date_period(date(2002,Feb,16), date(2002,Feb,18)), + date_period(date(2002,Feb,23), date(2002,Feb,25)), + date_period(date(2002,Feb,12), date(2002,Feb,13))//a random holiday 2-12 + }; + const int num_periods = sizeof(periods_array)/sizeof(date_period); + + date_period_set ps; + //insert the periods in the set + std::insert_iterator itr(ps, ps.begin()); + std::copy(periods_array, periods_array+num_periods, itr ); + return ps; + +} + + +int main() +{ + using namespace boost::gregorian; + + date_period_set ps = generateExclusion(); + std::cout << "Number Excluded Periods: " << ps.size() << std::endl; + + date d(2002,Feb,16); + date_period_set::const_iterator i = ps.begin(); + //print the periods, check for containment + for (;i != ps.end(); i++) { + std::cout << to_iso_string(*i) << std::endl; + //if date is in exclusion period then print it + if (i->contains(d)) { + std::cout << "In Exclusion Period: " + << to_iso_string(d) << " --> " << to_iso_string(*i) + << std::endl; + } + } + + return 0; + +} + + + + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/gregorian/print_holidays.cpp b/src/boost/libs/date_time/example/gregorian/print_holidays.cpp new file mode 100644 index 000000000..2d2fa53b1 --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/print_holidays.cpp @@ -0,0 +1,83 @@ +/* Generate a set of dates using a collection of date generators + * Output looks like: + * Enter Year: 2002 + * 2002-Jan-01 [Tue] + * 2002-Jan-21 [Mon] + * 2002-Feb-12 [Tue] + * 2002-Jul-04 [Thu] + * 2002-Sep-02 [Mon] + * 2002-Nov-28 [Thu] + * 2002-Dec-25 [Wed] + * Number Holidays: 7 + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include +#include +#include +#include +#include + +void +print_date(boost::gregorian::date d) +{ + using namespace boost::gregorian; +#if defined(BOOST_DATE_TIME_NO_LOCALE) + std::cout << to_simple_string(d) << " [" << d.day_of_week() << "]\n"; +#else + std::cout << d << " [" << d.day_of_week() << "]\n"; +#endif +} + + +int +main() { + + using namespace boost::gregorian; + + std::cout << "Enter Year: "; + greg_year::value_type year; + std::cin >> year; + + //define a collection of holidays fixed by month and day + std::vector holidays; + holidays.push_back(new partial_date(1,Jan)); //Western New Year + holidays.push_back(new partial_date(4,Jul)); //US Independence Day + holidays.push_back(new partial_date(25, Dec));//Christmas day + + + //define a shorthand for the nth_day_of_the_week_in_month function object + typedef nth_day_of_the_week_in_month nth_dow; + + //US labor day + holidays.push_back(new nth_dow(nth_dow::first, Monday, Sep)); + //MLK Day + holidays.push_back(new nth_dow(nth_dow::third, Monday, Jan)); + //Pres day + holidays.push_back(new nth_dow(nth_dow::second, Tuesday, Feb)); + //Thanksgiving + holidays.push_back(new nth_dow(nth_dow::fourth, Thursday, Nov)); + + typedef std::set date_set; + date_set all_holidays; + + for(std::vector::iterator it = holidays.begin(); + it != holidays.end(); ++it) + { + all_holidays.insert((*it)->get_date(year)); + } + + //print the holidays to the screen + std::for_each(all_holidays.begin(), all_holidays.end(), print_date); + std::cout << "Number Holidays: " << all_holidays.size() << std::endl; + + return 0; +} + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/gregorian/print_month.cpp b/src/boost/libs/date_time/example/gregorian/print_month.cpp new file mode 100644 index 000000000..34e741aea --- /dev/null +++ b/src/boost/libs/date_time/example/gregorian/print_month.cpp @@ -0,0 +1,64 @@ +/* This example prints all the dates in a month. It demonstrates + * the use of iterators as well as functions of the gregorian_calendar + * + * Output: + * Enter Year: 2002 + * Enter Month(1..12): 2 + * 2002-Feb-01 [Fri] + * 2002-Feb-02 [Sat] + * 2002-Feb-03 [Sun] + * 2002-Feb-04 [Mon] + * 2002-Feb-05 [Tue] + * 2002-Feb-06 [Wed] + * 2002-Feb-07 [Thu] + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include + +int +main() +{ + using namespace boost::gregorian; + + std::cout << "Enter Year: "; + greg_year::value_type year; + greg_month::value_type month; + std::cin >> year; + std::cout << "Enter Month(1..12): "; + std::cin >> month; + + try { + //Use the calendar to get the last day of the month + greg_day::value_type eom_day = gregorian_calendar::end_of_month_day(year,month); + date endOfMonth(year,month,eom_day); + + //construct an iterator starting with firt day of the month + day_iterator ditr(date(year,month,1)); + //loop thru the days and print each one + for (; ditr <= endOfMonth; ++ditr) { +#if defined(BOOST_DATE_TIME_NO_LOCALE) + std::cout << to_simple_string(*ditr) << " [" +#else + std::cout << *ditr << " [" +#endif + << ditr->day_of_week() << " week: " + << ditr->week_number() << "]" + << std::endl; + } + } + catch(std::exception& e) { + + std::cout << "Error bad date, check your entry: \n" + << " Details: " << e.what() << std::endl; + } + return 0; +} + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/local_time/calc_rules.cpp b/src/boost/libs/date_time/example/local_time/calc_rules.cpp new file mode 100644 index 000000000..f8a21ed49 --- /dev/null +++ b/src/boost/libs/date_time/example/local_time/calc_rules.cpp @@ -0,0 +1,47 @@ +/* A simple example for creating various dst_calc_rule instances + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "boost/date_time/local_time/local_time.hpp" +#include + +int +main() +{ + using namespace boost; + using namespace local_time; + using namespace gregorian; + + /***** create the necessary date_generator objects *****/ + // starting generators + first_day_of_the_week_in_month fd_start(Sunday, May); + last_day_of_the_week_in_month ld_start(Sunday, May); + nth_day_of_the_week_in_month nkd_start(nth_day_of_the_week_in_month::third, + Sunday, May); + partial_date pd_start(1, May); + // ending generators + first_day_of_the_week_in_month fd_end(Sunday, Oct); + last_day_of_the_week_in_month ld_end(Sunday, Oct); + nth_day_of_the_week_in_month nkd_end(nth_day_of_the_week_in_month::third, + Sunday, Oct); + partial_date pd_end(31, Oct); + + /***** create the various dst_calc_rule objects *****/ + dst_calc_rule_ptr pdr(new partial_date_dst_rule(pd_start, pd_end)); + dst_calc_rule_ptr flr(new first_last_dst_rule(fd_start, ld_end)); + dst_calc_rule_ptr llr(new last_last_dst_rule(ld_start, ld_end)); + dst_calc_rule_ptr nlr(new nth_last_dst_rule(nkd_start, ld_end)); + dst_calc_rule_ptr ndr(new nth_day_of_the_week_in_month_dst_rule(nkd_start, nkd_end)); + + std::cout << "Program run successfully" << std::endl; + + return 0; +} + +/* Copyright 2001-2005: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/local_time/flight.cpp b/src/boost/libs/date_time/example/local_time/flight.cpp new file mode 100644 index 000000000..170f482b4 --- /dev/null +++ b/src/boost/libs/date_time/example/local_time/flight.cpp @@ -0,0 +1,60 @@ + +#include "boost/date_time/local_time/local_time.hpp" +#include + +/* This example shows a program that calculates the arrival time of a plane + * that flys from Phoenix to New York. During the flight New York shifts + * into daylight savings time (Phoenix doesn't because Arizona doesn't use + * DST). + * + * + */ + +int main() +{ + using namespace boost::gregorian; + using namespace boost::local_time; + using namespace boost::posix_time; + + + //setup some timezones for creating and adjusting local times + //This user editable file can be found in libs/date_time/data. + tz_database tz_db; + try { + tz_db.load_from_file("../../data/date_time_zonespec.csv"); + }catch(const data_not_accessible& dna) { + std::cerr << "Error with time zone data file: " << dna.what() << std::endl; + exit(EXIT_FAILURE); + }catch(const bad_field_count& bfc) { + std::cerr << "Error with time zone data file: " << bfc.what() << std::endl; + exit(EXIT_FAILURE); + } + time_zone_ptr nyc_tz = tz_db.time_zone_from_region("America/New_York"); + //Use a newly created time zone rule + time_zone_ptr phx_tz(new posix_time_zone("MST-07:00:00")); + + //local departure time in Phoenix is 11 pm on March 13 2010 + // (NY changes to DST on March 14 at 2 am) + local_date_time phx_departure(date(2010, Mar, 13), hours(23), + phx_tz, + local_date_time::NOT_DATE_TIME_ON_ERROR); + local_date_time nyc_departure = phx_departure.local_time_in(nyc_tz); + + time_duration flight_length = hours(4) + minutes(30); + local_date_time phx_arrival = phx_departure + flight_length; + local_date_time nyc_arrival = phx_arrival.local_time_in(nyc_tz); + + std::cout << "departure PHX time: " << phx_departure << std::endl; + std::cout << "departure NYC time: " << nyc_departure << std::endl; + std::cout << "arrival PHX time: " << phx_arrival << std::endl; + std::cout << "arrival NYC time: " << nyc_arrival << std::endl; + +} + + +/* Copyright 2005: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ diff --git a/src/boost/libs/date_time/example/local_time/local_date_time.cpp b/src/boost/libs/date_time/example/local_time/local_date_time.cpp new file mode 100644 index 000000000..8e1669526 --- /dev/null +++ b/src/boost/libs/date_time/example/local_time/local_date_time.cpp @@ -0,0 +1,45 @@ +#include "boost/date_time/gregorian/gregorian.hpp" +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/date_time/local_time/local_time.hpp" +#include +#include + +int main() { + using namespace boost::gregorian; + using namespace boost::posix_time; + using namespace boost::local_time; + + tz_database tz_db; + try { + tz_db.load_from_file("../../data/date_time_zonespec.csv"); + }catch(data_not_accessible dna) { + std::cerr << "Error with time zone data file: " << dna.what() << std::endl; + exit(EXIT_FAILURE); + }catch(bad_field_count bfc) { + std::cerr << "Error with time zone data file: " << bfc.what() << std::endl; + exit(EXIT_FAILURE); + } + + time_zone_ptr nyc = tz_db.time_zone_from_region("America/New_York"); + local_date_time ny_time(date(2004, Aug, 30), hours(10), nyc, true); + + typedef boost::date_time::time_facet ldt_facet; + ldt_facet* timefacet = new ldt_facet("%Y-%b-%d %H:%M:%S""%F %Z"); + std::locale loc(std::locale::classic(), timefacet); + + std::cout << ny_time << std::endl; + // 2004-Aug-30 10:00:00 EDT + std::cout.imbue(loc); + std::cout << ny_time << std::endl; + // 2004-Aug-30 10:00:00 Eastern Daylight Time + + return 0; +} + + +/* Copyright 2004-2005: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ diff --git a/src/boost/libs/date_time/example/local_time/seconds_since_epoch.cpp b/src/boost/libs/date_time/example/local_time/seconds_since_epoch.cpp new file mode 100644 index 000000000..decaf33bb --- /dev/null +++ b/src/boost/libs/date_time/example/local_time/seconds_since_epoch.cpp @@ -0,0 +1,65 @@ +/* This example demonstrates the use of the time zone database and + * local time to calculate the number of seconds since the UTC + * time_t epoch 1970-01-01 00:00:00. Note that the selected timezone + * could be any timezone supported in the time zone database file which + * can be modified and updated as needed by the user. + * + * To solve this problem the following steps are required: + * 1) Get a timezone from the tz database for the local time + * 2) Construct a local time using the timezone + * 3) Construct a posix_time::ptime for the time_t epoch time + * 4) Convert the local_time to utc and subtract the epoch time + * + */ + +#include "boost/date_time/local_time/local_time.hpp" +#include + +int main() +{ + using namespace boost::gregorian; + using namespace boost::local_time; + using namespace boost::posix_time; + + tz_database tz_db; + try { + tz_db.load_from_file("../data/date_time_zonespec.csv"); + }catch(const data_not_accessible& dna) { + std::cerr << "Error with time zone data file: " << dna.what() << std::endl; + exit(EXIT_FAILURE); + }catch(const bad_field_count& bfc) { + std::cerr << "Error with time zone data file: " << bfc.what() << std::endl; + exit(EXIT_FAILURE); + } + + time_zone_ptr nyc_tz = tz_db.time_zone_from_region("America/New_York"); + date in_date(2004,10,04); + time_duration td(12,14,32); + // construct with local time value + // create not-a-date-time if invalid (eg: in dst transition) + local_date_time nyc_time(in_date, + td, + nyc_tz, + local_date_time::NOT_DATE_TIME_ON_ERROR); + + std::cout << nyc_time << std::endl; + + ptime time_t_epoch(date(1970,1,1)); + std::cout << time_t_epoch << std::endl; + + // first convert nyc_time to utc via the utc_time() + // call and subtract the ptime. + time_duration diff = nyc_time.utc_time() - time_t_epoch; + + //Expected 1096906472 + std::cout << "Seconds diff: " << diff.total_seconds() << std::endl; + +} + + +/* Copyright 2005: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ diff --git a/src/boost/libs/date_time/example/local_time/simple_time_zone.cpp b/src/boost/libs/date_time/example/local_time/simple_time_zone.cpp new file mode 100644 index 000000000..6675774bf --- /dev/null +++ b/src/boost/libs/date_time/example/local_time/simple_time_zone.cpp @@ -0,0 +1,86 @@ +/* A simple example for using a custom_time_zone and a posix_time_zone. + */ + +#include "boost/date_time/local_time/local_time.hpp" +#include + +int +main() +{ + using namespace boost; + using namespace local_time; + using namespace gregorian; + using posix_time::time_duration; + + /***** custom_time_zone *****/ + + // create the dependent objects for a custom_time_zone + time_zone_names tzn("Eastern Standard Time", "EST", + "Eastern Daylight Time", "EDT"); + time_duration utc_offset(-5,0,0); + dst_adjustment_offsets adj_offsets(time_duration(1,0,0), + time_duration(2,0,0), + time_duration(2,0,0)); + // rules for this zone are: + // start on first Sunday of April at 2 am + // end on last Sunday of October at 2 am + // so we use a first_last_dst_rule + first_day_of_the_week_in_month start_rule(Sunday, Apr); + last_day_of_the_week_in_month end_rule(Sunday, Oct); + shared_ptr nyc_rules(new first_last_dst_rule(start_rule, + end_rule)); + // create more dependent objects for a non-dst custom_time_zone + time_zone_names tzn2("Mountain Standard Time", "MST", + "", ""); // no dst means empty dst strings + time_duration utc_offset2(-7,0,0); + dst_adjustment_offsets adj_offsets2(time_duration(0,0,0), + time_duration(0,0,0), + time_duration(0,0,0)); + // no dst means we need a null pointer to the rules + shared_ptr phx_rules; + + // create the custom_time_zones + time_zone_ptr nyc_1(new custom_time_zone(tzn, utc_offset, adj_offsets, nyc_rules)); + time_zone_ptr phx_1(new custom_time_zone(tzn2, utc_offset2, adj_offsets2, phx_rules)); + + /***** posix_time_zone *****/ + + // create posix_time_zones that are the duplicates of the + // custom_time_zones created above. See posix_time_zone documentation + // for details on full zone names. + std::string nyc_string, phx_string; + nyc_string = "EST-05:00:00EDT+01:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00"; + // nyc_string = "EST-05EDT,M4.1.0,M10.5.0"; // shorter when defaults used + phx_string = "MST-07"; // no-dst + time_zone_ptr nyc_2(new posix_time_zone(nyc_string)); + time_zone_ptr phx_2(new posix_time_zone(phx_string)); + + + /***** show the sets are equal *****/ + + std::cout << "The first zone is in daylight savings from:\n " + << nyc_1->dst_local_start_time(2004) << " through " + << nyc_1->dst_local_end_time(2004) << std::endl; + + std::cout << "The second zone is in daylight savings from:\n " + << nyc_2->dst_local_start_time(2004) << " through " + << nyc_2->dst_local_end_time(2004) << std::endl; + + std::cout << "The third zone (no daylight savings):\n " + << phx_1->std_zone_abbrev() << " and " + << phx_1->base_utc_offset() << std::endl; + + std::cout << "The fourth zone (no daylight savings):\n " + << phx_2->std_zone_abbrev() << " and " + << phx_2->base_utc_offset() << std::endl; + + return 0; +} + +/* Copyright 2001-2005: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/posix_time/Jamfile.v2 b/src/boost/libs/date_time/example/posix_time/Jamfile.v2 new file mode 100644 index 000000000..b7bf07e6c --- /dev/null +++ b/src/boost/libs/date_time/example/posix_time/Jamfile.v2 @@ -0,0 +1,13 @@ +# Copyright (c) 2002-2005 CrystalClear Software, Inc. +# Use, modification and distribution is 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) + +project + : requirements ../../build/boost_date_time + ; + +exe time_math : time_math.cpp ; +exe local_utc_conversion : local_utc_conversion.cpp ; +exe print_hours : print_hours.cpp ; +exe time_periods : time_periods.cpp ; diff --git a/src/boost/libs/date_time/example/posix_time/local_utc_conversion.cpp b/src/boost/libs/date_time/example/posix_time/local_utc_conversion.cpp new file mode 100644 index 000000000..5e712e88e --- /dev/null +++ b/src/boost/libs/date_time/example/posix_time/local_utc_conversion.cpp @@ -0,0 +1,90 @@ +/* Demonstrate conversions between a local time and utc + * Output: + * + * UTC <--> New York while DST is NOT active (5 hours) + * 2001-Dec-31 19:00:00 in New York is 2002-Jan-01 00:00:00 UTC time + * 2002-Jan-01 00:00:00 UTC is 2001-Dec-31 19:00:00 New York time + * + * UTC <--> New York while DST is active (4 hours) + * 2002-May-31 20:00:00 in New York is 2002-Jun-01 00:00:00 UTC time + * 2002-Jun-01 00:00:00 UTC is 2002-May-31 20:00:00 New York time + * + * UTC <--> Arizona (7 hours) + * 2002-May-31 17:00:00 in Arizona is 2002-Jun-01 00:00:00 UTC time + */ + +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/date_time/local_time_adjustor.hpp" +#include "boost/date_time/c_local_time_adjustor.hpp" +#include + +int +main() +{ + using namespace boost::posix_time; + using namespace boost::gregorian; + + //This local adjustor depends on the machine TZ settings-- highly dangerous! + typedef boost::date_time::c_local_adjustor local_adj; + ptime t10(date(2002,Jan,1), hours(7)); + ptime t11 = local_adj::utc_to_local(t10); + std::cout << "UTC <--> Zone base on TZ setting" << std::endl; + std::cout << to_simple_string(t11) << " in your TZ is " + << to_simple_string(t10) << " UTC time " + << std::endl; + time_duration td = t11 - t10; + std::cout << "A difference of: " + << to_simple_string(td) << std::endl; + + + //eastern timezone is utc-5 + typedef boost::date_time::local_adjustor us_eastern; + + ptime t1(date(2001,Dec,31), hours(19)); //5 hours b/f midnight NY time + + std::cout << "\nUTC <--> New York while DST is NOT active (5 hours)" + << std::endl; + ptime t2 = us_eastern::local_to_utc(t1); + std::cout << to_simple_string(t1) << " in New York is " + << to_simple_string(t2) << " UTC time " + << std::endl; + + ptime t3 = us_eastern::utc_to_local(t2);//back should be the same + std::cout << to_simple_string(t2) << " UTC is " + << to_simple_string(t3) << " New York time " + << "\n\n"; + + ptime t4(date(2002,May,31), hours(20)); //4 hours b/f midnight NY time + std::cout << "UTC <--> New York while DST is active (4 hours)" << std::endl; + ptime t5 = us_eastern::local_to_utc(t4); + std::cout << to_simple_string(t4) << " in New York is " + << to_simple_string(t5) << " UTC time " + << std::endl; + + ptime t6 = us_eastern::utc_to_local(t5);//back should be the same + std::cout << to_simple_string(t5) << " UTC is " + << to_simple_string(t6) << " New York time " + << "\n" << std::endl; + + + //Arizona timezone is utc-7 with no dst + typedef boost::date_time::local_adjustor us_arizona; + + ptime t7(date(2002,May,31), hours(17)); + std::cout << "UTC <--> Arizona (7 hours)" << std::endl; + ptime t8 = us_arizona::local_to_utc(t7); + std::cout << to_simple_string(t7) << " in Arizona is " + << to_simple_string(t8) << " UTC time " + << std::endl; + + return 0; +} + + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/posix_time/print_hours.cpp b/src/boost/libs/date_time/example/posix_time/print_hours.cpp new file mode 100644 index 000000000..3877a3c73 --- /dev/null +++ b/src/boost/libs/date_time/example/posix_time/print_hours.cpp @@ -0,0 +1,53 @@ +/* Print the remaining hours of the day + * Uses the clock to get the local time + * Use an iterator to iterate over the remaining hours + * Retrieve the date part from a time + * + * Expected Output something like: + * + * 2002-Mar-08 16:30:59 + * 2002-Mar-08 17:30:59 + * 2002-Mar-08 18:30:59 + * 2002-Mar-08 19:30:59 + * 2002-Mar-08 20:30:59 + * 2002-Mar-08 21:30:59 + * 2002-Mar-08 22:30:59 + * 2002-Mar-08 23:30:59 + * Time left till midnight: 07:29:01 + */ + +#include "boost/date_time/posix_time/posix_time.hpp" +#include + +int +main() +{ + using namespace boost::posix_time; + using namespace boost::gregorian; + + //get the current time from the clock -- one second resolution + ptime now = second_clock::local_time(); + //Get the date part out of the time + date today = now.date(); + date tomorrow = today + days(1); + ptime tomorrow_start(tomorrow); //midnight + + //iterator adds by one hour + time_iterator titr(now,hours(1)); + for (; titr < tomorrow_start; ++titr) { + std::cout << to_simple_string(*titr) << std::endl; + } + + time_duration remaining = tomorrow_start - now; + std::cout << "Time left till midnight: " + << to_simple_string(remaining) << std::endl; + return 0; +} + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/posix_time/time_math.cpp b/src/boost/libs/date_time/example/posix_time/time_math.cpp new file mode 100644 index 000000000..99793ebc7 --- /dev/null +++ b/src/boost/libs/date_time/example/posix_time/time_math.cpp @@ -0,0 +1,36 @@ +/* Some simple examples of constructing and calculating with times + * Output: + * 2002-Feb-01 00:00:00 - 2002-Feb-01 05:04:02.001000000 = -5:04:02.001000000 + */ + +#include "boost/date_time/posix_time/posix_time.hpp" +#include + +int +main() +{ + using namespace boost::posix_time; + using namespace boost::gregorian; + + date d(2002,Feb,1); //an arbitrary date + //construct a time by adding up some durations + ptime t1(d, hours(5)+minutes(4)+seconds(2)+milliseconds(1)); + //construct a new time by subtracting some times + ptime t2 = t1 - hours(5)- minutes(4)- seconds(2)- milliseconds(1); + //construct a duration by taking the difference between times + time_duration td = t2 - t1; + + std::cout << to_simple_string(t2) << " - " + << to_simple_string(t1) << " = " + << to_simple_string(td) << std::endl; + + return 0; +} + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/posix_time/time_periods.cpp b/src/boost/libs/date_time/example/posix_time/time_periods.cpp new file mode 100644 index 000000000..28e38708b --- /dev/null +++ b/src/boost/libs/date_time/example/posix_time/time_periods.cpp @@ -0,0 +1,58 @@ +/* Some simple examples of constructing and calculating with times + * Returns: + * [2002-Feb-01 00:00:00/2002-Feb-01 23:59:59.999999999] contains 2002-Feb-01 03:00:05 + * [2002-Feb-01 00:00:00/2002-Feb-01 23:59:59.999999999] intersected with + * [2002-Feb-01 00:00:00/2002-Feb-01 03:00:04.999999999] is + * [2002-Feb-01 00:00:00/2002-Feb-01 03:00:04.999999999] + */ + +#include "boost/date_time/posix_time/posix_time.hpp" +#include + +using namespace boost::posix_time; +using namespace boost::gregorian; + +//Create a simple period class to contain all the times in a day +class day_period : public time_period +{ +public: + day_period(date d) : time_period(ptime(d),//midnight + ptime(d,hours(24))) + {} + +}; + +int +main() +{ + + date d(2002,Feb,1); //an arbitrary date + //a period that represents a day + day_period dp(d); + ptime t(d, hours(3)+seconds(5)); //an arbitray time on that day + if (dp.contains(t)) { + std::cout << to_simple_string(dp) << " contains " + << to_simple_string(t) << std::endl; + } + //a period that represents part of the day + time_period part_of_day(ptime(d, hours(0)), t); + //intersect the 2 periods and print the results + if (part_of_day.intersects(dp)) { + time_period result = part_of_day.intersection(dp); + std::cout << to_simple_string(dp) << " intersected with\n" + << to_simple_string(part_of_day) << " is \n" + << to_simple_string(result) << std::endl; + } + + + return 0; +} + + +/* Copyright 2001-2004: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/example/tutorial/io_tutorial.cpp b/src/boost/libs/date_time/example/tutorial/io_tutorial.cpp new file mode 100644 index 000000000..165a53f93 --- /dev/null +++ b/src/boost/libs/date_time/example/tutorial/io_tutorial.cpp @@ -0,0 +1,194 @@ +#include +#include + +int main(){ + using namespace boost::gregorian; + using namespace boost::posix_time; + using namespace boost::local_time; + using namespace std; + + /****** basic use ******/ + date d(2004, Feb, 29); + time_duration td(12,34,56,789); + stringstream ss; + ss << d << ' ' << td; + ptime pt(not_a_date_time); + cout << pt << endl; // "not-a-date-time" + ss >> pt; + cout << pt << endl; // "2004-Feb-29 12:34:56.000789" + ss.str(""); + ss << pt << " EDT-05EDT,M4.1.0,M10.5.0"; + local_date_time ldt(not_a_date_time); + ss >> ldt; + cout << ldt << endl; // " 2004-Feb-29 12:34:56.000789 EDT" + + + /****** format strings ******/ + local_time_facet* output_facet = new local_time_facet(); + local_time_input_facet* input_facet = new local_time_input_facet(); + ss.imbue(locale(locale::classic(), output_facet)); + ss.imbue(locale(ss.getloc(), input_facet)); + output_facet->format("%a %b %d, %H:%M %z"); + ss.str(""); + ss << ldt; + cout << ss.str() << endl; // "Sun Feb 29, 12:34 EDT" + + output_facet->format(local_time_facet::iso_time_format_specifier); + ss.str(""); + ss << ldt; + cout << ss.str() << endl; // "20040229T123456.000789-0500" + output_facet->format(local_time_facet::iso_time_format_extended_specifier); + ss.str(""); + ss << ldt; + cout << ss.str() << endl; // "2004-02-29 12:34:56.000789-05:00" + + // extra words in format + string my_format("The extended ordinal time %Y-%jT%H:%M can also be represented as %A %B %d, %Y"); + output_facet->format(my_format.c_str()); + input_facet->format(my_format.c_str()); + ss.str(""); + ss << ldt; + cout << ss.str() << endl; + + // matching extra words in input + ss.str("The extended ordinal time 2005-128T12:15 can also be represented as Sunday May 08, 2005"); + ss >> ldt; + cout << ldt << endl; // cout is using default format "2005-May-08 12:15:00 UTC" + + /****** content strings ******/ + // set up the collections of custom strings. + // only the full names are altered for the sake of brevity + string month_names[12] = { "january", "february", "march", + "april", "may", "june", + "july", "august", "september", + "october", "november", "december" }; + vector long_months(&month_names[0], &month_names[12]); + string day_names[7] = { "sunday", "monday", "tuesday", "wednesday", + "thursday", "friday", "saturday" }; + vector long_days(&day_names[0], &day_names[7]); + + // create date_facet and date_input_facet using all defaults + date_facet* date_output = new date_facet(); + date_input_facet* date_input = new date_input_facet(); + ss.imbue(locale(ss.getloc(), date_output)); + ss.imbue(locale(ss.getloc(), date_input)); + + // replace names in the output facet + date_output->long_month_names(long_months); + date_output->long_weekday_names(long_days); + + // replace names in the input facet + date_input->long_month_names(long_months); + date_input->long_weekday_names(long_days); + + // customize month, weekday and date formats + date_output->format("%Y-%B-%d"); + date_input->format("%Y-%B-%d"); + date_output->month_format("%B"); // full name + date_input->month_format("%B"); // full name + date_output->weekday_format("%A"); // full name + date_input->weekday_format("%A"); // full name + + ss.str(""); + ss << greg_month(3); + cout << ss.str() << endl; // "march" + ss.str(""); + ss << greg_weekday(3); + cout << ss.str() << endl; // "tuesday" + ss.str(""); + ss << date(2005,Jul,4); + cout << ss.str() << endl; // "2005-july-04" + + + /****** special values ******/ + // reset the formats to defaults + output_facet->format(local_time_facet::default_time_format); + input_facet->format(local_time_input_facet::default_time_input_format); + + // create custom special_values parser and formatter objects + // and add them to the facets + string sv[5] = {"nadt","neg_inf", "pos_inf", "min_dt", "max_dt" }; + vector sv_names(&sv[0], &sv[5]); + special_values_parser sv_parser(sv_names.begin(), sv_names.end()); + special_values_formatter sv_formatter(sv_names.begin(), sv_names.end()); + output_facet->special_values_formatter(sv_formatter); + input_facet->special_values_parser(sv_parser); + + ss.str(""); + ldt = local_date_time(not_a_date_time); + ss << ldt; + cout << ss.str() << endl; // "nadt" + + ss.str("min_dt"); + ss >> ldt; + ss.str(""); + ss << ldt; + cout << ss.str() << endl; // "1400-Jan-01 00:00:00 UTC" + + /****** date/time periods ******/ + // reset all formats to defaults + date_output->format(date_facet::default_date_format); + date_input->format(date_facet::default_date_format); + date_output->month_format("%b"); // abbrev + date_input->month_format("%b"); // abbrev + date_output->weekday_format("%a"); // abbrev + date_input->weekday_format("%a"); // abbrev + + // create our date_period + date_period dp(date(2005,Mar,1), days(31)); // month of march + + // custom period formatter and parser + period_formatter per_formatter(period_formatter::AS_OPEN_RANGE, + " to ", "from ", " exclusive", " inclusive" ); + period_parser per_parser(period_parser::AS_OPEN_RANGE, + " to ", "from ", " exclusive" , " inclusive" ); + + // default output + ss.str(""); + ss << dp; + cout << ss.str() << endl; // "[2005-Mar-01/2005-Mar-31]" + + // add out custom parser and formatter to the facets + date_output->period_formatter(per_formatter); + date_input->period_parser(per_parser); + + // custom output + ss.str(""); + ss << dp; + cout << ss.str() << endl; // "from 2005-Feb-01 to 2005-Apr-01 exclusive" + + + /****** date generators ******/ + // custom date_generator phrases + string dg_phrases[9] = { "1st", "2nd", "3rd", "4th", "5th", + "final", "prior to", "following", "in" }; + vector phrases(&dg_phrases[0], &dg_phrases[9]); + + // create our date_generator + first_day_of_the_week_before d_gen(Monday); + + // default output + ss.str(""); + ss << d_gen; + cout << ss.str() << endl; // "Mon before" + + // add our custom strings to the date facets + date_output->date_gen_phrase_strings(phrases); + date_input->date_gen_element_strings(phrases); + + // custom output + ss.str(""); + ss << d_gen; + cout << ss.str() << endl; // "Mon prior to" + + return 0; +} + + +/* Copyright 2005: CrystalClear Software, Inc + * http://www.crystalclearsoftware.com + * + * 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) + */ + diff --git a/src/boost/libs/date_time/index.html b/src/boost/libs/date_time/index.html new file mode 100644 index 000000000..e68c1cfe8 --- /dev/null +++ b/src/boost/libs/date_time/index.html @@ -0,0 +1,13 @@ + + + + + +Automatic redirection failed, please go to +../../doc/html/date_time.html +

© Copyright CrystalClear Software, 2003

+

Use, modification, and distribution are subject to the Boost Software +License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +www.boost.org/LICENSE_1_0.txt)

+ + diff --git a/src/boost/libs/date_time/meta/libraries.json b/src/boost/libs/date_time/meta/libraries.json new file mode 100644 index 000000000..d860312f0 --- /dev/null +++ b/src/boost/libs/date_time/meta/libraries.json @@ -0,0 +1,16 @@ +{ + "key": "date_time", + "name": "Date Time", + "authors": [ + "Jeff Garland" + ], + "description": "A set of date-time libraries based on generic programming concepts.", + "category": [ + "Domain", + "System" + ], + "maintainers": [ + "Jeff Garland ", + "James E. King III " + ] +} diff --git a/src/boost/libs/date_time/src/date_time.doc b/src/boost/libs/date_time/src/date_time.doc new file mode 100644 index 000000000..920fac2e5 --- /dev/null +++ b/src/boost/libs/date_time/src/date_time.doc @@ -0,0 +1,72 @@ +/* Copyright (c) 2001-2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + * $Date$ + */ + + +/*! @mainpage Boost Date-Time Library Reference Documentation + * + * + *@section intro Introduction + * + * The Boost Date-Time Library (originally the Generic Date-Time Library or GDTL) + * is a set of C++ date-time libraries based on the concepts of generic programming. + * This is an online reference guide generated from the source code + * that provides a handy way to learn about the details of the + * library. If you are a user you should start with the + * User Documentation. + * + *@section using Using This Documentation + * + * The online documentation provides extensive information about the details + * of the library including: + * - Class hierarchy + * - Namespace Documentation + * - List of source files + * - Annotated list of classes and structs + * (Compound List) + * + * For example, suppose you wanted to learn more about the + * gregorian::greg_month class. + * You could alternatively browse the + * - Class documentation page + * - Include dependencies for greg_month.hpp + * - Hyperlinked and colorized source files: [hpp file] [cpp file] + * + * The main navigation bar at the top provides that access to many + * different modes of naviation through the library. + + * + */ + +//! Overall boost namespace -- library does not put any symbols here +namespace boost { + +//! Namespace for basic templates and components used to construct date-time systems +/*! + This namespace encapsulates various types of templates and classes used + to construct coherent date-time systems including date, time, etc. These + components should be considered helper components to be utilized in the + construction of specific date-time system implementations. See namespace + gregorian for one such example. +*/ +namespace date_time {} + +} +/*! Namespace for the c++ standard library. Library does not define any symbols in the namespace, but uses some classes from this namespace. +*/ +namespace std {} + +/*!\class std::out_of_range + \brief Exception class defined in c++ standard library. + A derivative of std::logic_error and std::exception and base class for + many exceptions in the library. See also: + + Mandragor docs for libstdcpp_v3 std::out_of_range +*/ + + + diff --git a/src/boost/libs/date_time/src/gregorian/date_generators.cpp b/src/boost/libs/date_time/src/gregorian/date_generators.cpp new file mode 100644 index 000000000..32a58c179 --- /dev/null +++ b/src/boost/libs/date_time/src/gregorian/date_generators.cpp @@ -0,0 +1,38 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + + + +#ifndef BOOST_DATE_TIME_SOURCE +#define BOOST_DATE_TIME_SOURCE +#endif +#include "boost/date_time/date_generators.hpp" + +namespace boost { +namespace date_time { + + const char* const _nth_as_str[] = {"out of range", "first", "second", + "third", "fourth", "fifth"}; + + //! Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5. + BOOST_DATE_TIME_DECL const char* nth_as_str(int ele) + { + if(ele >= 1 && ele <= 5) { + return _nth_as_str[ele]; + } + else { + return _nth_as_str[0]; + } + } + +} } //namespace date_time + + + + + diff --git a/src/boost/libs/date_time/src/gregorian/greg_month.cpp b/src/boost/libs/date_time/src/gregorian/greg_month.cpp new file mode 100644 index 000000000..e610afc61 --- /dev/null +++ b/src/boost/libs/date_time/src/gregorian/greg_month.cpp @@ -0,0 +1,31 @@ +/* Copyright (c) 2002-2020 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + + +// define BOOST_DATE_TIME_SOURCE so that knows +// the library is being built (possibly exporting rather than importing code) +#ifndef BOOST_DATE_TIME_SOURCE +#define BOOST_DATE_TIME_SOURCE +#endif + +#include + +namespace boost { +namespace gregorian { + + +BOOST_DATE_TIME_DECL void date_time_dummy_exported_function() +{} + +} } //namespace boost::gregorian + + + + + + diff --git a/src/boost/libs/date_time/src/gregorian/greg_names.hpp b/src/boost/libs/date_time/src/gregorian/greg_names.hpp new file mode 100644 index 000000000..f20b320d1 --- /dev/null +++ b/src/boost/libs/date_time/src/gregorian/greg_names.hpp @@ -0,0 +1,43 @@ +/* Copyright (c) 2002-2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + + + +#ifndef DATE_TIME_SRC_GREG_NAMES_HPP___ +#define DATE_TIME_SRC_GREG_NAMES_HPP___ + +#include "boost/date_time/gregorian/greg_month.hpp" +#include "boost/date_time/special_defs.hpp" +namespace boost { +namespace gregorian { + + + const char* const short_month_names[NumMonths]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec", "NAM"}; + const char* const long_month_names[NumMonths]={"January","February","March","April","May","June","July","August","September","October","November","December","NotAMonth"}; + const char* const special_value_names[date_time::NumSpecialValues]={"not-a-date-time","-infinity","+infinity","min_date_time","max_date_time","not_special"}; + + + const char* const short_weekday_names[]={"Sun", "Mon", "Tue", + "Wed", "Thu", "Fri", "Sat"}; + const char* const long_weekday_names[]= {"Sunday","Monday","Tuesday", + "Wednesday", "Thursday", + "Friday", "Saturday"}; + +#ifndef BOOST_NO_STD_WSTRING + const wchar_t* const w_short_month_names[NumMonths]={L"Jan",L"Feb",L"Mar",L"Apr",L"May",L"Jun",L"Jul",L"Aug",L"Sep",L"Oct",L"Nov",L"Dec",L"NAM"}; + const wchar_t* const w_long_month_names[NumMonths]={L"January",L"February",L"March",L"April",L"May",L"June",L"July",L"August",L"September",L"October",L"November",L"December",L"NotAMonth"}; + const wchar_t* const w_special_value_names[date_time::NumSpecialValues]={L"not-a-date-time",L"-infinity",L"+infinity",L"min_date_time",L"max_date_time",L"not_special"}; + + const wchar_t* const w_short_weekday_names[]={L"Sun", L"Mon", L"Tue", + L"Wed", L"Thu", L"Fri", L"Sat"}; + const wchar_t* const w_long_weekday_names[]= {L"Sunday",L"Monday",L"Tuesday", + L"Wednesday", L"Thursday", + L"Friday", L"Saturday"}; +#endif // BOOST_NO_STD_WSTRING +} } // boost::gregorian +#endif // DATE_TIME_SRC_GREG_NAMES_HPP___ diff --git a/src/boost/libs/date_time/src/gregorian/greg_weekday.cpp b/src/boost/libs/date_time/src/gregorian/greg_weekday.cpp new file mode 100644 index 000000000..ffdc96f8e --- /dev/null +++ b/src/boost/libs/date_time/src/gregorian/greg_weekday.cpp @@ -0,0 +1,50 @@ +/* Copyright (c) 2002-2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + + + +#ifndef BOOST_DATE_TIME_SOURCE +#define BOOST_DATE_TIME_SOURCE +#endif +#include "boost/date_time/gregorian/greg_weekday.hpp" + +#include "greg_names.hpp" + +namespace boost { +namespace gregorian { + + //! Return a 3 digit english string of the day of week (eg: Sun) + const char* + greg_weekday::as_short_string() const + { + return short_weekday_names[value_]; + } + //! Return a point to a long english string representing day of week + const char* + greg_weekday::as_long_string() const + { + return long_weekday_names[value_]; + } + +#ifndef BOOST_NO_STD_WSTRING + //! Return a 3 digit english wchar_t string of the day of week (eg: Sun) + const wchar_t* + greg_weekday::as_short_wstring() const + { + return w_short_weekday_names[value_]; + } + //! Return a point to a long english wchar_t string representing day of week + const wchar_t* + greg_weekday::as_long_wstring() const + { + return w_long_weekday_names[value_]; + } +#endif // BOOST_NO_STD_WSTRING + +} } //namespace gregorian + diff --git a/src/boost/libs/date_time/src/gregorian/gregorian_types.cpp b/src/boost/libs/date_time/src/gregorian/gregorian_types.cpp new file mode 100644 index 000000000..7dd7f22bf --- /dev/null +++ b/src/boost/libs/date_time/src/gregorian/gregorian_types.cpp @@ -0,0 +1,62 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + * $Date$ + */ + + +/** @defgroup date_basics Date Basics + This page summarizes some of the key user types and functions needed + to write programs using the gregorian date system. This is not a + comprehensive list, but rather some key types to start exploring. + + +**/ + +/** @defgroup date_alg Date Algorithms / Generators + Date algorithms or generators are tools for generating other dates or + schedules of dates. A generator function starts with some part of a + date such as a month and day and is supplied another part to then + generate a final date. + +**/ + +/** @defgroup date_format Date Formatting + The functions on these page are some of the key formatting functions + for dates. +**/ + + +//File doesn't have a current purpose except to generate docs +//and keep it changeable without recompiles +/*! @example days_alive.cpp + Calculate the number of days you have been living using durations and dates. +*/ +/*! @example days_till_new_year.cpp + Calculate the number of days till new years +*/ +/*! @example print_month.cpp + Simple utility to print out days of the month with the days of a month. Demontstrates date iteration (date_time::date_itr). +*/ +/*! @example localization.cpp + An example showing localized stream-based I/O. +*/ +/*! @example dates_as_strings.cpp + Various parsing and output of strings (mostly supported for + compilers that do not support localized streams). +*/ +/*! @example period_calc.cpp + Calculates if a date is in an 'irregular' collection of periods using + period calculation functions. +*/ +/*! @example print_holidays.cpp + This is an example of using functors to define a holiday schedule + */ +/*! @example localization.cpp + Demonstrates the use of facets to localize date output for Gregorian dates. + */ + + + diff --git a/src/boost/libs/date_time/src/posix_time/posix_time_types.cpp b/src/boost/libs/date_time/src/posix_time/posix_time_types.cpp new file mode 100644 index 000000000..439530104 --- /dev/null +++ b/src/boost/libs/date_time/src/posix_time/posix_time_types.cpp @@ -0,0 +1,35 @@ + +/* Copyright (c) 2002-2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + * $Date$ + */ + + +//File doesn't have a current purpose except to generate docs +//and keep it changeable without recompiles + +/** @defgroup time_basics Time Basics + +**/ + +/** @defgroup time_format Time Formatting + +**/ + + + +/*! @example local_utc_conversion.cpp + Demonstrate utc to local and local to utc calculations including dst. +*/ +/*! @example time_periods.cpp Demonstrate some simple uses of time periods. +*/ +/*! @example print_hours.cpp Demonstrate time iteration, clock retrieval, and simple calculation. + */ +/*! @example time_math.cpp Various types of calculations with times and time durations. + */ + + + diff --git a/src/boost/libs/date_time/test/Jamfile.v2 b/src/boost/libs/date_time/test/Jamfile.v2 new file mode 100644 index 000000000..74da9b90a --- /dev/null +++ b/src/boost/libs/date_time/test/Jamfile.v2 @@ -0,0 +1,168 @@ +import os ; +import path ; +import regex ; +import testing ; + +local DATE_TIME_DYNAMIC_PROPERTIES = BOOST_ALL_DYN_LINK shared BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG BOOST_ALL_NO_LIB ; +local DATE_TIME_PROPERTIES = BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + # FIXME + #std::locale-support + BOOST_ALL_NO_LIB ; + +# core stuff +run testint_adapter.cpp ; +run testtime_resolution_traits.cpp ; +run testwrapping_int.cpp ; +run testconstrained_value.cpp ; +run testgregorian_calendar.cpp ; +run testgeneric_period.cpp ; +# the library dependence below is just to test that the +# stub library will build, it's completely uneeded not that +# date-time is all inline +run testmisc.cpp + ../build//boost_date_time/static + : : : BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + : testmisc_std_cfg ; + +### gregorian + +run gregorian/testdate.cpp ; +run gregorian/testdate_duration.cpp ; +run gregorian/testdate_facet_new.cpp ; +run gregorian/testdate_input_facet.cpp ; +run gregorian/testdate_iterator.cpp ; + +run gregorian/testgenerators.cpp ; +run gregorian/testgreg_cal.cpp ; +run gregorian/testgreg_day.cpp ; +run gregorian/testgreg_durations.cpp ; +run gregorian/testgreg_month.cpp ; +run gregorian/testgreg_year.cpp ; +run gregorian/testformatters.cpp ; +run gregorian/testparse_date.cpp ; +run gregorian/testperiod.cpp ; + +run gregorian/testgreg_serialize.cpp + ../../serialization/build//boost_serialization + : : : DATE_TIME_XML_SERIALIZE + : testgreg_serialize_xml ; + +run gregorian/testgreg_serialize.cpp + ../../serialization/build//boost_serialization + : : : + : testgreg_serialize ; + +run posix_time/testfiletime_functions.cpp ; +run posix_time/testlocal_adjustor.cpp ; +run posix_time/testc_local_adjustor.cpp ; +run posix_time/testclock.cpp ; +run posix_time/testdst_rules.cpp ; +run posix_time/testduration.cpp ; +run posix_time/testiterator.cpp ; +run posix_time/testparse_time.cpp ; +run posix_time/testtime_period.cpp ; +run posix_time/testtime.cpp ; +run posix_time/testmicrosec_time_clock.cpp ; +run posix_time/testgreg_duration_operators.cpp ; +run posix_time/testtime_facet.cpp ; +run posix_time/testtime_input_facet.cpp + : : : BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + : testtime_input_facet ; + +run posix_time/testtime_formatters.cpp + : : : BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + : testtime_formatters ; + +# text archive tests +run posix_time/testtime_serialize.cpp + ../../serialization/build//boost_serialization + : : : + : testtime_serialize ; + +run posix_time/testtime_serialize.cpp + ../../serialization/build//boost_serialization + : : : BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + : testtime_serialize_std_config ; + +# xml archive tests +run posix_time/testtime_serialize.cpp + ../../serialization/build//boost_serialization + : : : DATE_TIME_XML_SERIALIZE BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + : testtime_serialize_xml_std_config ; + +run posix_time/testtime_serialize.cpp + ../../serialization/build//boost_serialization + : : : DATE_TIME_XML_SERIALIZE + : testtime_serialize_xml ; + +# versioning tests +run posix_time/testtime_serialize_versioning.cpp + ../../serialization/build//boost_serialization + : : testtime_serialize_versioning_prev + : BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + : testtime_serialize_versioning_curr ; + +run posix_time/testtime_serialize_versioning.cpp + ../../serialization/build//boost_serialization + : : : BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION=0 + : testtime_serialize_versioning_prev ; + + + + +compile-fail posix_time/compile_fail/hours_special_value.cpp ; +compile-fail posix_time/compile_fail/minutes_special_value.cpp ; +compile-fail posix_time/compile_fail/seconds_special_value.cpp ; +compile-fail posix_time/compile_fail/millisec_special_value.cpp ; + +run local_time/testdst_transition_day_rule.cpp ; +run local_time/testcustom_time_zone.cpp ; +run local_time/testposix_time_zone.cpp ; +run local_time/testwcustom_time_zone.cpp ; +run local_time/testwposix_time_zone.cpp ; +run local_time/testlocal_time.cpp ; +run local_time/testlocal_time_iterator.cpp ; +run local_time/testlocal_time_period.cpp ; + +run local_time/testtz_database.cpp + : : ../data/date_time_zonespec.csv local_time/poorly_formed_zonespec.csv + : ; +run local_time/testlocal_time_facet.cpp + : : ../data/date_time_zonespec.csv : ; +run local_time/testclocks.cpp ; + + +#todo +#if ! [ os.environ UBSAN_OPTIONS ] +#{ +# local DATE_TIME_PROPERTIES = BOOST_ALL_NO_LIB USE_DATE_TIME_PRE_1_33_FACET_IO +# # FIXME +# # std::locale-support toolset::require-boost-spirit-support +# ; + +# Iterate over all public headers and generate a self-contained header test to check for any missing includes +# and basic syntax errors. +if ! [ os.environ BOOST_DATE_TIME_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS ] +{ + local headers_path = [ path.make $(BOOST_ROOT)/libs/date_time/include/boost ] ; + for file in [ path.glob-tree $(headers_path) : *.hpp ] + { + local rel_file = [ path.relative-to $(headers_path) $(file) ] ; + # Note: The test name starts with '~' in order to group these tests in the test report table, preferably at the end. + # All '/' are replaced with '-' because apparently test scripts have a problem with test names containing slashes. + local test_name = [ regex.replace ~hdr/$(rel_file) "/" "-" ] ; + #ECHO $(rel_file) ; + compile self_contained_header.cpp : "BOOST_DATE_TIME_TEST_HEADER=$(rel_file)" $(file) : $(test_name) ; + } +} + + +# Copyright (c) 2000-2020 +# 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) + + + + diff --git a/src/boost/libs/date_time/test/gregorian/testcurrent_day.cpp b/src/boost/libs/date_time/test/gregorian/testcurrent_day.cpp new file mode 100644 index 000000000..e89e32df4 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testcurrent_day.cpp @@ -0,0 +1,37 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include + +int +main() +{ + + boost::gregorian::date d1(boost::gregorian::day_clock::local_day()); + std::cout << "Check the printed date by hand: " + << boost::gregorian::to_iso_string(d1) << std::endl; + + using namespace boost::gregorian; + date::ymd_type ymd = day_clock::local_day_ymd(); + std::cout << ymd.year << "-" + << ymd.month.as_long_string() << "-" + << ymd.day << std::endl; + + date d2(day_clock::universal_day()); + std::cout << "Getting UTC date: " + << to_iso_string(d2) << std::endl; + + date::ymd_type ymd2 = day_clock::universal_day_ymd(); + std::cout << ymd2.year << "-" + << ymd2.month.as_long_string() << "-" + << ymd2.day << std::endl; + + return 0; + +} + diff --git a/src/boost/libs/date_time/test/gregorian/testdate.cpp b/src/boost/libs/date_time/test/gregorian/testdate.cpp new file mode 100644 index 000000000..e8b957ed9 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testdate.cpp @@ -0,0 +1,319 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" +#include +#include + +void test_yearlimit(int yr, bool allowed) +{ + std::stringstream sdesc; + sdesc << "should" << (allowed ? "" : " not") << " be able to make a date in year " << yr; + + try { + boost::gregorian::date chkyr(yr, 1, 1); + check(sdesc.str(), allowed); + } + catch (std::out_of_range&) { check(sdesc.str(), !allowed); } +} + +int +main() +{ + + using namespace boost::gregorian; + + //various constructors +#if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR) + date def; + check("Default constructor", def == date(not_a_date_time)); +#endif + + date d1(1900,1,1); + date d2 = date(2000,1,1); + date d3(d2); + check("Copy constructor", d3 == d2); + date d4(2000,12,31); + date d4a(2000,Dec,31); + //d4a.print(std::cout); std::cout << std::endl; + check("month_rep constructor", d4 == d4a); + //std::cout << d3 << std::endl; + //retrieval functions + check_equal("1900-01-01 day is 01", d1.day(), 1); + check_equal("1900-01-01 month is 01", d1.month(), 1); + check_equal("1900-01-01 year is 1900", d1.year(), 1900); + check_equal("2000-12-31 day is 31", d4.day(), 31); + check_equal("2000-12-31 month is 12", d4.month(), 12); + check_equal("2000-12-31 year is 2000", d4.year(), 2000); + //operator< + check("1900-01-01 is less than 2000-01-01", d1 < d2); + check("2000-01-01 is NOT less than 2000-01-01", !(d1 < d1)); + //operator<= + check("2000-01-01 is less equal than 2000-01-01", d1 <= d1); + //operator> + check("2000-01-01 is greater than 1900-01-01", d2 > d1); + check("2000-01-01 is NOT greater than 2000-01-01", !(d1 < d1)); + //operator>= + check("2000-01-01 is greater equal than 2000-01-01", d1 >= d1); + //operator!= + check("2000-01-01 is NOT equal to 1900-01-01", d2 != d1); + //operator== + check_equal("2000-01-01 is equal 2000-01-01", d3, d2); + check("2000-01-01 is greater equal 2000-01-01", d3 >= d2); + check("2000-01-01 is greater equal 2000-01-01", d3 <= d2); + + date::ymd_type ymd = d1.year_month_day(); + check_equal("ymd year", ymd.year, 1900); + check_equal("ymd month", ymd.month, 1); + check_equal("ymd day", ymd.day, 1); + + //The max function will not compile with Borland 5.5 + //Complains about must specialize basic_data ??? +// std::cout << "Max date is " << (date::max)() << std::endl; +// //std::cout << "Max date is " << (basic_date< date_limits >::max)() << std::endl; +// //std::cout << "Max date is " << (date_limits::max)() << std::endl; + + const date answers[] = {date(1900,Jan,1),date(1900,Jan,4),date(1900,Jan,7), + date(1900,Jan,10),date(1900,Jan,13)}; + date_duration off(3); + date d5(1900,1,1); + for (int i=0; i < 5; ++i) { + //std::cout << d5 << " "; + check(" addition ", d5 == answers[i]); + d5 = d5 + off; + } + std::cout << std::endl; + + const date answers1[] = {date(2000,2,26),date(2000,2,28),date(2000,Mar,1)}; + date d8(2000,Feb,26); + for (int j=0; j < 3; ++j) { + //std::cout << d8 << " "; + check(" more addition ", d8 == answers1[j]); + d8 = d8 + days(2); + } + // std::cout << std::endl; + + date d6(2000,2,28); + date d7(2000,3,1); + date_duration twoDays(2); + date_duration negtwoDays(-2); + date_duration zeroDays(0); + check_equal("2000-03-01 - 2000-02-28 == 2 days", twoDays, (d7-d6)); + check_equal("2000-02-28 - 2000-03-01 == - 2 days", negtwoDays, (d6-d7)); + check_equal("2000-02-28 - 2000-02-28 == 0 days", zeroDays, (d6-d6)); + check_equal("2000-02-28 + 2 days == 2000-03-01 ", d6 + twoDays, d7); + check_equal("2000-03-01 - 2 days == 2000-02-28 ", d7 - twoDays, d6); + check_equal("Add duration to date", date(1999,1,1) + date_duration(365), date(2000,1,1)); + check_equal("Add zero days", date(1999,1,1) + zeroDays, date(1999,1,1)); + //can't do this... + //check("Add date to duration", date_duration(365) + date(1999,1,1) == date(2000,1,1)); + + { + date d(2003,Oct,31); + date_duration dd(55); + d += dd; + check("date += date_duration", d == date(2003,Dec,25)); + d -= dd; + check("date -= date_duration", d == date(2003,Oct,31)); + /* special_values is more thoroughly tested later, + * this is just a test of += & -= with special values */ + d += date_duration(pos_infin); + check("date += inf_dur", d == date(pos_infin)); + d -= dd; + check("inf_date -= dur", d == date(pos_infin)); + } + { + date d(2003,Oct,31); + date_duration dd1(pos_infin), dd2(neg_infin), dd3(not_a_date_time); + check_equal("date + inf_dur", d + dd1, date(pos_infin)); + check_equal("date + inf_dur", d + dd2, date(neg_infin)); + check_equal("date + nan_dur", d + dd3, date(not_a_date_time)); + check_equal("date - inf_dur", d - dd1, date(neg_infin)); + check_equal("date - inf_dur", d - dd2, date(pos_infin)); + check_equal("date - nan_dur", d - dd3, date(not_a_date_time)); + check_equal("inf_date + inf_dur", date(pos_infin) + dd1, date(pos_infin)); + check_equal("inf_date - inf_dur", date(pos_infin) - dd1, date(not_a_date_time)); + check_equal("inf_date + inf_dur", date(neg_infin) + dd1, date(not_a_date_time)); + check_equal("inf_date - inf_dur", date(neg_infin) - dd1, date(neg_infin)); + } + + + try { + date d9(2000, Jan, 32); + check("day out of range", false); + //never reached if working -- but stops compiler warnings :-) + std::cout << "Oops: " << to_iso_string(d9) << std::endl; + } + catch (bad_day_of_month&) { + check("day out of range", true); + } + try { + date d9(2000, Jan, 0); + check("day out of range", false); + //never reached if working -- but stops compiler warnings :-) + std::cout << "Oops: " << to_iso_string(d9) << std::endl; + } + catch (bad_day_of_month&) { + check("day out of range", true); + } + + try { + date d20(2000, Feb, 31); + check("day out of range", false); + //never reached if working -- but stops compiler warnings :-) + std::cout << "Oops: " << to_iso_string(d20) << std::endl; + } + catch (bad_day_of_month&) { + check("day out of range", true); + } + + //more subtle -- one day past in a leap year + try { + date d21(2000, Feb, 30); + check("day out of range", false); + //never reached if working -- but stops compiler warnings :-) + std::cout << "Oops: " << to_iso_string(d21) << std::endl; + } + catch (bad_day_of_month&) { + check("day out of range", true); + } + + //more subtle -- one day past in a leap year + try { + date d22(2000, Feb, 29); + check("last day of month ok", true); + std::cout << to_iso_string(d22) << std::endl; //stop compiler warning + } + catch (bad_day_of_month&) { + check("last day of month -- oops bad exception", false); + } + + //Not a leap year -- now Feb 29 is bad + try { + date d23(1999, Feb, 29); + check("day out of range", false); + //never reached if working -- but stops compiler warnings :-) + std::cout << "Oops: " << to_iso_string(d23) << std::endl; + } + catch (bad_day_of_month&) { + check("day out of range", true); + } + + //check out some special values + check("check not a date - false", !d7.is_not_a_date()); + check("check positive infinity - false", !d7.is_pos_infinity()); + check("check negative infinity - false", !d7.is_neg_infinity()); + + date d10(neg_infin); + check("check negative infinity - true", d10.is_infinity()); + d10 = d10 + twoDays; //still neg infinity + check("check negative infinity - true", d10.is_neg_infinity()); + + date d11(pos_infin); + check("check positive infinity - true", d11.is_infinity()); + d11 = d11 + twoDays; + check("check positive infinity add - true", d11.is_pos_infinity()); + + date d12(not_a_date_time); + check("check not a date", d12.is_not_a_date()); + check("check infinity compare ", d10 != d11); + check("check infinity compare ", d10 < d11); + check("check infinity nad compare ", d12 != d11); + date d13(max_date_time); + check("check infinity - max compare ", d13 < d11); + check_equal("max date_time value ", d13, date(9999,Dec, 31)); + std::cout << to_simple_string(d13) << std::endl; + date d14(min_date_time); + check("check infinity - min compare ", d14 > d10); + std::cout << to_simple_string(d14) << std::endl; + check_equal("min date_time value ", d14, date(1400,Jan, 1)); + + + date d15(1400,1,1); + std::cout << d15.day_of_week().as_long_string() << std::endl; + check("check infinity - min compare ", d10 < d15); + + // most of this testing is in the gregorian_calendar tests + std::cout << d15.julian_day() << std::endl; + check_equal("check julian day ", d15.julian_day(), + static_cast(2232400)); + check_equal("check modjulian day ", d15.modjulian_day(), -167601); + date d16(2004,2,29); + check_equal("check julian day ", d16.julian_day(), + static_cast(2453065)); + check_equal("check modjulian day ", d16.modjulian_day(), + static_cast(53064)); + + // most of this testing is in the gregorian_calendar tests + date d31(2000, Jun, 1); + check_equal("check iso week number ", d31.week_number(), 22); + date d32(2000, Aug, 1); + check_equal("check iso week number ", d32.week_number(), 31); + date d33(2000, Oct, 1); + check_equal("check iso week number ", d33.week_number(), 39); + date d34(2000, Dec, 1); + check_equal("check iso week number ", d34.week_number(), 48); + date d35(2000, Dec, 24); + check_equal("check iso week number ", d35.week_number(), 51); + date d36(2000, Dec, 25); + check_equal("check iso week number ", d36.week_number(), 52); + date d37(2000, Dec, 31); + check_equal("check iso week number ", d37.week_number(), 52); + date d38(2001, Jan, 1); + check_equal("check iso week number ", d38.week_number(), 1); + + try { + int dayofyear1 = d38.day_of_year(); + check_equal("check day of year number", dayofyear1, 1); + check_equal("check day of year number", d37.day_of_year(), 366); + date d39(2001,Dec,31); + check_equal("check day of year number", d39.day_of_year(), 365); + date d40(2000,Feb,29); + check_equal("check day of year number", d40.day_of_year(), 60); + date d41(1400,Jan,1); + check_equal("check day of year number", d41.day_of_year(), 1); + date d42(1400,Jan,1); + check_equal("check day of year number", d42.day_of_year(), 1); + date d43(2002,Nov,17); + check_equal("check day of year number", d43.day_of_year(), 321); + } + catch(std::exception& e) { + std::cout << e.what() << std::endl; + check("check day of year number", false); + } + + //converts to date and back -- should get same result + check_equal("tm conversion functions 2000-1-1", date_from_tm(to_tm(d2)), d2); + check_equal("tm conversion functions 1900-1-1", date_from_tm(to_tm(d1)), d1); + check_equal("tm conversion functions min date 1400-1-1 ", date_from_tm(to_tm(d14)), d14); + check_equal("tm conversion functions max date 9999-12-31", date_from_tm(to_tm(d13)), d13); + + try{ + date d(neg_infin); + tm d_tm = to_tm(d); + check("Exception not thrown (special_value to_tm)", false); + std::cout << d_tm.tm_sec << std::endl; //does nothing useful but stops compiler from complaining about unused d_tm + }catch(std::out_of_range&){ + check("Caught expected exception (special_value to_tm)", true); + }catch(...){ + check("Caught un-expected exception (special_value to_tm)", false); + } + + // trac-13159 + test_yearlimit( 0, false); + test_yearlimit( 1399, false); + test_yearlimit( 1400, true); + test_yearlimit( 1401, true); + test_yearlimit( 9999, true); + test_yearlimit(10000, false); + test_yearlimit(10001, false); + + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/gregorian/testdate_duration.cpp b/src/boost/libs/date_time/test/gregorian/testdate_duration.cpp new file mode 100644 index 000000000..12bee2dbb --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testdate_duration.cpp @@ -0,0 +1,77 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" +#include + + +void test_date_duration() +{ + using namespace boost::gregorian; + + date_duration threeDays(3); + date_duration twoDays(2); + //date_duration zeroDays(0); + check("Self equal case", threeDays == threeDays); + check("Not equal case", !(threeDays == twoDays)); + check("Less case succeed", twoDays < threeDays); + check("Not less case", !(threeDays < twoDays)); + check("Not less case - equal", !(threeDays < threeDays)); + check("Greater than ", !(threeDays > threeDays)); + check("Greater equal ", threeDays >= threeDays); + check("Greater equal - false", !(twoDays >= threeDays)); + check("add", twoDays + threeDays == date_duration(5)); + date_duration fiveDays = threeDays; + fiveDays += twoDays; + check("add", fiveDays == date_duration(5)); + date_duration tenDays = fiveDays; + tenDays += date_duration(5); + check("add", tenDays.days() == 10); + + date_duration derivedOneDay = threeDays - twoDays; + check("Subtraction - neg result", twoDays - threeDays == date_duration(-1)); + date_duration oneDay(1); + check("Subtraction", oneDay == derivedOneDay); + date_duration fiveDaysDerived = tenDays; + fiveDaysDerived -= fiveDays; + check("Subtraction", fiveDaysDerived == fiveDays); + + oneDay = twoDays / 2; + check("Division", oneDay.days() == 1); + date_duration oneDayDivide = threeDays / 2; + check("Division", oneDayDivide.days() == 1); + date_duration hundred(100); + hundred /= -10; + check("Division", hundred.days() == -10 && hundred.is_negative()); + + date_duration pos_dur(123); + date_duration neg_dur(-pos_dur); + check("unary-", neg_dur.days() == -123); + + // special values tests + date_duration pi_dur(pos_infin); + date_duration ni_dur(neg_infin); + date_duration nd_dur(not_a_date_time); + check("pos_inf + neg_inf", (pi_dur + ni_dur) == nd_dur); + //check("inf * integer", (pi_dur * 2) == pi_dur); // not implemented + check("neg_inf / integer", (ni_dur / 3) == ni_dur); + check("inf + dur", (pi_dur + hundred) == pi_dur); + check("unary-", date_duration(-pi_dur) == ni_dur); + +// date_duration dd(1); +// dd++; +// check("Increment", dd == twoDays); + +} + +int main() { + test_date_duration(); + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/gregorian/testdate_facet_new.cpp b/src/boost/libs/date_time/test/gregorian/testdate_facet_new.cpp new file mode 100644 index 000000000..9c6dafbe2 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testdate_facet_new.cpp @@ -0,0 +1,388 @@ + + +/* Copyright (c) 2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "boost/date_time/date_facet.hpp" +#include "../testfrmwk.hpp" +#include +#include + + +template +inline +void +teststreaming(std::string testname, + temporal_type value, + std::basic_string expected_result, + const std::locale& locale = std::locale::classic()) +{ + std::basic_stringstream ss; + ss.imbue(locale); + ss << value; + check_equal(testname, ss.str(), expected_result); +} + + +// collections for adding to facet +const char* const month_short_names[]={"*jan*","*feb*","*mar*", + "*apr*","*may*","*jun*", + "*jul*","*aug*","*sep*", + "*oct*","*nov*","*dec*"}; + +const char* const month_long_names[]={"**January**","**February**","**March**", + "**April**","**May**","**June**", + "**July**","**August**","**September**", + "**October**","**November**","**December**"}; + +const char* const weekday_short_names[]={"day1", "day2","day3","day4", + "day5","day6","day7"}; + +const char* const weekday_long_names[]= {"Sun-0", "Mon-1", "Tue-2", + "Wed-3", "Thu-4", + "Fri-5", "Sat-6"}; + +std::vector > short_weekday_names; +std::vector > long_weekday_names; +std::vector > short_month_names; +std::vector > long_month_names; + +#if !defined(BOOST_NO_STD_WSTRING) +// collections of test results +const std::wstring full_months[]={L"January",L"February",L"March", + L"April",L"May",L"June", + L"July",L"August",L"September", + L"October",L"November",L"December"}; +const std::wstring short_months[]={L"Jan",L"Feb",L"Mar", + L"Apr",L"May",L"Jun", + L"Jul",L"Aug",L"Sep", + L"Oct",L"Nov",L"Dec"}; + +const std::wstring full_weekdays[]= {L"Sunday", L"Monday",L"Tuesday", + L"Wednesday", L"Thursday", + L"Friday", L"Saturday"}; +const std::wstring short_weekdays[]= {L"Sun", L"Mon",L"Tue", + L"Wed", L"Thu", + L"Fri", L"Sat"}; + +//const whcar_t const +#endif // BOOST_NO_STD_WSTRING + +int main() { + using namespace boost::gregorian; + + std::copy(&month_short_names[0], + &month_short_names[12], + std::back_inserter(short_month_names)); + + std::copy(&month_long_names[0], + &month_long_names[12], + std::back_inserter(long_month_names)); + + std::copy(&weekday_short_names[0], + &weekday_short_names[7], + std::back_inserter(short_weekday_names)); + + std::copy(&weekday_long_names[0], + &weekday_long_names[7], + std::back_inserter(long_weekday_names)); + + { + std::stringstream ss; + date d(2004,Oct,31); + date_period dp(d, d + days(7)); + ss << d; + check("to_string & default formats match", + to_simple_string(d) == ss.str()); + ss.str(""); + ss << dp; + check("to_string & default formats match", + to_simple_string(dp) == ss.str()); + } + + { + date d(2004,Oct, 13); + date_period dp(d, d + days(7)); + { + date_facet* datefacet = new date_facet(); + datefacet->format(date_facet::standard_format_specifier); + std::cout.imbue(std::locale(std::locale::classic(), datefacet)); + teststreaming("default classic date", d, std::string("10/13/04"), + std::locale(std::locale::classic(), datefacet)); + std::cout << "default classic date output: " << d << std::endl; + + } + { + date_facet* datefacet = new date_facet(); + datefacet->format(date_facet::standard_format_specifier); + teststreaming("default classic date period", dp, + std::string("[10/13/04/10/19/04]"), + std::locale(std::locale::classic(), datefacet)); + } + + { + date_facet* datefacet = new date_facet(); + datefacet->format("%Y-%d-%b %a"); + teststreaming("custom date facet date period", dp, + std::string("[2004-13-Oct Wed/2004-19-Oct Tue]"), + std::locale(std::locale::classic(), datefacet)); + } + + { + date_facet* datefacet = new date_facet(); + datefacet->set_iso_format(); + teststreaming("custom date facet date", d, + std::string("20041013"), + std::locale(std::locale::classic(), datefacet)); + + } + { + date_facet* datefacet = new date_facet(); + datefacet->set_iso_format(); + teststreaming("custom date facet date period", dp, + std::string("[20041013/20041019]"), + std::locale(std::locale::classic(), datefacet)); + } + + { + date_facet* datefacet = new date_facet(); + datefacet->set_iso_extended_format(); + teststreaming("custom date facet date", d, + std::string("2004-10-13"), + std::locale(std::locale::classic(), datefacet)); + + } + { + date_facet* datefacet = new date_facet(); + datefacet->set_iso_extended_format(); + teststreaming("custom date facet date period", dp, + std::string("[2004-10-13/2004-10-19]"), + std::locale(std::locale::classic(), datefacet)); + } + + { + date_facet* datefacet = new date_facet(); + datefacet->set_iso_extended_format(); + period_formatter pf(period_formatter::AS_OPEN_RANGE, " / ", "[ ", " )", " ]"); + datefacet->period_formatter(pf); + teststreaming("custom date facet date period - open range custom delimeters", dp, + std::string("[ 2004-10-13 / 2004-10-20 )"), + std::locale(std::locale::classic(), datefacet)); + } + + // trac-11142: actually test delimiter_strings(...) + { + date_facet* datefacet = new date_facet(); + datefacet->set_iso_extended_format(); + period_formatter pf(period_formatter::AS_OPEN_RANGE, " / ", "[ ", " )", " ]"); + pf.delimiter_strings(" to ", "from ", " inclusive", " exclusive"); + datefacet->period_formatter(pf); + teststreaming("custom date facet date period - delimiter_strings", dp, + std::string("from 2004-10-13 to 2004-10-20 inclusive"), + std::locale(std::locale::classic(), datefacet)); + } + + { + date_facet* datefacet = new date_facet("%A %b %d, %Y"); + datefacet->short_month_names(short_month_names); + teststreaming("custom date facet -- custom short month names", d, + std::string("Wednesday *oct* 13, 2004"), + std::locale(std::locale::classic(), datefacet)); + } + + { + date_facet* datefacet = new date_facet("%B %A %d, %Y"); + datefacet->long_month_names(long_month_names); + teststreaming("custom date facet -- custom long month names", d, + std::string("**October** Wednesday 13, 2004"), + std::locale(std::locale::classic(), datefacet)); + } + + { + date_facet* datefacet = new date_facet("%a - %b %d, %Y"); + datefacet->short_weekday_names(short_weekday_names); + std::cout.imbue(std::locale(std::locale::classic(), datefacet)); + std::cout << d << std::endl; + teststreaming("custom date facet -- custom short weekday names", d, + std::string("day4 - Oct 13, 2004"), + std::locale(std::locale::classic(), datefacet)); + } + + { + date_facet* datefacet = new date_facet("%b %d, %Y ++ %A"); + datefacet->long_weekday_names(long_weekday_names); + teststreaming("custom date facet -- custom short weekday names", d, + std::string("Oct 13, 2004 ++ Wed-3"), + std::locale(std::locale::classic(), datefacet)); + } + + {//date + date_facet* datefacet = new date_facet("%Y-%b-%d %%d"); + teststreaming("Literal '%' in date format", d, + std::string("2004-Oct-13 %d"), + std::locale(std::locale::classic(), datefacet)); + } + { + date_facet* datefacet = new date_facet("%Y-%b-%d %%%d"); + teststreaming("Multiple literal '%'s in date format", d, + std::string("2004-Oct-13 %13"), + std::locale(std::locale::classic(), datefacet)); + } + { + date d1(2004,Oct, 13); + date_facet* datefacet = new date_facet("%d%m%y"); + teststreaming("Single digit year and %y", d1, + std::string("131004"), + std::locale(std::locale::classic(), datefacet)); + } + {//month + date_facet* datefacet = new date_facet(); + datefacet->month_format("%b %%b"); + teststreaming("Literal '%' in month format", d.month(), + std::string("Oct %b"), + std::locale(std::locale::classic(), datefacet)); + } + { + date_facet* datefacet = new date_facet(); + datefacet->month_format("%b %%%b"); + teststreaming("Multiple literal '%'s in month format", d.month(), + std::string("Oct %Oct"), + std::locale(std::locale::classic(), datefacet)); + } + {//weekday + date_facet* datefacet = new date_facet(); + datefacet->weekday_format("%a %%a"); + teststreaming("Literal '%' in weekday format", d.day_of_week(), + std::string("Wed %a"), + std::locale(std::locale::classic(), datefacet)); + } + { + date_facet* datefacet = new date_facet(); + datefacet->weekday_format("%a %%%a"); + teststreaming("Multiple literal '%'s in weekday format", d.day_of_week(), + std::string("Wed %Wed"), + std::locale(std::locale::classic(), datefacet)); + } + + + + date d_not_date(not_a_date_time); + teststreaming("special value, no special facet", d_not_date, std::string("not-a-date-time")); + + +// std::cout.imbue(std::locale(std::locale::classic(), datefacet)); +// std::cout << d << std::endl; + + + } + + // date_generator tests + { + partial_date pd(31,Oct); + teststreaming("partial date", pd, std::string("31 Oct")); + first_kday_of_month fkd(Tuesday, Sep); + teststreaming("first kday", fkd, std::string("first Tue of Sep")); + nth_kday_of_month nkd2(nth_kday_of_month::second, Tuesday, Sep); + teststreaming("nth kday", nkd2, std::string("second Tue of Sep")); + nth_kday_of_month nkd3(nth_kday_of_month::third, Tuesday, Sep); + teststreaming("nth kday", nkd3, std::string("third Tue of Sep")); + nth_kday_of_month nkd4(nth_kday_of_month::fourth, Tuesday, Sep); + teststreaming("nth kday", nkd4, std::string("fourth Tue of Sep")); + nth_kday_of_month nkd5(nth_kday_of_month::fifth, Tuesday, Sep); + teststreaming("nth kday", nkd5, std::string("fifth Tue of Sep")); + last_kday_of_month lkd(Tuesday, Sep); + teststreaming("last kday", lkd, std::string("last Tue of Sep")); + first_kday_before fkb(Wednesday); + teststreaming("First before", fkb, std::string("Wed before")); + first_kday_after fka(Thursday); + teststreaming("First after", fka, std::string("Thu after")); + } + +#if !defined(BOOST_NO_STD_WSTRING) + date d(2004,Oct, 13); + date_period dp(d, d + days(7)); + date d_not_date(not_a_date_time); + + teststreaming("special value, no special facet wide", d_not_date, + std::wstring(L"not-a-date-time")); + { + wdate_facet* wdatefacet = new wdate_facet(); + wdatefacet->format(wdate_facet::standard_format_specifier); + teststreaming("widestream default classic date", d, + std::wstring(L"10/13/04"), + std::locale(std::locale::classic(), wdatefacet)); + } + { + wdate_facet* wdatefacet = new wdate_facet(); + wdatefacet->format(wdate_facet::standard_format_specifier); + teststreaming("widestream default classic date period", dp, + std::wstring(L"[10/13/04/10/19/04]"), + std::locale(std::locale::classic(), wdatefacet)); + } + { + wdate_facet* wdatefacet = new wdate_facet(); + wdatefacet->format(L"%Y-%d-%b %a"); + teststreaming("widestream custom date facet", d, + std::wstring(L"2004-13-Oct Wed"), + std::locale(std::locale::classic(), wdatefacet)); + } + { + wdate_facet* wdatefacet = new wdate_facet(); + wdatefacet->format(L"%Y-%d-%b %a"); + teststreaming("widestream custom date facet date period", dp, + std::wstring(L"[2004-13-Oct Wed/2004-19-Oct Tue]"), + std::locale(std::locale::classic(), wdatefacet)); + } + { + wdate_facet* wdatefacet = new wdate_facet(); + wdatefacet->set_iso_extended_format(); + wperiod_formatter pf(wperiod_formatter::AS_OPEN_RANGE, L" / ", L"[ ", L" )", L" ]"); + wdatefacet->period_formatter(pf); + teststreaming("custom date facet date period - open range custom delimeters", dp, + std::wstring(L"[ 2004-10-13 / 2004-10-20 )"), + std::locale(std::locale::classic(), wdatefacet)); + } + /************* small gregorian types tests *************/ + wdate_facet* small_types_facet = new wdate_facet(); + std::locale loc = std::locale(std::locale::classic(), small_types_facet); + + // greg_year test + greg_year gy(2004); + teststreaming("greg_year", gy, std::string("2004")); + + // greg_month tests + { + for(greg_month::value_type i = 0; i < 12; ++i) { + greg_month m(i+1); // month numbers 1-12 + teststreaming("greg_month short", m, short_months[i], loc); + } + small_types_facet->month_format(L"%B"); // full name + for(greg_month::value_type i = 0; i < 12; ++i) { + greg_month m(i+1); // month numbers 1-12 + teststreaming("greg_month full", m, full_months[i], loc); + } + } + + // greg_weekday tests + { + for(greg_weekday::value_type i = 0; i < 7; ++i) { + greg_weekday gw(i); // weekday numbers 0-6 + teststreaming("greg_weekday short", gw, short_weekdays[i], loc); + } + small_types_facet->weekday_format(L"%A"); // full name + for(greg_weekday::value_type i = 0; i < 7; ++i) { + greg_weekday gw(i); // weekday numbers 0-6 + teststreaming("greg_weekday full", gw, full_weekdays[i], loc); + } + } +#endif // BOOST_NO_STD_WSTRING + + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/gregorian/testdate_input_facet.cpp b/src/boost/libs/date_time/test/gregorian/testdate_input_facet.cpp new file mode 100644 index 000000000..d0b9c19cc --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testdate_input_facet.cpp @@ -0,0 +1,582 @@ +/* Copyright (c) 2005 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" +#include +#include +#include +#include + +#ifndef USE_DATE_TIME_PRE_1_33_FACET_IO +// for tests that are expected to fail and throw exceptions +template +bool failure_test(temporal_type component, + const std::string& input, + exception_type const& /*except*/, + boost::gregorian::date_input_facet* facet) +{ + using namespace boost::gregorian; + bool result = false; + std::istringstream iss(input); + iss.exceptions(std::ios_base::failbit); // turn on exceptions + iss.imbue(std::locale(std::locale::classic(), facet)); + try { + iss >> component; + } + catch(exception_type& e) { + std::cout << "Expected exception caught: \"" + << e.what() << "\"" << std::endl; + result = iss.fail(); // failbit must be set to pass test + } + catch(...) { + result = false; + } + + return result; +} + +// for tests that are expected to fail quietly +template +bool failure_test(temporal_type component, + const std::string& input, + boost::gregorian::date_input_facet* facet) +{ + using namespace boost::gregorian; + std::istringstream iss(input); + /* leave exceptions turned off + * iss.exceptions(std::ios_base::failbit); */ + iss.imbue(std::locale(std::locale::classic(), facet)); + try { + iss >> component; + } + catch(...) { + std::cout << "Caught unexpected exception" << std::endl; + return false; + } + + return iss.fail(); // failbit must be set to pass test +} + +#endif + + + +int main(){ +#ifndef USE_DATE_TIME_PRE_1_33_FACET_IO + using namespace boost::gregorian; + + { + // verify no extra character are consumed + greg_month m(1); + std::stringstream ss("Mar."); + std::istreambuf_iterator sitr(ss), str_end; + + date_input_facet f; + f.get(sitr, str_end, ss, m); + check("No extra characters consumed", m == greg_month(Mar) && *sitr == '.'); + } + + // set up initial objects + date d(not_a_date_time); + days dd(not_a_date_time); + greg_month m(1); + greg_weekday gw(0); + greg_day gd(1); + greg_year gy(2000); + // exceptions for failure_tests + std::ios_base::failure e_failure("default"); + bad_month e_bad_month; + bad_year e_bad_year; + bad_day_of_month e_bad_day_of_month; + bad_weekday e_bad_weekday; + bad_day_of_year e_bad_day_of_year; + + // default format tests: date, days, month, weekday, day, year + std::istringstream iss("2005-Jan-15 21 Feb Tue 4 2002"); + iss >> d; + check_equal("Default format date", d, date(2005,Jan,15)); + iss >> dd; + check_equal("Default (only) format positive days", dd, days(21)); + iss >> m; + check_equal("Default format month", m, greg_month(2)); + iss >> gw; + check_equal("Default format weekday", gw, greg_weekday(2)); + iss >> gd; + check_equal("Default (only) format day of month", gd, greg_day(4)); + iss >> gy; + check_equal("Default format year", gy, greg_year(2002)); + // failure tests + check("Input Misspelled in year (date) w/exceptions", + failure_test(d, "205-Jan-15", e_bad_year, new date_input_facet())); + check("Input Misspelled in year (date) no-exceptions", + failure_test(d, "205-Jan-15", new date_input_facet())); + check("Input Misspelled in month (date) w/exceptions", + failure_test(d, "2005-Jsn-15", e_bad_month, new date_input_facet())); + check("Input Misspelled in month (date) no-exceptions", + failure_test(d, "2005-Jsn-15", new date_input_facet())); + check("Input Misspelled in day (date) w/exceptions", + failure_test(d, "2005-Jan-51", e_bad_day_of_month, new date_input_facet())); + check("Input Misspelled in day (date) no-exceptions", + failure_test(d, "2005-Jan-51", new date_input_facet())); + check("Input Misspelled greg_weekday w/exceptions", + failure_test(gw, "San", e_bad_weekday, new date_input_facet())); + check("Input Misspelled greg_weekday no-exceptions", + failure_test(gw, "San", new date_input_facet())); + check("Input Misspelled month w/exceptions", + failure_test(m, "Jsn", e_bad_month, new date_input_facet())); + check("Input Misspelled month no-exceptions", + failure_test(m, "Jsn", new date_input_facet())); + check("Bad Input greg_day w/exceptions", + failure_test(gd, "Sun", e_bad_day_of_month, new date_input_facet())); + check("Bad Input greg_day no-exceptions", + failure_test(gd, "Sun", new date_input_facet())); + check("Input Misspelled greg_year w/exceptions", + failure_test(gy, "205", e_bad_year, new date_input_facet())); + check("Input Misspelled greg_year no-exceptions", + failure_test(gy, "205", new date_input_facet())); + + // change to full length names, iso date format, and 2 digit year + date_input_facet* facet = new date_input_facet(); + facet->set_iso_format(); + facet->month_format("%B"); + facet->weekday_format("%A"); + facet->year_format("%y"); + iss.str("20050115 -55 February Tuesday 02"); + iss.imbue(std::locale(std::locale::classic(), facet)); + + iss >> d; + check_equal("ISO format date", d, date(2005,Jan,15)); + iss >> dd; + check_equal("Default (only) format negative days", dd, days(-55)); + iss >> m; + check_equal("Full format month", m, greg_month(2)); + iss >> gw; + check_equal("Full format weekday", gw, greg_weekday(2)); + iss >> gy; + check_equal("2 digit format year", gy, greg_year(2002)); + + date_input_facet* f1 = new date_input_facet(); + date_input_facet* f2 = new date_input_facet(); + f1->set_iso_format(); + f2->set_iso_format(); + check("Missing digit(s) in ISO string", failure_test(d,"2005071", f1)); + check("Missing digit(s) in ISO string", + failure_test(d,"2005071", e_bad_day_of_month, f2)); + + { // literal % in format tests + date dx(not_a_date_time); + greg_month mx(1); + greg_weekday gwx(0); + greg_year y(1400); + date_input_facet* f = new date_input_facet("%%d %Y-%b-%d"); + std::stringstream ss; + ss.imbue(std::locale(ss.getloc(), f)); + + ss.str("%d 2005-Jun-14"); + ss >> dx; + check_equal("Literal '%' in date format", dx, date(2005,Jun,14)); + f->format("%%%d %Y-%b-%d"); + ss.str("%14 2005-Jun-14"); + ss >> dx; + check_equal("Multiple literal '%'s in date format", dx, date(2005,Jun,14)); + + f->month_format("%%b %b"); + ss.str("%b Jun"); + ss >> mx; + check_equal("Literal '%' in month format", mx, greg_month(6)); + f->month_format("%%%b"); + ss.str("%Jun"); + ss >> mx; + check_equal("Multiple literal '%'s in month format", mx, greg_month(6)); + + f->weekday_format("%%a %a"); + ss.str("%a Tue"); + ss >> gwx; + check_equal("Literal '%' in weekday format", gwx, greg_weekday(2)); + f->weekday_format("%%%a"); + ss.str("%Tue"); + ss >> gwx; + check_equal("Multiple literal '%'s in weekday format", gwx, greg_weekday(2)); + + f->year_format("%%Y %Y"); + ss.str("%Y 2005"); + ss >> y; + check_equal("Literal '%' in year format", y, greg_year(2005)); + f->year_format("%%%Y"); + ss.str("%2005"); + ss >> y; + check_equal("Multiple literal '%'s in year format", y, greg_year(2005)); + + f->year_format("%Y%"); + ss.str("2005%"); + ss >> y; + check_equal("Trailing'%'s in year format", y, greg_year(2005)); + } + + // All days, month, weekday, day, and year formats have been tested + // begin testing other date formats + facet->set_iso_extended_format(); + iss.str("2005-01-15"); + iss >> d; + check_equal("ISO Extended format date", d, date(2005,Jan,15)); + + facet->format("%B %d, %Y"); + iss.str("March 15, 2006"); + iss >> d; + check_equal("Custom date format: \"%B %d, %Y\" => 'March 15, 2006'", + d, date(2006,Mar,15)); + + facet->format("%Y-%j"); // Ordinal format ISO8601(2000 sect 5.2.2.1 extended) + iss.str("2006-074"); + iss >> d; + check_equal("Custom date format: \"%Y-%j\" => '2006-074'", + d, date(2006,Mar,15)); + check("Bad input Custom date format: \"%Y-%j\" => '2006-74' (w/exceptions)", + failure_test(d, "2006-74", e_bad_day_of_year, facet)); + check("Bad input Custom date format: \"%Y-%j\" => '2006-74' (no exceptions)", + failure_test(d, "2006-74", facet)); + + // date_period tests + + // A date_period is constructed with an open range. So the periods + // [2000-07--04/2000-07-25) <-- open range + // And + // [2000-07--04/2000-07-24] <-- closed range + // Are equal + date begin(2002, Jul, 4); + days len(21); + date_period dp(date(2000,Jan,1), days(1)); + iss.str("[2002-07-04/2002-07-24]"); + facet->set_iso_extended_format(); + iss >> dp; + check_equal("Default period (closed range)", dp, date_period(begin,len)); + { + std::stringstream ss; + date dx(not_a_date_time); + date d2 = day_clock::local_day(); + date d3(neg_infin); + date d4(pos_infin); + date_period dpx(d2, dx); // date/nadt + date_period dp2(dx, dx); // nadt/nadt + date_period dp3(d3, d4); + ss << dpx; + ss >> dp2; + check_equal("Special values period (reversibility test)", dpx, dp2); + ss.str("[-infinity/+infinity]"); + ss >> dp2; + check_equal("Special values period (infinities)", dp3, dp2); + } + + + // open range + period_parser pp(period_parser::AS_OPEN_RANGE); + iss.str("[2002-07-04/2002-07-25)"); + facet->period_parser(pp); + iss >> dp; + check_equal("Open range period", dp, date_period(begin,len)); + // custom period delimiters + pp.delimiter_strings(" to ", "from ", " exclusive", " inclusive"); + iss.str("from 2002-07-04 to 2002-07-25 exclusive"); + facet->period_parser(pp); + iss >> dp; + check_equal("Open range period - custom delimiters", dp, date_period(begin,len)); + pp.range_option(period_parser::AS_CLOSED_RANGE); + iss.str("from 2002-07-04 to 2002-07-24 inclusive"); + facet->period_parser(pp); + iss >> dp; + check_equal("Closed range period - custom delimiters", dp, date_period(begin,len)); + + + // date_generator tests + + // date_generators use formats contained in the + // date_input_facet for weekdays and months + // reset month & weekday formats to defaults + facet->month_format("%b"); + facet->weekday_format("%a"); + + partial_date pd(1,Jan); + nth_kday_of_month nkd(nth_kday_of_month::first, Sunday, Jan); + first_kday_of_month fkd(Sunday, Jan); + last_kday_of_month lkd(Sunday, Jan); + first_kday_before fkb(Sunday); + first_kday_after fka(Sunday); + // using default date_generator_parser "nth_strings" + iss.str("29 Feb"); + iss >> pd; + // Feb-29 is a valid date_generator, get_date() will fail in a non-leap year + check_equal("Default strings, partial_date", + pd.get_date(2004), date(2004,Feb,29)); + iss.str("second Mon of Mar"); + iss >> nkd; + check_equal("Default strings, nth_day_of_the_week_in_month", + nkd.get_date(2004), date(2004,Mar,8)); + iss.str("first Tue of Apr"); + iss >> fkd; + check_equal("Default strings, first_day_of_the_week_in_month", + fkd.get_date(2004), date(2004,Apr,6)); + iss.str("last Wed of May"); + iss >> lkd; + check_equal("Default strings, last_day_of_the_week_in_month", + lkd.get_date(2004), date(2004,May,26)); + iss.str("Thu before"); + iss >> fkb; + check_equal("Default strings, first_day_of_the_week_before", + fkb.get_date(date(2004,Feb,8)), date(2004,Feb,5)); + iss.str("Fri after"); + iss >> fka; + check_equal("Default strings, first_day_of_the_week_after", + fka.get_date(date(2004,Feb,1)), date(2004,Feb,6)); + // failure tests + check("Incorrect elements (date_generator) w/exceptions", // after/before type mixup + failure_test(fkb, "Fri after", e_failure, new date_input_facet())); + check("Incorrect elements (date_generator) no exceptions", // after/before type mixup + failure_test(fkb, "Fri after", new date_input_facet())); + check("Incorrect elements (date_generator) w/exceptions", // first/last type mixup + failure_test(lkd, "first Tue of Apr", e_failure, new date_input_facet())); + check("Incorrect elements (date_generator) no exceptions", // first/last type mixup + failure_test(lkd, "first Tue of Apr", new date_input_facet())); + check("Incorrect elements (date_generator) w/exceptions", // 'in' is wrong + failure_test(nkd, "second Mon in Mar", e_failure, new date_input_facet())); + check("Incorrect elements (date_generator) no exceptions", // 'in' is wrong + failure_test(nkd, "second Mon in Mar", new date_input_facet())); + + // date_generators - custom element strings + facet->date_gen_element_strings("1st","2nd","3rd","4th","5th","final","prior to","past","in"); + iss.str("3rd Sat in Jul"); + iss >> nkd; + check_equal("Custom strings, nth_day_of_the_week_in_month", + nkd.get_date(2004), date(2004,Jul,17)); + iss.str("1st Wed in May"); + iss >> fkd; + check_equal("Custom strings, first_day_of_the_week_in_month", + fkd.get_date(2004), date(2004,May,5)); + iss.str("final Tue in Apr"); + iss >> lkd; + check_equal("Custom strings, last_day_of_the_week_in_month", + lkd.get_date(2004), date(2004,Apr,27)); + iss.str("Fri prior to"); + iss >> fkb; + check_equal("Custom strings, first_day_of_the_week_before", + fkb.get_date(date(2004,Feb,8)), date(2004,Feb,6)); + iss.str("Thu past"); + iss >> fka; + check_equal("Custom strings, first_day_of_the_week_after", + fka.get_date(date(2004,Feb,1)), date(2004,Feb,5)); + + // date_generators - special case with empty element string + /* Doesn't work. Empty string returns -1 from string_parse_tree + * because it attempts to match the next set of characters in the + * stream to the wrong element. Ex. It attempts to match "Mar" to + * the 'of' element in the test below. + * + facet->date_gen_element_strings("1st","2nd","3rd","4th","5th","final","prior to","past",""); // the 'of' string is an empty string + iss.str("final Mon Mar"); + iss >> lkd; + check_equal("Special case, empty element string", + lkd.get_date(2005), date(2005,Mar,28)); + */ + + + // special values tests (date and days only) + iss.str("minimum-date-time +infinity"); + iss >> d; + iss >> dd; + check_equal("Special values, default strings, min_date_time date", + d, date(min_date_time)); + check_equal("Special values, default strings, pos_infin days", + dd, days(pos_infin)); + iss.str("-infinity maximum-date-time"); + iss >> d; + iss >> dd; + check_equal("Special values, default strings, neg_infin date", + d, date(neg_infin)); + check_equal("Special values, default strings, max_date_time days", + dd, days(max_date_time)); + iss.str("not-a-date-time"); + iss >> d; + check_equal("Special values, default strings, not_a_date_time date", + d, date(not_a_date_time)); + + // in addition check that special_value_from_string also works correctly for other special values + check_equal("Special values, default strings, not_special test", + special_value_from_string("not_special"), not_special); + check_equal("Special values, default strings, junk test", + special_value_from_string("junk"), not_special); + + // special values custom, strings + special_values_parser svp("NADT", "MINF", "INF", "MINDT", "MAXDT"); + facet->special_values_parser(svp); + iss.str("MINDT INF"); + iss >> d; + iss >> dd; + check_equal("Special values, custom strings, min_date_time date", + d, date(min_date_time)); + check_equal("Special values, custom strings, pos_infin days", + dd, days(pos_infin)); + iss.str("MINF MAXDT"); + iss >> d; + iss >> dd; + check_equal("Special values, custom strings, neg_infin date", + d, date(neg_infin)); + check_equal("Special values, custom strings, max_date_time days", + dd, days(max_date_time)); + iss.str("NADT"); + iss >> dd; + check_equal("Special values, custom strings, not_a_date_time days", + dd, days(not_a_date_time)); + // failure test + check("Misspelled input, special_value date w/exceptions", + failure_test(d, "NSDT", e_bad_year, new date_input_facet())); + check("Misspelled input, special_value date no exceptions", + failure_test(d, "NSDT", new date_input_facet())); + check("Misspelled input, special_value days w/exceptions", + failure_test(dd, "NSDT", e_failure, new date_input_facet())); + check("Misspelled input, special_value days no exceptions", + failure_test(dd, "NSDT", new date_input_facet())); + + { + // German names. Please excuse any errors, I don't speak German and + // had to rely on an on-line translation service. + // These tests check one of each (at least) from all sets of custom strings + + // create a custom format_date_parser + std::string m_a[] = {"Jan","Feb","Mar","Apr","Mai", + "Jun","Jul","Aug","Sep","Okt","Nov","Dez"}; + std::string m_f[] = {"Januar","Februar","Marz","April", + "Mai","Juni","Juli","August", + "September","Oktober","November","Dezember"}; + std::string w_a[] = {"Son", "Mon", "Die","Mit", "Don", "Fre", "Sam"}; + std::string w_f[] = {"Sonntag", "Montag", "Dienstag","Mittwoch", + "Donnerstag", "Freitag", "Samstag"}; + typedef boost::date_time::format_date_parser date_parser; + date_parser::input_collection_type months_abbrev; + date_parser::input_collection_type months_full; + date_parser::input_collection_type wkdays_abbrev; + date_parser::input_collection_type wkdays_full; + months_abbrev.assign(m_a, m_a+12); + months_full.assign(m_f, m_f+12); + wkdays_abbrev.assign(w_a, w_a+7); + wkdays_full.assign(w_f, w_f+7); + date_parser d_parser("%B %d %Y", + months_abbrev, months_full, + wkdays_abbrev, wkdays_full); + + // create a special_values parser + special_values_parser sv_parser("NichtDatumzeit", + "Negativ Unendlichkeit", + "Positiv Unendlichkeit", + "Wenigstes Datum", + "Maximales Datum"); + + // create a period_parser + period_parser p_parser; // default will do + // create date_generator_parser + typedef boost::date_time::date_generator_parser date_gen_parser; + date_gen_parser dg_parser("Zuerst","Zweitens","Dritt","Viert", + "F\xC3\xBCnft","Letzt","Vor","Nach","Von"); + + // create the date_input_facet + date_input_facet* de_facet = + new date_input_facet("%B %d %Y", + d_parser, + sv_parser, + p_parser, + dg_parser); + std::istringstream iss2; + iss2.imbue(std::locale(std::locale::classic(), de_facet)); + // June 06 2005, Dec, minimum date, Tues + iss2.str("Juni 06 2005 Dez Wenigstes Datum Die"); + iss2 >> d; + iss2 >> m; + check_equal("German names: date", d, date(2005, Jun, 6)); + check_equal("German names: month", m, greg_month(Dec)); + iss2 >> d; + iss2 >> gw; + check_equal("German names: special value date", d, date(min_date_time)); + check_equal("German names: short weekday", gw, greg_weekday(Tuesday)); + de_facet->weekday_format("%A"); // long weekday + // Tuesday, Second Tuesday of Mar + iss2.str("Dienstag Zweitens Dienstag von Mar"); + iss2 >> gw; + iss2 >> nkd; + check_equal("German names: long weekday", gw, greg_weekday(Tuesday)); + check_equal("German names, nth_day_of_the_week_in_month", + nkd.get_date(2005), date(2005,Mar,8)); + // Tuesday after + iss2.str("Dienstag Nach"); + iss2 >> fka; + check_equal("German names, first_day_of_the_week_after", + fka.get_date(date(2005,Apr,5)), date(2005,Apr,12)); + } + + { + // test name replacement functions + + // collections for adding to facet + const char* const month_short_names[]={"*jan*","*feb*","*mar*", + "*apr*","*may*","*jun*", + "*jul*","*aug*","*sep*", + "*oct*","*nov*","*dec*"}; + const char* const month_long_names[]={"**January**","**February**","**March**", + "**April**","**May**","**June**", + "**July**","**August**","**September**", + "**October**","**November**","**December**"}; + const char* const weekday_short_names[]={"day1", "day2","day3","day4", + "day5","day6","day7"}; + const char* const weekday_long_names[]= {"Sun-0", "Mon-1", "Tue-2", + "Wed-3", "Thu-4", + "Fri-5", "Sat-6"}; + + std::vector > short_weekday_names; + std::vector > long_weekday_names; + std::vector > short_month_names; + std::vector > long_month_names; + + std::copy(&weekday_short_names[0], + &weekday_short_names[7], + std::back_inserter(short_weekday_names)); + std::copy(&weekday_long_names[0], + &weekday_long_names[7], + std::back_inserter(long_weekday_names)); + std::copy(&month_short_names[0], + &month_short_names[12], + std::back_inserter(short_month_names)); + std::copy(&month_long_names[0], + &month_long_names[12], + std::back_inserter(long_month_names)); + + date dx(not_a_date_time); + date_input_facet* facetx = new date_input_facet(); + std::stringstream ss; + ss.imbue(std::locale(std::locale::classic(), facetx)); + facetx->short_month_names(short_month_names); + facetx->short_weekday_names(short_weekday_names); + facetx->long_month_names(long_month_names); + facetx->long_weekday_names(long_weekday_names); + facetx->format("%a %b %d, %Y"); + ss.str("day7 *apr* 23, 2005"); + ss >> dx; + check_equal("Short custom names, set via accessor function", dx.day_of_week(), greg_weekday(6)); + check_equal("Short custom names, set via accessor function", dx.month(), greg_month(4)); + ss.str(""); + ss.str("Sun-0 **April** 24, 2005"); + facetx->format("%A %B %d, %Y"); + ss >> dx; + check_equal("Long custom names, set via accessor function", dx.day_of_week(), greg_weekday(0)); + check_equal("Long custom names, set via accessor function", dx.month(), greg_month(4)); + + } +#else + check("This test is a nop for platforms with USE_DATE_TIME_PRE_1_33_FACET_IO", + true); +#endif + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/gregorian/testdate_iterator.cpp b/src/boost/libs/date_time/test/gregorian/testdate_iterator.cpp new file mode 100644 index 000000000..f82e3d22f --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testdate_iterator.cpp @@ -0,0 +1,367 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" +#include + + +void test_month_decrement_iterator(const boost::gregorian::date *Answers, int array_len){ + using namespace boost::gregorian; + typedef boost::date_time::month_functor mfg; + + boost::date_time::date_itr ditr(Answers[array_len-1]); + int i = array_len-1; + std::cout << "month iter decrement test..." << std::endl; + try { + for (; ditr > Answers[0] - date_duration(1); --ditr) { + check("month iterator: " + to_iso_string(*ditr), Answers[i] == *ditr); + i--; + } + check("month iterator iteration count", i == -1); + } + catch(std::exception& e) + { + check("month iterator: exception failure", false); + std::cout << e.what() << std::endl; + } +} + +void test_base_iterator(boost::gregorian::date end, + boost::gregorian::date_iterator& di, + std::string& data) +{ + using namespace boost::gregorian; + for (; di < end; ++di) { + data += to_iso_string(*di) + " "; + } +} + +int +main() +{ + using namespace boost::gregorian; + + day_iterator di(date(2002,Jan,1)); + std::string data; + test_base_iterator(date(2002,Jan,3),di,data); + month_iterator di2(date(2002,Jan,3)); + test_base_iterator(date(2002,Mar,1),di2,data); + std::string result("20020101 20020102 20020103 20020203 "); + check("base iterator", data == result); + std::cout << data << std::endl; + + + typedef boost::date_time::day_functor dfg; + + { + const date DayAnswers[] = {date(2000,Jan,20),date(2000,Jan,22),date(2000,Jan,24)}; + boost::date_time::date_itr ditr(date(2000,Jan,20),2); + int i=0; + for (; ditr < date(2000,Jan,25); ++ditr) { + //std::cout << *ditr << " "; + check("day iterator -- 2 days", DayAnswers[i] == *ditr); + i++; + } + check("day iterator -- 2 days", i == 3); // check the number of iterations + // decrement + i = 2; + --ditr; + for (; ditr > date(2000,Jan,19); --ditr) { + //std::cout << *ditr << " "; + check("day iterator decrement -- 2 days", DayAnswers[i] == *ditr); + i--; + } + check("day iterator decrement -- 2 days", i == -1); // check the number of iterations + } + + typedef boost::date_time::week_functor wfg; + { + const date WeekAnswers[] = {date(2000,Jan,20),date(2000,Jan,27),date(2000,Feb,3)}; + boost::date_time::date_itr ditr(date(2000,Jan,20)); + int i=0; + for (; ditr < date(2000,Feb,6); ++ditr) { + //std::cout << *ditr << " "; + check("week iterator", WeekAnswers[i] == *ditr); + i++; + } + check("week iterator", i == 3); + // decrement + i=2; + --ditr; + for (; ditr > date(2000,Jan,19); --ditr) { + //std::cout << *ditr << " "; + check("week iterator", WeekAnswers[i] == *ditr); + i--; + } + check("week iterator", i == -1); + } + + { + const date WeekAnswers[] = {date(2000,Jan,20),date(2000,Feb,3)}; + boost::date_time::date_itr ditr(date(2000,Jan,20),2); + int i=0; + for (; ditr < date(2000,Feb,6); ++ditr) { + //std::cout << *ditr << " "; + check("week iterator", WeekAnswers[i] == *ditr); + i++; + } + check("week iterator", i == 2); + // decrement + i=1; + --ditr; + for (; ditr > date(2000,Jan,19); --ditr) { + //std::cout << *ditr << " "; + check("week iterator", WeekAnswers[i] == *ditr); + i--; + } + check("week iterator", i == -1); + } + + { + const date WeekAnswers[] = {date(2000,Jan,20),date(2000,Feb,3), date(2000,Feb,17)}; + boost::date_time::date_itr ditr(date(2000,Jan,20),2); + int i=0; + for (; ditr < date(2000,Feb,20); ++ditr) { + //std::cout << *ditr << " "; + check("week iterator -- 2 weeks", WeekAnswers[i] == *ditr); + i++; + } + check("week iterator -- 2 weeks", i == 3); + // decrement + i=2; + --ditr; + for (; ditr > date(2000,Jan,19); --ditr) { + //std::cout << *ditr << " "; + check("week iterator -- 2 weeks", WeekAnswers[i] == *ditr); + i--; + } + check("week iterator -- 2 weeks", i == -1); + } + + typedef boost::date_time::month_functor mfg; + { + const date MonthAnswers[] = { + date(2000,Jan,1),date(2000,Feb,1),date(2000,Mar,1),date(2000,Apr,1), + date(2000,May,1),date(2000,Jun,1),date(2000,Jul,1),date(2000,Aug,1), + date(2000,Sep,1),date(2000,Oct,1),date(2000,Nov,1),date(2000,Dec,1), + date(2001,Jan,1) + }; + test_month_decrement_iterator(MonthAnswers, 13); + + boost::date_time::date_itr ditr(date(2000,Jan,1)); + int i = 0; + try { + for (; ditr < date(2001,Jan,2); ++ditr) { + check("month iterator: " + to_iso_string(*ditr), MonthAnswers[i] == *ditr); + i++; + } + check("month iterator iteration count", i == 13); + } + catch(std::exception& e) + { + check("month iterator: exception failure", false); + std::cout << e.what() << std::endl; + } + } + + { + const date MonthAnswers[] = { + date(2000,Jan,31),date(2000,Feb,29),date(2000,Mar,31),date(2000,Apr,30), + date(2000,May,31),date(2000,Jun,30),date(2000,Jul,31),date(2000,Aug,31), + date(2000,Sep,30),date(2000,Oct,31),date(2000,Nov,30),date(2000,Dec,31), + date(2001,Jan,31) + }; + test_month_decrement_iterator(MonthAnswers, 13); + + boost::date_time::date_itr ditr(date(2000,Jan,31)); + int i = 0; + try { + for (; ditr < date(2001,Feb,1); ++ditr) { + // std::cout << *ditr << " "; + check("last day of month iterator: " + to_iso_string(*ditr), + MonthAnswers[i] == *ditr); + //check("last day of month iterator", MonthAnswers[i] == *ditr); + i++; + } + check("last day of month iterator", i == 13); + } + catch(std::exception& e) + { + check("last day of month iterator: exception failure", false); + std::cout << e.what() << std::endl; + } + } + + { + const date MonthAnswers[] = { + date(2000,Feb,29),date(2000,Mar,31),date(2000,Apr,30), + date(2000,May,31),date(2000,Jun,30),date(2000,Jul,31),date(2000,Aug,31), + date(2000,Sep,30),date(2000,Oct,31),date(2000,Nov,30),date(2000,Dec,31), + date(2001,Jan,31),date(2001,Feb,28) + }; + test_month_decrement_iterator(MonthAnswers, 13); + + boost::date_time::date_itr ditr(date(2000,Feb,29)); + int i = 0; + try { + for (; ditr < date(2001,Mar,1); ++ditr) { + // std::cout << *ditr << " "; + check("last day of month iterator2: " + to_iso_string(*ditr), + MonthAnswers[i] == *ditr); + //check("last day of month iterator", MonthAnswers[i] == *ditr); + i++; + } + check("last day of month iterator2", i == 13); + } + catch(std::exception& e) + { + check("last day of month iterator: exception failure", false); + std::cout << e.what() << std::endl; + } + } + + { // running a span of 5 years to verify snap to end doesn't occur at next leap year + const date MonthAnswers[] = { + date(2000,Feb,28),date(2000,Mar,28),date(2000,Apr,28),date(2000,May,28), + date(2000,Jun,28),date(2000,Jul,28),date(2000,Aug,28),date(2000,Sep,28), + date(2000,Oct,28),date(2000,Nov,28),date(2000,Dec,28),date(2001,Jan,28), + date(2001,Feb,28),date(2001,Mar,28),date(2001,Apr,28),date(2001,May,28), + date(2001,Jun,28),date(2001,Jul,28),date(2001,Aug,28),date(2001,Sep,28), + date(2001,Oct,28),date(2001,Nov,28),date(2001,Dec,28),date(2002,Jan,28), + date(2002,Feb,28),date(2002,Mar,28),date(2002,Apr,28),date(2002,May,28), + date(2002,Jun,28),date(2002,Jul,28),date(2002,Aug,28),date(2002,Sep,28), + date(2002,Oct,28),date(2002,Nov,28),date(2002,Dec,28),date(2003,Jan,28), + date(2003,Feb,28),date(2003,Mar,28),date(2003,Apr,28),date(2003,May,28), + date(2003,Jun,28),date(2003,Jul,28),date(2003,Aug,28),date(2003,Sep,28), + date(2003,Oct,28),date(2003,Nov,28),date(2003,Dec,28),date(2004,Jan,28), + date(2004,Feb,28),date(2004,Mar,28),date(2004,Apr,28),date(2004,May,28), + date(2004,Jun,28),date(2004,Jul,28),date(2004,Aug,28),date(2004,Sep,28), + date(2004,Oct,28),date(2004,Nov,28),date(2004,Dec,28),date(2005,Jan,28), + }; + test_month_decrement_iterator(MonthAnswers, 60); + + boost::date_time::date_itr ditr(date(2000,Feb,28)); + int i = 0; + try { + for (; ditr < date(2005,Feb,1); ++ditr) { + // std::cout << *ditr << " "; + check("last day of month iterator3: " + to_iso_string(*ditr), + MonthAnswers[i] == *ditr); + //check("last day of month iterator", MonthAnswers[i] == *ditr); + i++; + } + check("last day of month iterator3", i == 60); + } + catch(std::exception& e) + { + check("last day of month iterator: exception failure", false); + std::cout << e.what() << std::endl; + } + } + + typedef boost::date_time::year_functor yfg; + { + const date YearAnswers[] = { + date(2000,Jan,1),date(2001,Jan,1),date(2002,Jan,1),date(2003,Jan,1), + date(2004,Jan,1),date(2005,Jan,1),date(2006,Jan,1),date(2007,Jan,1), + date(2008,Jan,1),date(2009,Jan,1),date(2010,Jan,1) + }; + + boost::date_time::date_itr d3(date(2000,Jan,1)); + int i = 0; + for (; d3 < date(2010,Jan,2); ++d3) { + //std::cout << *d3 << " "; + check("year iterator: " + to_iso_string(*d3), YearAnswers[i] == *d3); + i++; + } + std::cout << "Decrementing...." << std::endl; + i = 10; + --d3; + for (; d3 > date(1999,Dec,31); --d3) { + //std::cout << *d3 << " "; + check("year iterator: " + to_iso_string(*d3), YearAnswers[i] == *d3); + i--; + } + } + { // WON'T snap top end of month + const date YearAnswers[] = { + date(2000,Feb,28),date(2001,Feb,28),date(2002,Feb,28),date(2003,Feb,28), + date(2004,Feb,28),date(2005,Feb,28),date(2006,Feb,28),date(2007,Feb,28), + date(2008,Feb,28),date(2009,Feb,28),date(2010,Feb,28) + }; + + boost::date_time::date_itr d3(date(2000,Feb,28)); + int i = 0; + for (; d3 < date(2010,Mar,1); ++d3) { + //std::cout << *d3 << " "; + check("year iterator: " + to_iso_string(*d3), YearAnswers[i] == *d3); + i++; + } + std::cout << "Decrementing...." << std::endl; + i = 10; + --d3; + for (; d3 > date(2000,Feb,27); --d3) { + //std::cout << *d3 << " "; + check("year iterator: " + to_iso_string(*d3), YearAnswers[i] == *d3); + i--; + } + } + {// WILL snap top end of month + const date YearAnswers[] = { + date(2000,Feb,29),date(2001,Feb,28),date(2002,Feb,28),date(2003,Feb,28), + date(2004,Feb,29),date(2005,Feb,28),date(2006,Feb,28),date(2007,Feb,28), + date(2008,Feb,29),date(2009,Feb,28),date(2010,Feb,28) + }; + + boost::date_time::date_itr d3(date(2000,Feb,29)); + int i = 0; + for (; d3 < date(2010,Mar,1); ++d3) { + //std::cout << *d3 << " "; + check("year iterator: " + to_iso_string(*d3), YearAnswers[i] == *d3); + i++; + } + std::cout << "Decrementing...." << std::endl; + i = 10; + --d3; + for (; d3 > date(2000,Feb,27); --d3) { + //std::cout << *d3 << " "; + check("year iterator: " + to_iso_string(*d3), YearAnswers[i] == *d3); + i--; + } + } + + { + std::cout << "Increment by 2 years...." << std::endl; + const date YearAnswers[] = { + date(2000,Jan,1),date(2002,Jan,1), + date(2004,Jan,1),date(2006,Jan,1), + date(2008,Jan,1),date(2010,Jan,1) + }; + + boost::date_time::date_itr d3(date(2000,Jan,1),2); + int i = 0; + for (; d3 < date(2010,Jan,2); ++d3) { + //std::cout << *d3 << " "; + check("year iterator: " + to_iso_string(*d3), YearAnswers[i] == *d3); + i++; + } + // decrement + std::cout << "Decrementing...." << std::endl; + i = 5; + --d3; + for (; d3 > date(1999,Dec,31); --d3) { + //std::cout << *d3 << " "; + check("year iterator: " + to_iso_string(*d3), YearAnswers[i] == *d3); + i--; + } + } + + + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/gregorian/testfacet.cpp b/src/boost/libs/date_time/test/gregorian/testfacet.cpp new file mode 100644 index 000000000..82a7253db --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testfacet.cpp @@ -0,0 +1,342 @@ +/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include +#include +#include + +#include "boost/date_time/gregorian/greg_month.hpp" +#include "boost/date_time/gregorian/greg_facet.hpp" +#include "boost/date_time/date_format_simple.hpp" +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" + +#ifndef BOOST_DATE_TIME_NO_LOCALE + + const char* const de_short_month_names[]={"Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez", "NAM"}; + + const char* const de_long_month_names[]={"Januar","Februar","Marz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember","NichtDerMonat"}; + const char* const de_special_value_names[]={"NichtDatumzeit","-unbegrenztheit", "+unbegrenztheit"}; + +const char* const de_short_weekday_names[]={"Son", "Mon", "Die","Mit", "Don", "Fre", "Sam"}; + + const char* const de_long_weekday_names[]={"Sonntag", "Montag", "Dienstag","Mittwoch", "Donnerstag", "Freitag", "Samstag"}; + +#endif + +/** Not used for now + const char* const es_short_month_names[]={"Ene","Feb","Mar","Abr","Pue","Jun","Jul","Ago","Sep","Oct","Nov","Dic", "NAM"}; + + const char* const es_long_month_names[]={"Enero","Febrero","Marcha","Abril","Pueda","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre","NoAMes"}; + const char* const es_special_value_names[]={"NoUnRatoDeLaFacha","-infinito", "+infinito"}; +**/ +int +main() +{ +// std::locale native(""); +// std::cout << "native: " << native.name() << std::endl; +//#ifndef BOOST_NO_STD_LOCALE +#ifndef BOOST_DATE_TIME_NO_LOCALE + + using namespace boost::gregorian; + + typedef greg_facet_config facet_config; + typedef boost::date_time::all_date_names_put date_facet; + typedef boost::date_time::date_names_put date_facet_base; + typedef boost::date_time::ostream_month_formatter month_formatter; + + { + // special_values tests + std::stringstream ss; + date_facet_base* f = new date_facet_base(); + std::locale loc(std::locale::classic(), f); + ss.imbue(loc); + date d(not_a_date_time); + ss << d; + check("Special value, stream out nadt" , ss.str() == std::string("not-a-date-time")); + ss.str(""); + d = date(neg_infin); + ss << d; + check("Special value, stream out neg_infin" , ss.str() == std::string("-infinity")); + ss.str(""); + d = date(pos_infin); + ss << d; + check("Special value, stream out pos_infin" , ss.str() == std::string("+infinity")); + } + + date_facet gdnp(de_short_month_names, de_long_month_names, + de_special_value_names, de_long_weekday_names, + de_long_weekday_names, + '.', + boost::date_time::ymd_order_dmy); + + std::stringstream ss; + std::ostreambuf_iterator coi(ss); + gdnp.put_month_short(coi, Oct); + check("check german short month: " + ss.str(), + ss.str() == std::string("Okt")); + + ss.str(""); //reset string stream + greg_month mo(Oct); + month_formatter::format_month(mo, ss, gdnp); + check("check german short month: " + ss.str(), + ss.str() == std::string("Okt")); + ss.str(""); //reset string stream +// month_formatter::format_month(mo, ss, gdnp); +// check("check german long month: " + ss.str(), +// ss.str() == std::string("Oktober")); + + + greg_year_month_day ymd(2002,Oct,1); + typedef boost::date_time::ostream_ymd_formatter ymd_formatter; + ss.str(""); //reset string stream + ymd_formatter::ymd_put(ymd, ss, gdnp); + check("check ymd: " + ss.str(), + ss.str() == std::string("01.Okt.2002")); + + + typedef boost::date_time::ostream_date_formatter datef; + + std::stringstream os; + date d1(2002, Oct, 1); + datef::date_put(d1, os, gdnp); + check("ostream low level check string:"+os.str(), + os.str() == std::string("01.Okt.2002")); + +// //Locale tests + std::locale global; + std::cout << "global: " << global.name() << std::endl; + + // put a facet into a locale + //check for a facet p319 + check("no registered facet here", + !std::has_facet(global)); + + std::locale global2(global, + new date_facet(de_short_month_names, + de_long_month_names, + de_special_value_names, + de_long_weekday_names, + de_long_weekday_names)); + + check("facet registered here", + std::has_facet >(global2)); + + std::stringstream os2; + os2.imbue(global2); + datef::date_put(d1, os2); + check("check string imbued ostream: "+os2.str(), + os2.str() == std::string("2002-Okt-01")); + + date infin(pos_infin); + os2.str(""); //clear stream + datef::date_put(infin, os2); + check("check string imbued ostream: "+os2.str(), + os2.str() == std::string("+unbegrenztheit")); + + os2.str(""); //clear stream + os2 << infin; + check("check string imbued ostream: "+os2.str(), + os2.str() == std::string("+unbegrenztheit")); + + + date nadt(not_a_date_time); + os2.str(""); //clear stream + datef::date_put(nadt, os2); + check("check string imbued ostream: "+os2.str(), + os2.str() == std::string("NichtDatumzeit")); + + + std::stringstream os3; + os3 << d1; + check("check any old ostream: "+os3.str(), + os3.str() == std::string("2002-Oct-01")); + + std::ofstream f("test_facet_file.out"); + f << d1 << std::endl; + +// // date formatter that takes locale and gets facet from locale + std::locale german_dates1(global, + new date_facet(de_short_month_names, + de_long_month_names, + de_special_value_names, + de_short_weekday_names, + de_long_weekday_names, + '.', + boost::date_time::ymd_order_dmy, + boost::date_time::month_as_integer)); + + os3.imbue(german_dates1); + os3.str(""); + os3 << d1; + check("check date order: "+os3.str(), + os3.str() == std::string("01.10.2002")); + + std::locale german_dates2(global, + new date_facet(de_short_month_names, + de_long_month_names, + de_special_value_names, + de_short_weekday_names, + de_long_weekday_names, + ' ', + boost::date_time::ymd_order_iso, + boost::date_time::month_as_short_string)); + + os3.imbue(german_dates2); + os3.str(""); + os3 << d1; + check("check date order: "+os3.str(), + os3.str() == std::string("2002 Okt 01")); + + std::locale german_dates3(global, + new date_facet(de_short_month_names, + de_long_month_names, + de_special_value_names, + de_short_weekday_names, + de_long_weekday_names, + ' ', + boost::date_time::ymd_order_us, + boost::date_time::month_as_long_string)); + + os3.imbue(german_dates3); + os3.str(""); + os3 << d1; + check("check date order: "+os3.str(), + os3.str() == std::string("Oktober 01 2002")); + + date_period dp(d1, date_duration(3)); + os3.str(""); + os3 << dp; + check("check date period: "+os3.str(), + os3.str() == std::string("[Oktober 01 2002/Oktober 03 2002]")); + + + /*******************************************************************/ + /* Streaming operations for date durations */ + /*******************************************************************/ + + date_duration dur(26); + std::stringstream ss2; + ss2 << dur; + check("date_duration stream out", ss2.str() == std::string("26")); + + dur = date_duration(boost::date_time::pos_infin); + ss2.str(""); + ss2 << dur; + check("date_duration stream out", ss2.str() == std::string("+infinity")); + + /*******************************************************************/ + /* Streaming operations for date generator functions */ + /*******************************************************************/ + + partial_date pd(26, Jun); + //std::stringstream ss2; + ss2.str(""); + ss2 << pd; + check("partial date stream out", ss2.str() == std::string("26 Jun")); + + ss2.str(""); + nth_kday_of_month nkm(nth_kday_of_month::second, Friday, Sep); + ss2 << nkm; + check("nth kday of month", ss2.str() == std::string("second Fri of Sep")); + + ss2.str(""); + first_kday_of_month fkm(Saturday, May); + ss2 << fkm; + check("first kday of month", ss2.str() == std::string("first Sat of May")); + + ss2.str(""); + last_kday_of_month lkm(Monday, Aug); + ss2 << lkm; + check("last kday of month", ss2.str() == std::string("last Mon of Aug")); + + ss2.str(""); + first_kday_after fka(Thursday);//fkb.get_date(d) + ss2 << fka; + check("first kday after", ss2.str() == std::string("Thu after")); + + ss2.str(""); + first_kday_before fkb(Tuesday); // same ^ + ss2 << fkb; + check("first kday after", ss2.str() == std::string("Tue before")); + + std::cout << pd << '\n' + << nkm << '\n' + << fkm << '\n' + << lkm << '\n' + << fka << '\n' + << fkb << '\n' + << std::endl; + + /*******************************************************************/ + /* Input Streaming for greg_month */ + /*******************************************************************/ + { + std::stringstream ss1("January"); + std::stringstream ss2m("dec"); // misspelled + std::stringstream german("Okt"); + german.imbue(global2); + greg_month m(3); + ss1 >> m; + check("Stream in month", m == greg_month(Jan)); +#ifndef BOOST_NO_STD_WSTRING + std::wstringstream ws1(L"Dec"); + ws1 >> m; + check("Wide Stream in month", m == greg_month(Dec)); +#else + check("Wide Stream in not supported by this compiler", false); +#endif // BOOST_NO_STD_WSTRING + german >> m; + check("Stream in German month", m == greg_month(Oct)); + try{ + ss2m >> m; // misspelled + check("Bad month exception NOT thrown (misspelled name)", false); + }catch(bad_month&){ + check("Bad month exception caught (misspelled name)", true); + }catch(...){ + check("Bad month exception NOT caught (misspelled name)", false); + } + } + /*******************************************************************/ + /* Input Streaming for greg_weekday */ + /*******************************************************************/ + { + std::stringstream ss1("Sun"); + std::stringstream ss2w("Wensday"); // misspelled + std::stringstream german("Mittwoch"); // Wednesday + german.imbue(global2); + greg_weekday wd(Friday); //something not Sunday... + ss1 >> wd; + check("Stream in weekday", wd == greg_weekday(Sunday)); +#ifndef BOOST_NO_STD_WSTRING + std::wstringstream ws1(L"Saturday"); + ws1 >> wd; + check("Wide Stream in weekday", wd == greg_weekday(Saturday)); +#else + check("Wide Stream in not supported by this compiler", false); +#endif // BOOST_NO_STD_WSTRING + german >> wd; + check("Stream in German weekday", wd == greg_weekday(Wednesday)); + try{ + ss2w >> wd; + check("Bad weekday exception NOT thrown (misspelled name)", false); + }catch(bad_weekday&){ + check("Bad weekday exception caught (misspelled name)", true); + }catch(...){ + check("Bad weekday exception NOT caught (misspelled name)", false); + } + } + +#else + check("No tests executed - Locales not supported by this compiler", false); + +#endif //BOOST_DATE_TIME_NO_LOCALE + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/gregorian/testformat_date_parser.cpp b/src/boost/libs/date_time/test/gregorian/testformat_date_parser.cpp new file mode 100644 index 000000000..f29ab4ed2 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testformat_date_parser.cpp @@ -0,0 +1,363 @@ + +/* Copyright (c) 2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" +#include "boost/date_time/format_date_parser.hpp" +#include +#include +#include + +const wchar_t* const wmonth_short_names[]={L"Jan",L"Feb",L"Mar", + L"Apr",L"May",L"Jun", + L"Jul",L"Aug",L"Sep", + L"Oct",L"Nov",L"Dec"}; + +const char* const month_short_names[]={"Jan","Feb","Mar", + "Apr","May","Jun", + "Jul","Aug","Sep", + "Oct","Nov","Dec"}; + +const char* const month_long_names[]={"January","February","March", + "April","May","June", + "July","August","September", + "October","November","December"}; + +const wchar_t* const wmonth_long_names[]={L"January",L"February",L"March", + L"April",L"May",L"June", + L"July",L"August",L"September", + L"October",L"Novomber",L"December"}; + +const wchar_t* const wweek_short_names[]= {L"Sun", L"Mon", L"Tue", L"Wed", + L"Thu", L"Fri", L"Sat"}; + +const char* const week_short_names[]={"Sun", "Mon","Tue","Wed", + "Thu","Fri","Sat"}; + +const wchar_t* const wweek_long_names[]= {L"Sunday", L"Monday", L"Tuesday", + L"Wednesday", L"Thursday", + L"Friday", L"Saturday"}; + +const char* const week_long_names[]= {"Sunday", "Monday", "Tuesday", + "Wednesday", "Thursday", + "Friday", "Saturday"}; + + + + +std::vector > short_month_names; +std::vector > wshort_month_names; +std::vector > long_month_names; +std::vector > wlong_month_names; +std::vector > short_week_names; +std::vector > wshort_week_names; +std::vector > long_week_names; +std::vector > wlong_week_names; + + +using namespace boost::gregorian; + +void +wtest_format(const std::basic_string& format, + const std::basic_string& value, + const std::string& testname, + boost::gregorian::date expected_res) +{ + typedef boost::date_time::format_date_parser parser_type; + typedef std::basic_string string_type; + typedef std::istreambuf_iterator iter_type; + try { + // string_type format(format); + std::basic_stringstream ws; + ws << value; + iter_type sitr(ws); + iter_type stream_end; + + parser_type p(format, wshort_month_names, wlong_month_names, + wshort_week_names, wlong_week_names); + date d = p.parse_date(sitr, stream_end, format); + check_equal(testname, d, expected_res); + } + catch(std::exception& e) { + std::cout << "Got an exception: " << e.what() << std::endl; + check(testname, false); + } +} + + +void +test_format(const std::basic_string& format, + const std::basic_string& value, + const std::string& testname, + boost::gregorian::date expected_res) +{ + typedef boost::date_time::format_date_parser parser_type; + typedef std::basic_string string_type; + typedef std::istreambuf_iterator iter_type; + try { + string_type format(format); + std::basic_stringstream ws; + ws << value; + iter_type sitr(ws); + iter_type stream_end; + + parser_type pt(format, short_month_names, long_month_names, + short_week_names, long_week_names); + date d = pt.parse_date(sitr, stream_end, format); + check_equal(testname, d, expected_res); + } + catch(std::exception& e) { + std::cout << "Got an exception: " << e.what() << std::endl; + check(testname, false); + } +} + + +template +void +test_format2(boost::date_time::format_date_parser& parser, + const charT* const format, + const charT* const value, + const std::string& testname, + boost::gregorian::date expected_res) +{ + try { + date d = parser.parse_date(value, format); + check_equal(testname, d == expected_res); + } + catch(std::exception& e) { + std::cout << "Got an exception: " << e.what() << std::endl; + check(testname, false); + } +} + +int +main() +{ + std::copy(&wmonth_short_names[0], + &wmonth_short_names[12], + std::back_inserter(wshort_month_names)); + + std::copy(&month_short_names[0], + &month_short_names[12], + std::back_inserter(short_month_names)); + + std::copy(&month_long_names[0], + &month_long_names[12], + std::back_inserter(long_month_names)); + + std::copy(&wmonth_long_names[0], + &wmonth_long_names[12], + std::back_inserter(wlong_month_names)); + + + std::copy(&wweek_short_names[0], + &wweek_short_names[7], + std::back_inserter(wshort_week_names)); + + std::copy(&week_short_names[0], + &week_short_names[7], + std::back_inserter(short_week_names)); + + std::copy(&wweek_long_names[0], + &wweek_long_names[7], + std::back_inserter(wlong_week_names)); + + std::copy(&week_long_names[0], + &week_long_names[7], + std::back_inserter(long_week_names)); + + + wtest_format(L"1%%23%Y %m %d", L"1232004 12 31 other stuff...", + "wide and weird", date(2004,12,31)); + + wtest_format(L"%Y-%m-%d", L"2004-12-31", + "%Y-%m-%d wide", date(2004,12,31)); + + wtest_format(L"%Y day %j", L"2004 day 001", + "%Y day %j wide", date(2004,1,1)); + + test_format("%m/%d/%y", "10/31/04", + "%m/%d/%y", date(2004,10,31)); + + + wtest_format(L"%Y/%m/%d", L"2004-12-31", + "%Y/%m/%d wide 2004-12-31 input", date(2004,12,31)); + + test_format("%Y.%d.%m", "2004.31.1", + "%Y.%d.%m var length", date(2004,Jan,31)); + + test_format("%d.%m.%Y", "1.1.2004", + "%d.%m.%Y var length month and day", date(2004,1,1)); + + test_format("%Y.%m.%d", "2004.1.31", + "%Y.%m.%d var length month", date(2004,Jan,31)); + + test_format("%Y.%b.%d", "2004.Jan.1", + "%Y.%b.%d var length month", date(2004,Jan,1)); + + test_format("%Y%m%d", "20041231", + "%Y%m%d undelimited", date(2004,12,31)); + + test_format("%Y/%d/%b", "2004/01/Jan", + "%Y/%d/%b month at end", date(2004,1,1)); + + test_format("%Y/%b/%d", "2004/Jan/01", + "%Y/%b/%d named month jan", date(2004,1,1)); + + test_format("%Y/%b/%d", "2004/Dec/20", + "%Y/%b/%d named month dec", date(2004,12,20)); + + wtest_format(L"%Y/%b/%d", L"2004-Jul-31", + "%Y/%b/%d wide 2004-Jul-31 input", date(2004,7,31)); + + wtest_format(L"%B %d, %Y", L"March 15, 2004", + "%B %d, %Y", date(2004,3,15)); + + wtest_format(L"%a %B %d, %Y", L"Sun March 15, 2004", + "%a %B %d, %Y", date(2004,3,15)); + + wtest_format(L"%A %B %d, %Y", L"Sunday March 15, 2004", + "%A %B %d, %Y", date(2004,3,15)); + + // bad format case... + + { + try { + std::wstring format(L"%Y-%d"); + std::wstringstream ws; + ws << L"2004-12-31"; + std::istreambuf_iterator sitr(ws); + std::istreambuf_iterator stream_end; + + boost::date_time::format_date_parser pt(format, + wshort_month_names, + wlong_month_names, + wshort_week_names, + wlong_week_names); + date d = pt.parse_date(sitr, stream_end); + check("Bad format spec test", false); + } + catch(std::exception& e) { + std::cout << "Got an expected exception: " << e.what() << std::endl; + check("Bad format spec test -- pass", true); + + } + } + + { + //some interesting month names + const char* const roman_months[]={"I","II","III", + "IV","V","VI", + "VII","VIII","IX", + "X","XI","XII"}; + std::vector > roman_month_names; + std::copy(&roman_months[0], + &roman_months[12], + std::back_inserter(roman_month_names)); + + std::string format("%Y.%b.%d"); + + boost::date_time::format_date_parser parser(format, + roman_month_names, + long_month_names, + short_week_names, + long_week_names); + + + test_format2(parser, "%Y.%b.%d", "2004-I-1", + "roman I", date(2004,Jan,1)); + test_format2(parser, "%Y.%b.%d", "2004-II-01", + "roman II", date(2004,Feb,1)); + test_format2(parser, "%Y.%b.%d", "2004-III-01", + "roman III", date(2004,Mar,1)); + test_format2(parser, "%Y.%b.%d", "2004-IV-01", + "roman IV", date(2004,Apr,1)); + test_format2(parser, "%Y.%b.%d", "2004-V-01", + "roman V", date(2004,May,1)); + test_format2(parser, "%Y.%b.%d", "2004-VI-01", + "roman VI", date(2004,Jun,1)); + test_format2(parser, "%Y.%b.%d", "2004-VII-01", + "roman VII", date(2004,Jul,1)); + test_format2(parser, "%Y.%b.%d", "2004-VIII-01", + "roman VIII", date(2004,Aug,1)); + test_format2(parser, "%Y.%b.%d", "2004-IX-01", + "roman IX", date(2004,Sep,1)); + test_format2(parser, "%Y.%b.%d", "2004-X-01", + "roman X", date(2004,Oct,1)); + test_format2(parser, "%Y.%b.%d", "2004-XI-01", + "roman XI", date(2004,Nov,1)); + test_format2(parser, "%Y.%b.%d", "2004 XII 1", + "roman XII", date(2004,Dec,1)); + + } + + { + //alternate constructor that takes month/weekday strings + //from a locale + std::string format("%Y %m %d"); + boost::date_time::format_date_parser parser(format, + std::locale::classic()); + test_format2(parser, "%a %Y.%b.%d", "Sun 2004 Jan 1", + "strings from locale", date(2004,Jan,1)); + test_format2(parser, "%a %Y.%b.%d", "Mon 2004 Feb 1", + "strings from locale", date(2004,Feb,1)); + test_format2(parser, "%a %Y.%b.%d", "Tue 2004 Mar 1", + "strings from locale", date(2004,Mar,1)); + test_format2(parser, "%a %Y.%b.%d", "Wed 2004 Apr 1", + "strings from locale", date(2004,Apr,1)); + test_format2(parser, "%a %Y.%b.%d", "thu 2004 May 1", + "strings from locale", date(2004,May,1)); + test_format2(parser, "%a %Y.%b.%d", "fri 2004 Jun 1", + "strings from locale", date(2004,Jun,1)); + test_format2(parser, "%a %Y.%b.%d", "sat 2004 Jul 1", + "strings from locale", date(2004,Jul,1)); + test_format2(parser, "%Y.%b.%d", "2004 Aug 1", + "strings from locale", date(2004,Aug,1)); + test_format2(parser, "%Y.%b.%d", "2004 Sep 1", + "strings from locale", date(2004,Sep,1)); + test_format2(parser, "%Y.%b.%d", "2004 Sep 1", + "strings from locale", date(2004,Sep,1)); + test_format2(parser, "%Y.%b.%d", "2004 Oct 1", + "strings from locale", date(2004,Oct,1)); + test_format2(parser, "%Y.%b.%d", "2004 Nov 1", + "strings from locale", date(2004,Nov,1)); + test_format2(parser, "%Y.%b.%d", "2004 Dec 1", + "strings from locale", date(2004,Dec,1)); + + test_format2(parser, "%A %B %d, %Y", "Sunday January 1, 2004", + "long strings from locale", date(2004,Jan,1)); + test_format2(parser, "%A %B %d, %Y", "Monday February 29, 2004", + "long strings from locale", date(2004,Feb,29)); + test_format2(parser, "%A %B %d, %Y", "Tuesday March 1, 2004", + "long strings from locale", date(2004,Mar,1)); + test_format2(parser, "%A %B %d, %Y", "Wednesday APRIL 1, 2004", + "long strings from locale", date(2004,Apr,1)); + test_format2(parser, "%A %B %d, %Y", "thursday may 15, 2004", + "long strings from locale", date(2004,May,15)); + test_format2(parser, "%A %B %d, %Y", "friday june 15, 2004", + "long strings from locale", date(2004,Jun,15)); + test_format2(parser, "%A %B %d, %Y", "saturday july 30, 2004", + "long strings from locale", date(2004,Jul,30)); + test_format2(parser, "%A %B %d, %Y", "thursday auguST 15, 2004", + "long strings from locale", date(2004,Aug,15)); + test_format2(parser, "%A %B %d, %Y", "thursday september 1, 2004", + "long strings from locale", date(2004,Sep,1)); + test_format2(parser, "%A %B %d, %Y", "thursday october 1, 2004", + "long strings from locale", date(2004,Oct,1)); + test_format2(parser, "%A %B %d, %Y", "thursday november 1, 2004", + "long strings from locale", date(2004,Nov,1)); + test_format2(parser, "%A %B %d, %Y", "thursday december 31, 2004", + "long strings from locale", date(2004,Dec,31)); + + } + + return printTestStats(); + +} diff --git a/src/boost/libs/date_time/test/gregorian/testformatters.cpp b/src/boost/libs/date_time/test/gregorian/testformatters.cpp new file mode 100644 index 000000000..80d778c1f --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testformatters.cpp @@ -0,0 +1,62 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" + +int +main() +{ + + boost::gregorian::date d1(2002,01,02); + std::string ds1 = boost::gregorian::to_simple_string(d1); + check("check string: " + ds1, ds1 == "2002-Jan-02"); + + std::string ids1(boost::gregorian::to_iso_string(d1)); + // std::cout << boost::gregorian::to_iso_string(d1) << std::endl; + check("check iso normal: " + ids1, ids1 == "20020102"); + + std::string sds1 = boost::gregorian::to_sql_string(d1); + check("check sql string: "+sds1, sds1 == "2002-01-02"); + + boost::gregorian::date d2(2001,12,30); + std::string ds2 = boost::gregorian::to_simple_string(d2); + check("check string: "+ds2, ds2 == "2001-Dec-30"); + std::string ids2 = boost::gregorian::to_iso_extended_string(d2); + check("check iso extended string: "+ids2, ids2 == "2001-12-30"); + + using namespace boost::gregorian; + date d3(neg_infin); + std::cout << "|" << to_simple_string(d3) << "|" << std::endl; + check("check negative infinity", + (to_simple_string(d3) == std::string("-infinity"))); + date d4(pos_infin); + check("check positive infinity", + (to_simple_string(d4) == std::string("+infinity"))); + date d5(not_a_date_time); + std::cout << to_simple_string(d5) << "|" << std::endl; + check("check not a date", + (to_simple_string(d5) == std::string("not-a-date-time"))); + + date_period p1(date(2000,Jan,1), date(2001,Jan,1)); + check("check period format", + (to_simple_string(p1) == std::string("[2000-Jan-01/2000-Dec-31]"))); + date_period p2(date(2000,Jan,1), date(pos_infin)); + check("check period format", + (to_simple_string(p2) == std::string("[2000-Jan-01/+infinity]"))); + std::cout << to_simple_string(p2) << std::endl; + + + + // TODO enhance wchar support +// std::wstringstream wss; +// wss << d3 << std::endl; +// std::wcout << d3; + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/gregorian/testgenerators.cpp b/src/boost/libs/date_time/test/gregorian/testgenerators.cpp new file mode 100644 index 000000000..b58c1c343 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testgenerators.cpp @@ -0,0 +1,175 @@ +/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" +#include +#include +#include + +int +main() +{ + + using namespace boost::gregorian; + + partial_date pd1(1,Jan); + date d = pd1.get_date(2000); + check("Partial date to_string()", pd1.to_string() == std::string("0")); + check("Partial date getdate", date(2000,1,1) == d); + d = pd1.get_date(2001); + check("Partial date getdate", date(2001,1,1) == d); + partial_date pd2(1,Feb); + check("Partial date to_string()", pd2.to_string() == std::string("31")); + check("Partial date operator==", pd1 == pd1); + check("Partial date operator==", !(pd1 == pd2)); + check("Partial date operator==", !(pd2 == pd1)); + check("Partial date operator<", !(pd1 < pd1)); + check("Partial date operator<", pd1 < pd2); + check("Partial date operator<", !(pd2 < pd1)); + + typedef last_day_of_the_week_in_month lastkday; + + //Find last Sunday in Feb + lastkday lsif(Sunday, Feb); + std::cout << lsif.get_date(2002) << std::endl; //24th + check("Last kday", date(2002,Feb,24) == lsif.get_date(2002)); + check("Last kday to_string()", lsif.to_string() == std::string("M2.5.0")); + lastkday ltif(Thursday, Feb); + check("Last kday", date(2002,Feb,28) == ltif.get_date(2002)); + check("Last kday to_string()", ltif.to_string() == std::string("M2.5.4")); + lastkday lfif(Friday, Feb); + check("Last kday", date(2002,Feb,22) == lfif.get_date(2002)); + check("Last kday to_string()", lfif.to_string() == std::string("M2.5.5")); + + typedef first_day_of_the_week_in_month firstkday; + + firstkday fsif(Sunday, Feb); + std::cout << fsif.get_date(2002) << std::endl; //24th + check("First kday", date(2002,Feb,3) == fsif.get_date(2002)); + check("First kday to_string()", fsif.to_string() == std::string("M2.1.0")); + firstkday ftif(Thursday, Feb); + check("First kday", date(2002,Feb,7) == ftif.get_date(2002)); + check("First kday to_string()", ftif.to_string() == std::string("M2.1.4")); + firstkday ffif(Friday, Feb); + check("First kday", date(2002,Feb,1) == ffif.get_date(2002)); + check("First kday to_string()", ffif.to_string() == std::string("M2.1.5")); + + typedef first_day_of_the_week_after firstkdayafter; + firstkdayafter fkaf(Monday); + std::cout << fkaf.get_date(date(2002,Feb,1)) << std::endl; //feb 4 + check("kday after",date(2002,Feb,4) == fkaf.get_date(date(2002,Feb,1))); + firstkdayafter fkaf2(Thursday); + check("kday after",date(2002,Feb,7) == fkaf2.get_date(date(2002,Feb,1))); + check("kday after",date(2002,Feb,28)== fkaf2.get_date(date(2002,Feb,21))); + + typedef first_day_of_the_week_before firstkdaybefore; + firstkdaybefore fkbf(Monday); + std::cout << fkaf.get_date(date(2002,Feb,10)) + << std::endl; //feb 4 + check("kday before",date(2002,Feb,4) == fkbf.get_date(date(2002,Feb,10))); + firstkdaybefore fkbf2(Thursday); + check("kday before",date(2002,Jan,31) == fkbf2.get_date(date(2002,Feb,1))); + check("kday before",date(2002,Feb,7)== fkbf2.get_date(date(2002,Feb,14))); + + typedef nth_day_of_the_week_in_month nthkdayofmonth; + nthkdayofmonth nkd1(nthkdayofmonth::third, Sunday, Jul); + check("nth_kday 1", date(1969, Jul, 20) == nkd1.get_date(1969)); + check("Nth kday to_string()", nkd1.to_string() == std::string("M7.3.0")); + nthkdayofmonth nkd2(nthkdayofmonth::second, Monday, Dec); + check("nth_kday 2", date(1980, Dec, 8) == nkd2.get_date(1980)); + check("Nth kday to_string()", nkd2.to_string() == std::string("M12.2.1")); + nthkdayofmonth nkd3(nthkdayofmonth::fifth, Wednesday, Jan); + check("nth_kday fifth wed jan 2003 2003-Jan-29", + date(2003, Jan, 29) == nkd3.get_date(2003)); + check("Nth kday to_string()", nkd3.to_string() == std::string("M1.5.3")); + nthkdayofmonth nkd4(nthkdayofmonth::fifth, Monday, Jan); + check("nth_kday fifth mon jan 2003 (actaully 4th) 2003-Jan-27", + date(2003, Jan, 27) == nkd4.get_date(2003)); + check("Nth kday to_string()", nkd4.to_string() == std::string("M1.5.1")); + + // greg date_generator functions tests + { + date sunday(2003,Feb,2),tuesday(2003,Feb,4); + date friday(2003,Feb,7),saturday(2003,Feb,8); + greg_weekday sat(Saturday), tue(Tuesday), fri(Friday), sund(Sunday); + + check("Days until weekday" , days_until_weekday(saturday, sund) == days(1)); + check("Days until weekday" , days_until_weekday(friday, tue) == days(4)); + check("Days until weekday" , days_until_weekday(tuesday, fri) == days(3)); + check("Days until weekday" , days_until_weekday(sunday, sat) == days(6)); + check("Days until weekday" , days_until_weekday(sunday, sund) == days(0)); + check("Days until weekday" , days_until_weekday(tuesday, tue) == days(0)); + + check("Days before weekday" , days_before_weekday(saturday, sund) == days(6)); + check("Days before weekday" , days_before_weekday(friday, tue) == days(3)); + check("Days before weekday" , days_before_weekday(tuesday, fri) == days(4)); + check("Days before weekday" , days_before_weekday(sunday, sat) == days(1)); + check("Days before weekday" , days_before_weekday(sunday, sund) == days(0)); + check("Days before weekday" , days_before_weekday(tuesday, tue) == days(0)); + + check("Date of next weekday", next_weekday(saturday, sund)== date(2003,Feb,9)); + check("Date of next weekday", next_weekday(friday, tue) == date(2003,Feb,11)); + check("Date of next weekday", next_weekday(tuesday, fri) == date(2003,Feb,7)); + check("Date of next weekday", next_weekday(sunday, sat) == date(2003,Feb,8)); + check("Date of next weekday", next_weekday(sunday, sund) == sunday); + check("Date of next weekday", next_weekday(tuesday, tue) == tuesday); + + check("Date of previous weekday", previous_weekday(saturday, sund)== date(2003,Feb,2)); + check("Date of previous weekday", previous_weekday(friday, tue) == date(2003,Feb,4)); + check("Date of previous weekday", previous_weekday(tuesday, fri) == date(2003,Jan,31)); + check("Date of previous weekday", previous_weekday(sunday, sat) == date(2003,Feb,1)); + check("Date of previous weekday", previous_weekday(sunday, sund) == sunday); + check("Date of previous weekday", previous_weekday(tuesday, tue) == tuesday); + + } +#ifndef BOOST_DATE_TIME_NO_LOCALE +#if !defined(USE_DATE_TIME_PRE_1_33_FACET_IO) + //TODO: this is temporary condition -- don't force a failure... + // check("no streaming implemented for new facet", false); +#else + // streaming tests... + std::stringstream ss(""); + std::string s(""); + + ss.str(""); + ss << pd1; + s = "01 Jan"; + check("streaming partial_date", ss.str() == s); + std::cout << ss.str() << std::endl; + + ss.str(""); + ss << lsif; + s = "last Sun of Feb"; + check("streaming last_kday_of_month", ss.str() == s); + + ss.str(""); + ss << fsif; + s = "first Sun of Feb"; + check("streaming first_kday_of_month", ss.str() == s); + + ss.str(""); + ss << fkaf; + s = "Mon after"; + check("streaming first_kday_after", ss.str() == s); + + ss.str(""); + ss << fkbf; + s = "Mon before"; + check("streaming first_kday_before", ss.str() == s); + + ss.str(""); + ss << nkd1; + s = "third Sun of Jul"; + check("streaming nth_kday", ss.str() == s); +#endif // USE_DATE_TIME_PRE_1_33_FACET_IO +#endif // NO_LOCAL + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/gregorian/testgreg_cal.cpp b/src/boost/libs/date_time/test/gregorian/testgreg_cal.cpp new file mode 100644 index 000000000..43558a20c --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testgreg_cal.cpp @@ -0,0 +1,135 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/gregorian/greg_calendar.hpp" +#include "../testfrmwk.hpp" +#include + + +void +test_greg_calendar() +{ + using namespace boost::gregorian; + check("Day of week 2000-09-24 == 0 (Sun)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,24))==0); + check("Day of week 2000-09-25 == 1 (Mon)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,25))==1); + check("Day of week 2000-09-26 == 2 (Tue)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,26))==2); + check("Day of week 2000-09-27 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,27))==3); + check("Day of week 2000-09-28 == 4 (Thu)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,28))==4); + check("Day of week 2000-09-29 == 5 (Fri)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,29))==5); + check("Day of week 2000-09-30 == 6 (Sat)", gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,30))==6); + //see calendar FAQ 2.2 for reference + check("Day of week 1953-08-02 == 0 (Sun)", gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,2))==0); + check("Day of week 1953-08-03 == 1 (Mon)", gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,3))==1); + check("Day of week 1953-08-04 == 2 (Tue)", gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,4))==2); + check("Day of week 1953-08-05 == 3 (Wed)", gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,5))==3); + check("Day of week 1953-08-06 == 4 (Thu)", gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,6))==4); + check("Day of week 1953-08-07 == 5 (Fri)", gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,7))==5); + check("Day of week 1953-08-08 == 6 (Sat)", gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,8))==6); + check("Day of week 2001-08-31 == 5 (Fri)", gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2001,8,31))==5); + + //Checked against Caledrical Calc M. Edition p 396 and www site + check("Day of week 1400-01-01 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1400,1,1))==3); + check("Day of week 1436-02-03 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1436,2,3))==3); + check("Day of week 1492-04-9 == 6 (Sat)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1492,4,9))==6); + check("Day of week 1560-03-5 == 6 (Sat)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1560,3,5))==6); + check("Day of week 1716-07-24 == 5 (Fri)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1716,7,24))==5); + check("Day of week 1768-06-19 == 0 (Sun)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1768,6,19))==0); + check("Day of week 1839-03-27 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1839,3,27))==3); + check("Day of week 1819-08-02 == 1 (Mon)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1819,8,2))==1); + check("Day of week 1903-04-19 == 0 (Sun)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1903,4,19))==0); + check("Day of week 1929-08-25 == 0 (Sun)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1929,8,25))==0); + check("Day of week 2038-11-10 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2038,11,10))==3); + check("Day of week 2094-07-18 == 0 (Sun)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2094,7,18))==0); + //verified against website applet + check("Day of week 3002-07-10 == 6 (Sat)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(3002,7,10))==6); + //verified against website applet + check("Day of week 4002-07-10 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(4002,7,10))==3); + //verified against website applet + check("Day of week 5002-07-10 == 6 (Sat)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(5002,7,10))==6); + + check("1404 is a leap year", gregorian_calendar::is_leap_year(1404)); + check("2000 is a leap year", gregorian_calendar::is_leap_year(2000)); + check("2004 is a leap year", gregorian_calendar::is_leap_year(2004)); + check("2400 is a leap year", gregorian_calendar::is_leap_year(2400)); + check("4000 is a leap year", gregorian_calendar::is_leap_year(4000)); + check("1400 is NOT a leap year", !gregorian_calendar::is_leap_year(1400)); + check("1900 is NOT a leap year", !gregorian_calendar::is_leap_year(1900)); + check("2100 is NOT a leap year", !gregorian_calendar::is_leap_year(2100)); + check("1999 is NOT a leap year", !gregorian_calendar::is_leap_year(1999)); + check("5000 is NOT a leap year", !gregorian_calendar::is_leap_year(5000)); + + + unsigned long jday1 = gregorian_calendar::day_number(gregorian_calendar::ymd_type(2000,1,1)); + unsigned long jday2 = gregorian_calendar::day_number(gregorian_calendar::ymd_type(2001,1,1)); +// unsigned short year, month, day; +// //2451545 is 2000-1-1 + check("ToDayNumber 2000-1-1 is day 2451545", jday1 == 2451545); + check("ToDayNumber 2001-1-1 is day 2451911", jday2 == 2451911); + gregorian_calendar::ymd_type ymd = gregorian_calendar::from_day_number(jday1); + check("from_day_number test 2000-1-1", (ymd.year==2000)&& + (ymd.month==1) && + (ymd.day==1) ); + + unsigned long jday3 = gregorian_calendar::day_number(gregorian_calendar::ymd_type(1999,1,1)); + check("366 days between 2000-1-1 and 2001-1-1", (jday2-jday1) == 366); + check("731 days between 1999-1-1 and 2001-1-1 ",(jday2-jday3) == 731); + + unsigned long jday4 = gregorian_calendar::day_number(gregorian_calendar::ymd_type(2000,2,28)); + unsigned long jday5 = gregorian_calendar::day_number(gregorian_calendar::ymd_type(2000,3,1)); + check("2 days between 2000-2-28 and 2000-3-1 ",(jday5-jday4) == 2); + + check("31 days in month Jan 2000", gregorian_calendar::end_of_month_day(2000,1) == 31); + check("29 days in month Feb 2000", gregorian_calendar::end_of_month_day(2000,2) == 29); + check("28 days in month Feb 1999", gregorian_calendar::end_of_month_day(1999,2) == 28); + check("28 days in month Feb 2001", gregorian_calendar::end_of_month_day(2001,2) == 28); + check("31 days in month Mar 2000", gregorian_calendar::end_of_month_day(2000,3) == 31); + check("30 days in month Apr 2000", gregorian_calendar::end_of_month_day(2000,4) == 30); + check("31 days in month May 2000", gregorian_calendar::end_of_month_day(2000,5) == 31); + check("30 days in month Jun 2000", gregorian_calendar::end_of_month_day(2000,6) == 30); + check("31 days in month Jul 2000", gregorian_calendar::end_of_month_day(2000,7) == 31); + check("31 days in month Aug 2000", gregorian_calendar::end_of_month_day(2000,8) == 31); + check("30 days in month Sep 2000", gregorian_calendar::end_of_month_day(2000,9) == 30); + check("31 days in month Oct 2000", gregorian_calendar::end_of_month_day(2000,10) == 31); + check("30 days in month Nov 2000", gregorian_calendar::end_of_month_day(2000,11) == 30); + check("31 days in month Dec 2000", gregorian_calendar::end_of_month_day(2000,12) == 31); + + +// unsigned long jday0 = date_limits<>::dayNumber(gregorian_calendar::ymd_type(1900,1,1)); +// std::cout << "Day 0: " << jday0 << std::endl; + + std::cout << gregorian_calendar::epoch().year << std::endl; +} + + +int +main() +{ + test_greg_calendar(); + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/gregorian/testgreg_day.cpp b/src/boost/libs/date_time/test/gregorian/testgreg_day.cpp new file mode 100644 index 000000000..1cb5c4470 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testgreg_day.cpp @@ -0,0 +1,91 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/gregorian/greg_day.hpp" +#include "boost/date_time/gregorian/greg_weekday.hpp" +#include "boost/date_time/gregorian/greg_day_of_year.hpp" +#include "../testfrmwk.hpp" +#include + + +void +test_day() +{ + using namespace boost::gregorian; + greg_day d1(1); + check("Basic test", d1 == 1); + try { + greg_day bad(0); + check("Bad day creation", false); //oh oh, fail + //unreachable + std::cout << "Shouldn't reach here: " << bad << std::endl; + } + catch(std::exception &) { + check("Bad day creation", true); //good + + } + try { + greg_day bad(32); + check("Bad day creation2", false); //oh oh, fail + //unreachable + std::cout << "Shouldn't reach here: " << bad << std::endl; + } + catch(std::exception&) { + check("Bad day creation2", true); //good + + } + check("traits min day", (greg_day::min)() == 1); + check("traits max day", (greg_day::max)() == 31); + + greg_weekday sunday(0); + greg_weekday monday(1); + + check("Weekday 0 short name == Sun", + sunday.as_short_string() == std::string("Sun")); + check("Weekday 1 short name == Mon", + monday.as_short_string() == std::string("Mon")); + check("Weekday 2 short name == Tue", + greg_weekday(2).as_short_string() == std::string("Tue")); + check("Weekday 3 short name == Wed", + greg_weekday(3).as_short_string() == std::string("Wed")); + check("Weekday 4 short name == Thu", + greg_weekday(4).as_short_string() == std::string("Thu")); + check("Weekday 5 short name == Fri", + greg_weekday(5).as_short_string() == std::string("Fri")); + check("Weekday 6 short name == Sat", + greg_weekday(6).as_short_string() == std::string("Sat")); + try { + greg_weekday bad(7); + check("Bad weekday creation", false); //oh oh, fail + //unreachable + std::cout << "Shouldn't reach here: " << bad << std::endl; + } + catch(bad_weekday&) { + check("Bad weekday creation", true); //good + + } + + try { + greg_day_of_year_rep bad(367); + check("Bad day of year", false); //oh oh, fail + //unreachable + std::cout << "Shouldn't reach here: " << bad << std::endl; + + } + catch(bad_day_of_year&) { + check("Bad day of year", true); //good + } + +} + +int +main() +{ + test_day(); + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/gregorian/testgreg_durations.cpp b/src/boost/libs/date_time/test/gregorian/testgreg_durations.cpp new file mode 100644 index 000000000..53c3c0420 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testgreg_durations.cpp @@ -0,0 +1,241 @@ +/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" + + +int main(){ + +#if !defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES) + // do not set this test to return fail - + // this is not necessarily a compiler problem + check("Optional gregorian types not selected - no tests run", true); +#else + + using namespace boost::gregorian; + + + /*** months ***/ + { + months m1(5), m2(3), m3(1); + check("months & months addable", months(8) == m1 + m2); + m1 += m2; + check("months & months addable", months(8) == m1); + check("months & months subtractable", months(-5) == m2 - m1); + m2 -= m1; + check("months & months subtractable", months(-5) == m2); + { + // adding and subtracting negative values + date d1(2005, Jan, 1); + date d2(2005, Feb, 1); + check("add neg months (year wrap under)", + d1 + months(-1) == date(2004,Dec,1)); + check("add neg months (no year wrap under)", + d2 + months(-1) == date(2005,Jan,1)); + check("add neg months (year wrap under)", + d2 + months(-2) == date(2004,Dec,1)); + check("add neg months (year wrap under)", + d2 + months(-12) == date(2004,Feb,1)); + check("add neg months (year wrap under)", + d2 + months(-13) == date(2004,Jan,1)); + check("add neg months (year wrap under)", + d2 + months(-14) == date(2003,Dec,1)); + date d3(2005, Dec, 1); + date d4(2005, Nov, 1); + check("subtract neg months (year wrap over)", + d3 - months(-1) == date(2006,Jan,1)); + check("subtract neg months (no year wrap over)", + d4 - months(-1) == date(2005,Dec,1)); + check("subtract neg months (year wrap over)", + d4 - months(-2) == date(2006,Jan,1)); + check("subtract neg months (year wrap over)", + d4 - months(-12) == date(2006,Nov,1)); + check("subtract neg months (year wrap over)", + d4 - months(-13) == date(2006,Dec,1)); + check("subtract neg months (year wrap over)", + d4 - months(-14) == date(2007,Jan,1)); + } + { + months m1x(5), m3x(10); + check("months & int multipliable", months(15) == m1x * 3); + m1x *= 3; + check("months & int multipliable", months(15) == m1x); + //check("int * months", months(12) == 4 * m2x); + check("months & int dividable", months(3) == m3x / 3); + m3x /= 3; + check("months & int dividable", months(3) == m3x); + } + { + months m(-5), m_pos(pos_infin), m_neg(neg_infin), m_nadt(not_a_date_time); + check("months add special_values", m + m_pos == m_pos); + check("months add special_values", m + m_neg == m_neg); + check("months add special_values", m_pos + m_neg == m_nadt); + check("months add special_values", m_neg + m_neg == m_neg); + check("months subtract special_values", m - m_pos == m_neg); + check("months subtract special_values", m - m_neg == m_pos); + check("months subtract special_values", m_pos - m_neg == m_pos); + check("months special_values & int multipliable", m_pos * -1 == m_neg); + check("months special_values & int multipliable", m_pos * 0 == m_nadt); + check("months special_values & int dividable", m_neg / 3 == m_neg); + } + + years y1(2), y2(4); + check("months & years addable", months(25) == m3 + y1); + m3 += y1; + check("months & years addable", months(25) == m3); + check("months & years subtractable", months(-23) == m3 - y2); + m3 -= y2; + check("months & years subtractable", months(-23) == m3); + + { + date d(2001, Oct, 31); + check("date + months", date(2002, Feb, 28) == d + months(4)); + d += months(4); + check("date += months", date(2002, Feb, 28) == d); + } + { + date d(2001, Oct, 31); + check("date - months", date(2001, Apr, 30) == d - months(6)); + d -= months(6); + check("date -= months", date(2001, Apr, 30) == d); + } + } + + /*** years ***/ + { + years y1(2), y2(4), y3(1); + check("years & years addable", years(3) == y3 + y1); + y3 += y1; + check("years & years addable", years(3) == y3); + check("years & years subtractable", years(-1) == y3 - y2); + y3 -= y2; + check("years & years subtractable", years(-1) == y3); + { + years y1x(5), y3x(10); + check("years & int multipliable", years(15) == y1x * 3); + y1x *= 3; + check("years & int multipliable", years(15) == y1x); + //check("int * years", years(12) == 4 * y2x); + check("years & int dividable", years(3) == y3x / 3); + y3x /= 3; + check("years & int dividable", years(3) == y3x); + } + { + years m(15), y_pos(pos_infin), y_neg(neg_infin), y_nadt(not_a_date_time); + check("years add special_values", m + y_pos == y_pos); + check("years add special_values", m + y_neg == y_neg); + check("years add special_values", y_pos + y_neg == y_nadt); + check("years add special_values", y_neg + y_neg == y_neg); + check("years subtract special_values", m - y_pos == y_neg); + check("years subtract special_values", m - y_neg == y_pos); + check("years subtract special_values", y_pos - y_neg == y_pos); + check("years special_values & int multipliable", y_pos * -1 == y_neg); + check("years special_values & int multipliable", y_pos * 0 == y_nadt); + check("years special_values & int dividable", y_neg / 3 == y_neg); + } + + months m1(5), m2(3); + check("years & months addable", months(51) == y2 + m2); + check("years & months subtractable", months(43) == y2 - m1); + + { + date d(2001, Feb, 28); // not a leap year + check("date + years", date(2004, Feb, 29) == d + years(3)); + d += years(3); + check("date += years", date(2004, Feb, 29) == d); + } + { + date d(2000, Feb, 29); + check("date - years", date(1994, Feb, 28) == d - years(6)); + d -= years(6); + check("date -= years", date(1994, Feb, 28) == d); + } + + try { + date d1(1400, 6, 1); + const date d2 = d1 + years(8599); + check("date + many years != overflow", d2 == date(9999, 6, 1)); + } + catch (...) { + check("date + many years != overflow", false); + } + + try { + date d1(9999, 1, 1); + const date d2 = d1 - years(8599); + check("date - many years != overflow", d2 == date(1400, 1, 1)); + } + catch (...) { + check("date - many years != overflow", false); + } + + } + + /*** weeks ***/ + // shouldn't need many tests, it is nothing more than a date_duration + // so all date_duration tests should prove this class + { + weeks w1(2), w2(4), w3(1), pi(pos_infin); + check("add special_values", weeks(pos_infin) == w1 + pi); + check("weeks & weeks addable", weeks(3) == w3 + w1); + w3 += w1; + check("weeks & weeks addable", weeks(3) == w3); + check("weeks & weeks subtractable", weeks(-1) == w3 - w2); + w3 -= w2; + check("weeks & weeks subtractable", weeks(-1) == w3); + { + days d(10); + check("days + weeks", days(31) == d + weeks(3)); + d += weeks(3); + check("days += weeks", days(31) == d); + } + { + days d(10); + check("days - weeks", days(-32) == d - weeks(6)); + d -= weeks(6); + check("days -= weeks", days(-32) == d); + } + { + date d(2001, Feb, 28); + check("date + weeks", date(2001, Mar, 21) == d + weeks(3)); + d += weeks(3); + check("date += weeks", date(2001, Mar, 21) == d); + } + { + date d(2001, Feb, 28); + check("date - weeks", date(2001, Jan, 17) == d - weeks(6)); + d -= weeks(6); + check("date -= weeks", date(2001, Jan, 17) == d); + } + } + + { + date d(2000, Oct, 31); + date d2 = d + months(4) + years(2); + date d3 = d + years(2) + months(4); + check("date + years + months", date(2003,Feb,28) == d2); + check("date + years + months", date(2003,Feb,28) == d3); + months m = years(2) + months(4) - months(4) - years(2); + check("sanity check", m.number_of_months() == 0); + } + /*{ + date d(2001, Mar, 31); + date d1 = (d - months(1)) + months(1); //Mar 28, right? WRONG + // Mar31 - 1 month is Feb28 (last day of month) so Feb28 + 1 month + // will be Mar31 (last day of month) + check("date + 1 months - 1 months", date(2001,Mar,28) == d1); + std::cout << d1 << std::endl; + //date d2 = (d - months(1)) + d; //compile error, right? RIGHT + //weeks w1 = weeks(1) + months(1); //compiler error, right? RIGHT + }*/ + +#endif // BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES + + return printTestStats(); + +} diff --git a/src/boost/libs/date_time/test/gregorian/testgreg_month.cpp b/src/boost/libs/date_time/test/gregorian/testgreg_month.cpp new file mode 100644 index 000000000..3e5db8fa9 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testgreg_month.cpp @@ -0,0 +1,67 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/gregorian/greg_month.hpp" +#include "../testfrmwk.hpp" +#include + + +void +test_month() +{ + using namespace boost::gregorian; + greg_month m1(Jan), m2(Feb), m3(Mar), m4(Apr), m5(May), m6(Jun); + greg_month m7(Jul), m8(Aug), m9(Sep), m10(Oct), m11(Nov),m12(Dec); + check("January as_number", m1.as_number() == 1); + check("December as_number", m12.as_number() == 12); + check("Jan as Short String", m1.as_short_string() == std::string("Jan")); + check("Feb as Short String", m2.as_short_string() == std::string("Feb")); + check("Mar as Short String", m3.as_short_string() == std::string("Mar")); + check("Apr as Short String", m4.as_short_string() == std::string("Apr")); + check("May as Short String", m5.as_short_string() == std::string("May")); + check("Jun as Short String", m6.as_short_string() == std::string("Jun")); + check("Jul as Short String", m7.as_short_string() == std::string("Jul")); + check("Aug as Short String", m8.as_short_string() == std::string("Aug")); + check("Sep as Short String", m9.as_short_string() == std::string("Sep")); + check("Oct as Short String", m10.as_short_string() == std::string("Oct")); + check("Nov as Short String", m11.as_short_string() == std::string("Nov")); + check("Dec as Short String", m12.as_short_string() == std::string("Dec")); + check("Jan as Long String", m1.as_long_string() == std::string("January")); + check("Feb as Long String", m2.as_long_string() == std::string("February")); + check("Mar as Long String", m3.as_long_string() == std::string("March")); + check("Apr as Long String", m4.as_long_string() == std::string("April")); + check("May as Long String", m5.as_long_string() == std::string("May")); + check("Jun as Long String", m6.as_long_string() == std::string("June")); + check("Jul as Long String", m7.as_long_string() == std::string("July")); + check("Aug as Long String", m8.as_long_string() == std::string("August")); + check("Sep as Long String", m9.as_long_string() == std::string("September")); + check("Oct as Long String", m10.as_long_string() == std::string("October")); + check("Nov as Long String", m11.as_long_string() == std::string("November")); + check("Dec as Long String", m12.as_long_string() == std::string("December")); + //month m(5); + + //TODO can this support NAM? or check exception + // greg_month sm0(0); + greg_month sm1(1); + greg_month sm12(12); + //check("check not a month value", sm0.as_short_string() == "NAM"); + check("short construction -- 1", + sm1.as_short_string() == std::string("Jan")); + check("short construction -- 12", + sm12.as_short_string() == std::string("Dec")); + check("month traits min", (greg_month::min)() == 1); + check("month traits max", (greg_month::max)() == 12); + +} + +int +main() +{ + test_month(); + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/gregorian/testgreg_serialize.cpp b/src/boost/libs/date_time/test/gregorian/testgreg_serialize.cpp new file mode 100644 index 000000000..e1b608b40 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testgreg_serialize.cpp @@ -0,0 +1,190 @@ +/* Copyright (c) 2002-2005 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include +#include +#include +#include + +#include +#include +#include "../testfrmwk.hpp" +#include + +using namespace boost; +using namespace gregorian; + +template +void save_to(archive_type& ar, const temporal_type& tt) +{ + ar << tt; +} + +int main(){ + date d(2002,Feb,12); + date sv_d1(not_a_date_time); + date sv_d2(pos_infin); + date_duration dd(11); + date_duration sv_dd(neg_infin); + date_period dp(d,dd); + greg_year gy(1959); + greg_month gm(Feb); + greg_day gd(14); + greg_weekday gwd(Friday); + partial_date pd(26,Jul); + nth_kday_of_month nkd(nth_kday_of_month::second,Tuesday,Mar); + first_kday_of_month fkd(Saturday,Apr); + last_kday_of_month lkd(Saturday,Apr); + first_kday_before fkdb(Thursday); + first_kday_after fkda(Thursday); + + std::ostringstream oss; + + { + + // NOTE: DATE_TIME_XML_SERIALIZE is only used in testing and is + // defined in the testing Jamfile +#if defined(DATE_TIME_XML_SERIALIZE) + std::cout << "Running xml archive tests" << std::endl; + archive::xml_oarchive oa(oss); +#else + std::cout << "Running text archive tests" << std::endl; + archive::text_oarchive oa(oss); +#endif + + // load up the archive + try{ +#if defined(DATE_TIME_XML_SERIALIZE) + save_to(oa, BOOST_SERIALIZATION_NVP(d)); + save_to(oa, BOOST_SERIALIZATION_NVP(sv_d1)); + save_to(oa, BOOST_SERIALIZATION_NVP(sv_d2)); + save_to(oa, BOOST_SERIALIZATION_NVP(dd)); + save_to(oa, BOOST_SERIALIZATION_NVP(sv_dd)); + save_to(oa, BOOST_SERIALIZATION_NVP(dp)); + save_to(oa, BOOST_SERIALIZATION_NVP(gy)); + save_to(oa, BOOST_SERIALIZATION_NVP(gm)); + save_to(oa, BOOST_SERIALIZATION_NVP(gd)); + save_to(oa, BOOST_SERIALIZATION_NVP(gwd)); + save_to(oa, BOOST_SERIALIZATION_NVP(pd)); + save_to(oa, BOOST_SERIALIZATION_NVP(nkd)); + save_to(oa, BOOST_SERIALIZATION_NVP(fkd)); + save_to(oa, BOOST_SERIALIZATION_NVP(lkd)); + save_to(oa, BOOST_SERIALIZATION_NVP(fkdb)); + save_to(oa, BOOST_SERIALIZATION_NVP(fkda)); +#else + save_to(oa, d); + save_to(oa, sv_d1); + save_to(oa, sv_d2); + save_to(oa, dd); + save_to(oa, sv_dd); + save_to(oa, dp); + save_to(oa, gy); + save_to(oa, gm); + save_to(oa, gd); + save_to(oa, gwd); + save_to(oa, pd); + save_to(oa, nkd); + save_to(oa, fkd); + save_to(oa, lkd); + save_to(oa, fkdb); + save_to(oa, fkda); +#endif + }catch(archive::archive_exception& ae){ + std::string s(ae.what()); + check("Error writing to archive: " + s + "\nWritten data: \"" + oss.str() + "\"", false); + return printTestStats(); + } + } + + // read from the archive + date d2(not_a_date_time); + date sv_d3(min_date_time); + date sv_d4(min_date_time); + date_duration dd2(not_a_date_time); + date_duration sv_dd2(0); + date_period dp2(date(2000,Jan,1),date_duration(1)); + greg_year gy2(1960); + greg_month gm2(Jan); + greg_day gd2(1); + greg_weekday gwd2(Monday); + partial_date pd2(1); + nth_kday_of_month nkd2(nth_kday_of_month::first,Monday,Jan); + first_kday_of_month fkd2(Monday,Jan); + last_kday_of_month lkd2(Monday,Jan); + first_kday_before fkdb2(Monday); + first_kday_after fkda2(Monday); + + { + std::istringstream iss(oss.str()); +#if defined(DATE_TIME_XML_SERIALIZE) + archive::xml_iarchive ia(iss); +#else + archive::text_iarchive ia(iss); +#endif + + try{ +#if defined(DATE_TIME_XML_SERIALIZE) + ia >> BOOST_SERIALIZATION_NVP(d2); + ia >> BOOST_SERIALIZATION_NVP(sv_d3); + ia >> BOOST_SERIALIZATION_NVP(sv_d4); + ia >> BOOST_SERIALIZATION_NVP(dd2); + ia >> BOOST_SERIALIZATION_NVP(sv_dd2); + ia >> BOOST_SERIALIZATION_NVP(dp2); + ia >> BOOST_SERIALIZATION_NVP(gy2); + ia >> BOOST_SERIALIZATION_NVP(gm2); + ia >> BOOST_SERIALIZATION_NVP(gd2); + ia >> BOOST_SERIALIZATION_NVP(gwd2); + ia >> BOOST_SERIALIZATION_NVP(pd2); + ia >> BOOST_SERIALIZATION_NVP(nkd2); + ia >> BOOST_SERIALIZATION_NVP(fkd2); + ia >> BOOST_SERIALIZATION_NVP(lkd2); + ia >> BOOST_SERIALIZATION_NVP(fkdb2); + ia >> BOOST_SERIALIZATION_NVP(fkda2); +#else + ia >> d2; + ia >> sv_d3; + ia >> sv_d4; + ia >> dd2; + ia >> sv_dd2; + ia >> dp2; + ia >> gy2; + ia >> gm2; + ia >> gd2; + ia >> gwd2; + ia >> pd2; + ia >> nkd2; + ia >> fkd2; + ia >> lkd2; + ia >> fkdb2; + ia >> fkda2; +#endif + }catch(archive::archive_exception& ae){ + std::string s(ae.what()); + check("Error reading from archive: " + s + "\nWritten data: \"" + oss.str() + "\"", false); + return printTestStats(); + } + } + + check("date", d == d2); + check("special_value date (nadt)", sv_d1 == sv_d3); + check("special_value date (pos_infin)", sv_d2 == sv_d4); + check("date_duration", dd == dd2); + check("special_value date_duration (neg_infin)", sv_dd == sv_dd2); + check("date_period", dp == dp2); + check("greg_year", gy == gy2); + check("greg_month", gm == gm2); + check("greg_day", gd == gd2); + check("greg_weekday", gwd == gwd2); + check("date_generator: partial_date", pd == pd2); + check("date_generator: nth_kday_of_month", nkd.get_date(2002) == nkd2.get_date(2002)); // no operator== for nth_kday_of_week - yet + check("date_generator: first_kday_of_month", fkd.get_date(2002) == fkd2.get_date(2002)); // no operator== for first_kday_of_week - yet + check("date_generator: last_kday_of_month", lkd.get_date(2002) == lkd2.get_date(2002)); // no operator== for last_kday_of_week - yet + check("date_generator: first_kday_before", fkdb.get_date(d) == fkdb2.get_date(d)); // no operator== for first_kday_before - yet + check("date_generator: first_kday_after", fkda.get_date(d) == fkda2.get_date(d)); // no operator== for first_kday_after - yet + + return printTestStats(); +} diff --git a/src/boost/libs/date_time/test/gregorian/testgreg_wstream.cpp b/src/boost/libs/date_time/test/gregorian/testgreg_wstream.cpp new file mode 100644 index 000000000..08173fc8c --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testgreg_wstream.cpp @@ -0,0 +1,178 @@ +/* Copyright (c) 2003-2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Bart Garst + * $Date$ + */ +#include +#include +#include +#include "../testfrmwk.hpp" + +using namespace boost::gregorian; + +int main(){ +#if defined(BOOST_NO_STD_WSTRING) || \ + defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS) + check("No wstring/wstream support for this compiler", false); +#else + std::wstring res, ws; + std::wstringstream wss; + /* date_period is used because almost all the date-type objects + * that have the operator<< can be easily accessed from it. + * Those are: date, greg_month, greg_day_of_week, + * date_period, date_duration (also date_generators) */ + date_period dp(date(2003,Aug,21), date(2004,May,27)); + + + // date + wss << dp.begin(); + res = L"2003-Aug-21"; + check("date operator<<", wss.str() == res); + wss.str(L""); + ws = to_simple_wstring(dp.begin()); + check("date to_simple_string", ws == res); + ws = to_iso_wstring(dp.begin()); + res = L"20030821"; + check("date to_iso_string", ws == res); + ws = to_iso_extended_wstring(dp.begin()); + res = L"2003-08-21"; + check("date to_iso_extended_string", ws == res); + ws = to_sql_wstring(dp.begin()); + check("date to_sql_string", ws == res); + wss.str(L""); +#ifndef BOOST_NO_STD_ITERATOR_TRAITS + { + res = L"2003-Aug-21"; + std::wstringstream wss2(L"2003-Aug-21"); + date testdate(not_a_date_time); + wss2 >> testdate; + check("date operator>>", to_simple_wstring(testdate) == res); + } +#else + check("no date operator>> for this compiler", false); +#endif + + // greg_month + wss << dp.begin().month(); + res = L"08"; + check("greg_month", wss.str() == res); + wss.str(L""); + ws = dp.begin().month().as_short_wstring(); + res = L"Aug"; + check("greg_month as_short_wstring", ws == res); + ws = dp.begin().month().as_long_wstring(); + res = L"August"; + check("greg_month as_long_wstring", ws == res); + /*{ + std::wstringstream wss2(L"August"); + greg_month testmonth(not_a_date_time); + wss2 >> testmonth; + check("greg_month operator>>", to_simple_wstring(testmonth) == res); + }*/ + + // greg_day_of_week + wss << dp.begin().day_of_week(); + res = L"Thu"; + check("greg_day_of_week", wss.str() == res); + wss.str(L""); + ws = dp.begin().day_of_week().as_short_wstring(); + check("greg_day_of_week as_short_wstring", ws == res); + ws = dp.begin().day_of_week().as_long_wstring(); + res = L"Thursday"; + check("greg_day_of_week as_long_wstring", ws == res); + /*{ + std::wstringstream wss2(L"Thu"); + greg_day_of_week testday(not_a_date_time); + wss2 >> testday; + check("greg_day_of_week operator>>", to_simple_wstring(testday) == res); + }*/ + + // date_period + wss << dp; + res = L"[2003-Aug-21/2004-May-26]"; + check("date_period", wss.str() == res); + wss.str(L""); + ws = to_simple_wstring(dp); + check("date_period to_simple_string", ws == res); + res = L"20030821/20040526"; + ws = to_iso_wstring(dp); + check("date_period to_iso_string", ws == res); + { + std::wstringstream wss2(L"[2003-Aug-21/2004-May-27]"); + res = L"[2003-Aug-21/2004-May-26]"; + // following line gives an ambiguous overload of op>> + //date_period testperiod(date(not_a_date_time),date_duration(not_a_date_time)); + date_period testperiod(date(2003,Aug,21), date(2004,May,27)); + wss2 >> testperiod; + check("date_period operator>>", to_simple_wstring(testperiod) == res); + } + + // date_duration + wss << dp.length(); + res = L"280"; + check("date_duration", wss.str() == res); + wss.str(L""); + { + std::wstringstream wss2(L"280"); + date_duration testduration(not_a_date_time); + wss2 >> testduration; + check("date_duration operator>>", testduration.days() == 280); + } + + // special values + date sv_d(neg_infin); + date_duration sv_dd(pos_infin); + //date_period sv_dp(sv_d,sv_dd); + // sv-date + wss << sv_d; + res = L"-infinity"; + check("date operator<< special value", wss.str() == res); + wss.str(L""); + ws = to_simple_wstring(sv_d); + check("date to_simple_string special value", ws == res); + // sv-date_duration + wss << sv_dd; + res = L"+infinity"; + check("date_duration operator<< special value", wss.str() == res); + wss.str(L""); + // sv-date_period + /* + * works - just gives unexpected results: + *[-infinity/not-a-date-time] + wss << sv_dp; + res = L"[2003-Aug-21/2004-May-26]"; + check("date_period", wss.str() == res); + std::wcout << wss.str() << std::endl; + wss.str(L""); + */ + + // date_generators + first_day_of_the_week_after fka(Monday); + wss << fka; + res = L"Mon after"; + check("first_kday_after", wss.str() == res); + wss.str(L""); + + first_day_of_the_week_before fkb(Monday); + wss << fkb; + res = L"Mon before"; + check("first_kday_before", wss.str() == res); + wss.str(L""); + + first_day_of_the_week_in_month fkom(Monday,Jan); + wss << fkom; + res = L"first Mon of Jan"; + check("first_kday_of_month", wss.str() == res); + wss.str(L""); + + last_day_of_the_week_in_month lkom(Monday,Jan); + wss << lkom; + res = L"last Mon of Jan"; + check("last_kday_of_month", wss.str() == res); + wss.str(L""); + +#endif + return printTestStats(); +} diff --git a/src/boost/libs/date_time/test/gregorian/testgreg_year.cpp b/src/boost/libs/date_time/test/gregorian/testgreg_year.cpp new file mode 100644 index 000000000..2f2f3a4d1 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testgreg_year.cpp @@ -0,0 +1,45 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/gregorian/greg_year.hpp" +#include "../testfrmwk.hpp" +#include +#include + +void test_yearlimit(int yr, bool allowed) +{ + std::stringstream sdesc; + sdesc << "should" << (allowed ? "" : " not") << " be able to make a year " << yr; + + try { + boost::gregorian::greg_year chkyr(yr); + check(sdesc.str(), allowed); + if (allowed) { + check_equal("year operator ==", chkyr, yr); + } + } + catch (std::out_of_range&) { check(sdesc.str(), !allowed); } +} + +int +main() +{ + // trac-13159 better limit testing + test_yearlimit( 0, false); + test_yearlimit( 1399, false); + test_yearlimit( 1400, true); + test_yearlimit( 1401, true); + test_yearlimit( 9999, true); + test_yearlimit(10000, false); + test_yearlimit(10001, false); + + check("traits min year", (boost::gregorian::greg_year::min)() == 1400); + check("traits max year", (boost::gregorian::greg_year::max)() == 9999); + + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/gregorian/testparse_date.cpp b/src/boost/libs/date_time/test/gregorian/testparse_date.cpp new file mode 100644 index 000000000..a28280a38 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testparse_date.cpp @@ -0,0 +1,368 @@ +/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" +#include "boost/lexical_cast.hpp" +#include +#include + +// missing or misspelled parts of date string tests +// 'output_str' will be overwritten with what() from caught exception +bool failure_tests(std::string date_spec, + std::string& output_str) +{ + using namespace boost::gregorian; + bool result = false; + date d(not_a_date_time); + try { + d = from_simple_string(date_spec); + } + catch(bad_year& by){ // ex: "205-Jan-15" + result = true; + output_str = by.what(); + } + catch(bad_month& bm){ // ex: "2005-Jsn-15" + result = true; + output_str = bm.what(); + } + catch(bad_day_of_month& bd){ // ex: "2005-Jan-51" + result = true; + output_str = bd.what(); + } + catch(...){ + // test failed - unexpected exception, leave result set to false + } + return result; +} + +int +main() +{ + + +// Examples from 8601 +// Full date +// Extended CCYY-MM-DD + std::string s("2001-10-5"); + + //This one aborts gcc2.95.3 on mandrake 8.1 linux with + //bad lexical cast? + try { + boost::gregorian::date d(boost::gregorian::from_string(s)); + check("check year", d.year() == 2001); + check("check month", d.month() == 10); + check("check day", d.day() == 5); + } + catch(std::exception& e) { + check("parse 2001-10-5", false); + std::cout << "Fail: " << e.what() << std::endl; + } + + { + using namespace boost::gregorian; + // date objects from strings & strings to date objects + date d(2000, 2, 29); + date d2 = from_string("2000-2-29"); + check("2000-2-29", d2 == d); + date d3 = from_string("2000-FEB-29"); + check("2000-FEB-29 (uppercase)", d3 == d); + date d4 = from_string("2000-february-29"); + check("2000-february-29 (lowercase)", d4 == d); + date d5 = from_string(to_simple_string(d)); + check("date to string to date", d5 == d); + date d6 = from_string(to_iso_extended_string(d)); + check("date to string to date", d6 == d); + date d7 = from_us_string("Feb-29-2000"); + check("date from month-day-year string", d7 == d); + date d8 = from_uk_string("29-Feb-2000"); + check("date from day-month-year string", d8 == d); + { + std::string sn("20050229"); // no Feb-29 in 2005 + date dn(not_a_date_time); + try { + dn = date_from_iso_string(sn); + check("Expected exception not thrown: from ISO string (bad_day_of_month)", false); + std::cout << date_from_iso_string(sn) << std::endl; + } + catch(bad_day_of_month&) { + check("Caught expected exception: bad_day_of_month ", true); + } + catch(...) { + check("Caught unexpected exception", false); + } +/* not currently passing due to a bug in boost::offset_separator (reported 2005-Aug-02) + sn = "2005022"; // missing a digit + try { + d = date_from_iso_string(sn); + check("Expected exception not thrown: from ISO string (missing digit)", false); + std::cout << date_from_iso_string(sn) << std::endl; + } + catch(bad_day_of_month& e) { + check("Caught expected exception: bad_day_of_month ", true); + } + catch(...) { + check("Caught unexpected exception", false); + } + */ + sn = "20050228"; // now it's correct + dn = date_from_iso_string(sn); + check("from ISO string", date(2005,Feb,28) == dn); + } + + date d9 = from_us_string(__DATE__); + std::cout << "Today's date: " << to_simple_string(d9) << std::endl; + date d10 = from_us_string("Feb 29, 2000"); + std::cout << "With comma: " << to_simple_string(d10) << std::endl; + check("american date with comma: Feb 29, 2000 ", d10 == d); + + date d11 = from_us_string("feb 29 2000"); + check("american date with comma: feb 29 2000 ", d11 == d); + + // test for missing or misspelled date spec components + std::string output_str("unexpected exception caught"); + check("Year misspelled/out of range: " + output_str, + failure_tests("205-Jan-15", output_str)); + output_str = "unexpected exception caught"; + check("Month misspelled: " + output_str, + failure_tests("2005-Jsn-15", output_str)); + output_str = "unexpected exception caught"; + check("Day out of range: " + output_str, + failure_tests("2005-Jan-55", output_str)); + output_str = "unexpected exception caught"; + check("Missing month and day: " + output_str, + failure_tests("2005", output_str)); + output_str = "unexpected exception caught"; + check("Missing day: " + output_str, + failure_tests("2005-Jan", output_str)); + + +#if defined(BOOST_DATE_TIME_NO_LOCALE) || defined(BOOST_NO_STD_ITERATOR_TRAITS) || !defined(USE_DATE_TIME_PRE_1_33_FACET_IO) + + //TODO -- all these PRE_1_33 exclusions need to be removed. In the meantime, don't make + //this stuff fail. +#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO) + check("input streaming for date not available", false); // force a failure +#endif +#else + { + std::stringstream ss("2000-2-29"); + ss >> d2; + check("2000-2-29 stream-in", d2 == d); + } + { + std::stringstream ss("2000-FEB-29"); + ss >> d2; + //std::cout << d2 << std::endl; + check("2000-FEB-29 stream-in (uppercase)", d2 == d); + } + { + std::stringstream ss("2000-february-29"); + ss >> d2; + check("2000-february-29 stream-in (lowercase)", d2 == d); + } + // the removed (3) tests require a stream manipulator for date_order + // and date_separator (not yet implemented) + /*{ + std::stringstream ss("Feb-29-2000"); + ss >> d2; + check("date from month-day-year string stream-in", d2 == d); + } + { + std::stringstream ss("29-Feb-2000"); + ss >> d2; + check("date from day-month-year string stream-in", d2 == d); + } + { + std::stringstream ss("Feb 29, 2000"); + ss >> d2; + check("american date with comma: Feb 29, 2000 stream-in", d2 == d); + }*/ +#endif //BOOST_DATE_TIME_NO_LOCALE + + + + // check proper range + d = date(2001, 1, 1); + d2 = from_string("2001-Jan-1"); + d3 = from_string("2001-January-1"); + check("January", d == d2); + check("January", d == d3); + d = date(2001, 12, 1); + d2 = from_string("2001-Dec-1"); + d3 = from_string("2001-December-1"); + check("December", d == d2); + check("December", d == d3); +#if defined(BOOST_NO_STD_ITERATOR_TRAITS) + check("date from stream not available: no std iterator traits", false); +#else + // from stream + d = date(2000, 10, 31); + std::stringstream ss(""); + ss << "2000-Oct-31 is Halloween 2k!"; + std::istream_iterator iter(ss), eos; + check("from stream - stringstream", d == from_stream(iter, eos)); +#if !(defined(BOOST_NO_STD_WSTRING)) +#if !(defined(BOOST_DATE_TIME_NO_WISTREAM_ITERATOR)) + std::wstringstream ws; + ws << "2000-Oct-31 is Halloween 2k!"; + std::istream_iterator witer(ws), weos; + check("from stream - wstringstream", d == from_stream(witer, weos)); +#endif // NO_WSTREAM_ITERATOR +#endif // BOOST_NO_WSTRING + char d2_string[] = {"2000-10-31 is Halloween 2k!"}; + char* end = d2_string + sizeof(d2_string) - 1; + check("from stream - char[]", d == from_stream(d2_string, end)); + + std::string s1_string("2000-Oct-31 is Halloween 2k!"); + std::string::iterator s1_start = s1_string.begin(); + std::string::iterator s1_end = s1_string.end(); + check("from stream - string", d == from_stream(s1_start, s1_end)); +#ifndef BOOST_NO_STD_WSTRING + std::wstring w1_string(boost::lexical_cast("2000-Oct-31 is Halloween 2k!")); + std::wstring::iterator w1_start = w1_string.begin(); + std::wstring::iterator w1_end = w1_string.end(); + check("from stream - wstring", d == from_stream(w1_start, w1_end)); +#endif // BOOST_NO_STD_WSTRING +#endif // BOOST_NO_STD_ITERATOR_TRAITS + /* date objects from strings & strings to date objects + * with misspelled months */ + try { + date bd = from_string("2002-Jull-4"); + std::cout << "Shouldn't be reached." << + boost::gregorian::to_simple_string(bd) << std::endl; + } + catch(boost::gregorian::bad_month&){ + check("bad spelling 'Jull'", true); + } + catch(std::exception& e){ + check("bad spelling", false); + std::cout << "Fail: " << e.what() << std::endl; + } + } + + + try { + std::string s2("2001-12-41"); //oops should be 31 + boost::gregorian::date bad_day(boost::gregorian::from_string(s2)); //won't construct + check("check bad day", false); + //The line below won't execute, but make the compiler think + //we are using bad day.... + std::cout << "Oh oh, this shouldn't be reached: " + << boost::gregorian::to_iso_string(bad_day) << std::endl; + + } + catch(boost::gregorian::bad_day_of_month&) { //expected + check("check bad day", true); + } + catch(std::exception& e) { + //oops wrong exception + check("check bad day", false); + std::cout << "Fail: " << e.what() << std::endl; + } + + try { + std::string s2("2001-02-29"); //oops should be 28 + boost::gregorian::date bad_day(boost::gregorian::from_string(s2)); //won't construct + check("check bad leap year", false); + //The line below won't execute, but make the compiler think + //we are using bad day.... + std::cout << "Oh oh, this shouldn't be reached: " + << boost::gregorian::to_iso_string(bad_day) << std::endl; + + } + catch(boost::gregorian::bad_day_of_month&) { //expected + check("check bad leap year", true); + } + catch(std::exception& e) { + //oops wrong exception + check("check bad leap year", false); + std::cout << "Fail: " << e.what() << std::endl; + } + + try { + std::string s2("2001-14-1"); //oops should be <= 12 + boost::gregorian::date bad_month(boost::date_time::parse_date(s2)); + check("check bad month", false); //fail the test + //The line below won't execute, but make the compiler think + //we are using bad day.... + std::cout << "Oh oh, this shouldn't be reached: " + << boost::gregorian::to_iso_string(bad_month) << std::endl; + + } + catch(boost::gregorian::bad_month&) { //expected + check("check bad month", true); + } + catch(std::exception& e) { + //oops wrong exception + check("check bad month", false); + std::cout << "Fail: " << e.what() << std::endl; + } + + //This one aborts gcc2.95.3 on mandrake 8.1 linux with + //bad lexical cast? + try { + //Example of ISO Standard -- CCYYMMDD + using namespace boost::gregorian; + std::string ud("20011009"); //2001-Oct-09 + date d1(boost::gregorian::from_undelimited_string(ud)); + // std::cout << to_string(d1) << std::endl; + check("undelimited date string", d1 == date(2001,Oct,9)); + + + std::string ad("2001/10/09"); + date d2(boost::date_time::parse_date(ad)); + check("check american date", d2 == date(2001,Oct,9)); + } + catch(std::exception& e) { + check("more parsing", false); + std::cout << "Fail: " << e.what() << std::endl; + } + + using namespace boost::gregorian; + std::string s2("2003-07-28"); + date d2(from_string(s2)); + check("check date", d2.month() == 7 && + d2.year() == 2003 && + d2.day() == 28); +// std::string s1("2001-Oct-5"); +// gregorian::date d1(parse_date(s1)); +// check("check month", d1.month() == 10); + + + //Check that the from_string and to_string can be reversed + date d10(2003, 10, 19); + std::string d10s = to_simple_string(d10); + date d11 = from_simple_string(d10s); + check("to from string inversion", d10 == d11); + + try { + using namespace boost::gregorian; + std::string ud(""); //empty string error sf bug# 1155556 + date d1(from_simple_string(ud)); + check("empty string", false); //should never reach this piont + (void)d1; + } + catch(std::exception& e) { + check(std::string("empty string parse (exception expected): ") + e.what(), true); + } + + +//Calendar Week + Day Number +// CCYYWwwDThhmmss +// 1986W105T +// week == 10 day=5 +// see page 5 + + +//Duration rep +//CCYYMMDDThhmmss/PnYnMnDTnHnMnS + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/gregorian/testperiod.cpp b/src/boost/libs/date_time/test/gregorian/testperiod.cpp new file mode 100644 index 000000000..bca235276 --- /dev/null +++ b/src/boost/libs/date_time/test/gregorian/testperiod.cpp @@ -0,0 +1,153 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" +#include + +int main() +{ + using namespace boost::gregorian; + date d1(2000,Jan,1),d2(2000,Jan,4); + date d3 = d2; + check("assignment", d3 == d2); + date_period p1(d1,d2); + date_period p2(d1,date_duration(3)); + check("construction and ==", p1 == p2); + check("begin", p1.begin() == d1); + check("last", p1.last() == d2-date_duration(1) ); + check("end", p1.end() == d2); + check("length", p2.length() == date_duration(3)); + check("contains begin", p1.contains(d1)); + check("contains last", !p1.contains(d2)); + date_period p3(date(2000,Jan,4),date(2000,Feb,1)); + check("operator== not equal case", !(p1 == p3)); + check("less than order", p1 < p3); + check("greater than order", p3 > p1); + check("not equal", p3 != p1); + check("intersects with myself", p1.intersects(p1)); + check("not intersects", !(p1.intersects(p3))); + check("not intersects", !(p3.intersects(p1))); + date_period p4(date(1999,Dec,1), d2); + check("intersects", p1.intersects(p4)); + check("intersects", p4.intersects(p1)); + date_period p5(date(1999,Dec,1), date(2000,Dec,31)); + check("intersects", p1.intersects(p5)); + check("intersects", p5.intersects(p1)); + date_period p6(date(2000,Jan,1),date(2000,Dec,31)); + check("contains period", p5.contains(p6)); + check("contains period equal", p6.contains(p6)); + check("not contains period", !p6.contains(p5)); + + //shift test + date_duration fourDays(4); + p1.shift(fourDays); //from 2000-Jan-01--2000-Jan-04 + date_period shifted(date(2000,Jan,5),date(2000,Jan,8)); + // std::cout << to_string(p1.begin()) <<"--" + // << to_string(p1.last()) << std::endl; + check("shift", p1 == shifted); + + //expand the date period + date_period p10(date(2000,Jan,5),date(2000,Jan,8)); + p10.expand(days(2)); //from 2000-Jan-01--2000-Jan-04 + check("expand", p10 == date_period(date(2000,Jan,3),date(2000,Jan,10))); + + //intersection tests + date_period i1(date(2000,Jan,5), date(2000,Jan,10)); + date_period i2(date(2000,Jan,1), date(2000,Jan,7)); + date_period r1(date(2000,Jan,5), date(2000,Jan,7)); + //case 1 [5 -10) intersect [1-7) -> [5-7) + std::cout << i1.intersection(i2) << std::endl; + check("intersect case1", i1.intersection(i2) == r1); + check("intersect case1", i2.intersection(i1) == r1); + //case 2 [5 -10) intersect [1-15) -> [5-10) + date_period i3(date(2000,Jan,1), date(2000,Jan,15)); + check("intersect case2", i1.intersection(i3) == i1); + check("intersect case2", i3.intersection(i1) == i1); + //case 3 [5-10) intersect [7-15) -> [7-10) + date_period i4(date(2000,Jan,7), date(2000,Jan,10)); + date_period r2(date(2000,Jan,7), date(2000,Jan,10)); + check("intersect case3", i1.intersection(i4) == r2); + check("intersect case3", i4.intersection(i1) == r2); + //case 4 [5-10) intersect [6-9) -> [6-9) + date_period i5(date(2000,Jan,6), date(2000,Jan,9)); + check("intersect case4", i1.intersection(i5) == i5); + check("intersect case4", i5.intersection(i1) == i5); + //case 5 no intersection [1-7) intersect [7-10) + check("no intersection", i2.intersection(i4).is_null()); + + //case 1 [5 -10) merge [1-7) -> [1-10) + date_period r3(date(2000,Jan,1), date(2000,Jan,10)); + // std::cout << to_iso_string(i1.merge(i2).begin()) << "/" << to_iso_string(i1.merge(i2).last()) << std::endl; + check("[5 -10) merge [1-7) -> [1-10)", i1.merge(i2) == r3); + check("[1 -7) merge [7-10) -> null", i2.merge(i4).is_null()); + date_period r4(date(2000,Jan,5), date(2000,Jan,10)); + check("[5 -10) merge [6-9) -> [5-10)", i1.merge(i5) == r4); + + check("[5-10) span [1-7) -> [1-10)", i1.span(i2) == r3); + check("[1-7) span [7-10) -> [1-10)", i2.span(i4) == r3); + check("[7-10) span [1-7) -> [1-10)", i4.span(i2) == r3); + check("[1-15) span [1-7) -> [1-15)", i3.span(i2) == i3); + + date_period i6(date(2000,Jan,1), date(2000,Jan,2)); + check("[1-2) span [7-10) -> [1-10)", i6.span(i4) == r3); + check("[7-10) span [1-2) -> [1-10)", i4.span(i6) == r3); + + + date bf_start(2000,Jan,5); + date bf_end(2000,Jan,10); + date bf_before(2000,Jan,4); //is before the period + date bf_after(2000,Jan,11); //is really after + date bf_during(2000, Jan, 7); + date_period bfp1(bf_start, bf_end); //[2000-Jan-5 - 2000-Jan10) + + check("is before -- start boundary", !bfp1.is_before(bf_start)); + check("is before -- end boundary", bfp1.is_before(bf_end)); + check("is before -- last boundary", !bfp1.is_before(bfp1.last())); + check("is before -- false", !bfp1.is_before(bf_before)); + check("is before -- false", !bfp1.is_before(bf_during)); + check("is before -- true", bfp1.is_before(bf_after)); + + check("is after -- start boundary", !bfp1.is_after(bf_start)); + check("is after -- end boundary", !bfp1.is_after(bf_end)); + check("is after -- last boundary", !bfp1.is_after(bfp1.last())); + check("is after -- true", bfp1.is_after(bf_before)); + check("is after -- false", !bfp1.is_after(bf_during)); + check("is after -- false", !bfp1.is_after(bf_after)); + + //adjacent tests + /* + [5-----10) adj1 + [1----5) adj2 + [7-----12) adj3 + [12----15) adj4 + [1-3) adj5 + [7-9) adj6 + */ + date_period adj1(date(2000,Jan,5), date(2000,Jan,10)); + date_period adj2(date(2000,Jan,1), date(2000,Jan,5)); + date_period adj3(date(2000,Jan,7), date(2000,Jan,12)); + date_period adj4(date(2000,Jan,12), date(2000,Jan,15)); + date_period adj5(date(2000,Jan,1), date(2000,Jan,3)); + date_period adj6(date(2000,Jan,7), date(2000,Jan,9)); + + check("is adjacent -- adj1-->adj2", adj1.is_adjacent(adj2)); + check("is adjacent -- adj2-->adj1", adj2.is_adjacent(adj1)); + check("is adjacent -- adj1-->adj3", !adj1.is_adjacent(adj3)); + check("is adjacent -- adj3-->adj1", !adj3.is_adjacent(adj1)); + check("is adjacent -- adj1-->adj4", !adj1.is_adjacent(adj4)); + check("is adjacent -- adj4-->adj1", !adj4.is_adjacent(adj1)); + check("is adjacent -- adj1-->adj5", !adj1.is_adjacent(adj5)); + check("is adjacent -- adj5-->adj1", !adj5.is_adjacent(adj1)); + check("is adjacent -- adj1-->adj6", !adj1.is_adjacent(adj6)); + check("is adjacent -- adj6-->adj1", !adj6.is_adjacent(adj1)); + + printTestStats(); + + return 0; +} + diff --git a/src/boost/libs/date_time/test/local_time/README.poorly_formed_zonespec b/src/boost/libs/date_time/test/local_time/README.poorly_formed_zonespec new file mode 100644 index 000000000..b417cc8a6 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/README.poorly_formed_zonespec @@ -0,0 +1,4 @@ +The file "poorly_formed_zonespec.csv" is only used for testing. + +This file has the wrong number of fields in it and should not be used for +any other prupose. diff --git a/src/boost/libs/date_time/test/local_time/poorly_formed_zonespec.csv b/src/boost/libs/date_time/test/local_time/poorly_formed_zonespec.csv new file mode 100644 index 000000000..d5eb87149 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/poorly_formed_zonespec.csv @@ -0,0 +1,2 @@ +"ID","STD ABBR","STD NAME","DST ABBR","DST NAME","GMT offset","DST adjustment","DST Start Date rule","Start time","DST End date rule","End time" +"Unique/Zone_name","GMT","","+00:00:00" diff --git a/src/boost/libs/date_time/test/local_time/testclocks.cpp b/src/boost/libs/date_time/test/local_time/testclocks.cpp new file mode 100644 index 000000000..6744631e2 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testclocks.cpp @@ -0,0 +1,40 @@ +/* Copyright (c) 2003-2004 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include "boost/date_time/local_time/local_time.hpp" +#include + +// The actual clocks are tested in posix_time/testclock.cpp. +// These tests are to verify that the time zone is applied correctly + +int +main() +{ + using namespace boost::gregorian; + using namespace boost::posix_time; + using namespace boost::local_time; + + + boost::shared_ptr az_tz(new posix_time_zone("MST-07")); + boost::shared_ptr ny_tz(new posix_time_zone("EST-05EDT,M4.1.0,M10.5.0")); + + ptime tl = second_clock::local_time(); + std::cout << tl << std::endl; + local_date_time ldt1 = local_sec_clock::local_time(az_tz); + std::cout << ldt1.to_string() << std::endl; + local_date_time ldt2 = local_sec_clock::local_time(ny_tz); + std::cout << ldt2.to_string() << std::endl; + + tl = microsec_clock::local_time(); + std::cout << tl << std::endl; + local_date_time ldt3 = local_microsec_clock::local_time(az_tz); + std::cout << ldt3.to_string() << std::endl; + local_date_time ldt4 = local_microsec_clock::local_time(ny_tz); + std::cout << ldt4.to_string() << std::endl; + + return 0; +} diff --git a/src/boost/libs/date_time/test/local_time/testcustom_time_zone.cpp b/src/boost/libs/date_time/test/local_time/testcustom_time_zone.cpp new file mode 100644 index 000000000..c45965e55 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testcustom_time_zone.cpp @@ -0,0 +1,88 @@ +/* Copyright (c) 2003-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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include "boost/date_time/local_time/local_time.hpp" +#include "../testfrmwk.hpp" +#include + +int +main() +{ + + using namespace boost::gregorian; + using namespace boost::posix_time; + using namespace boost::local_time; + + + boost::shared_ptr + rule1(new partial_date_dst_rule(partial_date(30,Apr), + partial_date(30,Oct))); + + boost::shared_ptr + rule2(new first_last_dst_rule(first_last_dst_rule::start_rule(Sunday,Apr), + first_last_dst_rule::end_rule(Sunday,Oct))); + boost::shared_ptr + rule3(new last_last_dst_rule(last_last_dst_rule::start_rule(Sunday,Mar), + last_last_dst_rule::end_rule(Sunday,Oct))); + boost::shared_ptr rule4; // no daylight savings + + time_zone_names pst("Pacific Standard Time", + "PST", + "Pacific Daylight Time" , + "PDT"); + time_zone_names mst("Mountain Standard Time", + "MST", + "" , + ""); + + dst_adjustment_offsets of(hours(1), hours(2), hours(2)); + dst_adjustment_offsets of2(hours(0), hours(0), hours(0)); // no daylight savings + + time_zone_ptr tz1(new custom_time_zone(pst, hours(-8), of, rule1)); + time_zone_ptr tz2(new custom_time_zone(pst, hours(-8), of, rule2)); + time_zone_ptr tz3(new custom_time_zone(pst, hours(-8), of, rule3)); + time_zone_ptr tz4(new custom_time_zone(mst, hours(-7), of2, rule4)); + + check("out string", + tz1->dst_zone_abbrev() == std::string("PDT")); + check("out string", + tz1->std_zone_abbrev() == std::string("PST")); + check("out string", + tz1->std_zone_name() == std::string("Pacific Standard Time")); + check("out string", + tz1->dst_zone_name() == std::string("Pacific Daylight Time")); + + check("dst offset", tz1->dst_offset() == hours(1)); + check("base offset", tz1->base_utc_offset() == hours(-8)); + check("has dst", tz1->has_dst()); + + check("dst start time", + tz1->dst_local_start_time(2003) == ptime(date(2003,Apr,30),hours(2))); + check("dst end time", + tz1->dst_local_end_time(2003) == ptime(date(2003,Oct,30),hours(2))); + + check("tz1 to posix string", + tz1->to_posix_string() == std::string("PST-08PDT+01,120/02:00,303/02:00")); + check("tz2 to posix string", + tz2->to_posix_string() == std::string("PST-08PDT+01,M4.1.0/02:00,M10.5.0/02:00")); + check("tz3 to posix string", + tz3->to_posix_string() == std::string("PST-08PDT+01,M3.5.0/02:00,M10.5.0/02:00")); + check("tz4 to posix string", + tz4->to_posix_string() == std::string("MST-07")); + + // test start/end for non-dst zone + check("has dst in non-dst zone", !tz4->has_dst()); + check("dst start in non-dst zone", + tz4->dst_local_start_time(2005) == ptime(not_a_date_time)); + check("dst end in non-dst zone", + tz4->dst_local_end_time(2005) == ptime(not_a_date_time)); + + + return printTestStats(); +} + + diff --git a/src/boost/libs/date_time/test/local_time/testdst_transition_day_rule.cpp b/src/boost/libs/date_time/test/local_time/testdst_transition_day_rule.cpp new file mode 100644 index 000000000..d3ca19afa --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testdst_transition_day_rule.cpp @@ -0,0 +1,65 @@ +/* Copyright (c) 2003-2004 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "boost/date_time/local_time/dst_transition_day_rules.hpp" +#include "boost/shared_ptr.hpp" +#include "../testfrmwk.hpp" + + + +// see http://www.timeanddate.com/time/aboutdst.html for some info +// also +int +main() +{ + // using namespace boost::posix_time; + using namespace boost::local_time; + using namespace boost::gregorian; + + boost::shared_ptr + rule1(new partial_date_dst_rule(partial_date(30,Apr), + partial_date(30,Oct))); + + check("partial date rule", rule1->start_day(2001) == date(2001, Apr, 30)); + check("partial date rule", rule1->end_day(2001) == date(2001, Oct, 30)); + + boost::shared_ptr + rule2(new first_last_dst_rule(first_last_dst_rule::start_rule(Sunday,Apr), + first_last_dst_rule::end_rule(Sunday,Oct))); + + check("first last rule", rule2->start_day(2001) == date(2001, Apr, 1)); + check("first last rule", rule2->end_day(2001) == date(2001, Oct, 28)); + + boost::shared_ptr + rule3(new last_last_dst_rule(last_last_dst_rule::start_rule(Sunday,Mar), + last_last_dst_rule::end_rule(Sunday,Oct))); + + check("last last rule", rule3->start_day(2001) == date(2001, Mar, 25)); + check("last last rule", rule3->end_day(2001) == date(2001, Oct, 28)); + + typedef nth_kday_of_month nkday; + boost::shared_ptr + rule4(new nth_last_dst_rule(nth_last_dst_rule::start_rule(nkday::first,Sunday,Mar), + nth_last_dst_rule::end_rule(Sunday,Oct))); + + check("nth Last rule", rule4->start_day(2001) == date(2001, Mar, 4)); + check("nth Last rule", rule4->end_day(2001) == date(2001, Oct, 28)); + + boost::shared_ptr + rule5(new nth_kday_dst_rule(nth_kday_dst_rule::start_rule(nkday::first,Sunday,Mar), + nth_kday_dst_rule::end_rule(nkday::fourth,Sunday,Oct))); + + check("nth_kday rule", rule5->start_day(2001) == date(2001, Mar, 4)); + check("nth_kday rule", rule5->end_day(2001) == date(2001, Oct, 28)); + + + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/local_time/testlocal_time.cpp b/src/boost/libs/date_time/test/local_time/testlocal_time.cpp new file mode 100644 index 000000000..058090fc0 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testlocal_time.cpp @@ -0,0 +1,370 @@ +/* Copyright (c) 2003-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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + + +#include "boost/date_time/local_time/custom_time_zone.hpp" +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/date_time/local_time/local_time.hpp" +// #include "boost/date_time/local_time/posix_time_zone.hpp" +#include "../testfrmwk.hpp" +//#include "boost/date_time/c_time.hpp" +#include + +#include +// function eases testing +std::string tm_out(const tm& ptr){ + std::stringstream ss; + + ss + << ptr.tm_wday << ' ' << ptr.tm_yday << ' ' + << std::setw(2) << std::setfill('0') << ptr.tm_mon + 1 << '/' + << std::setw(2) << std::setfill('0') << ptr.tm_mday << '/' + << std::setw(2) << std::setfill('0') << ptr.tm_year + 1900 << ' ' + << std::setw(2) << std::setfill('0') << ptr.tm_hour << ':' + << std::setw(2) << std::setfill('0') << ptr.tm_min << ':' + << std::setw(2) << std::setfill('0') << ptr.tm_sec << ' '; + if(ptr.tm_isdst >= 0){ + ss << (ptr.tm_isdst ? "DST" : "STD"); + } + else{ + ss << "DST/STD unknown"; + } + return ss.str(); +} + +int +main() +{ + + using namespace boost::gregorian; + using namespace boost::posix_time; + using namespace boost::local_time; + + // since local_date_time inherits it's math operations from time, the + // tests here only show that the operations work. The thorough testing + // of these operations is done in the posix_time tests + + try { + time_zone_ptr az_tz(new posix_time_zone("MST-07")); + time_zone_ptr ny_tz(new posix_time_zone("EST-05EDT,M4.1.0,M10.5.0")); + // EST & EST for sydney is correct, according to zoneinfo files + time_zone_ptr sydney(new posix_time_zone("EST+10EST,M10.5.0,M3.5.0/03:00")); + time_zone_ptr null_tz; + date d(2003, 12, 20); + hours h(12); + ptime t(d,h); + local_date_time az_time(t, az_tz); // ptime constructor is a UTC time + + check("Zone abbreviation", az_time.zone()->std_zone_abbrev() == std::string("MST")); + check("base offset", az_time.zone()->base_utc_offset() == hours(-7)); + check("zone has dst", az_time.zone()->has_dst() == false); + check("is_dst check", az_time.is_dst() == false); + check("to_string: " + az_time.to_string(), + az_time.to_string() == "2003-Dec-20 05:00:00 MST"); + + + + std::cout << "\nChecking copy construction" << std::endl; + local_date_time az_time2(az_time); //copy constructor + // Now test the copy + check("is_dst check", az_time2.is_dst() == false); + check("to_string: " + az_time2.to_string(), + az_time2.to_string() == "2003-Dec-20 05:00:00 MST"); + check("zone has dst", az_time2.zone()->has_dst() == false); + check("base offset", az_time2.zone()->base_utc_offset() == hours(-7)); + + + std::cout << "\nChecking special_value construction" << std::endl; + // since local_date_time inherits its special value operatorations + // from time, we only need to show here that they work as thorough + // testing is done in the posix_time tests + ptime svpt(not_a_date_time); + local_date_time sv_time(svpt, ny_tz); + check("is special_value", sv_time.is_not_a_date_time()); + check("to_string: " + sv_time.to_string(), + sv_time.to_string() == "not-a-date-time"); + check("is_dst", sv_time.is_dst() == false); + local_date_time sv_time2(pos_infin); + check("is special_value", sv_time2.is_pos_infinity()); + check("to_string: " + sv_time2.to_string(), + sv_time2.to_string() == "+infinity"); + check("is_dst", sv_time2.is_dst() == false); + sv_time2 += days(12); // add a duration to a special value + check("Add a duration to a special value", sv_time2.is_pos_infinity()); + + local_date_time sv_time3(max_date_time, ny_tz); +#ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + check("max_date_time to_string: " + sv_time3.to_string(), + sv_time3.to_string() == "9999-Dec-31 18:59:59.999999999 EST"); +#else + check("max_date_time to_string: " + sv_time3.to_string(), + sv_time3.to_string() == "9999-Dec-31 18:59:59.999999 EST"); +#endif + + try { + local_date_time sv_time4(min_date_time); + check("min_date_time to_string: " + sv_time4.to_string(), + sv_time4.to_string() == "1400-Jan-01 00:00:00 UTC"); + } + catch (std::exception& e) { + check("min_date_time to_string -- exception" , false); + std::cout << "Exception is : " << e.what() << std::endl; + } + +/** todo -- this will cause an out of range when min_date is adjusted for ny_tz + local_date_time sv_time5(min_date_time, ny_tz); + std::cout << sv_time5.to_string() << std::endl; +**/ + + std::cout << "\nChecking calc_options construction" << std::endl; + { // invalid NADT + date dx(2004, Apr, 4); + time_duration td(2,30,0); // invalid local time in ny_tz + local_date_time calcop(dx, td, ny_tz, local_date_time::NOT_DATE_TIME_ON_ERROR); + check("is NADT", calcop.is_not_a_date_time()); + } + { // invalid exception + date dx(2004, Apr, 4); + time_duration td(2,30,0); // invalid local time in ny_tz + try{ + local_date_time calcop(dx, td, ny_tz, local_date_time::EXCEPTION_ON_ERROR); + check("Did not catch expected exception", false); + }catch(time_label_invalid& /*i*/){ + check("Caught expected exception", true); + }catch(...){ + check("Caught unexpected exception", false); + } + } + { // ambig NADT + date dx(2004, Oct, 31); + time_duration td(1,30,0); // ambig local time in ny_tz + local_date_time calcop(dx, td, ny_tz, local_date_time::NOT_DATE_TIME_ON_ERROR); + check("is NADT", calcop.is_not_a_date_time()); + } + { // ambig exception + date dx(2004, Oct, 31); + time_duration td(1,30,0); // ambig local time in ny_tz + try{ + local_date_time calcop(dx, td, ny_tz, local_date_time::EXCEPTION_ON_ERROR); + check("Did not catch expected exception", false); + }catch(ambiguous_result& /*a*/){ + check("Caught expected exception", true); + }catch(...){ + check("Caught unexpected exception", false); + } + } + + + //Now construct with a date and time + std::cout << "\nChecking construct with date and time_duration" << std::endl; + local_date_time az_time3(d, h, az_tz, false); + check("Zone abbreviation", az_time3.zone()->std_zone_abbrev() == std::string("MST")); + check("base offset", az_time3.zone()->base_utc_offset() == hours(-7)); + check("base offset", az_time3.zone()->has_dst() == false); + check("is_dst check", az_time3.is_dst() == false); + check("to_string: " + az_time3.to_string(), + az_time3.to_string() == "2003-Dec-20 12:00:00 MST"); + + // construct with a null tz + //local_date_time null_tz_time(d, h, null_tz, false); + local_date_time null_tz_time(d, h, null_tz, true); + // TODO: how to handle calls to null_tz_time.zone()->... + check("is_dst check", null_tz_time.is_dst() == false); + check("to_string: " + null_tz_time.to_string(), + null_tz_time.to_string() == "2003-Dec-20 12:00:00 UTC"); + + //Now construct with a date and time - invalid parameters + try{ + local_date_time blt(d, h, ny_tz, true); + check("Did not catch expected exception (dst_not_valid)", false); + }catch(dst_not_valid& e){ + check(std::string("Caught expected exception (dst_not_valid) ") + e.what(), true); + }catch(std::exception& e){ + check(std::string("Caught unexpected exception ") + e.what(), false); + } + try{ + local_date_time blt(date(2004,Apr,4), time_duration(2,30,0), ny_tz, true); + check("Did not catch expected exception (Invalid_Time_Label)", false); + }catch(time_label_invalid& e){ + check(std::string("Caught expected exception (Invalid_Time_Label) ") + e.what(), true); + }catch(std::exception& e){ + check(std::string("Caught unexpected exception ") + e.what(), false); + } + + + // thorough is_dst() tests, tests againts null_tz and non dst tz are + // done where those local times were tested + { + date dx(2004,Apr,4); + time_duration td(1,15,0); // local + local_date_time lt1(dx,td,ny_tz,false); + local_date_time lt2(ptime(dx,time_duration(6,15,0)), ny_tz); + check("are local_times equal", lt1.utc_time() == lt2.utc_time()); + check("is_dst - transition in 1", lt1.is_dst() == false); + check("is_dst - transition in 2", lt2.is_dst() == false); + lt1 += hours(1); + lt2 += hours(1); + check("is_dst - transition in 1", lt1.is_dst() == true); + check("is_dst - transition in 2", lt2.is_dst() == true); + } + { + date dx(2004,Oct,31); + time_duration td(1,15,0); // local + local_date_time lt1(dx,td,ny_tz,true); + /*try{ + //local_date_time lt1(dx,td,ny_tz,false); + local_date_time lt1(dx,td,ny_tz,true); + std::cout << "no exception thrown" << std::endl; + }catch(time_label_invalid& e){ + std::cout << "caught: " << e.what() << std::endl; + }*/ + local_date_time lt2(ptime(dx,time_duration(5,15,0)), ny_tz); + check("are local_times equal", lt1.utc_time() == lt2.utc_time()); + check("is_dst - transition out 1", lt1.is_dst() == true); + check("is_dst - transition out 2", lt2.is_dst() == true); + lt1 += hours(1); + lt2 += hours(1); + check("is_dst - transition out 1", lt1.is_dst() == false); + check("is_dst - transition out 2", lt2.is_dst() == false); + } + { // southern hemisphere + date dx(2004,Oct,31); + time_duration td(1,15,0); // local + local_date_time lt1(dx,td,sydney,false); + check("is_dst - transition in (sydney)", lt1.is_dst() == false); + lt1 += hours(1); + check("is_dst - transition in (sydney)", lt1.is_dst() == true); + } + { + date dx(2004,Mar,28); + time_duration td(2,15,0); // local; sydney has a weird trans time + local_date_time lt1(dx,td,sydney,true); + check("is_dst - transition out (sydney)", lt1.is_dst() == true); + lt1 += hours(1); + check("is_dst - transition out (sydney)", lt1.is_dst() == false); + } + + + + std::cout << "\nTest conversion of time zone from Arizona to New York" << std::endl; + local_date_time ny_time = az_time.local_time_in(ny_tz); + check("Zone abbreviation", ny_time.zone()->std_zone_abbrev() == std::string("EST")); + check("base offset", ny_time.zone()->base_utc_offset() == hours(-5)); + check("base offset", ny_time.zone()->has_dst() == true); + check("to_string: " + ny_time.to_string(), + ny_time.to_string() == "2003-Dec-20 07:00:00 EST"); + ny_time += hours(3); + check("to_string after add 3 hours: " + ny_time.to_string(), + ny_time.to_string() == "2003-Dec-20 10:00:00 EST"); + ny_time += days(3); + check("to_string after add 3 days: " + ny_time.to_string(), + ny_time.to_string() == "2003-Dec-23 10:00:00 EST"); + + + { // test comparisons & math operations + date dx(2003, Aug, 28); + ptime sv_pt(pos_infin); + local_date_time sv_lt(sv_pt, ny_tz); + ptime utc_pt(dx, hours(12)); + // all 4 of the following local times happen at the same instant + // so they are all equal + local_date_time utc_lt(utc_pt, null_tz); // noon in utc + local_date_time az_lt(dx, hours(5), az_tz, false); // 5am local std + local_date_time ny_lt(dx, hours(8), ny_tz, true); // 8am local dst + local_date_time au_lt(dx, hours(22), sydney, false);// 10pm local std + + check("local_date_time to tm", + std::string("4 239 08/28/2003 05:00:00 STD") == tm_out(to_tm(az_lt))); + check("local_date_time to tm", + std::string("4 239 08/28/2003 08:00:00 DST") == tm_out(to_tm(ny_lt))); + check("local_date_time to tm", + std::string("4 239 08/28/2003 22:00:00 STD") == tm_out(to_tm(au_lt))); + + try{ + local_date_time ldt(not_a_date_time); + tm ldt_tm = to_tm(ldt); + check("Exception not thrown (special_value to_tm)", false); + //does nothing useful but stops compiler from complaining about unused ldt_tm + std::cout << ldt_tm.tm_sec << std::endl; + }catch(std::out_of_range&){ + check("Caught expected exception (special_value to_tm)", true); + }catch(...){ + check("Caught un-expected exception (special_value to_tm)", false); + } + // check that all are equal to sv_pt + check("local == utc", az_lt == utc_lt); + check("local == utc", ny_lt == utc_lt); + check("local == utc", au_lt == utc_lt); + check("local <= utc", au_lt <= utc_lt); + check("local >= utc", au_lt >= utc_lt); + check("local == local", az_lt == ny_lt); + check("local < local", az_lt < ny_lt+seconds(1)); + check("local > local", az_lt+seconds(1) > ny_lt); + check("local <= local", az_lt <= ny_lt); + check("local >= local", az_lt >= ny_lt); + check("local != local", az_lt+seconds(1) != ny_lt); + + au_lt += hours(1); + check("local != after +=", au_lt != utc_lt); + check("local <= after +=", utc_lt <= au_lt); + check("local >= after +=", au_lt >= utc_lt); + check("local < after +=", utc_lt < au_lt); + check("local > after +=", au_lt > utc_lt); + au_lt -= hours(1); + check("local == utc after -=", au_lt == utc_lt); + + check("local + days", + (az_lt + days(2)).to_string() == "2003-Aug-30 05:00:00 MST"); + check("local - days", + (az_lt - days(2)).to_string() == "2003-Aug-26 05:00:00 MST"); + check("local += days", + (az_lt += days(2)).to_string() == "2003-Aug-30 05:00:00 MST"); + check("local -= days", + (az_lt -= days(2)).to_string() == "2003-Aug-28 05:00:00 MST"); + check("local + time_duration", + (az_lt + hours(2)).to_string() == "2003-Aug-28 07:00:00 MST"); + check("local - time_duration", + (az_lt - hours(2)).to_string() == "2003-Aug-28 03:00:00 MST"); + // special_values is more thoroughly tested in posix_time + check("pos_infinity > local", sv_lt > au_lt); + local_date_time sv_lt2(sv_lt + days(2)); + check("pos_infin + duration == pos_infin", sv_lt2 == sv_lt); + +#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES) + months m(2); + years y(2); + check("Local + months", + (az_lt + m).to_string() == "2003-Oct-28 05:00:00 MST"); + az_lt += m; + check("Local += months", + az_lt.to_string() == "2003-Oct-28 05:00:00 MST"); + check("Local - months", + (az_lt - m).to_string() == "2003-Aug-28 05:00:00 MST"); + az_lt -= m; + check("Local -= months", + az_lt.to_string() == "2003-Aug-28 05:00:00 MST"); + check("Local + years", + (az_lt + y).to_string() == "2005-Aug-28 05:00:00 MST"); + az_lt += y; + check("Local += years", + az_lt.to_string() == "2005-Aug-28 05:00:00 MST"); + check("Local - years", + (az_lt - y).to_string() == "2003-Aug-28 05:00:00 MST"); + az_lt -= y; + check("Local -= years", + az_lt.to_string() == "2003-Aug-28 05:00:00 MST"); + +#endif // BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES + } + } + catch(std::exception& e) { + check(std::string("test failed due to exception: ") + e.what(), false); + } + + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/local_time/testlocal_time_facet.cpp b/src/boost/libs/date_time/test/local_time/testlocal_time_facet.cpp new file mode 100644 index 000000000..2046ac156 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testlocal_time_facet.cpp @@ -0,0 +1,188 @@ + +/* Copyright (c) 2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include +#include +#include +#include "boost/date_time/local_time/local_time.hpp" +#include "../testfrmwk.hpp" + + +template +inline +void +teststreaming(std::string const& testname, + temporal_type value, + std::basic_string const& expected_result, + const std::locale& locale) +{ + std::basic_stringstream ss; + ss.imbue(locale); + ss << value; + + if (!check(testname, ss.str() == expected_result)) +#if !defined(BOOST_NO_STD_WSTRING) + std::wcout << L"Expected: \"" << expected_result.c_str() << L"\"\nGot: \"" << ss.str().c_str() << L"\"" << std::endl; +#else + std::cout << "Expected: \"" << expected_result.c_str() << "\"\nGot: \"" << ss.str().c_str() << L"\"" << std::endl; +#endif +} + +int main(int /* argc */, char const* argv[]){ + /* use the tz_database for the time zones. + * Chicago, Denver, Los_Angeles, New_Tork, and Phoenix + * have all had full names added */ + using namespace boost; + using namespace boost::local_time; + using namespace boost::posix_time; + using namespace boost::gregorian; + + tz_database time_zones; + + try { + // first try to find the data file from the test dir + time_zones.load_from_file(argv[1]); + } + catch(const data_not_accessible&) { + check("Cannot locate data file - aborting.", false); + return printTestStats(); + } + + time_zone_ptr utc; + time_zone_ptr chicago = time_zones.time_zone_from_region("America/Chicago"); + time_zone_ptr denver = time_zones.time_zone_from_region("America/Denver"); + time_zone_ptr la = time_zones.time_zone_from_region("America/Los_Angeles"); + time_zone_ptr nyc = time_zones.time_zone_from_region("America/New_York"); + time_zone_ptr phx = time_zones.time_zone_from_region("America/Phoenix"); + // sydney does not have full time zone names in the tz_database + time_zone_ptr sydney = time_zones.time_zone_from_region("Australia/Sydney"); + + ptime a_time(date(2004,Dec,15), hours(12)); + ptime b_time(date(2004,Aug,15), hours(12)); + local_date_time ldt1(a_time, utc); + local_date_time ldt2(b_time, chicago); + local_date_time ldt3(a_time, denver); + local_date_time ldt4(b_time, la); + local_date_time ldt5(a_time, nyc); + local_date_time ldt6(b_time, phx); + + local_time_period ltp1(ldt1, hours(10) + minutes(24) + seconds(5)); + local_time_period ltp2(ldt4, hours(15) + minutes(20) + seconds(41)); + + typedef boost::date_time::time_facet ldt_facet; + //ldt_facet* timefacet = new ldt_facet("%c %Z"); // full name + ldt_facet* timefacet = new ldt_facet("%a %b %d %H:%M:%S %Y %Z"); // full name + std::locale loc1(std::locale::classic(), timefacet); + + typedef boost::date_time::time_facet pt_facet; + //pt_facet* ptimefacet1 = new pt_facet("%c %Z"); // show that zone is ignored + pt_facet* ptimefacet1 = new pt_facet("%a %b %d %H:%M:%S %Y %Z"); // show that zone is ignored + std::locale loc2(std::locale::classic(), ptimefacet1); + + + std::cout << "\nFull time zone names tests" << std::endl; + teststreaming("ptime with %Z flag\n", a_time, std::string("Wed Dec 15 12:00:00 2004") , loc2); + + teststreaming("UTC local_date_time", ldt1, std::string("Wed Dec 15 12:00:00 2004 Coordinated Universal Time"), loc1); + teststreaming("Chicago in summer", ldt2, std::string("Sun Aug 15 07:00:00 2004 Central Daylight Time") , loc1); + teststreaming("Denver in winter", ldt3, std::string("Wed Dec 15 05:00:00 2004 Mountain Standard Time"), loc1); + teststreaming("Los Angeles in summer", ldt4, std::string("Sun Aug 15 05:00:00 2004 Pacific Daylight Time"), loc1); + teststreaming("New York in winter", ldt5, std::string("Wed Dec 15 07:00:00 2004 Eastern Standard Time"), loc1); + teststreaming("Phoenix in Summer", ldt6, std::string("Sun Aug 15 05:00:00 2004 Mountain Standard Time"), loc1); + + teststreaming("UTC local_time_period", ltp1, std::string("[Wed Dec 15 12:00:00 2004 Coordinated Universal Time/Wed Dec 15 22:24:04 2004 Coordinated Universal Time]"), loc1); + teststreaming("LA local_time_period", ltp2, std::string("[Sun Aug 15 05:00:00 2004 Pacific Daylight Time/Sun Aug 15 20:20:40 2004 Pacific Daylight Time]"), loc1); + + //ptimefacet1->format("%c %z"); // show that zone abbrev is ignored + ptimefacet1->format("%a %b %d %H:%M:%S %Y %z"); // show that zone abbrev is ignored + std::cout << "\nTime zone abbreviation tests" << std::endl; + teststreaming("ptime with %z flag\n", a_time, std::string("Wed Dec 15 12:00:00 2004") , loc2); + + // using standard format + //timefacet->format("%c %z"); // abbreviated zone + timefacet->format("%a %b %d %H:%M:%S %Y %z"); // abbreviated zone + teststreaming("UTC local_date_time", ldt1, std::string("Wed Dec 15 12:00:00 2004 UTC"), loc1); + teststreaming("Chicago in summer", ldt2, std::string("Sun Aug 15 07:00:00 2004 CDT") , loc1); + teststreaming("Denver in winter", ldt3, std::string("Wed Dec 15 05:00:00 2004 MST"), loc1); + teststreaming("Los Angeles in summer", ldt4, std::string("Sun Aug 15 05:00:00 2004 PDT"), loc1); + teststreaming("New York in winter", ldt5, std::string("Wed Dec 15 07:00:00 2004 EST"), loc1); + teststreaming("Phoenix in Summer", ldt6, std::string("Sun Aug 15 05:00:00 2004 MST"), loc1); + + // iso format + // show that zone offset is ignored + ptimefacet1->format(pt_facet::iso_time_format_specifier); + std::cout << "\nLocal time iso format tests" << std::endl; + teststreaming("ptime with iso format\n", a_time, + std::string("20041215T120000") , loc2); + + timefacet->format(ldt_facet::iso_time_format_specifier); + teststreaming("UTC local_date_time", ldt1, + std::string("20041215T120000Z"), loc1); + teststreaming("Chicago in summer", ldt2, + std::string("20040815T070000-0500") , loc1); + teststreaming("Denver in winter", ldt3, + std::string("20041215T050000-0700"), loc1); + teststreaming("Los Angeles in summer", ldt4, + std::string("20040815T050000-0700"), loc1); + teststreaming("New York in winter", ldt5, + std::string("20041215T070000-0500"), loc1); + teststreaming("Phoenix in Summer", ldt6, + std::string("20040815T050000-0700"), loc1); + teststreaming("Sydney in December", ldt1.local_time_in(sydney), + std::string("20041215T230000+1100"), loc1); + + // iso extended format + // show that zone offset is ignored + ptimefacet1->format(pt_facet::iso_time_format_extended_specifier); + std::cout << "\nLocal time iso_extended tests" << std::endl; + teststreaming("ptime with iso extended format\n", a_time, + std::string("2004-12-15 12:00:00") , loc2); + + timefacet->format(ldt_facet::iso_time_format_extended_specifier); + teststreaming("UTC local_date_time", ldt1, + std::string("2004-12-15 12:00:00Z"), loc1); + teststreaming("Chicago in summer", ldt2, + std::string("2004-08-15 07:00:00-05:00") , loc1); + teststreaming("Denver in winter", ldt3, + std::string("2004-12-15 05:00:00-07:00"), loc1); + teststreaming("Los Angeles in summer", ldt4, + std::string("2004-08-15 05:00:00-07:00"), loc1); + teststreaming("New York in winter", ldt5, + std::string("2004-12-15 07:00:00-05:00"), loc1); + teststreaming("Phoenix in Summer", ldt6, + std::string("2004-08-15 05:00:00-07:00"), loc1); + teststreaming("Sydney in December", ldt1.local_time_in(sydney), + std::string("2004-12-15 23:00:00+11:00"), loc1); + +#if !defined(BOOST_NO_STD_WSTRING) + + typedef boost::date_time::time_facet wldt_facet; + //wldt_facet* wtimefacet = new wldt_facet(L"%c %Z"); // full name + wldt_facet* wtimefacet = new wldt_facet(L"%a %b %d %H:%M:%S %Y %Z"); // full name + std::locale loc3(std::locale::classic(), wtimefacet); + + /* Again, wide stream tests are more thoroughly done in the + * time_facet tests. Here we just need to show that they work */ + std::cout << "\nFull time zone names tests - wide stream" << std::endl; + teststreaming("UTC local_date_time", ldt1, std::wstring(L"Wed Dec 15 12:00:00 2004 Coordinated Universal Time"), loc3); + teststreaming("Chicago in summer", ldt2, std::wstring(L"Sun Aug 15 07:00:00 2004 Central Daylight Time") , loc3); + + teststreaming("UTC local_time_period", ltp1, std::wstring(L"[Wed Dec 15 12:00:00 2004 Coordinated Universal Time/Wed Dec 15 22:24:04 2004 Coordinated Universal Time]"), loc3); + teststreaming("LA local_time_period", ltp2, std::wstring(L"[Sun Aug 15 05:00:00 2004 Pacific Daylight Time/Sun Aug 15 20:20:40 2004 Pacific Daylight Time]"), loc3); + + //wtimefacet->format(L"%c %z"); // abbrev + wtimefacet->format(L"%a %b %d %H:%M:%S %Y %z"); // abbrev + std::cout << "\nAbbreviated time zone names tests - wide stream" << std::endl; + teststreaming("UTC local_date_time", ldt1, std::wstring(L"Wed Dec 15 12:00:00 2004 UTC"), loc3); + teststreaming("Phoenix in Summer", ldt6, std::wstring(L"Sun Aug 15 05:00:00 2004 MST"), loc3); + +#endif // BOOST_NO_STD_WSTRING + + return printTestStats(); +} diff --git a/src/boost/libs/date_time/test/local_time/testlocal_time_input_facet.cpp b/src/boost/libs/date_time/test/local_time/testlocal_time_input_facet.cpp new file mode 100644 index 000000000..7622e5676 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testlocal_time_input_facet.cpp @@ -0,0 +1,239 @@ +/* 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include "boost/date_time/local_time/local_time.hpp" +#include "../testfrmwk.hpp" +#include +#include +#include + +// for tests that are expected to fail and throw exceptions +template +bool failure_test(temporal_type component, + const std::string& input, + exception_type const& /*except*/, + boost::local_time::local_time_input_facet* facet) +{ + using namespace boost::local_time; + bool result = false; + std::istringstream iss(input); + iss.exceptions(std::ios_base::failbit); // turn on exceptions + iss.imbue(std::locale(std::locale::classic(), facet)); + try { + iss >> component; + } + catch(exception_type& e) { + std::cout << "Expected exception caught: \"" + << e.what() << "\"" << std::endl; + result = iss.fail(); // failbit must be set to pass test + } + catch(...) { + result = false; + } + + return result; +} + +// for tests that are expected to fail quietly +template +bool failure_test(temporal_type component, + const std::string& input, + boost::local_time::local_time_input_facet* facet) +{ + using namespace boost::local_time; + std::istringstream iss(input); + /* leave exceptions turned off + * iss.exceptions(std::ios_base::failbit); */ + iss.imbue(std::locale(std::locale::classic(), facet)); + try { + iss >> component; + } + catch(...) { + std::cout << "Caught unexpected exception" << std::endl; + return false; + } + + return iss.fail(); // failbit must be set to pass test +} + +int main() { + using namespace boost::gregorian; + using namespace boost::posix_time; + using namespace boost::local_time; + time_zone_ptr null_zone; + local_date_time ldt1(not_a_date_time, null_zone); + + // verify wide stream works, thorough tests done in narrow stream +#if !defined(BOOST_NO_STD_WSTRING) + { + std::wstringstream ws; + ws.str(L"2005-Feb-15 12:15:00 EST-05EDT,M4.1.0,M10.5.0"); + ws >> ldt1; + check("Wide stream, Eastern US, daylight savings, winter, minimal input", + ldt1.local_time() == ptime(date(2005,2,15), time_duration(12,15,0))); + check("Wide stream, Eastern US, daylight savings, winter, minimal input", + ldt1.utc_time() == ptime(date(2005,2,15), time_duration(17,15,0))); + check("Wide stream, Eastern US, daylight savings, winter, minimal input", !ldt1.is_dst()); + ws.str(L""); + wlocal_time_input_facet* wfacet = new wlocal_time_input_facet(L"%m/%d/%y %ZP"); + std::locale loc(std::locale::classic(), wfacet); + ws.imbue(loc); + ws.str(L"10/31/04 PST-08PDT,M4.1.0,M10.5.0"); // midnight on end transition day, still in dst + ws >> ldt1; + std::wcout << ldt1.local_time() << std::endl; + check("Wide stream, Eastern US, daylight savings, winter, custom format", + ldt1.local_time() == ptime(date(2004,10,31), time_duration(0,0,0))); + check("Wide stream, Eastern US, daylight savings, winter, custom format", + ldt1.utc_time() == ptime(date(2004,10,31), time_duration(7,0,0))); + check("Wide stream, Eastern US, daylight savings, winter, custom format", ldt1.is_dst()); + } +#endif // BOOST_NO_STD_WSTRING + + std::stringstream ss; + ss.str("2005-Feb-25 12:15:00 EST-05EDT,M4.1.0,M10.5.0"); + ss >> ldt1; + check("Eastern US, daylight savings, winter, minimal input", + ldt1.local_time() == ptime(date(2005,2,25), time_duration(12,15,0))); + check("Eastern US, daylight savings, winter, minimal input", + ldt1.utc_time() == ptime(date(2005,2,25), time_duration(17,15,0))); + check("Eastern US, daylight savings, winter, minimal input", !ldt1.is_dst()); + ss.str(""); + + ss.str("2005-Aug-25 12:15:00 EST-05EDT,M4.1.0,M10.5.0"); + ss >> ldt1; + check("Eastern US, daylight savings, summer, minimal input", + ldt1.local_time() == ptime(date(2005,8,25), time_duration(12,15,0))); + check("Eastern US, daylight savings, summer, minimal input", + ldt1.utc_time() == ptime(date(2005,8,25), time_duration(16,15,0))); + check("Eastern US, daylight savings, summer, minimal input", ldt1.is_dst()); + ss.str(""); + + ss.str("2005-Apr-03 01:15:00 EST-05EDT,M4.1.0,M10.5.0"); + ss >> ldt1; + check("Eastern US, daylight savings, transition point", !ldt1.is_dst()); + ldt1 += hours(1); + check("Eastern US, daylight savings, transition point", ldt1.is_dst()); + ss.str(""); + ss.str("2005-Apr-03 01:15:00 EST-05EDT,93,303"); + ss >> ldt1; + check("Eastern US, daylight savings, transition point", !ldt1.is_dst()); + ldt1 += hours(1); + check("Eastern US, daylight savings, transition point", ldt1.is_dst()); + ss.str(""); + + ss.str("2005-Oct-30 00:15:00 EST-05EDT,M4.1.0,M10.5.0"); + ss >> ldt1; + check("Eastern US, daylight savings, transition point", ldt1.is_dst()); + ldt1 += hours(1); + check("Eastern US, daylight savings, transition point", ldt1.is_dst()); + ldt1 += hours(1); + check("Eastern US, daylight savings, transition point", !ldt1.is_dst()); + ss.str(""); + ss.str("2005-Oct-30 00:15:00 EST-05EDT,93,303"); + ss >> ldt1; + check("Eastern US, daylight savings, transition point", ldt1.is_dst()); + ldt1 += hours(1); + check("Eastern US, daylight savings, transition point", ldt1.is_dst()); + ldt1 += hours(1); + check("Eastern US, daylight savings, transition point", !ldt1.is_dst()); + ss.str(""); + + ss.str("2005-Aug-25 12:15:00 MST-07"); + ss >> ldt1; + check("Mountain US, no daylight savings", + ldt1.local_time() == ptime(date(2005,8,25), time_duration(12,15,0))); + check("Mountain US, no daylight savings", + ldt1.utc_time() == ptime(date(2005,8,25), time_duration(19,15,0))); + check("Mountain US, no daylight savings", !ldt1.is_dst()); + ss.str(""); + + // insure input & output formats match + local_time_facet* out_facet = + new local_time_facet(local_time_input_facet::default_time_input_format); + std::locale loc(std::locale::classic(), out_facet); + ss.imbue(loc); + time_zone_ptr syd_tz(new posix_time_zone("EST+10EST,M10.5.0,M3.5.0/03:00")); + ptime pt(date(2005,6,12), hours(0)); + local_date_time ldt2(pt, syd_tz); + ss << ldt2; + ss >> ldt1; + check("Output as input makes match", ldt1 == ldt2); + check("Output as input makes match", + ldt1.zone()->dst_local_start_time(2004) == ldt2.zone()->dst_local_start_time(2004)); + ss.str(""); + + time_zone_ptr f_tz(new posix_time_zone("FST+03FDT,90,300")); + ldt2 = local_date_time(ptime(date(2005,6,12), hours(0)), f_tz); + ss << ldt2; + ss >> ldt1; + check("Output as input makes match", ldt1 == ldt2); + check("Output as input makes match", + ldt1.zone()->dst_local_start_time(2004) == ldt2.zone()->dst_local_start_time(2004)); + ss.str(""); + + // missing input & wrong format tests + ss.str("2005-Oct-30 00:15:00"); + ss >> ldt1; + check("Missing time_zone spec makes UTC", ldt1.zone_as_posix_string() == std::string("UTC+00")); + check("Missing time_zone spec makes UTC", ldt1.utc_time() == ldt1.local_time()); + ss.str(""); + { + std::istringstream iss("2005-Aug-25 12:15:00 MST-07"); + local_time_input_facet* f = new local_time_input_facet("%Y-%b-%d %H:%M:%S %z"); + std::locale locx(std::locale::classic(), f); + iss.imbue(locx); + iss >> ldt1; + check("Wrong format flag makes UTC", ldt1.zone_as_posix_string() == std::string("UTC+00")); + check("Wrong format flag makes UTC", ldt1.utc_time() == ldt1.local_time()); + } + + + // failure tests: (posix_time_zone) bad_offset, bad_adjustment, + // (local_date_time) ambiguous_result, time_label_invalid, + // time/date failures already tested + ambiguous_result amb_ex("default"); + time_label_invalid inv_ex("default"); + check("Failure test ambiguous time label (w/exceptions)", + failure_test(ldt1, + "2005-Oct-30 01:15:00 EST-05EDT,M4.1.0,M10.5.0", + amb_ex, + new local_time_input_facet())); + check("Failure test ambiguous time label (no exceptions)", + failure_test(ldt1, + "2005-Oct-30 01:15:00 EST-05EDT,M4.1.0,M10.5.0", + new local_time_input_facet())); + check("Failure test ambiguous time label (w/exceptions)", + failure_test(ldt1, + "2005-Oct-30 01:15:00 EST-05EDT,93,303", + amb_ex, + new local_time_input_facet())); + check("Failure test ambiguous time label (no exceptions)", + failure_test(ldt1, + "2005-Oct-30 01:15:00 EST-05EDT,93,303", + new local_time_input_facet())); + check("Failure test invalid time label (w/exceptions)", + failure_test(ldt1, + "2005-Apr-03 02:15:00 EST-05EDT,M4.1.0,M10.5.0", + inv_ex, + new local_time_input_facet())); + check("Failure test invalid time label (no exceptions)", + failure_test(ldt1, + "2005-Apr-03 02:15:00 EST-05EDT,M4.1.0,M10.5.0", + new local_time_input_facet())); + check("Failure test invalid time label (w/exceptions)", + failure_test(ldt1, + "2005-Apr-03 02:15:00 EST-05EDT,93,303", + inv_ex, + new local_time_input_facet())); + check("Failure test invalid time label (no exceptions)", + failure_test(ldt1, + "2005-Apr-03 02:15:00 EST-05EDT,93,303", + new local_time_input_facet())); + + + return printTestStats(); +} diff --git a/src/boost/libs/date_time/test/local_time/testlocal_time_iterator.cpp b/src/boost/libs/date_time/test/local_time/testlocal_time_iterator.cpp new file mode 100644 index 000000000..670b572f4 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testlocal_time_iterator.cpp @@ -0,0 +1,95 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include +#include "boost/date_time/local_time/local_time.hpp" +#include "../testfrmwk.hpp" +// #if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS) +// #include "boost/date_time/gregorian/formatters_limited.hpp" +// #else +// #include "boost/date_time/gregorian/formatters.hpp" +// #endif + +using namespace boost::posix_time; +using namespace boost::gregorian; +using namespace boost::local_time; + +void iterate_backward(const local_date_time *answers, + int ary_len, + const time_duration& td) +{ + int i = ary_len -1; + local_date_time end = answers[i]; + local_time_iterator titr(end,td); + + std::cout << "counting down by previous duration..." << std::endl; + for (; titr >= answers[0]; --titr) { + std::cout << *titr << std::endl; + check("iterating backward", answers[i] == *titr); + --i; + } + check("iterating backward count", i == -1); // check the number of iterations + std::cout << std::endl; +} + +int +main() +{ + + time_zone_ptr ny_tz(new posix_time_zone("EST-05EDT,M4.1.0,M10.5.0")); + + //set up a time right on the dst boundary -- iterator will + //jump forward an hour at the boundary + date d(2005,Apr,3); + time_duration dst_offset(1,59,59); + local_date_time start(d, dst_offset, ny_tz, false); + + const local_date_time answer1[] = + { + local_date_time(d,dst_offset, ny_tz, false), + local_date_time(d,hours(3), ny_tz, true), + local_date_time(d,hours(3)+seconds(1), ny_tz, true), + local_date_time(d,hours(3)+seconds(2), ny_tz, true) + }; + + int i=0; + local_time_iterator titr(start,seconds(1)); + local_date_time end = start + seconds(4); + for (; titr < end; ++titr) { + std::cout << (*titr) << std::endl; + check("iterator -- 1 sec", answer1[i] == *titr); + i++; + } + check("iterator -- 1 sec -- num iterations", i == 4); // check the number of iterations + + iterate_backward(answer1, 4, seconds(1)); + + //iterate by hours + const local_date_time answer2[] = + { local_date_time(d,dst_offset, ny_tz, false), + local_date_time(d,dst_offset+hours(2), ny_tz, true), + local_date_time(d,dst_offset+hours(3), ny_tz, true), + local_date_time(d,dst_offset+hours(4), ny_tz, true) + }; + i=0; + local_time_iterator titr2(start,hours(1)); + local_date_time end2 = start + hours(4); + for (; titr2 < end2; ++titr2) { + std::cout << *titr2 << std::endl; + check("iterator -- 1 hour", answer2[i] == *titr2); + i++; + } + check("iterator -- 1 hour -- num iterations", i == 4); + + iterate_backward(answer2, 4, hours(1)); + + + + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/local_time/testlocal_time_period.cpp b/src/boost/libs/date_time/test/local_time/testlocal_time_period.cpp new file mode 100644 index 000000000..64c8f7564 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testlocal_time_period.cpp @@ -0,0 +1,82 @@ +/* Copyright (c) 2005 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/local_time/local_time.hpp" +#include "../testfrmwk.hpp" + +int main() +{ + using namespace boost::gregorian; + using namespace boost::posix_time; + using namespace boost::local_time; + date d1(2001,Jan, 1); + + time_zone_ptr az_tz(new posix_time_zone("MST-07")); + + local_date_time t1 (d1,hours(2), az_tz, false);//2001-Jan-1 02:00:00 + + local_date_time t2 (d1,hours(3), az_tz, false);//2001-Jan-1 03:00:00 + local_time_period p1(t1,t2); //2001-Jan-1 02:59:59 + local_time_period p2(p1); + check("copy construct & ==", p1 == p2); + local_time_period p3 = p2; + check("assignment", p3 == p2); + local_time_period p4(t1,hours(1)); + + check("length", p4.length() == hours(1)); + +// std::cout << to_simple_string(t1) << std::endl; +// std::cout << to_simple_string(p4) << std::endl; +// std::cout << to_simple_string(p1) << std::endl; + check("construction and ==", p1 == p4); + check("begin", p1.begin() == t1); + check("last", p1.end() == t2); + check("end", p1.last() == t2-time_duration::unit()); + +// std::cout << to_simple_string(p1) << std::endl; +// // check("last", p1.() == t2); + check("contains begin", p1.contains(t1)); + check("contains end-not", !p1.contains(t2)); + check("contains last", p1.contains(t2-seconds(1))); + local_date_time t3(date(2001,Jan,1),hours(4), az_tz, false); + local_time_period p5(t2,t3); + check("check contains", !p1.contains(p5.begin())); + check("check contains", !p5.contains(p1.begin())); + check("operator== not equal case", !(p1 == p5)); + check("less than order", p1 < p5); + check("greater than order", p5 > p1); + check("not equal", p5 != p1); + check("intersects with myself", p1.intersects(p1)); + check("not intersects", !(p1.intersects(p5))); + check("not intersects", !(p5.intersects(p1))); + + local_time_period p6(p5); + p6.shift(minutes(30)); +// std::cout << to_simple_string(p5) << std::endl; +// std::cout << to_simple_string(p6) << std::endl; + check("shifted intersects", p5.intersects(p6)); + check("shifted intersects", p6.intersects(p5)); + check("contains begin", p5.contains(p6.begin())); + p6.shift(minutes(30)); +// std::cout << to_simple_string(p5) << std::endl; +// std::cout << to_simple_string(p6) << std::endl; + check("shifted !intersects", !p5.intersects(p6)); + check("shifted !intersects", !p6.intersects(p5)); + p6.shift(minutes(-30)); +// std::cout << to_simple_string(p5) << std::endl; +// std::cout << to_simple_string(p6) << std::endl; + local_time_period p7 = p5.intersection(p6); +// std::cout << to_simple_string(p7) << std::endl; + check("shifted intersection", + p7 == local_time_period(local_date_time(d1,time_duration(3,30,0), az_tz, false), + local_date_time(d1,time_duration(4,0,0), az_tz, false))); + + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/local_time/testposix_time_zone.cpp b/src/boost/libs/date_time/test/local_time/testposix_time_zone.cpp new file mode 100644 index 000000000..7bf971e87 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testposix_time_zone.cpp @@ -0,0 +1,221 @@ +/* Copyright (c) 2003-2004 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + + +#include "boost/date_time/gregorian/gregorian.hpp" +//#include "boost/date_time/local_time/time_zone.hpp" +#include "../testfrmwk.hpp" + +#include "boost/date_time/local_time/posix_time_zone.hpp" + +#include +#include + +int main(){ + using namespace boost::local_time; + using namespace boost::posix_time; + using namespace boost::gregorian; + std::string specs[] = {"MST-07", "MST-07:00:00","EST-05EDT,M4.1.0,M10.5.0", "EST-05:00:00EDT+01:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00","PST-08PDT,J46/1:30,J310","PST-08PDT,45,310/0:30:00"}; + + posix_time_zone nyc1(specs[2]); + posix_time_zone nyc2(specs[3]); + time_duration td = hours(-5); + + check("Has DST", nyc1.has_dst() && nyc2.has_dst()); + check("UTC offset", nyc1.base_utc_offset() == td); + check("UTC offsets match", nyc1.base_utc_offset() == nyc2.base_utc_offset()); + check("Abbrevs", nyc1.std_zone_abbrev() == std::string("EST")); + check("Abbrevs", nyc2.std_zone_abbrev() == std::string("EST")); + check("Abbrevs", nyc1.dst_zone_abbrev() == std::string("EDT")); + check("Abbrevs", nyc2.dst_zone_abbrev() == std::string("EDT")); + // names not available for posix_time_zone, abbrevs used in their place + check("Names", nyc1.std_zone_name() == std::string("EST")); + check("Names", nyc2.std_zone_name() == std::string("EST")); + check("Names", nyc1.dst_zone_name() == std::string("EDT")); + check("Names", nyc2.dst_zone_name() == std::string("EDT")); + td = hours(1); + check("dst offset", nyc1.dst_offset() == td); + check("dst offsets match", nyc1.dst_offset() == nyc2.dst_offset()); + check("dst start", nyc1.dst_local_start_time(2003) == + ptime(date(2003,Apr,6),time_duration(2,0,0))); + check("dst starts match", nyc1.dst_local_start_time(2003) == + nyc2.dst_local_start_time(2003)); + check("dst end", nyc1.dst_local_end_time(2003) == + ptime(date(2003,Oct,26),time_duration(2,0,0))); + check("dst ends match", nyc1.dst_local_end_time(2003) == + nyc2.dst_local_end_time(2003)); + check("to posix string", + nyc1.to_posix_string() == std::string("EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00")); + check("to posix string", + nyc2.to_posix_string() == std::string("EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00")); + + + posix_time_zone az1(specs[0]); + posix_time_zone az2(specs[1]); + td = hours(-7); + + check("Has DST", !az1.has_dst() && !az2.has_dst()); + check("UTC offset", az1.base_utc_offset() == td); + check("UTC offsets match", az1.base_utc_offset() == az2.base_utc_offset()); + check("dst start in non-dst zone", + az1.dst_local_start_time(2005) == ptime(not_a_date_time)); + check("dst end in non-dst zone", + az2.dst_local_end_time(2005) == ptime(not_a_date_time)); + check("Abbrevs", az1.std_zone_abbrev() == std::string("MST")); + check("Abbrevs", az2.std_zone_abbrev() == std::string("MST")); + // non-dst zones default to empty strings for dst names & abbrevs + check("Abbrevs", az1.dst_zone_abbrev() == std::string("")); + check("Abbrevs", az2.dst_zone_abbrev() == std::string("")); + check("Names", az1.std_zone_name() == std::string("MST")); + check("Names", az2.std_zone_name() == std::string("MST")); + check("Names", az1.dst_zone_name() == std::string("")); + check("Names", az2.dst_zone_name() == std::string("")); + check("to posix string", + az1.to_posix_string() == std::string("MST-07")); + check("to posix string", + az2.to_posix_string() == std::string("MST-07")); + + + // bizzar time zone spec to fully test parsing + std::cout << "\nFictitious time zone" << std::endl; + posix_time_zone bz("BST+11:21:15BDT-00:28,M2.2.4/03:15:42,M11.5.2/01:08:53"); + check("hast dst", bz.has_dst()); + check("UTC offset", bz.base_utc_offset() == time_duration(11,21,15)); + check("Abbrev", bz.std_zone_abbrev() == std::string("BST")); + check("Abbrev", bz.dst_zone_abbrev() == std::string("BDT")); + check("dst offset", bz.dst_offset() == time_duration(0,-28,0)); + check("dst start", bz.dst_local_start_time(1962) == + ptime(date(1962,Feb,8),time_duration(3,15,42))); + check("dst end", bz.dst_local_end_time(1962) == + ptime(date(1962,Nov,27),time_duration(1,8,53))); + + // only checking start & end rules w/ 'J' notation + std::cout << "\n'J' notation Start/End rule tests..." << std::endl; + posix_time_zone la1(specs[4]); // "PST-08PDT,J124,J310" + //posix_time_zone la1("PST-08PDT,J1,J365");// Jan1/Dec31 + check("dst start", la1.dst_local_start_time(2003) == + ptime(date(2003,Feb,15),time_duration(1,30,0))); + check("dst end", la1.dst_local_end_time(2003) == + ptime(date(2003,Nov,6),time_duration(2,0,0))); + /* NOTE: la1 was created from a 'J' notation string but to_posix_string + * returns an 'n' notation string. The difference between the two + * is Feb-29 is always counted in an 'n' notation string and numbering + * starts at zero ('J' notation starts at one). + * Every possible date spec that can be written in 'J' notation can also + * be written in 'n' notation. The reverse is not true so 'n' notation + * is used as the output for to_posix_string(). */ + check("to posix string", + la1.to_posix_string() == std::string("PST-08PDT+01,45/01:30,310/02:00")); + + // only checking start & end rules w/ 'n' notation + std::cout << "\n'n' notation Start/End rule tests..." << std::endl; + posix_time_zone la2(specs[5]); // "PST-08PDT,124,310" + //posix_time_zone la2("PST-08PDT,0,365");// Jan1/Dec31 + check("dst start", la2.dst_local_start_time(2003) == + ptime(date(2003,Feb,15),time_duration(2,0,0))); + check("dst end", la2.dst_local_end_time(2003) == + ptime(date(2003,Nov,6),time_duration(0,30,0))); + check("to posix string", + la2.to_posix_string() == std::string("PST-08PDT+01,45/02:00,310/00:30")); + + // bad posix time zone strings tests + std::cout << "\nInvalid time zone string tests..." << std::endl; + try { + posix_time_zone badz("EST-13"); + check("Exception not thrown: bad UTC offset", false); + }catch(bad_offset& boff){ + std::string msg(boff.what()); + check("Exception caught: "+msg , true); + } + try { + posix_time_zone badz("EST-5EDT24:00:01,J124/1:30,J310"); + check("Exception not thrown: bad DST adjust", false); + }catch(bad_adjustment& badj){ + std::string msg(badj.what()); + check("Exception caught: "+msg , true); + } + try { + posix_time_zone badz("EST-5EDT01:00:00,J124/-1:30,J310"); + check("Exception not thrown: bad DST start/end offset", false); + }catch(bad_offset& boff){ + std::string msg(boff.what()); + check("Exception caught: "+msg , true); + } + try { + posix_time_zone badz("EST-5EDT01:00:00,J124/1:30,J370"); + check("Exception not thrown: invalid date spec", false); + }catch(boost::gregorian::bad_day_of_month& boff){ + std::string msg(boff.what()); + check("Exception caught: "+msg , true); + }catch(boost::gregorian::bad_month& boff){ + std::string msg(boff.what()); + check("Exception caught: "+msg , true); + }catch(...){ + check("Unexpected exception caught: ", false); + } + + std::cout << "\nTest some Central Europe specs" << std::endl; + + //Test a timezone spec on the positive side of the UTC line. + //This is the time for central europe which is one hour in front of UTC + //Note these Summer time transition rules aren't actually correct. + posix_time_zone cet_tz("CET+01:00:00EDT+01:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00"); + check("Has DST", cet_tz.has_dst()); + check("UTC offset", cet_tz.base_utc_offset() == hours(1)); + check("Abbrevs", cet_tz.std_zone_abbrev() == std::string("CET")); +// check("Abbrevs", nyc2.std_zone_abbrev() == std::string("EST")); + + std::cout << "\nTest some Central Austrialia UTC+8:30" << std::endl; + + //Test a timezone spec on the positive side of the UTC line. + //This is the time for central europe which is one hour in front of UTC + //Note these Summer time transition rules aren't actually correct. + posix_time_zone caus_tz("CAS+08:30:00CDT+01:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00"); + check("Has DST", caus_tz.has_dst()); + check("UTC offset", caus_tz.base_utc_offset() == hours(8)+minutes(30)); + check("Abbrevs", caus_tz.std_zone_abbrev() == std::string("CAS")); +// check("Abbrevs", nyc2.std_zone_abbrev() == std::string("EST")); + + { + /**** first/last of month Julian & non-Julian tests ****/ + // Mar-01 & Oct-31, count begins at 1 + std::string spec("FST+3FDT,J60,J304"); + posix_time_zone fl_1(spec); + check("Julian First/last of month", fl_1.dst_local_start_time(2003) == + ptime(date(2003,Mar,1),hours(2))); + check("Julian First/last of month", fl_1.dst_local_end_time(2003) == + ptime(date(2003,Oct,31),hours(2))); + check("Julian First/last of month", fl_1.dst_local_start_time(2004) == + ptime(date(2004,Mar,1),hours(2))); + check("Julian First/last of month", fl_1.dst_local_end_time(2004) == + ptime(date(2004,Oct,31),hours(2))); + + // Mar-01 & Oct-31 Non-leap year, count begins at 0 + spec = "FST+3FDT,59,304"; // "304" is not a mistake here, see posix_time_zone docs + posix_time_zone fl_2(spec); + try{ + check("Non-Julian First/last of month", fl_2.dst_local_start_time(2003) == + ptime(date(2003,Mar,1),hours(2))); + }catch(std::exception&){ + check("Expected exception caught for Non-Julian day of 59, in non-leap year (Feb-29)", true); + } + check("Non-Julian First/last of month", fl_2.dst_local_end_time(2003) == + ptime(date(2003,Oct,31),hours(2))); + + // Mar-01 & Oct-31 leap year, count begins at 0 + spec = "FST+3FDT,60,304"; + posix_time_zone fl_3(spec); + check("Non-Julian First/last of month", fl_3.dst_local_start_time(2004) == + ptime(date(2004,Mar,1),hours(2))); + check("Non-Julian First/last of month", fl_3.dst_local_end_time(2004) == + ptime(date(2004,Oct,31),hours(2))); + } + + printTestStats(); + return 0; +} + diff --git a/src/boost/libs/date_time/test/local_time/testtz_database.cpp b/src/boost/libs/date_time/test/local_time/testtz_database.cpp new file mode 100644 index 000000000..add2943b3 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testtz_database.cpp @@ -0,0 +1,116 @@ +/* Copyright (c) 2003-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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + + +#include "../testfrmwk.hpp" +#include "boost/date_time/gregorian/gregorian.hpp" +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/date_time/local_time/custom_time_zone.hpp" +#include "boost/date_time/local_time/local_time_types.hpp" +#include "boost/date_time/local_time/tz_database.hpp" +#include "boost/date_time/local_time/posix_time_zone.hpp" +#include + +bool run_bad_field_count_test(char const* fn); + +int main(int /* argc */, char const* argv[]){ + using namespace boost::gregorian; + using namespace boost::posix_time; + using namespace boost::local_time; + + /* NOTE: The testlocal_time_facet tests required full names + * be added to some of the date_time_zonespec.csv entries. The + * tests here also use those full names. Those entries are: + * Chicago, Denver, Los_Angeles, New_York, and Phoenix + * have all had full names added */ + + // run the exception tests first + try{ + tz_database tz_db; + tz_db.load_from_file("missing_file.csv"); // file does not exist + }catch(data_not_accessible&){ + check("Caught Missing data file exception", true); + }catch(...){ + check("Caught first unexpected exception", false); + } + check("Caught Bad field count exception", run_bad_field_count_test(argv[2])); + + tz_database tz_db; + try { + tz_db.load_from_file(argv[1]); + }catch(...) { + check("Cannot locate data file - aborting.", false); + return printTestStats(); + } + + time_zone_ptr bad_tz = tz_db.time_zone_from_region("Invalid/name"); + check("Expected null pointer return", bad_tz == time_zone_ptr()); + + time_zone_ptr nyc_test = tz_db.time_zone_from_region("America/New_York"); + check("nyc Valid pointer", nyc_test != time_zone_ptr() ); + check("nyc Abbreviations",nyc_test->std_zone_abbrev() == std::string("EST")); + check("nyc Full Name", nyc_test->std_zone_name() == std::string("Eastern Standard Time")); + check("nyc Abbreviations",nyc_test->dst_zone_abbrev() == std::string("EDT")); + //std::cout << nyc_test->std_zone_name() << std::endl; + check("nyc Full Name", nyc_test->dst_zone_name() == std::string("Eastern Daylight Time")); + check("nyc GMT Offset", nyc_test->base_utc_offset() == hours(-5)); + check("nyc DST Offset", nyc_test->dst_offset() == hours(1)); + //std::cout << nyc_test->dst_local_start_time(2004) << std::endl; + check("nyc dst start", nyc_test->dst_local_start_time(2007) == ptime(date(2007, Mar, 11), hours(2))); + check("nyc dst end", nyc_test->dst_local_end_time(2007) == ptime(date(2007, Nov, 4), hours(2))); + check("nyc has dst", nyc_test->has_dst()); + + time_zone_ptr phx_test = tz_db.time_zone_from_region("America/Phoenix"); + check("az Valid pointer", phx_test != time_zone_ptr() ); + check("az Abbreviations",phx_test->std_zone_abbrev() == std::string("MST")); + check("az Full Name", phx_test->std_zone_name() == std::string("Mountain Standard Time")); + check("az Abbreviations", phx_test->dst_zone_abbrev() == std::string("")); + check("az Full Name", phx_test->dst_zone_name() == std::string("")); + check("az GMT Offset", phx_test->base_utc_offset() == hours(-7)); + check("az DST Offset", phx_test->dst_offset() == hours(0)); + //std::cout << phx_test->dst_local_start_time(2004) << std::endl; + check("az has dst", phx_test->has_dst() == false); + + //Now add and retrieve a Posix tz spec from the database + time_zone_ptr eastern(new posix_time_zone("EST-05:00:00EDT+01:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00")); + tz_db.add_record("United States/Eastern", eastern); + time_zone_ptr eastern_test = tz_db.time_zone_from_region("United States/Eastern"); + check("eastern Valid pointer", eastern_test != time_zone_ptr() ); + check("eastern Abbreviations", + eastern_test->std_zone_abbrev() == std::string("EST")); + check("eastern Abbreviations", + eastern_test->std_zone_name() == std::string("EST")); + check("eastern Abbreviations", + eastern_test->dst_zone_abbrev() == std::string("EDT")); + check("eastern Abbreviations", + eastern_test->dst_zone_name() == std::string("EDT")); + check("eastern GMT Offset", eastern_test->base_utc_offset() == hours(-5)); + check("eastern dst start", eastern_test->dst_local_start_time(2004) == ptime(date(2004, Apr, 4), hours(2))); + check("eastern dst end", eastern_test->dst_local_end_time(2004) == ptime(date(2004, Oct, 31), hours(2))); + check("eastern has dst", eastern_test->has_dst() == true); + + + return printTestStats(); +} + +/* This test only checks to make sure the bad_field_count exception + * is properly thrown. It does not pay any attention to any other + * exception, those are tested elsewhere. */ +bool run_bad_field_count_test(char const* fn) +{ + using namespace boost::local_time; + bool caught_bfc = false; + tz_database other_db; + try{ + other_db.load_from_file(fn); + }catch(bad_field_count&){ + caught_bfc = true; + }catch(...) { + // do nothing (file not found) + } + return caught_bfc; +} diff --git a/src/boost/libs/date_time/test/local_time/testwcustom_time_zone.cpp b/src/boost/libs/date_time/test/local_time/testwcustom_time_zone.cpp new file mode 100644 index 000000000..ad25ac31d --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testwcustom_time_zone.cpp @@ -0,0 +1,89 @@ +/* Copyright (c) 2003-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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include "boost/date_time/local_time/local_time.hpp" +#include "../testfrmwk.hpp" +#include + +int +main() +{ + + using namespace boost::gregorian; + using namespace boost::posix_time; + using namespace boost::local_time; + + typedef custom_time_zone_base wcustom_time_zone; + + boost::shared_ptr + rule1(new partial_date_dst_rule(partial_date(30,Apr), + partial_date(30,Oct))); + + boost::shared_ptr + rule2(new first_last_dst_rule(first_last_dst_rule::start_rule(Sunday,Apr), + first_last_dst_rule::end_rule(Sunday,Oct))); + boost::shared_ptr + rule3(new last_last_dst_rule(last_last_dst_rule::start_rule(Sunday,Mar), + last_last_dst_rule::end_rule(Sunday,Oct))); + boost::shared_ptr rule4; // no daylight savings + + wtime_zone_names pst(L"Pacific Standard Time", + L"PST", + L"Pacific Daylight Time" , + L"PDT"); + wtime_zone_names mst(L"Mountain Standard Time", + L"MST", + L"" , + L""); + + dst_adjustment_offsets of(hours(1), hours(2), hours(2)); + dst_adjustment_offsets of2(hours(0), hours(0), hours(0)); // no daylight savings + + wtime_zone_ptr tz1(new wcustom_time_zone(pst, hours(-8), of, rule1)); + wtime_zone_ptr tz2(new wcustom_time_zone(pst, hours(-8), of, rule2)); + wtime_zone_ptr tz3(new wcustom_time_zone(pst, hours(-8), of, rule3)); + wtime_zone_ptr tz4(new wcustom_time_zone(mst, hours(-7), of2, rule4)); + + check("out string", + tz1->dst_zone_abbrev() == std::wstring(L"PDT")); + check("out string", + tz1->std_zone_abbrev() == std::wstring(L"PST")); + check("out string", + tz1->std_zone_name() == std::wstring(L"Pacific Standard Time")); + check("out string", + tz1->dst_zone_name() == std::wstring(L"Pacific Daylight Time")); + + check("dst offset", tz1->dst_offset() == hours(1)); + check("base offset", tz1->base_utc_offset() == hours(-8)); + check("has dst", tz1->has_dst()); + + check("dst start time", + tz1->dst_local_start_time(2003) == ptime(date(2003,Apr,30),hours(2))); + check("dst end time", + tz1->dst_local_end_time(2003) == ptime(date(2003,Oct,30),hours(2))); + + check("tz1 to posix string", + tz1->to_posix_string() == std::wstring(L"PST-08PDT+01,120/02:00,303/02:00")); + check("tz2 to posix string", + tz2->to_posix_string() == std::wstring(L"PST-08PDT+01,M4.1.0/02:00,M10.5.0/02:00")); + check("tz3 to posix string", + tz3->to_posix_string() == std::wstring(L"PST-08PDT+01,M3.5.0/02:00,M10.5.0/02:00")); + check("tz4 to posix string", + tz4->to_posix_string() == std::wstring(L"MST-07")); + + // test start/end for non-dst zone + check("has dst in non-dst zone", !tz4->has_dst()); + check("dst start in non-dst zone", + tz4->dst_local_start_time(2005) == ptime(not_a_date_time)); + check("dst end in non-dst zone", + tz4->dst_local_end_time(2005) == ptime(not_a_date_time)); + + + return printTestStats(); +} + + diff --git a/src/boost/libs/date_time/test/local_time/testwposix_time_zone.cpp b/src/boost/libs/date_time/test/local_time/testwposix_time_zone.cpp new file mode 100644 index 000000000..2bd11cbd6 --- /dev/null +++ b/src/boost/libs/date_time/test/local_time/testwposix_time_zone.cpp @@ -0,0 +1,224 @@ +/* Copyright (c) 2003-2004 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + + +#include "boost/date_time/gregorian/gregorian.hpp" +//#include "boost/date_time/local_time/time_zone.hpp" +#include "../testfrmwk.hpp" + +#include "boost/date_time/local_time/posix_time_zone.hpp" + +#include +#include + +int main(){ + using namespace boost::local_time; + using namespace boost::posix_time; + using namespace boost::gregorian; + + typedef posix_time_zone_base w_posix_time_zone; + + std::wstring specs[] = {L"MST-07", L"MST-07:00:00",L"EST-05EDT,M4.1.0,M10.5.0", L"EST-05:00:00EDT+01:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00",L"PST-08PDT,J46/1:30,J310",L"PST-08PDT,45,310/0:30:00"}; + + w_posix_time_zone nyc1(specs[2]); + w_posix_time_zone nyc2(specs[3]); + time_duration td = hours(-5); + + check("Has DST", nyc1.has_dst() && nyc2.has_dst()); + check("UTC offset", nyc1.base_utc_offset() == td); + check("UTC offsets match", nyc1.base_utc_offset() == nyc2.base_utc_offset()); + check("Abbrevs", nyc1.std_zone_abbrev() == std::wstring(L"EST")); + check("Abbrevs", nyc2.std_zone_abbrev() == std::wstring(L"EST")); + check("Abbrevs", nyc1.dst_zone_abbrev() == std::wstring(L"EDT")); + check("Abbrevs", nyc2.dst_zone_abbrev() == std::wstring(L"EDT")); + // names not available for w_posix_time_zone, abbrevs used in their place + check("Names", nyc1.std_zone_name() == std::wstring(L"EST")); + check("Names", nyc2.std_zone_name() == std::wstring(L"EST")); + check("Names", nyc1.dst_zone_name() == std::wstring(L"EDT")); + check("Names", nyc2.dst_zone_name() == std::wstring(L"EDT")); + td = hours(1); + check("dst offset", nyc1.dst_offset() == td); + check("dst offsets match", nyc1.dst_offset() == nyc2.dst_offset()); + check("dst start", nyc1.dst_local_start_time(2003) == + ptime(date(2003,Apr,6),time_duration(2,0,0))); + check("dst starts match", nyc1.dst_local_start_time(2003) == + nyc2.dst_local_start_time(2003)); + check("dst end", nyc1.dst_local_end_time(2003) == + ptime(date(2003,Oct,26),time_duration(2,0,0))); + check("dst ends match", nyc1.dst_local_end_time(2003) == + nyc2.dst_local_end_time(2003)); + check("to posix string", + nyc1.to_posix_string() == std::wstring(L"EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00")); + check("to posix string", + nyc2.to_posix_string() == std::wstring(L"EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00")); + + + w_posix_time_zone az1(specs[0]); + w_posix_time_zone az2(specs[1]); + td = hours(-7); + + check("Has DST", !az1.has_dst() && !az2.has_dst()); + check("UTC offset", az1.base_utc_offset() == td); + check("UTC offsets match", az1.base_utc_offset() == az2.base_utc_offset()); + check("dst start in non-dst zone", + az1.dst_local_start_time(2005) == ptime(not_a_date_time)); + check("dst end in non-dst zone", + az2.dst_local_end_time(2005) == ptime(not_a_date_time)); + check("Abbrevs", az1.std_zone_abbrev() == std::wstring(L"MST")); + check("Abbrevs", az2.std_zone_abbrev() == std::wstring(L"MST")); + // non-dst zones default to empty strings for dst names & abbrevs + check("Abbrevs", az1.dst_zone_abbrev() == std::wstring(L"")); + check("Abbrevs", az2.dst_zone_abbrev() == std::wstring(L"")); + check("Names", az1.std_zone_name() == std::wstring(L"MST")); + check("Names", az2.std_zone_name() == std::wstring(L"MST")); + check("Names", az1.dst_zone_name() == std::wstring(L"")); + check("Names", az2.dst_zone_name() == std::wstring(L"")); + check("to posix string", + az1.to_posix_string() == std::wstring(L"MST-07")); + check("to posix string", + az2.to_posix_string() == std::wstring(L"MST-07")); + + + // bizzar time zone spec to fully test parsing + std::cout << "\nFictitious time zone" << std::endl; + w_posix_time_zone bz(L"BST+11:21:15BDT-00:28,M2.2.4/03:15:42,M11.5.2/01:08:53"); + check("hast dst", bz.has_dst()); + check("UTC offset", bz.base_utc_offset() == time_duration(11,21,15)); + check("Abbrev", bz.std_zone_abbrev() == std::wstring(L"BST")); + check("Abbrev", bz.dst_zone_abbrev() == std::wstring(L"BDT")); + check("dst offset", bz.dst_offset() == time_duration(0,-28,0)); + check("dst start", bz.dst_local_start_time(1962) == + ptime(date(1962,Feb,8),time_duration(3,15,42))); + check("dst end", bz.dst_local_end_time(1962) == + ptime(date(1962,Nov,27),time_duration(1,8,53))); + + // only checking start & end rules w/ 'J' notation + std::cout << "\n'J' notation Start/End rule tests..." << std::endl; + w_posix_time_zone la1(specs[4]); // "PST-08PDT,J124,J310" + //w_posix_time_zone la1("PST-08PDT,J1,J365");// Jan1/Dec31 + check("dst start", la1.dst_local_start_time(2003) == + ptime(date(2003,Feb,15),time_duration(1,30,0))); + check("dst end", la1.dst_local_end_time(2003) == + ptime(date(2003,Nov,6),time_duration(2,0,0))); + /* NOTE: la1 was created from a 'J' notation string but to_posix_string + * returns an 'n' notation string. The difference between the two + * is Feb-29 is always counted in an 'n' notation string and numbering + * starts at zero ('J' notation starts at one). + * Every possible date spec that can be written in 'J' notation can also + * be written in 'n' notation. The reverse is not true so 'n' notation + * is used as the output for to_posix_string(). */ + check("to posix string", + la1.to_posix_string() == std::wstring(L"PST-08PDT+01,45/01:30,310/02:00")); + + // only checking start & end rules w/ 'n' notation + std::cout << "\n'n' notation Start/End rule tests..." << std::endl; + w_posix_time_zone la2(specs[5]); // "PST-08PDT,124,310" + //w_posix_time_zone la2("PST-08PDT,0,365");// Jan1/Dec31 + check("dst start", la2.dst_local_start_time(2003) == + ptime(date(2003,Feb,15),time_duration(2,0,0))); + check("dst end", la2.dst_local_end_time(2003) == + ptime(date(2003,Nov,6),time_duration(0,30,0))); + check("to posix string", + la2.to_posix_string() == std::wstring(L"PST-08PDT+01,45/02:00,310/00:30")); + + // bad posix time zone strings tests + std::cout << "\nInvalid time zone string tests..." << std::endl; + try { + w_posix_time_zone badz(L"EST-13"); + check("Exception not thrown: bad UTC offset", false); + }catch(bad_offset& boff){ + std::string msg(boff.what()); + check("Exception caught: "+msg , true); + } + try { + w_posix_time_zone badz(L"EST-5EDT24:00:01,J124/1:30,J310"); + check("Exception not thrown: bad DST adjust", false); + }catch(bad_adjustment& badj){ + std::string msg(badj.what()); + check("Exception caught: "+msg , true); + } + try { + w_posix_time_zone badz(L"EST-5EDT01:00:00,J124/-1:30,J310"); + check("Exception not thrown: bad DST start/end offset", false); + }catch(bad_offset& boff){ + std::string msg(boff.what()); + check("Exception caught: "+msg , true); + } + try { + w_posix_time_zone badz(L"EST-5EDT01:00:00,J124/1:30,J370"); + check("Exception not thrown: invalid date spec", false); + }catch(boost::gregorian::bad_day_of_month& boff){ + std::string msg(boff.what()); + check("Exception caught: "+msg , true); + }catch(boost::gregorian::bad_month& boff){ + std::string msg(boff.what()); + check("Exception caught: "+msg , true); + }catch(...){ + check("Unexpected exception caught: ", false); + } + + std::cout << "\nTest some Central Europe specs" << std::endl; + + //Test a timezone spec on the positive side of the UTC line. + //This is the time for central europe which is one hour in front of UTC + //Note these Summer time transition rules aren't actually correct. + w_posix_time_zone cet_tz(L"CET+01:00:00EDT+01:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00"); + check("Has DST", cet_tz.has_dst()); + check("UTC offset", cet_tz.base_utc_offset() == hours(1)); + check("Abbrevs", cet_tz.std_zone_abbrev() == std::wstring(L"CET")); +// check("Abbrevs", nyc2.std_zone_abbrev() == std::wstring("EST")); + + std::cout << "\nTest some Central Austrialia UTC+8:30" << std::endl; + + //Test a timezone spec on the positive side of the UTC line. + //This is the time for central europe which is one hour in front of UTC + //Note these Summer time transition rules aren't actually correct. + w_posix_time_zone caus_tz(L"CAS+08:30:00CDT+01:00:00,M4.1.0/02:00:00,M10.5.0/02:00:00"); + check("Has DST", caus_tz.has_dst()); + check("UTC offset", caus_tz.base_utc_offset() == hours(8)+minutes(30)); + check("Abbrevs", caus_tz.std_zone_abbrev() == std::wstring(L"CAS")); +// check("Abbrevs", nyc2.std_zone_abbrev() == std::wstring("EST")); + + { + /**** first/last of month Julian & non-Julian tests ****/ + // Mar-01 & Oct-31, count begins at 1 + std::wstring spec(L"FST+3FDT,J60,J304"); + w_posix_time_zone fl_1(spec); + check("Julian First/last of month", fl_1.dst_local_start_time(2003) == + ptime(date(2003,Mar,1),hours(2))); + check("Julian First/last of month", fl_1.dst_local_end_time(2003) == + ptime(date(2003,Oct,31),hours(2))); + check("Julian First/last of month", fl_1.dst_local_start_time(2004) == + ptime(date(2004,Mar,1),hours(2))); + check("Julian First/last of month", fl_1.dst_local_end_time(2004) == + ptime(date(2004,Oct,31),hours(2))); + + // Mar-01 & Oct-31 Non-leap year, count begins at 0 + spec = L"FST+3FDT,59,304"; // "304" is not a mistake here, see posix_time_zone docs + w_posix_time_zone fl_2(spec); + try{ + check("Non-Julian First/last of month", fl_2.dst_local_start_time(2003) == + ptime(date(2003,Mar,1),hours(2))); + }catch(std::exception&){ + check("Expected exception caught for Non-Julian day of 59, in non-leap year (Feb-29)", true); + } + check("Non-Julian First/last of month", fl_2.dst_local_end_time(2003) == + ptime(date(2003,Oct,31),hours(2))); + + // Mar-01 & Oct-31 leap year, count begins at 0 + spec = L"FST+3FDT,60,304"; + w_posix_time_zone fl_3(spec); + check("Non-Julian First/last of month", fl_3.dst_local_start_time(2004) == + ptime(date(2004,Mar,1),hours(2))); + check("Non-Julian First/last of month", fl_3.dst_local_end_time(2004) == + ptime(date(2004,Oct,31),hours(2))); + } + + printTestStats(); + return 0; +} + diff --git a/src/boost/libs/date_time/test/posix_time/compile_fail/hours_special_value.cpp b/src/boost/libs/date_time/test/posix_time/compile_fail/hours_special_value.cpp new file mode 100644 index 000000000..c2d001df7 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/compile_fail/hours_special_value.cpp @@ -0,0 +1,19 @@ +// +// Copyright (c) 2017 James E. King III +// Use, modification and distribution is 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) +// + +#include +#include +#include + +int main() +{ + using boost::date_time::pos_infin; + using boost::posix_time::hours; + boost::ignore_unused(hours(static_cast(pos_infin))); // compiles: it's an integral + boost::ignore_unused(hours(pos_infin)); // won't compile: not an integral + return 1; // return an error if we actually compile +} diff --git a/src/boost/libs/date_time/test/posix_time/compile_fail/millisec_special_value.cpp b/src/boost/libs/date_time/test/posix_time/compile_fail/millisec_special_value.cpp new file mode 100644 index 000000000..a8d18cc59 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/compile_fail/millisec_special_value.cpp @@ -0,0 +1,19 @@ +// +// Copyright (c) 2017 James E. King III +// Use, modification and distribution is 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) +// + +#include +#include +#include + +int main() +{ + using boost::date_time::pos_infin; + using boost::posix_time::millisec; + boost::ignore_unused(millisec(static_cast(pos_infin))); // compiles: it's a number + boost::ignore_unused(millisec(pos_infin)); // won't compile: not an integral + return 1; // return an error if we actually run for some reason +} diff --git a/src/boost/libs/date_time/test/posix_time/compile_fail/minutes_special_value.cpp b/src/boost/libs/date_time/test/posix_time/compile_fail/minutes_special_value.cpp new file mode 100644 index 000000000..f99b722f7 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/compile_fail/minutes_special_value.cpp @@ -0,0 +1,19 @@ +// +// Copyright (c) 2017 James E. King III +// Use, modification and distribution is 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) +// + +#include +#include +#include + +int main() +{ + using boost::date_time::pos_infin; + using boost::posix_time::minutes; + boost::ignore_unused(minutes(static_cast(pos_infin))); // compiles: it's an integral + boost::ignore_unused(minutes(pos_infin)); // won't compile: not an integral + return 1; // return an error if we actually run for some reason +} diff --git a/src/boost/libs/date_time/test/posix_time/compile_fail/seconds_special_value.cpp b/src/boost/libs/date_time/test/posix_time/compile_fail/seconds_special_value.cpp new file mode 100644 index 000000000..c3ccc7636 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/compile_fail/seconds_special_value.cpp @@ -0,0 +1,19 @@ +// +// Copyright (c) 2017 James E. King III +// Use, modification and distribution is 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) +// + +#include +#include +#include + +int main() +{ + using boost::date_time::pos_infin; + using boost::posix_time::seconds; + boost::ignore_unused(seconds(static_cast(pos_infin))); // compiles: it's an integral + boost::ignore_unused(seconds(pos_infin)); // won't compile: not an integral + return 1; // return an error if we actually run for some reason +} diff --git a/src/boost/libs/date_time/test/posix_time/testc_local_adjustor.cpp b/src/boost/libs/date_time/test/posix_time/testc_local_adjustor.cpp new file mode 100644 index 000000000..d9947a6eb --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testc_local_adjustor.cpp @@ -0,0 +1,131 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/date_time/c_local_time_adjustor.hpp" +#include "../testfrmwk.hpp" + +int +main() +{ + using namespace boost::posix_time; + using namespace boost::gregorian; + + //These are a compile check / test. They have to be hand inspected + //b/c they depend on the TZ settings of the machine and hence it is + //unclear what the results will be + typedef boost::date_time::c_local_adjustor local_adj; + + bool btd1e = false; + bool btd2e = false; + bool btd3e = false; + time_duration td1; + time_duration td2; + time_duration td3; + + try + { + ptime t1(date(2002,Jan,1), hours(7)+millisec(5)); + std::cout << "UTC <--> TZ Setting of Machine -- No DST" << std::endl; + ptime t2 = local_adj::utc_to_local(t1); + std::cout << t2 << " LOCAL is " + << t1 << " UTC time " + << std::endl; + td1 = t2 - t1; + std::cout << "A difference of: " << td1 + << std::endl; + } + catch (std::runtime_error & re) + { + btd1e = true; + check(re.what(), false); + } + + try + { + ptime t3(date(2002,May,1), hours(5)+millisec(5)); + std::cout << "UTC <--> TZ Setting of Machine -- In DST" << std::endl; + ptime t4 = local_adj::utc_to_local(t3); + std::cout << t4 << " LOCAL is " + << t3 << " UTC time " + << std::endl; + td2 = t4 - t3; + std::cout << "A difference of: " << td2 + << std::endl; + } + catch (std::runtime_error & re) + { + btd2e = true; + check(re.what(), false); + } + + try + { + ptime t5(date(2040,May,1), hours(5)+millisec(5)); + std::cout << "UTC <--> TZ Setting of Machine -- In DST" << std::endl; + ptime t6 = local_adj::utc_to_local(t5); + std::cout << t6 << " LOCAL is " + << t5 << " UTC time " + << std::endl; + td3 = t6 - t5; + std::cout << "a difference of: " << td3 + << std::endl; + } + catch (std::runtime_error & re) + { + btd3e = true; + check(re.what(), false); + } + catch (std::bad_cast&) + { + btd3e = true; + check("32-bit time_t overflow detected", sizeof(std::time_t) < 8); + } + + // The following tests are unaware of the local time zone, but they + // should help spot some errors. Manual inspection could still be + // required. + + // Based on http://stackoverflow.com/questions/8131023 + // All time zones are between -12 and +14 + if (!btd1e) + { + check("td1 isn't too low", td1 >= hours(-12)); + check("td1 isn't too high", td1 <= hours(14)); + } + if (!btd2e) + { + check("td2 isn't too low", td2 >= hours(-12)); + check("td2 isn't too high", td2 <= hours(14)); + } + if (!btd3e) + { + check("td3 isn't too low", td3 >= hours(-12)); + check("td3 isn't too high", td3 <= hours(14)); + } + + // Assuming that no one uses DST of more than an hour. + if (!btd1e && !btd2e) + { + check("td1 and td2 are close", + td1 - td2 <= hours(1) && td2 - td1 <= hours(1)); + } + if (!btd2e && !btd3e) + { + check("td2 and td3 are close", + td2 - td3 <= hours(2) && td3 - td2 <= hours(2)); + } + if (!btd1e && !btd3e) + { + check("td1 and td3 are close", + td1 - td3 <= hours(1) && td3 - td1 <= hours(1)); + } + + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/posix_time/testclock.cpp b/src/boost/libs/date_time/test/posix_time/testclock.cpp new file mode 100644 index 000000000..6341cc81b --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testclock.cpp @@ -0,0 +1,42 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include +#include "boost/date_time/posix_time/posix_time.hpp" +#include + +int +main() +{ + + using namespace boost::posix_time; + ptime tl = second_clock::local_time(); + std::cout << tl << std::endl; + + ptime tu = second_clock::universal_time(); + std::cout << tu << std::endl; + +#if !defined(BOOST_WINDOWS) && defined(_POSIX_TIMERS) + for (int i=0; i < 3; ++i) { + ptime t2 = second_clock::local_time(); + std::cout << t2 << std::endl; + sleep(1); + } +#endif + +#ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK + for (int i=0; i < 10; ++i) { + //ptime t2 = high_precision_clock::local_time(); + ptime t2 = microsec_clock::local_time(); + std::cout << t2 << std::endl; + } +#endif // BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK + + return 0; + +} + diff --git a/src/boost/libs/date_time/test/posix_time/testdst_rules.cpp b/src/boost/libs/date_time/test/posix_time/testdst_rules.cpp new file mode 100644 index 000000000..83fc1b523 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testdst_rules.cpp @@ -0,0 +1,451 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/date_time/local_timezone_defs.hpp" +#include "../testfrmwk.hpp" + +// Define dst rule for Paraguay which is transitions forward on Oct 1 and +// back Mar 1 + +struct paraguay_dst_traits { + typedef boost::gregorian::date date_type; + typedef boost::gregorian::date::day_type day_type; + typedef boost::gregorian::date::month_type month_type; + typedef boost::gregorian::date::year_type year_type; + typedef boost::date_time::partial_date start_rule_functor; + typedef boost::date_time::partial_date end_rule_functor; + static day_type start_day(year_type) {return 1;} + static month_type start_month(year_type) {return boost::date_time::Oct;} + static day_type end_day(year_type) {return 1;} + static month_type end_month(year_type) {return boost::date_time::Mar;} + static int dst_start_offset_minutes() { return 120;} + static int dst_end_offset_minutes() { return 120; } + static int dst_shift_length_minutes() { return 60; } + static date_type local_dst_start_day(year_type year) + { + start_rule_functor start(start_day(year), + start_month(year)); + return start.get_date(year); + } + static date_type local_dst_end_day(year_type year) + { + end_rule_functor end(end_day(year), + end_month(year)); + return end.get_date(year); + } + + +}; + + +// see http://www.timeanddate.com/time/aboutdst.html for some info +// also +int +main() +{ + using namespace boost::posix_time; + using namespace boost::gregorian; + date d(2002,Feb,1); + ptime t(d); + + //The following defines the US dst boundaries, except that the + //start and end dates are hard coded. + typedef boost::date_time::us_dst_rules us_dst_local; + date dst_start(2002,Apr, 7); + date dst_end(2002,Oct, 27); + + ptime t3a(dst_start, time_duration(2,0,0)); //invalid time label + ptime t3b(dst_start, time_duration(2,59,59)); //invalid time label + ptime t4(dst_start, time_duration(1,59,59)); //not ds + ptime t5(dst_start, time_duration(3,0,0)); //always dst + ptime t6(dst_end, time_duration(0,59,59)); //is dst + ptime t7(dst_end, time_duration(1,0,0)); //ambiguous + ptime t8(dst_end, time_duration(1,59,59)); //ambiguous + ptime t9(dst_end, time_duration(2,0,0)); //always not dst + + check("dst start", us_dst_local::local_dst_start_day(2002) == dst_start); + check("dst end", us_dst_local::local_dst_end_day(2002) == dst_end); + check("dst boundary", us_dst_local::is_dst_boundary_day(dst_start)); + check("dst boundary", us_dst_local::is_dst_boundary_day(dst_end)); + check("check if time is dst -- not", + us_dst_local::local_is_dst(t.date(), t.time_of_day())==boost::date_time::is_not_in_dst); + check("label on dst boundary invalid", + us_dst_local::local_is_dst(t3a.date(),t3a.time_of_day())==boost::date_time::invalid_time_label); + check("label on dst boundary invalid", + us_dst_local::local_is_dst(t3b.date(),t3b.time_of_day())==boost::date_time::invalid_time_label); + check("check if time is dst -- not", + us_dst_local::local_is_dst(t4.date(),t4.time_of_day())==boost::date_time::is_not_in_dst); + check("check if time is dst -- yes", + us_dst_local::local_is_dst(t5.date(),t5.time_of_day())==boost::date_time::is_in_dst); + + check("check if time is dst -- not", + us_dst_local::local_is_dst(t6.date(),t6.time_of_day())==boost::date_time::is_in_dst); + check("check if time is dst -- ambig", + us_dst_local::local_is_dst(t7.date(),t7.time_of_day())==boost::date_time::ambiguous); + check("check if time is dst -- ambig", + us_dst_local::local_is_dst(t8.date(),t8.time_of_day())==boost::date_time::ambiguous); + check("check if time is dst -- not", + us_dst_local::local_is_dst(t9.date(),t9.time_of_day())==boost::date_time::is_not_in_dst); + + + //Now try a local without dst + typedef boost::date_time::null_dst_rules no_dst_adj; + + check("check null dst rules", + no_dst_adj::local_is_dst(t4.date(),t4.time_of_day())==boost::date_time::is_not_in_dst); + check("check null dst rules", + no_dst_adj::local_is_dst(t5.date(),t5.time_of_day())==boost::date_time::is_not_in_dst); + check("check null dst rules", + no_dst_adj::utc_is_dst(t4.date(),t4.time_of_day())==boost::date_time::is_not_in_dst); + check("check null dst rules", + no_dst_adj::utc_is_dst(t5.date(),t5.time_of_day())==boost::date_time::is_not_in_dst); + + + //Try a southern hemisphere adjustment calculation + //This is following the rules for South Australia as best I can + //decipher them. Basically conversion to DST is last Sunday in + //October 02:00:00 and conversion off of dst is last sunday in + //March 02:00:00. + //This stuff uses the dst calculator directly... + date dst_start2(2002,Oct,27); //last Sunday in Oct + date dst_end2(2002,Mar,31); //last Sunday in March + + typedef boost::date_time::dst_calculator dstcalc; + //clearly not in dst + boost::date_time::time_is_dst_result a1 = + dstcalc::local_is_dst(date(2002,May,1),hours(3), + dst_start2, 120, + dst_end2, 180, + 60); + + check("check southern not dst", a1==boost::date_time::is_not_in_dst); + + boost::date_time::time_is_dst_result a2 = + dstcalc::local_is_dst(date(2002,Jan,1),hours(3), + dst_start2, 120, + dst_end2, 180, + 60); + + check("check southern is dst", a2==boost::date_time::is_in_dst); + + boost::date_time::time_is_dst_result a3 = + dstcalc::local_is_dst(date(2002,Oct,28),hours(3), + dst_start2, 120, + dst_end2, 180, + 60); + + check("check southern is dst", a3==boost::date_time::is_in_dst); + boost::date_time::time_is_dst_result a4 = + dstcalc::local_is_dst(date(2002,Oct,27),time_duration(1,59,59), + dst_start2, 120, + dst_end2, 180, + 60); + check("check southern boundary-not dst", a4==boost::date_time::is_not_in_dst); + boost::date_time::time_is_dst_result a5 = + dstcalc::local_is_dst(date(2002,Oct,27),hours(3), + dst_start2, 120, + dst_end2, 180, + 60); + check("check southern boundary-is dst", a5==boost::date_time::is_in_dst); + boost::date_time::time_is_dst_result a6 = + dstcalc::local_is_dst(date(2002,Oct,27),hours(2), + dst_start2, 120, + dst_end2, 180, + 60); + check("check southern boundary-invalid time", a6==boost::date_time::invalid_time_label); + boost::date_time::time_is_dst_result a7 = + dstcalc::local_is_dst(date(2002,Mar,31),time_duration(1,59,59), + dst_start2, 120, + dst_end2, 180, + 60); + check("check southern boundary-is dst", a7==boost::date_time::is_in_dst); + boost::date_time::time_is_dst_result a8 = + dstcalc::local_is_dst(date(2002,Mar,31),time_duration(2,0,0), + dst_start2, 120, + dst_end2, 180, + 60); + check("check southern boundary-ambiguous", a8==boost::date_time::ambiguous); + boost::date_time::time_is_dst_result a9 = + dstcalc::local_is_dst(date(2002,Mar,31),time_duration(2,59,59), + dst_start2, 120, + dst_end2, 180, + 60); + check("check southern boundary-ambiguous", a9==boost::date_time::ambiguous); + boost::date_time::time_is_dst_result a10 = + dstcalc::local_is_dst(date(2002,Mar,31),time_duration(3,0,0), + dst_start2, 120, + dst_end2, 180, + 60); + check("check southern boundary-not", a10==boost::date_time::is_not_in_dst); + + /******************** post release 1 -- new dst calc engine ********/ + + typedef boost::date_time::us_dst_trait us_dst_traits; + typedef boost::date_time::dst_calc_engine + us_dst_calc2; + + { + // us_dst_calc2 + check("dst start", us_dst_calc2::local_dst_start_day(2002) == dst_start); + check("dst end", us_dst_calc2::local_dst_end_day(2002) == dst_end); + // std::cout << us_dst_calc2::local_dst_end_day(2002) << std::endl; + check("dst boundary", us_dst_calc2::is_dst_boundary_day(dst_start)); + check("dst boundary", us_dst_calc2::is_dst_boundary_day(dst_end)); + + check("check if time is dst -- not", + us_dst_calc2::local_is_dst(t.date(), t.time_of_day())==boost::date_time::is_not_in_dst); + check("label on dst boundary invalid", + us_dst_calc2::local_is_dst(t3a.date(),t3a.time_of_day())==boost::date_time::invalid_time_label); + check("label on dst boundary invalid", + us_dst_calc2::local_is_dst(t3b.date(),t3b.time_of_day())==boost::date_time::invalid_time_label); + check("check if time is dst -- not", + us_dst_calc2::local_is_dst(t4.date(),t4.time_of_day())==boost::date_time::is_not_in_dst); + check("check if time is dst -- yes", + us_dst_calc2::local_is_dst(t5.date(),t5.time_of_day())==boost::date_time::is_in_dst); + + check("check if time is dst -- not", + us_dst_calc2::local_is_dst(t6.date(),t6.time_of_day())==boost::date_time::is_in_dst); + check("check if time is dst -- ambig", + us_dst_calc2::local_is_dst(t7.date(),t7.time_of_day())==boost::date_time::ambiguous); + check("check if time is dst -- ambig", + us_dst_calc2::local_is_dst(t8.date(),t8.time_of_day())==boost::date_time::ambiguous); + check("check if time is dst -- not", + us_dst_calc2::local_is_dst(t9.date(),t9.time_of_day())==boost::date_time::is_not_in_dst); + } + { + //some new checks for the new 2007 us dst rules + date dst_start07(2007,Mar, 11); + date dst_end07(2007,Nov, 4); + + check("dst start07", us_dst_calc2::local_dst_start_day(2007) == dst_start07); + check("dst end07", us_dst_calc2::local_dst_end_day(2007) == dst_end07); + check("dst boundary07", us_dst_calc2::is_dst_boundary_day(dst_start07)); + check("dst boundary07", us_dst_calc2::is_dst_boundary_day(dst_end07)); + + date dst_start08(2008,Mar, 9); + date dst_end08(2008,Nov, 2); + + check("dst start08", us_dst_calc2::local_dst_start_day(2008) == dst_start08); + check("dst end08", us_dst_calc2::local_dst_end_day(2008) == dst_end08); + check("dst boundary08", us_dst_calc2::is_dst_boundary_day(dst_start08)); + check("dst boundary08", us_dst_calc2::is_dst_boundary_day(dst_end08)); + + date dst_start09(2009,Mar, 8); + date dst_end09(2009,Nov, 1); + + check("dst start09", us_dst_calc2::local_dst_start_day(2009) == dst_start09); + check("dst end09", us_dst_calc2::local_dst_end_day(2009) == dst_end09); + check("dst boundary09", us_dst_calc2::is_dst_boundary_day(dst_start09)); + check("dst boundary09", us_dst_calc2::is_dst_boundary_day(dst_end09)); + + } + + + + /******************** post release 1 -- new dst calc engine - eu dst ********/ + + + typedef boost::date_time::eu_dst_trait eu_dst_traits; + typedef boost::date_time::dst_calc_engine + eu_dst_calc; + date eu_dst_start(2002,Mar, 31); + date eu_dst_end(2002,Oct, 27); + ptime eu_invalid1(eu_dst_start, time_duration(2,0,0)); //invalid time label + ptime eu_invalid2(eu_dst_start, time_duration(2,59,59)); //invalid time label + ptime eu_notdst1(eu_dst_start, time_duration(1,59,59)); //not ds + ptime eu_isdst1(eu_dst_start, time_duration(3,0,0)); //always dst + ptime eu_isdst2(eu_dst_end, time_duration(1,59,59)); //is dst + ptime eu_amgbig1(eu_dst_end, time_duration(2,0,0)); //ambiguous + ptime eu_amgbig2(eu_dst_end, time_duration(2,59,59)); //ambiguous + ptime eu_notdst2(eu_dst_end, time_duration(3,0,0)); //always not dst + + check("eu dst start", eu_dst_calc::local_dst_start_day(2002) == eu_dst_start); + check("eu dst end", eu_dst_calc::local_dst_end_day(2002) == eu_dst_end); + check("eu dst boundary", eu_dst_calc::is_dst_boundary_day(eu_dst_start)); + check("eu dst boundary", eu_dst_calc::is_dst_boundary_day(eu_dst_end)); + // on forward shift boundaries + check("eu label on dst boundary invalid", + eu_dst_calc::local_is_dst(eu_invalid1.date(),eu_invalid1.time_of_day())==boost::date_time::invalid_time_label); + check("eu label on dst boundary invalid", + eu_dst_calc::local_is_dst(eu_invalid2.date(),eu_invalid2.time_of_day())==boost::date_time::invalid_time_label); + check("eu check if time is dst -- not", + eu_dst_calc::local_is_dst(eu_notdst1.date(),eu_notdst1.time_of_day())==boost::date_time::is_not_in_dst); + check("check if time is dst -- yes", + eu_dst_calc::local_is_dst(eu_isdst1.date(),eu_isdst1.time_of_day())==boost::date_time::is_in_dst); + //backward shift boundary + check("eu check if time is dst -- yes", + eu_dst_calc::local_is_dst(eu_isdst2.date(),eu_isdst2.time_of_day())==boost::date_time::is_in_dst); + check("eu check if time is dst -- ambig", + eu_dst_calc::local_is_dst(eu_amgbig1.date(),eu_amgbig1.time_of_day())==boost::date_time::ambiguous); + check("eu check if time is dst -- ambig", + eu_dst_calc::local_is_dst(eu_amgbig2.date(),eu_amgbig2.time_of_day())==boost::date_time::ambiguous); + check("eu check if time is dst -- not", + eu_dst_calc::local_is_dst(eu_notdst2.date(),eu_notdst2.time_of_day())==boost::date_time::is_not_in_dst); + +/******************** post release 1 -- new dst calc engine - gb dst ********/ + + + /* Several places in Great Britan use eu start and end rules for the + day, but different local conversion times (eg: forward change at 1:00 + am local and backward change at 2:00 am dst instead of 2:00am + forward and 3:00am back for the EU). + */ + + typedef boost::date_time::uk_dst_trait uk_dst_traits; + + typedef boost::date_time::dst_calc_engine uk_dst_calc; + + + date uk_dst_start(2002,Mar, 31); + date uk_dst_end(2002,Oct, 27); + ptime uk_invalid1(uk_dst_start, time_duration(1,0,0)); //invalid time label + ptime uk_invalid2(uk_dst_start, time_duration(1,59,59)); //invalid time label + ptime uk_notdst1(uk_dst_start, time_duration(0,59,59)); //not ds + ptime uk_isdst1(uk_dst_start, time_duration(2,0,0)); //always dst + ptime uk_isdst2(uk_dst_end, time_duration(0,59,59)); //is dst + ptime uk_amgbig1(uk_dst_end, time_duration(1,0,0)); //ambiguous + ptime uk_amgbig2(uk_dst_end, time_duration(1,59,59)); //ambiguous + ptime uk_notdst2(uk_dst_end, time_duration(3,0,0)); //always not dst + + check("uk dst start", uk_dst_calc::local_dst_start_day(2002) == uk_dst_start); + check("uk dst end", uk_dst_calc::local_dst_end_day(2002) == uk_dst_end); + check("uk dst boundary", uk_dst_calc::is_dst_boundary_day(uk_dst_start)); + check("uk dst boundary", uk_dst_calc::is_dst_boundary_day(uk_dst_end)); + // on forward shift boundaries + check("uk label on dst boundary invalid", + uk_dst_calc::local_is_dst(uk_invalid1.date(),uk_invalid1.time_of_day())==boost::date_time::invalid_time_label); + check("uk label on dst boundary invalid", + uk_dst_calc::local_is_dst(uk_invalid2.date(),uk_invalid2.time_of_day())==boost::date_time::invalid_time_label); + check("uk check if time is dst -- not", + uk_dst_calc::local_is_dst(uk_notdst1.date(),uk_notdst1.time_of_day())==boost::date_time::is_not_in_dst); + check("uk check if time is dst -- yes", + uk_dst_calc::local_is_dst(uk_isdst1.date(),uk_isdst1.time_of_day())==boost::date_time::is_in_dst); + //backward shift boundary + check("uk check if time is dst -- yes", + uk_dst_calc::local_is_dst(uk_isdst2.date(),uk_isdst2.time_of_day())==boost::date_time::is_in_dst); + check("uk check if time is dst -- ambig", + uk_dst_calc::local_is_dst(uk_amgbig1.date(),uk_amgbig1.time_of_day())==boost::date_time::ambiguous); + check("uk check if time is dst -- ambig", + uk_dst_calc::local_is_dst(uk_amgbig2.date(),uk_amgbig2.time_of_day())==boost::date_time::ambiguous); + check("uk check if time is dst -- not", + uk_dst_calc::local_is_dst(uk_notdst2.date(),uk_notdst2.time_of_day())==boost::date_time::is_not_in_dst); + + +// /******************** post release 1 -- new dst calc engine ********/ + +// //Define dst rule for Paraguay which is transitions forward on Oct 1 and back Mar 1 + + typedef boost::date_time::dst_calc_engine pg_dst_calc; + + { + + date pg_dst_start(2002,Oct, 1); + date pg_dst_end(2002,Mar, 1); + date pg_indst(2002,Dec, 1); + date pg_notdst(2002,Jul, 1); + ptime pg_invalid1(pg_dst_start, time_duration(2,0,0)); //invalid time label + ptime pg_invalid2(pg_dst_start, time_duration(2,59,59)); //invalid time label + ptime pg_notdst1(pg_dst_start, time_duration(1,59,59)); //not ds + ptime pg_isdst1(pg_dst_start, time_duration(3,0,0)); //always dst + ptime pg_isdst2(pg_dst_end, time_duration(0,59,59)); //is dst + ptime pg_amgbig1(pg_dst_end, time_duration(1,0,0)); //ambiguous + ptime pg_amgbig2(pg_dst_end, time_duration(1,59,59)); //ambiguous + ptime pg_notdst2(pg_dst_end, time_duration(2,0,0)); //always not dst + + check("pg dst start", pg_dst_calc::local_dst_start_day(2002) == pg_dst_start); + check("pg dst end", pg_dst_calc::local_dst_end_day(2002) == pg_dst_end); + check("pg dst boundary", pg_dst_calc::is_dst_boundary_day(pg_dst_start)); + check("pg dst boundary", pg_dst_calc::is_dst_boundary_day(pg_dst_end)); + // on forward shift boundaries + check("pg label on dst boundary invalid", + pg_dst_calc::local_is_dst(pg_invalid1.date(),pg_invalid1.time_of_day())==boost::date_time::invalid_time_label); + check("pg label on dst boundary invalid", + pg_dst_calc::local_is_dst(pg_invalid2.date(),pg_invalid2.time_of_day())==boost::date_time::invalid_time_label); + check("pg check if time is dst -- not", + pg_dst_calc::local_is_dst(pg_notdst1.date(),pg_notdst1.time_of_day())==boost::date_time::is_not_in_dst); + check("check if time is dst -- yes", + pg_dst_calc::local_is_dst(pg_isdst1.date(),pg_isdst1.time_of_day())==boost::date_time::is_in_dst); + //backward shift boundary + check("pg check if time is dst -- yes", + pg_dst_calc::local_is_dst(pg_isdst2.date(),pg_isdst2.time_of_day())==boost::date_time::is_in_dst); + check("pg check if time is dst -- ambig", + pg_dst_calc::local_is_dst(pg_amgbig1.date(),pg_amgbig1.time_of_day())==boost::date_time::ambiguous); + check("pg check if time is dst -- ambig", + pg_dst_calc::local_is_dst(pg_amgbig2.date(),pg_amgbig2.time_of_day())==boost::date_time::ambiguous); + check("pg check if time is dst -- not", + pg_dst_calc::local_is_dst(pg_notdst2.date(),pg_notdst2.time_of_day())==boost::date_time::is_not_in_dst); + // a couple not on the boudnary + check("pg check if time is dst -- yes", + pg_dst_calc::local_is_dst(pg_indst,time_duration(0,0,0))==boost::date_time::is_in_dst); + check("pg check if time is dst -- not", + pg_dst_calc::local_is_dst(pg_notdst,time_duration(0,0,0))==boost::date_time::is_not_in_dst); + + } + +// /******************** post release 1 -- new dst calc engine ********/ + +// //Define dst rule for Adelaide australia + + typedef boost::date_time::acst_dst_trait acst_dst_traits; + typedef boost::date_time::dst_calc_engine acst_dst_calc; + + { + + date acst_dst_start(2002,Oct, 27); + date acst_dst_end(2002,Mar, 31); + date acst_indst(2002,Dec, 1); + date acst_notdst(2002,Jul, 1); + ptime acst_invalid1(acst_dst_start, time_duration(2,0,0)); //invalid time label + ptime acst_invalid2(acst_dst_start, time_duration(2,59,59)); //invalid time label + ptime acst_notdst1(acst_dst_start, time_duration(1,59,59)); //not ds + ptime acst_isdst1(acst_dst_start, time_duration(3,0,0)); //always dst + ptime acst_isdst2(acst_dst_end, time_duration(1,59,59)); //is dst + ptime acst_amgbig1(acst_dst_end, time_duration(2,0,0)); //ambiguous + ptime acst_amgbig2(acst_dst_end, time_duration(2,59,59)); //ambiguous + ptime acst_notdst2(acst_dst_end, time_duration(3,0,0)); //always not dst + +// std::cout << "acst dst_start: " << acst_dst_calc::local_dst_start_day(2002) +// << std::endl; + check("acst dst start", acst_dst_calc::local_dst_start_day(2002) == acst_dst_start); + check("acst dst end", acst_dst_calc::local_dst_end_day(2002) == acst_dst_end); + check("acst dst boundary", acst_dst_calc::is_dst_boundary_day(acst_dst_start)); + check("acst dst boundary", acst_dst_calc::is_dst_boundary_day(acst_dst_end)); + // on forward shift boundaries + check("acst label on dst boundary invalid", + acst_dst_calc::local_is_dst(acst_invalid1.date(),acst_invalid1.time_of_day())==boost::date_time::invalid_time_label); + check("acst label on dst boundary invalid", + acst_dst_calc::local_is_dst(acst_invalid2.date(),acst_invalid2.time_of_day())==boost::date_time::invalid_time_label); + check("acst check if time is dst -- not", + acst_dst_calc::local_is_dst(acst_notdst1.date(),acst_notdst1.time_of_day())==boost::date_time::is_not_in_dst); + check("check if time is dst -- yes", + acst_dst_calc::local_is_dst(acst_isdst1.date(),acst_isdst1.time_of_day())==boost::date_time::is_in_dst); + //backward shift boundary + check("acst check if time is dst -- yes", + acst_dst_calc::local_is_dst(acst_isdst2.date(),acst_isdst2.time_of_day())==boost::date_time::is_in_dst); + check("acst check if time is dst -- ambig", + acst_dst_calc::local_is_dst(acst_amgbig1.date(),acst_amgbig1.time_of_day())==boost::date_time::ambiguous); + check("acst check if time is dst -- ambig", + acst_dst_calc::local_is_dst(acst_amgbig2.date(),acst_amgbig2.time_of_day())==boost::date_time::ambiguous); + check("acst check if time is dst -- not", + acst_dst_calc::local_is_dst(acst_notdst2.date(),acst_notdst2.time_of_day())==boost::date_time::is_not_in_dst); + // a couple not on the boudnary + check("acst check if time is dst -- yes", + acst_dst_calc::local_is_dst(acst_indst,time_duration(0,0,0))==boost::date_time::is_in_dst); + check("acst check if time is dst -- not", + acst_dst_calc::local_is_dst(acst_notdst,time_duration(0,0,0))==boost::date_time::is_not_in_dst); + // ptime utc_t = ptime(acst_dst_start, hours(2)) - time_duration(16,30,0); + // std::cout << "UTC date/time of Adelaide switch over: " << utc_t << std::endl; + + } + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/posix_time/testduration.cpp b/src/boost/libs/date_time/test/posix_time/testduration.cpp new file mode 100644 index 000000000..061089290 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testduration.cpp @@ -0,0 +1,282 @@ +/* Copyright (c) 2002-2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include "boost/date_time/posix_time/posix_time_duration.hpp" +#include "boost/date_time/compiler_config.hpp" +#if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS) +#include "boost/date_time/posix_time/time_formatters_limited.hpp" +#else +#include "boost/date_time/posix_time/time_formatters.hpp" +#endif +#include "../testfrmwk.hpp" + + +int +main() +{ + using namespace boost::posix_time; + + +// std::cout << "Default limits: SECOND " << std::endl; + { + time_duration td; + check("default construction -- 0 ticks", td.ticks() == 0); +// check("default construction -- 0 secs", td.seconds() == 0); +// check("default construction -- 0 min", td.minutes() == 0); + } + + // construct from components + time_duration td1(1,25,0); + time_duration td3(td1.hours(),td1.minutes(),td1.seconds()); + check("total up elements", td1 == td3); + td1 = -td1; // td1 == "-1:25:00" + check("invert_sign",td3 == td1.invert_sign()); + check("invert_sign",td1 == td3.invert_sign()); + check("abs",td3 == td1.abs()); + check("abs",td3 == td3.abs()); + check("is_positive",td3.is_positive()); + check("is_positive",!td1.is_positive()); + check("is_negative",td1.is_negative()); + check("is_negative",!td3.is_negative()); + check("is_zero",!td1.is_zero()); + check("is_zero",(td1 - td1).is_zero()); + td3 = time_duration(td1.hours(),td1.minutes(),td1.seconds()); + check("total up elements-inverted sign", td1 == td3); + + + time_duration t_1(0,1,40); + time_duration t_2(0,1,41); + check("less test", !(t_2 < t_2)); + check("equal test", t_1 == t_1); + check("greater equal - equal", t_1 >= t_1); + check("greater equal - greater", t_2 >= t_1); + check("less equal - equal ", t_2 <= t_2); + check("greater ", t_2 > t_1); + check("greater - not ", !(t_1 > t_2)); + time_duration t_3(t_2); + check("copy constructor ", t_2 == t_3); + time_duration t_4 = t_3; + check("assignment operator ", t_2 == t_4); + + time_duration t_5(1,30,20,10); // 1hr, 30min, 20sec, 10 frac sec + t_5 /= 2; + check("divide equal", (t_5.hours() == 0 && + t_5.minutes() == 45 && + t_5.seconds() == 10 && + t_5.fractional_seconds() == 5)); + t_5 = time_duration(3,15,8,0) / 2; + check("divide int", t_5 == time_duration(1,37,34,0)); + { + time_duration td = hours(5); + td *= 5; + check("mult-equals int", time_duration(25,0,0,0) == td); + } + + + t_5 = t_2 + t_1; + //VC6 goes ambiguous on the next line... +#if (defined(BOOST_MSVC) && (_MSC_VER < 1300)) + //sorry ticks() doesn't work on VC6 +#else + std::cout << t_5.ticks() << std::endl; +#endif + check("add", t_5 == time_duration(0,3,21)); + time_duration td_a(5,5,5,5); + time_duration td_b(4,4,4,4); + time_duration td_c(2,2,2,2); + td_a += td_b; + check("add equal", td_a == time_duration(9,9,9,9)); + time_duration td_d = td_b - td_c; + check("subtract", td_d == time_duration(2,2,2,2)); + td_d -= td_b; + check("subtract equal (neg result)", td_d == td_c - td_b); + + time_duration utd(1,2,3,4); + time_duration utd2 = -utd; + //std::cout << td_d << '\n' << utd2 << std::endl; + check("unary-", ((utd2.hours() == -1) && + (utd2.minutes() == -2) && + (utd2.seconds() == -3) && + (utd2.fractional_seconds() == -4)) ); + utd2 = -hours(5); + check("unary-", utd2.hours() == -5); + utd2 = -utd2; + check("unary-", utd2.hours() == 5); + + time_duration t_6(5,4,3); //05:04:03 + check("h-m-s 5-4-3 hours", t_6.hours() == 5); + check("h-m-s 5-4-3 minutes", t_6.minutes() == 4); + check("h-m-s 5-4-3 seconds", t_6.seconds() == 3); + std::cout << t_6.total_seconds() << std::endl; + check("h-m-s 5-4-3 total_seconds", t_6.total_seconds() == 18243); + + hours tenhours(10); + minutes fivemin(5); + time_duration t7 = time_duration(1,2,3) + tenhours + fivemin; + check("short hand durations add", t7 == time_duration(11,7,3)); + time_duration t8 = tenhours + time_duration(1,2,3) + fivemin; + check("short hand durations add", t8 == time_duration(11,7,3)); + + if (time_duration::resolution() >= boost::date_time::micro) { + time_duration t_9(5,4,3,9876); //05:04:03.09876 + check("h-m-s 5-4-3.21 hours", t_9.hours() == 5); + check("h-m-s 5-4-3.21 min ", t_9.minutes() == 4); + check("h-m-s 5-4-3.21 sec ", t_9.seconds() == 3); + check("h-m-s 5-4-3.21 fs ", t_9.fractional_seconds() == 9876); + check("h-m-s 5-4-3.21 total_seconds", t_9.total_seconds() == 18243); + // check("h-m-s 5-4-3.21 fs ", t_9.fs_as_double() == 0.9876); + //std::cout << t_9.fs_as_double() << std::endl; + std::cout << to_simple_string(t_9) << std::endl; + } + + if (time_duration::resolution() >= boost::date_time::tenth) { + time_duration t_10(5,4,3,9); //05:04:03.00001 + check("h-m-s 5-4-3.9 hours", t_10.hours() == 5); + check("h-m-s 5-4-3.9 min ", t_10.minutes() == 4); + check("h-m-s 5-4-3.9 sec ", t_10.seconds() == 3); + check("h-m-s 5-4-3.9 fs ", t_10.fractional_seconds() == 9); + check("h-m-s 5-4-3.9 total_seconds", t_10.total_seconds() == 18243); + std::cout << to_simple_string(t_10) << std::endl; + } + + if (time_duration::resolution() >= boost::date_time::milli) { + millisec ms(9); + // time_duration t_10(0,0,0,); //00:00:00.009 + std::cout << "time_resolution: " << time_duration::resolution() << std::endl; +#if (defined(BOOST_MSVC) && (_MSC_VER < 1300)) + //sorry res_adjust() doesn't work on VC6 +#else + std::cout << "res_adjust " << time_res_traits::res_adjust() << std::endl; +#endif + if (time_duration::resolution() == boost::date_time::nano) { + check("millisec", ms.fractional_seconds() == 9000000); + check("total_seconds - nofrac", ms.total_seconds() == 0); + check("total_millisec", ms.total_milliseconds() == 9); + check("ticks per second", time_duration::ticks_per_second() == 1000000000); + } + else { + check("millisec 9000", ms.fractional_seconds() == 9000); + check("total_seconds - nofrac", ms.total_seconds() == 0); + check("total_millisec", ms.total_milliseconds() == 9); + } + } + +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + if (time_duration::resolution() >= boost::date_time::nano) { + nanosec ns(9); + // time_duration t_10(0,0,0,); //00:00:00.00009 + check("nanosec", ns.fractional_seconds() == 9); + check("total nanosec", ns.total_nanoseconds() == 9); + check("total microsec - truncated", ns.total_microseconds() == 0); + std::cout << to_simple_string(ns) << std::endl; + time_duration ns18 = ns + ns; + check("nanosec", ns18.fractional_seconds() == 18); + std::cout << to_simple_string(ns18) << std::endl; + nanosec ns2(1000000000); //one second + check("nano to second compare", ns2 == seconds(1)); + check("check total seconds", ns2.total_seconds() == 1); + std::cout << to_simple_string(ns2) << std::endl; + check("division of nanoseconds", (nanosec(3)/2) == nanosec(1)); + check("multiplication of nanosec", nanosec(3)*1000 == microsec(3)); + } +#endif + + // Test for overflows (ticket #3471) + { + ptime start(boost::gregorian::date(2000, 1, 1)); + ptime end(boost::gregorian::date(2000, 5, 1)); + time_duration td = end - start; + ptime end2 = start + microseconds(td.total_microseconds()); + check("microseconds constructor overflow", end == end2); + } + + time_duration t_11(3600,0,0); + check("3600 hours ", t_11.hours() == 3600); + check("total seconds 3600 hours", t_11.total_seconds() == 12960000); + + time_duration td_12(1,2,3,10); + std::cout << td_12.total_seconds() << std::endl; + check("total seconds 3723 hours", td_12.total_seconds() == 3723); + + // time_duration t_11a = t_11/time_duration(0,3,0); + + check("division", (hours(2)/2) == hours(1)); + check("division", (hours(3)/2) == time_duration(1,30,0)); + check("division", (hours(3)/3) == hours(1)); + check("multiplication", time_duration(3,0,0)*2 == hours(6)); + check("multiplication", hours(360)*1000 == hours(360000)); + + // special_values operations + time_duration pi_dur(pos_infin), ni_dur(neg_infin), ndt_dur(not_a_date_time); + check("+infin + -infin", pi_dur + ni_dur == ndt_dur); + check("infin / int", pi_dur / 3 == pi_dur); + check("infin + duration", pi_dur + td_12 == pi_dur); + check("infin - duration", pi_dur - td_12 == pi_dur); + check("unary-", -pi_dur == ni_dur); + check("-infin less than +infin", ni_dur < pi_dur); + check("-infin less than duration", ni_dur < td_12); + check("+infin greater than duration", pi_dur > td_12); + std::string result(""), answer("+infinity"); + result = to_simple_string(pi_dur); + check("to string +infin", result==answer); + result = to_simple_string(ni_dur); + answer = "-infinity"; + check("to string +infin", result==answer); + result = to_simple_string(ndt_dur); + //answer = "not-a-number"; + answer = "not-a-date-time"; + check("to string +infin", result==answer); + + using namespace boost::gregorian; + ptime t1(date(2001,7,14)); + ptime t2(date(2002,7,14)); + check("One year of hours: 365*24=8760", 365*24 == ((t2-t1).hours())); + check("Total seconds in a year", 365*24*3600 == ((t2-t1).total_seconds())); + + std::cout << to_simple_string(time_duration(20000 * 24, 0, 0, 0)) << std::endl; + std::cout << to_simple_string(time_duration(24855 * 24, 0, 0, 0)) << std::endl; + std::cout << to_simple_string(time_duration(24856 * 24, 0, 0, 0)) << std::endl; + std::cout << to_simple_string(time_duration(25000 * 24, 0, 0, 0)) << std::endl; + time_duration tdl1(25000*24, 0, 0, 0); + check("600000 hours", tdl1.hours() == 600000); + time_duration tdl2(2000000, 0, 0, 0); + check("2000000 hours", tdl2.hours() == 2000000); + + check("total milliseconds", seconds(1).total_milliseconds() == 1000); + check("total microseconds", seconds(1).total_microseconds() == 1000000); + check("total nanoseconds", seconds(1).total_nanoseconds() == 1000000000); + check("total milliseconds", hours(1).total_milliseconds() == 3600*1000); + boost::int64_t tms = static_cast(3600)*1000000*1001; //ms per sec + check("total microseconds 1000 hours", hours(1001).total_microseconds() == tms); + tms = static_cast(3600)*365*24*1000; + check("total milliseconds - one year", (t2-t1).total_milliseconds() == tms); + tms = 3600*365*24*static_cast(1000000000); + check("total nanoseconds - one year", (t2-t1).total_nanoseconds() == tms); +#if (defined(BOOST_MSVC) && (_MSC_VER < 1300)) +#else + std::cout << "tms: " << (t2-t1).total_milliseconds() << std::endl; + std::cout << "nano per year: " << (t2-t1).total_nanoseconds() << std::endl; +#endif + // make it into a double + double d1 = microseconds(25).ticks()/(double)time_duration::ticks_per_second(); + std::cout << d1 << std::endl; + + //Following causes errors on several compilers about value to large for + //type. So it is commented out for now. Strangely works on gcc 3.3 + //eg: integer constant out of range +// long sec_in_200k_hours(7200000000); +// check("total sec in 2000000 hours", +// tdl2.total_seconds() == sec_in_200k_hours); +// std::cout << to_simple_string(time_duration(2000000, 0, 0, 0)) << std::endl; + + + return printTestStats(); + +} + + diff --git a/src/boost/libs/date_time/test/posix_time/testfiletime_functions.cpp b/src/boost/libs/date_time/test/posix_time/testfiletime_functions.cpp new file mode 100644 index 000000000..d931dc1a5 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testfiletime_functions.cpp @@ -0,0 +1,90 @@ +/* Copyright (c) 2002,2003, 2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/posix_time/posix_time.hpp" +#include "../testfrmwk.hpp" +#include "boost/date_time/filetime_functions.hpp" +#include + +#if defined(BOOST_HAS_FTIME) +#include +#endif + +int main() +{ +#if defined(BOOST_HAS_FTIME) // skip tests if no FILETIME + + using namespace boost::posix_time; + + // adjustor is used to truncate ptime's fractional seconds for + // comparison with SYSTEMTIME's milliseconds + const time_duration::tick_type adjustor = time_duration::ticks_per_second() / 1000; + + for(int i = 0; i < 5; ++i){ + + FILETIME ft; + SYSTEMTIME st; + GetSystemTime(&st); + SystemTimeToFileTime(&st,&ft); + + ptime pt = from_ftime(ft); + + check_equal("ptime year matches systemtime year", + st.wYear, pt.date().year()); + check_equal("ptime month matches systemtime month", + st.wMonth, pt.date().month()); + check_equal("ptime day matches systemtime day", + st.wDay, pt.date().day()); + check_equal("ptime hour matches systemtime hour", + st.wHour, pt.time_of_day().hours()); + check_equal("ptime minute matches systemtime minute", + st.wMinute, pt.time_of_day().minutes()); + check_equal("ptime second matches systemtime second", + st.wSecond, pt.time_of_day().seconds()); + check_equal("truncated ptime fractional second matches systemtime millisecond", + st.wMilliseconds, (pt.time_of_day().fractional_seconds() / adjustor)); + + // burn up a little time + for (int j=0; j<100000; j++) + { + SYSTEMTIME tmp; + GetSystemTime(&tmp); + } + + } // for loop + + // check that time_from_ftime works for pre-1970-Jan-01 dates, too + // zero FILETIME should represent 1601-Jan-01 00:00:00.000 + FILETIME big_bang_by_ms; + big_bang_by_ms.dwLowDateTime = big_bang_by_ms.dwHighDateTime = 0; + ptime pt = from_ftime(big_bang_by_ms); + + check_equal("big bang ptime year matches 1601", + 1601, pt.date().year()); + check_equal("big bang ptime month matches Jan", + 1, pt.date().month()); + check_equal("big bang ptime day matches 1", + 1, pt.date().day()); + check_equal("big bang ptime hour matches 0", + 0, pt.time_of_day().hours()); + check_equal("big bang ptime minute matches 0", + 0, pt.time_of_day().minutes()); + check_equal("big bang ptime second matches 0", + 0, pt.time_of_day().seconds()); + check_equal("big bang truncated ptime fractional second matches 0", + 0, (pt.time_of_day().fractional_seconds() / adjustor)); + + +#else // BOOST_HAS_FTIME + // we don't want a forced failure here, not a shortcoming + check("FILETIME not available for this compiler/platform", true); +#endif // BOOST_HAS_FTIME + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/posix_time/testformatters.cpp b/src/boost/libs/date_time/test/posix_time/testformatters.cpp new file mode 100644 index 000000000..74dae8888 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testformatters.cpp @@ -0,0 +1,18 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/posix_time/posix_time.hpp" +#include "../testfrmwk.hpp" + +int +main() +{ + //This has been deprecated for testtime_formatters.cpp + return 0; + +} + diff --git a/src/boost/libs/date_time/test/posix_time/testgreg_duration_operators.cpp b/src/boost/libs/date_time/test/posix_time/testgreg_duration_operators.cpp new file mode 100644 index 000000000..005a61711 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testgreg_duration_operators.cpp @@ -0,0 +1,85 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "boost/date_time/posix_time/posix_time.hpp" +#include "../testfrmwk.hpp" + + +int main(){ + +#if !defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES) + // do not set this test to return fail - + // this is not necessarily a compiler problem + check("Optional gregorian types not selected - no tests run", true); +#else + + using namespace boost::gregorian; + using namespace boost::posix_time; + + + /*** months ***/ + { + ptime p(date(2001, Oct, 31), hours(5)); + check("ptime + months", + ptime(date(2002, Feb, 28), hours(5)) == p + months(4)); + p += months(4); + check("ptime += months", + ptime(date(2002, Feb, 28), hours(5)) == p); + } + { + ptime p(date(2001, Oct, 31), hours(5)); + check("ptime - months", + ptime(date(2001, Apr, 30), hours(5)) == p - months(6)); + p -= months(6); + check("ptime -= months", + ptime(date(2001, Apr, 30), hours(5)) == p); + } + + /*** years ***/ + { + ptime p(date(2001, Feb, 28), hours(5)); + check("ptime + years", + ptime(date(2004, Feb, 29), hours(5)) == p + years(3)); + p += years(3); + check("ptime += years", + ptime(date(2004, Feb, 29), hours(5)) == p); + } + { + ptime p(date(2000, Feb, 29), hours(5)); + check("ptime - years", + ptime(date(1998, Feb, 28), hours(5)) == p - years(2)); + p -= years(2); + check("ptime -= years", + ptime(date(1998, Feb, 28), hours(5)) == p); + } + + + /*** weeks ***/ + // shouldn't need many tests, it is nothing more than a date_duration + // so all date_duration tests should prove this class + { + ptime p(date(2001, Feb, 28), hours(5)); + check("ptime + weeks", + ptime(date(2001, Mar, 21), hours(5)) == p + weeks(3)); + p += weeks(3); + check("ptime += weeks", + ptime(date(2001, Mar, 21), hours(5)) == p); + } + { + ptime p(date(2001, Feb, 28), hours(5)); + check("ptime - weeks", + ptime(date(2001, Feb, 14), hours(5)) == p - weeks(2)); + p -= weeks(2); + check("ptime -= weeks", + ptime(date(2001, Feb, 14), hours(5)) == p); + } + +#endif // BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES + + return printTestStats(); +} diff --git a/src/boost/libs/date_time/test/posix_time/testiterator.cpp b/src/boost/libs/date_time/test/posix_time/testiterator.cpp new file mode 100644 index 000000000..47ebb603c --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testiterator.cpp @@ -0,0 +1,135 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include +#include "boost/date_time/posix_time/posix_time.hpp" +#include "../testfrmwk.hpp" +#if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS) +#include "boost/date_time/gregorian/formatters_limited.hpp" +#else +#include "boost/date_time/gregorian/formatters.hpp" +#endif + +void iterate_backward(const boost::posix_time::ptime *answers, int ary_len, + const boost::posix_time::time_duration& td) +{ + using namespace boost::posix_time; + using namespace boost::gregorian; + + int i = ary_len -1; + ptime end = answers[i]; + time_iterator titr(end,td); + + std::cout << "counting down by previous duration..." << std::endl; + for (; titr >= answers[0]; --titr) { + std::cout << *titr << std::endl; + check("iterating backward", answers[i] == *titr); + --i; + } + check("iterating backward count", i == -1); // check the number of iterations + std::cout << std::endl; +} + +int +main() +{ + using namespace boost::posix_time; + using namespace boost::gregorian; + + date d(2000,Jan,20); + ptime start(d); + const ptime answer1[] = {ptime(d), ptime(d,seconds(1)), + ptime(d,seconds(2)), ptime(d,seconds(3))}; + int i=0; + time_iterator titr(start,seconds(1)); + for (; titr < ptime(d,seconds(4)); ++titr) { + std::cout << *titr << std::endl; + check("iterator -- 1 sec", answer1[i] == *titr); + i++; + } + check("iterator -- 1 sec", i == 4); // check the number of iterations + + iterate_backward(answer1, 4, seconds(1)); + + //iterate by hours + const ptime answer2[] = {ptime(d), ptime(d,hours(1)), + ptime(d,hours(2)), ptime(d,hours(3))}; + i=0; + time_iterator titr2(start,hours(1)); + for (; titr2 < ptime(d,hours(4)); ++titr2) { + std::cout << *titr2 << std::endl; + check("iterator -- 1 hour", answer2[i] == *titr2); + i++; + } + check("iterator -- 1 hour", i == 4); // check the number of iterations + + iterate_backward(answer2, 4, hours(1)); + + + //iterate by 15 mintues + const ptime answer3[] = {ptime(d), ptime(d,minutes(15)), + ptime(d,minutes(30)), ptime(d,minutes(45)), + ptime(d,minutes(60)), ptime(d,minutes(75))}; + i=0; + time_iterator titr3(start,minutes(15)); + for (; titr3 < ptime(d,time_duration(1,20,0)); ++titr3) { + std::cout << *titr3 << std::endl; + check("iterator -- 15 min", answer3[i] == *titr3); + i++; + } + check("iterator -- 15 min", i == 6); // check the number of iterations + + iterate_backward(answer3, 6, minutes(15)); + + //iterate by .1 seconds + const ptime answer4[] = {ptime(d), ptime(d,time_duration(0,0,0,1000)), + ptime(d,time_duration(0,0,0,2000)), + ptime(d,time_duration(0,0,0,3000))}; + i=0; + time_iterator titr4(start,time_duration(0,0,0,1000)); + for (; titr4 < ptime(d,time_duration(0,0,0,4000)); ++titr4) { + std::cout << *titr4 << std::endl; + check("iterator -- tenth sec", answer4[i] == *titr4); + i++; + } + check("iterator -- tenth sec", i == 4); // check the number of iterations + + iterate_backward(answer4, 4, time_duration(0,0,0,1000)); + + //iterate by crazy duration + time_duration crzyd = duration_from_string("2:18:32.423"); + const ptime answer5[] = {ptime(d), ptime(d,crzyd), + ptime(d, crzyd * 2), + ptime(d, crzyd * 3)}; + i=0; + time_iterator titr5(start,crzyd); + for (; titr5 < ptime(d,crzyd * 4); ++titr5) { + std::cout << *titr5 << std::endl; + check("iterator -- crazy duration", answer5[i] == *titr5); + i++; + } + check("iterator -- crazy duration", i == 4); // check the number of iterations + + iterate_backward(answer5, 4, crzyd); + + //iterate up by neg_dur + time_duration pos_dur = minutes(3); + time_duration neg_dur = -pos_dur; + time_iterator up_itr(start, neg_dur), dn_itr(start, pos_dur); + + for(i=0; i < 10; ++i) + { + check("up-by-neg == backward iterate", *up_itr == *dn_itr); + ++up_itr; // up by -3 + --dn_itr; // down by 3 + } + + + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/posix_time/testlocal_adjustor.cpp b/src/boost/libs/date_time/test/posix_time/testlocal_adjustor.cpp new file mode 100644 index 000000000..a9f434079 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testlocal_adjustor.cpp @@ -0,0 +1,175 @@ +/* Copyright (c) 2002,2003, 2007 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/date_time/local_time_adjustor.hpp" +#include "boost/date_time/local_timezone_defs.hpp" +#include "../testfrmwk.hpp" + +int +main() +{ + using namespace boost::posix_time; + using namespace boost::gregorian; + + date dst_start(2002,Apr, 7); + date dst_end_day(2002,Oct, 27); + + typedef boost::date_time::utc_adjustment us_eastern_offset_adj; + //Type that embeds rules for UTC-5 plus DST offset + typedef boost::date_time::static_local_time_adjustor us_eastern; + + //test some times clearly not in DST + date d3(2002,Feb,1); + ptime t10(d3, hours(4)); + ptime t10_check(d3, hours(9)); //utc is 5 hours ahead + time_duration td = us_eastern::local_to_utc_offset(t10);//dst flag is defaulted + check("check local calculation", td == hours(5)); + ptime t10_local = t10 + td; + std::cout << t10_local << std::endl; + check("check local calculation", t10_local == t10_check); + check("check utc is dst", + us_eastern::utc_to_local_offset(t10) == hours(-5)); + + + //something clearly IN dst + date d4(2002,May,1); + ptime t11(d4, hours(3)); + check("check local offset",us_eastern::local_to_utc_offset(t11) == hours(4)); + std::cout << us_eastern::local_to_utc_offset(t11) << std::endl; + ptime t11_check(d4, hours(7));//now utc offset is only 4 hours + ptime t11_local = t11 + us_eastern::local_to_utc_offset(t11); + std::cout << t11_local << " " << t11_check << std::endl; + check("check local calculation", t11_local == t11_check); + //should get same offset with DST flag set + check("check local offset-dst flag on", + us_eastern::local_to_utc_offset(t11, boost::date_time::is_dst) == hours(4)); + check("check local offset-dst flag override", + us_eastern::local_to_utc_offset(t11, boost::date_time::not_dst) == hours(5)); + + + //Check the start of dst boundary + ptime l_not_dst(dst_start, time_duration(1,59,59)); //2002-Apr-07 01:59:59 + check("check local dst start boundary case", + us_eastern::local_to_utc_offset(l_not_dst) == hours(5)); + ptime u_not_dst(dst_start, time_duration(6,59,59)); + check("check utc dst start boundary case", + us_eastern::utc_to_local_offset(u_not_dst) == hours(-5)); + ptime l_in_dst(dst_start, hours(3)); //2002-Apr-07 03:00:00 1st sec of dst + check("check local dst start boundary case", + us_eastern::local_to_utc_offset(l_in_dst, boost::date_time::is_dst) == hours(4)); + ptime u_in_dst(dst_start, hours(7)); + check("check utc dst start boundary case", + us_eastern::utc_to_local_offset(u_in_dst) == hours(-4)); + + + //Check the end of dst boundary + ptime dst_end(dst_end_day, time_duration(1,59,59)); //2002-Oct-27 01:00:00 DST + check("check local dst end boundary case - still dst", + us_eastern::local_to_utc_offset(dst_end, boost::date_time::is_dst) == hours(4)); + check("check local dst end boundary case - still dst", + us_eastern::local_to_utc_offset(dst_end, boost::date_time::not_dst) == hours(5)); + ptime u_dst_end1(dst_end_day, time_duration(5,59,59)); + check("check utc dst end boundary case", + us_eastern::utc_to_local_offset(u_dst_end1) == hours(-4)); + ptime u_dst_end2(dst_end_day, time_duration(6,0,0)); + check("check utc dst end boundary case", + us_eastern::utc_to_local_offset(u_dst_end2) == hours(-5)); + ptime u_dst_end3(dst_end_day, time_duration(6,59,59)); + check("check utc dst end boundary case", + us_eastern::utc_to_local_offset(u_dst_end3) == hours(-5)); + ptime u_dst_end4(dst_end_day, time_duration(7,0,0)); + check("check utc dst end boundary case", + us_eastern::utc_to_local_offset(u_dst_end4) == hours(-5)); + + + //Now try a local adjustments without dst + typedef boost::date_time::utc_adjustment us_az_offset_adj; + typedef boost::date_time::null_dst_rules us_az_dst_adj; + //Type that embeds rules for UTC-7 with no dst + typedef boost::date_time::static_local_time_adjustor us_az; + + check("check local offset - no dst", + us_az::local_to_utc_offset(t10) == hours(7)); + check("check local offset - no dst", + us_az::local_to_utc_offset(t11) == hours(7)); + check("check local offset - no dst", + us_az::utc_to_local_offset(t10) == hours(-7)); + check("check local offset - no dst", + us_az::utc_to_local_offset(t11) == hours(-7)); + + + //Arizona timezone is utc-7 with no dst + typedef boost::date_time::local_adjustor us_arizona; + + ptime t7(date(2002,May,31), hours(17)); + ptime t8 = us_arizona::local_to_utc(t7); + ptime t9 = us_arizona::utc_to_local(t8); + //converted to local then back ot utc + check("check us_local_adjustor", t9 == t7); + + typedef boost::date_time::local_adjustor us_eastern2; + + { + ptime t7a(date(2002,May,31), hours(17)); + ptime t7b = us_eastern2::local_to_utc(t7a); + ptime t7c = us_eastern2::utc_to_local(t7b); + //converted to local then back ot utc + check("check us_local_adjustor", t7c == t7a); + } + + typedef boost::date_time::us_dst_trait us_dst_traits; + typedef boost::date_time::dst_calc_engine + us_dst_calc2; + + typedef boost::date_time::local_adjustor us_eastern3; + { + ptime t7a(date(2002,May,31), hours(17)); + ptime t7b = us_eastern3::local_to_utc(t7a); + ptime t7c = us_eastern3::utc_to_local(t7b); + //converted to local then back ot utc + check("check us_local_adjustor3", t7c == t7a); + } + + { + ptime t7a(date(2007,Mar,11), hours(4)); + ptime t7b = us_eastern3::local_to_utc(t7a); + ptime t7c = us_eastern3::utc_to_local(t7b); + //converted to local then back ot utc + check("check us_local_adjustor3 2007", t7c == t7a); + } + + { + ptime t7a(date(2007,Mar,11), hours(3)); + ptime t7b = us_eastern3::local_to_utc(t7a); + ptime t7c = us_eastern3::utc_to_local(t7b); + //converted to local then back ot utc + check("check us_local_adjustor3 2007 a", t7c == t7a); + } + + //still experimental + typedef boost::date_time::dynamic_local_time_adjustor lta; +// lta adjustor(hours(-7)); + check("dst start", lta::local_dst_start_day(2002) == dst_start); + check("dst end", lta::local_dst_end_day(2002) == dst_end_day); + check("dst boundary", lta::is_dst_boundary_day(dst_start)); + check("dst boundary", lta::is_dst_boundary_day(dst_end_day)); +// check("check non-dst offset", adjustor.utc_offset(false)==hours(-7)); +// check("check dst offset", adjustor.utc_offset(true)==hours(-6)); + + + check("dst start", lta::local_dst_start_day(2007) == date(2007,Mar,11)); + check("dst end", lta::local_dst_end_day(2007) == date(2007,Nov,4)); + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp b/src/boost/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp new file mode 100644 index 000000000..8f0553ab3 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp @@ -0,0 +1,139 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + + */ + +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/date_time/microsec_time_clock.hpp" +#include "../testfrmwk.hpp" +#if defined(BOOST_HAS_FTIME) +#include +#endif + +void +sync_to_next_second() +{ + using namespace boost::posix_time; + + ptime t_prev; + ptime t_now = second_clock::local_time(); + + // Wait the next seconds + do + { + t_prev = t_now; + t_now = second_clock::local_time(); + } while (t_now.time_of_day().seconds() == t_prev.time_of_day().seconds()); + + // Wait 300ms in order to avoid seconds of second_clock > microsec_clock. + t_now = microsec_clock::local_time(); + t_prev = t_now; + do + { + t_now = microsec_clock::local_time(); + } while (t_now - t_prev < milliseconds(300)); + +} + + +int +main() +{ +#ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK + + using namespace boost::posix_time; + + std::cout << "Check local time of microsec_clock against second_clock" << std::endl; + + ptime last = microsec_clock::local_time(); + int max = 30; + for (int i=0; i(s2); + check("parse time duration: " + s2, + td2 == time_duration(12,11,10,123456789)); + std::string s3("12:11:10"); + time_duration td3= boost::date_time::parse_delimited_time_duration(s3); + check("parse time duration: " + s3, + td3 == time_duration(12,11,10,0)); + std::string s4("23:59:59.000000001"); + time_duration td4= boost::date_time::parse_delimited_time_duration(s4); + check("parse time duration: " + s4, + td4 == time_duration(23,59,59)+nanosec(1)); + std::string s5("23:59:59.999999999"); + time_duration td5= boost::date_time::parse_delimited_time_duration(s5); + check("parse time duration: " + s5, + td5 == time_duration(23,59,59)+nanosec(999999999)); + std::string s5b("-23:59:59.999999999"); + time_duration td5b= boost::date_time::parse_delimited_time_duration(s5b); + check("parse time duration: " + s5b, + td5b == time_duration(-23,59,59)-nanosec(999999999)); + + std::string s6b("1:00:00.1"); // we want 1/10th + time_duration td6b= boost::date_time::parse_delimited_time_duration(s6b); + check("parse time duration: " + s6b, + td6b == time_duration(1,0,0)+nanosec(100000000)); // we want 1/10th + + std::string s7b("-1:00:00.0010"); // we want 1/1000th + time_duration td7b= boost::date_time::parse_delimited_time_duration(s7b); + check("parse time duration: " + s7b, + td7b == time_duration(-1,0,0)-nanosec(1000000)); // we want 1/1000th + + std::string s8b("1:22:33.123456789321"); // too many digits + time_duration td8b= boost::date_time::parse_delimited_time_duration(s8b); + check("parse time duration: " + s8b, + td8b == time_duration(1,22,33,123456789)); // excess digits should be dropped + } + { + + std::string s3("12:11:10"); + time_duration td3= boost::date_time::parse_delimited_time_duration(s3); + check("parse time duration: " + s3, + td3 == time_duration(12,11,10,0)); + std::string s4("23:59:59.000001"); + time_duration td4= boost::date_time::parse_delimited_time_duration(s4); + check("parse time duration: " + s4, + td4 == time_duration(23,59,59)+microsec(1)); + std::string s5("23:59:59.999999"); + time_duration td5= boost::date_time::parse_delimited_time_duration(s5); + check("parse time duration: " + s5, + td5 == time_duration(23,59,59)+microsec(999999)); + std::string s5b("-23:59:59.999999"); + time_duration td5b= boost::date_time::parse_delimited_time_duration(s5b); + check("parse time duration: " + s5b, + td5b == time_duration(-23,59,59)-microsec(999999)); + + std::string s6b("1:00:00.1"); // we want 1/10th + time_duration td6b= boost::date_time::parse_delimited_time_duration(s6b); + check("parse time duration: " + s6b, + td6b == time_duration(1,0,0)+microsec(100000)); // we want 1/10th + + std::string s7b("-1:00:00.0010"); // we want 1/1000th + time_duration td7b= boost::date_time::parse_delimited_time_duration(s7b); + check("parse time duration: " + s7b, + td7b == time_duration(-1,0,0)-microsec(1000)); // we want 1/1000th + + } + + { + std::string ts2("2002-12-31 00:00:00.999999999"); + ptime t2 = time_from_string(ts2); + check("parse time: " + ts2, + t2 == ptime(date(2002,12,31),time_duration(0,0,0)+nanosec(999999999))); + } + { + std::string ts2("2002-12-31 00:00:00."); + ptime t2 = time_from_string(ts2); + check("parse time (decimal but no digits): " + ts2, + t2 == ptime(date(2002,12,31),time_duration(0,0,0))); + } +#endif + + if (time_duration::resolution() != boost::date_time::nano) + { + + std::string s1("12:11:10.123456"); + time_duration td1= duration_from_string(s1); + check("parse time duration: " + s1, + td1 == time_duration(12,11,10,123456)); + std::cout << "td1: " << td1 << std::endl; + + std::string s2("12:11:10,123456"); + time_duration td2= boost::date_time::parse_delimited_time_duration(s2); + check("parse time duration: " + s2, + td2 == time_duration(12,11,10,123456)); + std::cout << "td2: " << td2 << std::endl; + + //truncate for non-nanosecond case + std::string s8b("1:22:33.123456321"); // too many digits + time_duration td8b= boost::date_time::parse_delimited_time_duration(s8b); + check("parse time duration: " + s8b, + td8b == time_duration(1,22,33,123456)); // excess digits should be dropped + } + + + std::string date_1, tod_1; + std::string ts1("2002-01-20 23:59:59.000"); + boost::date_time::split(ts1, ' ', date_1, tod_1); + check("split function date part of " + ts1, + date_1 == std::string("2002-01-20")); + check("time part of " + ts1, + tod_1 == std::string("23:59:59.000")); +// std::cout << date_1 << "|" << std::endl; +// std::cout << tod_1 << "|" << std::endl; + + + { + ptime t1 = time_from_string(ts1); + check("parse time: " + ts1, + t1 == ptime(date(2002,1,20),time_duration(23,59,59))); + } + { + std::string ts1x("2002-01-20 23:59:59."); + ptime t1 = time_from_string(ts1x); + check("parse time (decimal but no digits): " + ts1x, + t1 == ptime(date(2002,1,20),time_duration(23,59,59))); + } + + std::string s6("235859"); + time_duration td6= boost::date_time::parse_undelimited_time_duration(s6); + check("parse time duration: " + s6, + td6 == time_duration(23,58,59)); + + s6 = "-235859"; + td6= boost::date_time::parse_undelimited_time_duration(s6); + check("parse negative time duration: " + s6, + td6 == time_duration(-23,58,59)); + + { + std::string ts3("20020120T235859"); + ptime t20 = from_iso_string(ts3); + check("parse iso time: " + ts3, + t20 == ptime(date(2002,1,20),time_duration(23,58,59))); + } + + { + std::string ts4("19001231T000000"); + ptime t21 = from_iso_string(ts4); + check("parse iso time: " + ts4, + t21 == ptime(date(1900,12,31),time_duration(0,0,0))); + } + + { + std::string ts5("19001231T23"); + ptime t22 = from_iso_string(ts5); + check("parse iso time: " + ts5, + t22 == ptime(date(1900,12,31),time_duration(23,0,0))); + } + + { +#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG) + std::string ts3("20020120T235859.123456789"); + ptime t20 = from_iso_string(ts3); + check("parse iso time w/ frac sec: " + ts3, + t20 == ptime(date(2002,1,20),time_duration(23,58,59,123456789))); + + std::string ts4("19001231T000000.123"); + ptime t21 = from_iso_string(ts4); + check("parse iso time w/ frac sec (too short): " + ts4, + t21 == ptime(date(1900,12,31),time_duration(0,0,0,123000000))); + + std::string ts5("19001231T230000.123456789876"); + ptime t22 = from_iso_string(ts5); + check("parse iso time w/ frac sec (too long): " + ts5, + t22 == ptime(date(1900,12,31),time_duration(23,0,0,123456789))); + + std::string ts6("19001231T230000."); + ptime t23 = from_iso_string(ts6); + check("parse iso time w/ frac sec (dec only): " + ts6, + t23 == ptime(date(1900,12,31),time_duration(23,0,0,0))); + + std::string ts7("2002-01-20T23:58:59.123456789"); + ptime t24 = from_iso_extended_string(ts7); + check("parse iso extended time w/ frac sec: " + ts7, + t24 == ptime(date(2002,1,20),time_duration(23,58,59,123456789))); + + std::string ts8("1900-12-31T00:00:00.123"); + ptime t25 = from_iso_extended_string(ts8); + check("parse iso extended time w/ frac sec (too short): " + ts8, + t25 == ptime(date(1900,12,31),time_duration(0,0,0,123000000))); + + std::string ts9("1900-12-31T23:00:00.123456789876"); + ptime t26 = from_iso_extended_string(ts9); + check("parse iso extended time w/ frac sec (too long): " + ts9, + t26 == ptime(date(1900,12,31),time_duration(23,0,0,123456789))); + + std::string ts10("1900-12-31T23:00:00."); + ptime t27 = from_iso_extended_string(ts10); + check("parse iso extended time w/ frac sec (dec only): " + ts10, + t27 == ptime(date(1900,12,31),time_duration(23,0,0,0))); +#else + std::string ts3("20020120T235859.123456"); + ptime t20 = from_iso_string(ts3); + check("parse iso time w/ frac sec: " + ts3, + t20 == ptime(date(2002,1,20),time_duration(23,58,59,123456))); + + std::string ts4("19001231T000000.123"); + ptime t21 = from_iso_string(ts4); + check("parse iso time w/ frac sec (too short): " + ts4, + t21 == ptime(date(1900,12,31),time_duration(0,0,0,123000))); + + std::string ts5("19001231T230000.123456789876"); + ptime t22 = from_iso_string(ts5); + check("parse iso time w/ frac sec (too long): " + ts5, + t22 == ptime(date(1900,12,31),time_duration(23,0,0,123456))); + + std::string ts6("19001231T230000."); + ptime t23 = from_iso_string(ts6); + check("parse iso time w/ frac sec (dec only): " + ts6, + t23 == ptime(date(1900,12,31),time_duration(23,0,0,0))); + + std::string ts7("2002-01-20T23:58:59.123456"); + ptime t24 = from_iso_extended_string(ts7); + check("parse iso extended time w/ frac sec: " + ts7, + t24 == ptime(date(2002,1,20),time_duration(23,58,59,123456))); + + std::string ts8("1900-12-31T00:00:00.123"); + ptime t25 = from_iso_extended_string(ts8); + check("parse iso extended time w/ frac sec (too short): " + ts8, + t25 == ptime(date(1900,12,31),time_duration(0,0,0,123000))); + + std::string ts9("1900-12-31T23:00:00.123456789876"); + ptime t26 = from_iso_extended_string(ts9); + check("parse iso extended time w/ frac sec (too long): " + ts9, + t26 == ptime(date(1900,12,31),time_duration(23,0,0,123456))); + + std::string ts10("1900-12-31T23:00:00."); + ptime t27 = from_iso_extended_string(ts10); + check("parse iso extended time w/ frac sec (dec only): " + ts10, + t27 == ptime(date(1900,12,31),time_duration(23,0,0,0))); +#endif // BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + } + + std::string s7("-01:25:00"), s8("-00:40:00"), s9("0:45"), s10("0:-40"); + time_duration tds1 = duration_from_string(s7); + time_duration tds2 = duration_from_string(s8); + time_duration tds3 = duration_from_string(s9); + time_duration tds4 = duration_from_string(s10); + check("from string construct", tds1 == time_duration(-1,25,0)); + check("from string construct", tds2 == minutes(-40)); + check("from string construct", tds3 == minutes(45)); + // '-' in middle of string s10 should be ignored resulting in pos duration + check("from string construct", tds4 == minutes(40)); + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/posix_time/testperiod.cpp b/src/boost/libs/date_time/test/posix_time/testperiod.cpp new file mode 100644 index 000000000..211412e60 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testperiod.cpp @@ -0,0 +1,22 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/date_time/posix_time/time_period.hpp" +#include "../testfrmwk.hpp" + +int main() +{ + + //FILE OBSOLETE: replace by testtime_period.cpp + + return 1; + // return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/posix_time/teststreams.cpp b/src/boost/libs/date_time/test/posix_time/teststreams.cpp new file mode 100644 index 000000000..c772faebe --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/teststreams.cpp @@ -0,0 +1,179 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/date_time/gregorian/gregorian.hpp" +#include "../testfrmwk.hpp" + +#ifndef BOOST_DATE_TIME_NO_LOCALE + +const char* const de_short_month_names[]={"Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez", "NAM"}; + +const char* const de_long_month_names[]={"Januar","Februar","Marz","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember","NichtDerMonat"}; +const char* const de_special_value_names[]={"NichtDatumzeit","-unbegrenztheit", "+unbegrenztheit"}; + +const char* const de_short_weekday_names[]={"Son", "Mon", "Die","Mit", "Don", "Fre", "Sam"}; + +const char* const de_long_weekday_names[]={"Sonntag", "Montag", "Dienstag","Mittwoch", "Donnerstag", "Freitag", "Samstag"}; + +#endif + +int +main() +{ +#ifndef BOOST_DATE_TIME_NO_LOCALE + using namespace boost::gregorian; + using namespace boost::posix_time; + std::stringstream ss; + date d1(2002,May,1); + ptime t1(d1, hours(12)+minutes(10)+seconds(5)); + time_duration td0(12,10,5,123); + ptime t0(d1, td0); + ss << t0; +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + check("check time output: "+ss.str(), + ss.str() == std::string("2002-May-01 12:10:05.000000123")); +#else + check("check time output: "+ss.str(), + ss.str() == std::string("2002-May-01 12:10:05.000123")); +#endif // BOOST_DATE_TIME_HAS_NANOSECONDS + // ss.imbue(global); + time_period tp(t1, ptime(d1, hours(23)+time_duration::unit())); + ss.str(""); + ss << tp; + check("check time period output: "+ ss.str(), + ss.str() == std::string("[2002-May-01 12:10:05/2002-May-01 23:00:00]")); + + //Send out the same time with german + typedef boost::date_time::all_date_names_put date_facet; + + ss.imbue(std::locale(std::locale::classic(), + new date_facet(de_short_month_names, + de_long_month_names, + de_special_value_names, + de_short_weekday_names, + de_long_weekday_names, + '.', + boost::date_time::ymd_order_dmy, + boost::date_time::month_as_short_string))); + ss.str(""); + ss << t1; + check("check time output: "+ ss.str(), + ss.str() == std::string("01.Mai.2002 12:10:05")); + + + time_duration td(5,4,3); + time_duration td1(-1,25,0), td2(0,-40,0); + ss.str(""); + ss << td; + check("check time period output: "+ ss.str(), + ss.str() == std::string("05:04:03")); + ss.str(""); + ss << td1; + check("check time period output: "+ ss.str(), + ss.str() == std::string("-01:25:00")); + ss.str(""); + ss << td2; + check("check time period output: "+ ss.str(), + ss.str() == std::string("-00:40:00")); + + + ss.str(""); + ss << tp; + check("check time period output - german: "+ ss.str(), + ss.str() == std::string("[01.Mai.2002 12:10:05/01.Mai.2002 23:00:00]")); + + /* Input streaming is only available for compilers that + * do not have BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS defined */ +#ifndef BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS + + /****** test streaming in for time classes ******/ + { + std::istringstream iss("01:02:03.000004 garbage"); + iss >> td; +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + check("Stream in time_duration", td == time_duration(1,2,3,4000)); +#else + check("Stream in time_duration", td == time_duration(1,2,3,4)); +#endif + } +#if !defined(BOOST_NO_STD_ITERATOR_TRAITS) // vc6 & vc7 + { + std::istringstream iss("2003-May-13 01:02:03"); + iss >> t1; + check("Stream in ptime", t1 == ptime(date(2003,May,13), time_duration(1,2,3))); + std::istringstream iss2("2003-January-13 01:02:03"); + iss2 >> t1; + check("Stream in ptime2", t1 == ptime(date(2003,Jan,13), time_duration(1,2,3))); + std::istringstream iss3("2003-feb-13 11:10:09"); + iss3 >> t1; + check("Stream in ptime3", t1 == ptime(date(2003,Feb,13), time_duration(11,10,9))); + + try { + std::istringstream iss4("2003-xxx-13 11:10:09"); + iss3 >> t1; + check("Stream bad ptime", false); //never reach here, bad month exception + } + catch(std::exception& e) { + std::cout << "Got expected exception: " << e.what() << std::endl; + check("Stream bad ptime", true); + } + + } + { + date d1x(2001,Aug,1), d2x(2003,May,13); +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + time_duration td1x(15,32,18,20304000), td2x(1,2,3); +#else + time_duration td1x(15,32,18,20304), td2x(1,2,3); +#endif + + time_period result(ptime(d1x,td1x), ptime(d2x,td2x)); + std::istringstream iss("[2001-Aug-01 15:32:18.020304/2003-May-13 01:02:03]"); + iss >> tp; + check("Stream in time_period", tp == result); + } + +#if !defined(BOOST_NO_STD_WSTRING) + /*** wide streaming ***/ + { + std::wistringstream wiss1(L"01:02:03");//.000004"); + wiss1 >> td; + check("Wide stream in time_duration", td == time_duration(1,2,3)); + + std::wistringstream wiss2(L"2003-May-23 03:20:10"); + wiss2 >> t1; + check("Wide stream in ptime", t1 == ptime(date(2003,May,23), time_duration(3,20,10))); + + std::wistringstream wiss3(L"[2004-Jan-01 02:03:04/2004-May-13 01:00:00]"); + wiss3 >> tp; + date d1x = date(2004,Jan,1); + date d2x = date(2004,May,13); + time_duration td1x = time_duration(2,3,4); + time_duration td2x = time_duration(1,0,0); + time_period result = time_period(ptime(d1x,td1x), ptime(d2x,td2x)); + check("Wide stream in time_period", tp == result); + } +#else + check("Wide streaming not available for this compiler", false); +#endif // BOOST_NO_STD_WSTRING + +#else // BOOST_NO_STD_ITERATOR_TRAITS + check("Streaming in of alphabetic dates (Ex: 2003-Aug-21) \ + not supported by this compiler", false); +#endif // BOOST_NO_STD_ITERATOR_TRAITS + +#else // BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS + check("Streaming in of time classes not supported by this compiler", false); +#endif // BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS + +#else //BOOST_DATE_TIME_NO_LOCALE + check("No tests executed - Locales not supported by this compiler", false); +#endif //BOOST_DATE_TIME_NO_LOCALE + + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/posix_time/testtime.cpp b/src/boost/libs/date_time/test/posix_time/testtime.cpp new file mode 100644 index 000000000..f66c8692c --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testtime.cpp @@ -0,0 +1,336 @@ +/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include +#include "boost/date_time/gregorian/gregorian.hpp" +#include "boost/date_time/posix_time/posix_time.hpp" +#include "../testfrmwk.hpp" + +void special_values_tests() +{ + using namespace boost::posix_time; + using namespace boost::gregorian; + + time_duration td_pi(pos_infin), td_ni(neg_infin), td_ndt(not_a_date_time); + date_duration dd_pi(pos_infin), dd_ni(neg_infin), dd_ndt(not_a_date_time); + date d_pi(pos_infin), d_ni(neg_infin), d_ndt(not_a_date_time); + time_duration td(1,2,3,4); + date_duration dd(1234); + date d(2003,Oct,31); + +#if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR) + { // default constructor + ptime def; + check("Default constructor", def == ptime(not_a_date_time)); + } +#endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR + + { // special values construction tests + ptime p_sv1(pos_infin); + std::string s("+infinity"); + check("from special value +infinity", to_simple_string(p_sv1) == s); + ptime result = p_sv1 + dd; + check("Special value (pos infin) + date_duration = +infinity", to_iso_extended_string(result) == s); + check("is_special function - pos infin", result.is_special()); + result = p_sv1 - dd; + check("Special value (pos infin) - date_duration = +infinity", to_iso_extended_string(result) == s); + result = p_sv1 - dd_ni; + check("Special value (pos infin) - date_duration (neg infin) = +infinity", to_iso_extended_string(result) == s); + ptime p_sv2(neg_infin); + s = "-infinity"; + check("from special value -infinity", to_iso_string(p_sv2) == s); + result = p_sv2 - td_pi; + check("Special value (neg infin) - special time_duration (pos infin) = -infinity", to_iso_extended_string(result) == s); + ptime p_sv3(not_a_date_time); + check("is_special function - not_a_date_time", p_sv3.is_special()); + s = "not-a-date-time"; + check("from special value NADT", to_iso_extended_string(p_sv3) == s); + result = p_sv3 + td; + check("Special value (NADT) + time_duration = NADT", to_iso_extended_string(result) == s); + result = p_sv3 - td; + check("Special value (NADT) - time_duration = NADT", to_iso_extended_string(result) == s); + result = p_sv2 + td_pi; + check("Special value (neg infin) + special time_duration (pos infin) = NADT", to_iso_extended_string(result) == s); + result = p_sv1 + dd_ni; + check("Special value (pos infin) + date_duration (neg infin) = NADT", to_iso_extended_string(result) == s); + result = p_sv1 + dd_ndt; + check("Special value (pos infin) - date_duration (NADT) = NADT", to_iso_extended_string(result) == s); + } + { // special values construction tests + ptime p_sv1(d_pi, td); + std::string s("+infinity"); + check("duration & special_date", to_simple_string(p_sv1) == s); + ptime p_sv2(d_ni, td); + s = "-infinity"; + check("duration & special_date", to_iso_string(p_sv2) == s); + ptime p_sv3(d_ndt, td); + s = "not-a-date-time"; + check("duration & special_date", to_iso_extended_string(p_sv3) == s); + } + { // special values construction tests + ptime p_sv1(d_ndt, td); + std::string s("not-a-date-time"); + check("NADT & duration", to_simple_string(p_sv1) == s); + ptime p_sv2(d, td_ndt); + check("date & NADT", to_iso_string(p_sv2) == s); + ptime p_sv3(d_pi, td_ni); + check("+infinity_date & -infinity_duration", + to_iso_extended_string(p_sv3) == s); + + } + { // special values tests + ptime p_sv1(d, td_pi), pt(d,td); + std::string s("+infinity"); + check("special_duration & date", to_simple_string(p_sv1) == s); + check("ptime::date() +infinity", to_simple_string(p_sv1.date()) == s); + ptime p_sv2(d, td_ni); + s = "-infinity"; + check("special_duration & date", to_iso_string(p_sv2) == s); + check("ptime::time_of_day() -infinity", + to_simple_string(p_sv2.time_of_day()) == s); + ptime p_sv3(d, td_ndt); + s = "not-a-date-time"; + check("special_duration & date", to_iso_extended_string(p_sv3) == s); + check("ptime::date() - NADT", to_simple_string(p_sv3.date()) == s); + check("ptime::time_of_day() - NADT", + to_simple_string(p_sv3.time_of_day()) == s); + check("-infinity less than ...", p_sv2 < p_sv1); + check("-infinity less than ...", p_sv2 < pt); + check("+infinity greater than ...", pt < p_sv1); + check("-infinity less than equal to ...", p_sv2 <= p_sv2); + check("-infinity less than equal to ...", p_sv2 <= pt); + check("+infinity greater than equal to ...", p_sv1 >= pt); + check("not equal", p_sv1 != p_sv2); + check("not equal", p_sv3 != p_sv2); + check("not equal", pt != p_sv1); + + check("is_pos_infinity", p_sv1.is_infinity() && p_sv1.is_pos_infinity()); + check("is_neg_infinity", p_sv2.is_infinity() && p_sv2.is_neg_infinity()); + check("is_not_a_date_time", !p_sv3.is_infinity() && p_sv3.is_not_a_date_time()); + + check("special_ptime + date_duration", p_sv1 + dd == p_sv1); + check("ptime - special_date_duration", pt - dd_pi == p_sv2); + check("ptime - special_date_duration", pt - dd_ndt == p_sv3); + + check("special_ptime + time_duration", p_sv2 + td == p_sv2); + check("special_ptime - time_duration", pt - td_ni == p_sv1); + check("ptime + special_time_duration", pt + td_ndt == p_sv3); + check("ptime - special_ptime", pt - p_sv1 == td_ni); + check("ptime - special_ptime", pt - p_sv2 == td_pi); + check("ptime - special_ptime", pt - p_sv3 == td_ndt); + check("special_ptime - special_ptime", p_sv2 - p_sv2 == td_ndt); + } +} + +int +main() +{ + using namespace boost::posix_time; + using namespace boost::gregorian; + + date d(2001,Dec,1); + time_duration td(5,4,3); + ptime t1(d, td); //2001-Dec-1 05:04:03 + check("date part check", t1.date() == d); + check("time part check", t1.time_of_day() == td); + check("ptime with more than 24 hours", ptime(date(2005,10,30), hours(25)) == ptime(date(2005,10,31),hours(1))); + ptime t2(t1); //copy constructor + ptime t3 = t2; //assignment + check("date part check", t3.date() == d); + check("time part check", t3.time_of_day() == td); + check("equality", t1 == t3); + date d2(2001,Jan,1); + ptime t4(d2, td); //2001-Jan-1 05:04:03 + check("equality - not equal", !(t1 == t4)); + time_duration td1(5,4,0); + ptime t5(d, td1); //2001-Dec-1 05:04:00 + check("equality - not equal", !(t1 == t5)); + check("not equal - not equal", t1 != t5); + + check("less - not less", !(t1 < t1)); + check("less - less", t4 < t1); + check("less - less", t5 < t1); + check("less equal - equal", t1 <= t1); + check("greater equal - equal", t1 >= t1); + + date_duration twodays(2); + ptime t6 = t1 + twodays; + date d3(2001,Dec,3); + check("operator+(date_duration)", t6 == ptime(d3,td)); + ptime t7 = t1 - twodays; + check("operator-(date_duration)", t7 == ptime(date(2001,Nov,29),td)); + { + ptime t6b(date(2003,Oct,31),time_duration(10,0,0,0)); + t6b += date_duration(55); + check("operator +=(date_duration)", t6b == + ptime(date(2003,Dec,25), time_duration(10,0,0,0))); + t6b += hours(6); + check("operator +=(time_duration)", t6b == + ptime(date(2003,Dec,25), time_duration(16,0,0,0))); + t6b -= date_duration(55); + check("operator -=(date_duration)", t6b == + ptime(date(2003,Oct,31), time_duration(16,0,0,0))); + t6b -= hours(6); + check("operator -=(time_duration)", t6b == + ptime(date(2003,Oct,31), time_duration(10,0,0,0))); + t6b += hours(25); + check("operator +=(time_duration, more than 24 hours)", t6b == + ptime(date(2003,Nov,1), time_duration(11,0,0,0))); + t6b -= hours(49); + check("operator -=(time_duration, more than 48 hours)", t6b == + ptime(date(2003,Oct,30), time_duration(10,0,0,0))); + } + time_duration td2(1,2,3); + ptime t8(date(2001,Dec,1)); //midnight + ptime t9 = t8 + td2; //Dec 2 at 01:02:03 + ptime t10(date(2001,Dec,1),time_duration(1,2,3)); + std::cout << to_simple_string(t9) << std::endl; + std::cout << to_simple_string(t10) << std::endl; + std::cout << to_simple_string(td2) << std::endl; + check("add 2001-Dec-01 0:0:0 + 01:02:03", t9 == t10); + { + ptime t9x(date(2001,Dec,1), time_duration(12,0,0)); //Dec 1 at Noon + time_duration td3(-4,0,0); + check("add 2001-Dec-01 12:00:00 + (-04:00:00)", + t9x+td3 == ptime(date(2001,Dec,1), time_duration(8,0,0)) ); + std::cout << to_simple_string(t9x-td3) << std::endl; + } + time_duration td3(24,0,0); // a day + check("add 2001-Dec-01 0:0:0 + 24:00:00", t8+td3 == ptime(date(2001,Dec,2))); + time_duration td4(24,0,1); // a day, 1 second + check("add 2001-Dec-01 0:0:0 + 24:00:01", t8+td4 + == ptime(date(2001,Dec,2), time_duration(0,0,1))); + //looks like this fails b/c limits are exceeded now that we have subseconds.. + time_duration td5(168,0,1); //one week 24X7 + check("add 2001-Dec-01 0:0:0 + 168:00:01", t8+td5 + == ptime(date(2001,Dec,8), time_duration(0,0,1))); + + // ptime t10a = t8+td5; + // std::cout << to_simple_string(t10a) << std::endl; + + //Subtraction of time duration -- add more!! + ptime t11(date(2001,Dec,1), time_duration(12,0,0)); //noon + time_duration td6(12,0,1); + ptime t12 = t11-td6; + check("sub 2001-Dec-01 12:0:0 - 12:00:01", + t12 == ptime(date(2001,Nov,30), time_duration(23,59,59))); + + check("sub 2001-Dec-01 12:0:0 - 13:00:00", + (t11-time_duration(13,0,0))== ptime(date(2001,Nov,30), + time_duration(23,0,0))); + check("sub 2001-Dec-01 12:0:0 - (-13:00:00)", + (t11-time_duration(-13,0,0))== ptime(date(2001,Dec,2), + time_duration(1,0,0))); + // std::cout << to_simple_string(t12.date()) << std::endl; + + ptime t13(d, hours(3)); + ptime t14(d, hours(4)); + ptime t14a(d+date_duration(1), hours(4)); + //Subtract 2 times + std::cout << to_simple_string(t14-t13) << std::endl; + // time_duration td7 = + check("time subtraction positive result", + t14-t13 == hours(1)); + std::cout << to_simple_string(t13-t14) << std::endl; + check("time subtraction negative result", + t13-t14 == hours(-1)); + check("time subtraction positive result", + t14a-t14 == hours(24)); + + + ptime t15(d, time_duration(0,0,0,1)); + ptime t16(d, time_duration(0,0,0,2)); + check("time subsecond add test", + t15 + time_duration::unit() == t16); + check("time subsecond sub test", + t16 - time_duration::unit() == t15); + + ptime t17 = ptime(d) - time_duration::unit(); + std::cout << to_simple_string(t17) << std::endl; + + ptime t18(d, hours(25)); + std::cout << to_simple_string(t18) << std::endl; + + //time_t conversions: + t18 = from_time_t(0); //1970-1-1 0:0:0 + check("time_t conversion of 0", t18 == ptime(date(1970,1,1))); + check("time_t conversion from 0", to_time_t(t18) == 0); + + std::time_t tt(500000000); + t18 = from_time_t(tt); //1985-11-5 0:53:20 + check("time_t conversion of 500000000", + t18 == ptime(date(1985,11,5), time_duration(0,53,20))); + check("time_t conversion from 500000000", to_time_t(t18) == tt); + + std::time_t tt1(1060483634); + t18 = from_time_t(tt1); //2003-08-10 2:47:14 + check("time_t conversion of 1060483634", + t18 == ptime(date(2003,8,10), time_duration(2,47,14))); + check("time_t conversion from 1060483634", to_time_t(t18) == tt1); + + std::time_t tt2(1760483634); + t18 = from_time_t(tt2); //2025-10-14 23:13:54 + check("time_t conversion of 1760483634", + t18 == ptime(date(2025,10,14), time_duration(23,13,54))); + check("time_t conversion from 1760483634", to_time_t(t18) == tt2); + + std::time_t tt3(1960483634); + t18 = from_time_t(tt3); //2032-2-15 18:47:14 + check("time_t conversion of 1960483634", + t18 == ptime(date(2032,2,15), time_duration(18,47,14))); + check("time_t conversion from 1960483634", to_time_t(t18) == tt3); + + special_values_tests(); + + //min and max constructors + ptime min_ptime(min_date_time); + check("check min time constructor", min_ptime == ptime(date(1400,1,1), time_duration(0,0,0,0))); + // std::cout << min_ptime << std::endl; + ptime max_ptime(max_date_time); + check("check max time constructor", max_ptime == ptime(date(9999,12,31), + hours(24)-time_duration::unit())); + // std::cout << max_ptime << std::endl; + + //tm conversion checks + //converts to date and back -- should get same result -- note no fractional seconds in these times + check("tm conversion functions 2001-12-1 05:04:03", ptime_from_tm(to_tm(t1)) == t1); + check("tm conversion functions min date 1400-1-1 ", ptime_from_tm(to_tm(min_ptime)) == min_ptime); + //this conversion will drop fractional seconds + check("tm conversion functions max date 9999-12-31 23:59:59.9999 - truncated frac seconds", + ptime_from_tm(to_tm(max_ptime)) == ptime(date(max_date_time), time_duration(23,59,59))); + + try{ + ptime pt(pos_infin); + tm pt_tm = to_tm(pt); + check("Exception not thrown (special_value to_tm)", false); + //following code does nothing useful but stops compiler from complaining about unused pt_tm + std::cout << pt_tm.tm_sec << std::endl; + }catch(std::out_of_range&){ + check("Caught expected exception (special_value to_tm)", true); + }catch(...){ + check("Caught un-expected exception (special_value to_tm)", false); + } + try{ + // exception is only thrown from gregorian::to_tm. Needed to + // be sure it always gets thrown. + ptime pt(date(2002,Oct,31), hours(1)); + pt += time_duration(pos_infin); + tm pt_tm = to_tm(pt); + check("Exception not thrown (special_value to_tm)", false); + //following code does nothing useful but stops compiler from complaining about unused pt_tm + std::cout << pt_tm.tm_sec << std::endl; + }catch(std::out_of_range&){ + check("Caught expected exception (special_value to_tm)", true); + }catch(...){ + check("Caught un-expected exception (special_value to_tm)", false); + } + + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/posix_time/testtime_facet.cpp b/src/boost/libs/date_time/test/posix_time/testtime_facet.cpp new file mode 100644 index 000000000..f912f8d73 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testtime_facet.cpp @@ -0,0 +1,458 @@ + +/* Copyright (c) 2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include "boost/date_time/posix_time/posix_time.hpp" +#include "../testfrmwk.hpp" +#include +#include +#include + +template +inline +void +teststreaming(std::string testname, + temporal_type value, + std::basic_string expected_result, + const std::locale& locale = std::locale::classic()) +{ + std::basic_stringstream ss; + ss.imbue(locale); + ss << value; + check_equal(testname, ss.str(), expected_result); +} + + +#if !defined(BOOST_NO_STD_WSTRING) +static const wchar_t* long_month_names[] = + {L"Januar",L"Februar",L"Marz",L"April",L"Mai",L"Juni",L"Juli",L"August", + L"September",L"Oktober",L"November",L"Dezember"}; +static const wchar_t* short_month_names[]= + {L"Jan",L"Feb",L"Mar",L"Apr",L"Mai",L"Jun",L"Jul",L"Aug", + L"Sep",L"Okt",L"Nov",L"Dez"}; + +std::vector > de_short_month_names; +std::vector > de_long_month_names; +#endif // + +int main() { + using namespace boost::gregorian; + using namespace boost::posix_time; + + try { + date d(2004,Oct,13); + date min_date(min_date_time); + date max_date(max_date_time); + + date_period dp(d, d + date_duration(7)); + ptime t(d, time_duration(18,01,56)); + ptime tf = t + microseconds(3); + time_period tp(t, tf + days(7) + time_duration(1,1,1)); + time_duration td = hours(3) + minutes(2) + seconds(1) + milliseconds(9); + time_duration longer_td = hours(10) + minutes(22) + seconds(15) + milliseconds(980); // two characters in hours + time_duration long_td = hours(300) + minutes(2) + seconds(1) + milliseconds(9); // more than two characters in hours + { + std::stringstream ss; + ss << t; + check("Stream and to_string formats match (ptime)", + to_simple_string(t) == ss.str()); + std::cout << t << ' ' << td << std::endl; + ss.str(""); + ss << tf; + check("Stream and to_string formats match (ptime w/ fracsec)", + to_simple_string(tf) == ss.str()); + ss.str(""); + ss << tp; + check("Stream and to_string formats match (time_period)", + to_simple_string(tp) == ss.str()); + ss.str(""); + ss << td; + check("Stream and to_string formats match (time_duration)", + to_simple_string(td) == ss.str()); + std::cout << ss.str() << std::endl; + + time_facet* f = new time_facet(); + ss.imbue(std::locale(ss.getloc(), f)); + ss.str(""); + + f->format("%Y-%b-%d %H:%M:%S %%d"); + f->time_duration_format("%H:%M:%S %%S"); + ss << t; + check("Literal '%' in format", ss.str() == std::string("2004-Oct-13 18:01:56 %d")); + ss.str(""); + ss << td; + check("Literal '%' in time_duration format", ss.str() == std::string("03:02:01 %S")); + ss.str(""); + f->format("%Y-%b-%d %H:%M:%S %%%d"); + f->time_duration_format("%H:%M:%S %%%S"); + ss << t; + check("Multiple literal '%'s in format", ss.str() == std::string("2004-Oct-13 18:01:56 %13")); + ss.str(""); + ss << td; + check("Multiple literal '%'s in time_duration format", ss.str() == std::string("03:02:01 %01")); + ss.str(""); + + // Longer time durations + f->time_duration_format("%H:%M:%S"); + ss << longer_td; + check("Longer time durations", ss.str() == std::string("10:22:15")); + ss.str(""); + + // Long time durations + f->time_duration_format("%O:%M:%S"); + ss << long_td; + check("Long time durations", ss.str() == std::string("300:02:01")); + ss.str(""); + + // Short-hand format specifiers + f->format("%T"); + f->time_duration_format("%T"); + ss << t; + check("Short-hand '%T' in time format", ss.str() == std::string("18:01:56")); + ss.str(""); + ss << td; + check("Short-hand '%T' in time_duration format", ss.str() == std::string("03:02:01")); + ss.str(""); + + f->format("%R"); + f->time_duration_format("%R"); + ss << t; + check("Short-hand '%R' in time format", ss.str() == std::string("18:01")); + ss.str(""); + ss << td; + check("Short-hand '%R' in time_duration format", ss.str() == std::string("03:02")); + ss.str(""); + } + { // negative time_duration tests + std::string result; + std::stringstream ss; + time_duration td1(2,0,0); + time_duration td2(1,0,0); + ss << td2 - td1; + result = "-01:00:00"; + check("Negative time_duration", result == ss.str()); + ss.str(""); + + time_duration td3(0,2,0); + time_duration td4(0,1,0); + ss << td4 - td3; + result = "-00:01:00"; + check("Negative time_duration", result == ss.str()); + ss.str(""); + + time_duration td5(0,0,2); + time_duration td6(0,0,1); + ss << td6 - td5; + result = "-00:00:01"; + check("Negative time_duration", result == ss.str()); + ss.str(""); + +#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG) + result = "-00:00:00.000000001"; +#else + result = "-00:00:00.000001"; +#endif + time_duration td7(0,0,0,123); + time_duration td8(0,0,0,122); + ss << td8 - td7; + check("Negative time_duration: " + ss.str(), result == ss.str()); + + //reset the sign to always print + time_facet* f = new time_facet(); + ss.imbue(std::locale(ss.getloc(), f)); + f->time_duration_format("%+%H:%M:%S""%F"); + + ss.str(""); + ss << td4 - td3; + result = "-00:01:00"; + check("Negative time_duration sign always: " + ss.str(), result == ss.str()); + + ss.str(""); + ss << td3 - td4; + result = "+00:01:00"; + check("time_duration sign always: " + ss.str(), result == ss.str()); + + +#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG) + result = "-00:00:00.000000001"; +#else + result = "-00:00:00.000001"; +#endif + ss.str(""); + ss << td8 - td7; + check("Negative time_duration: " + ss.str(), result == ss.str()); + +#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG) + result = "+00:00:00.000000001"; +#else + result = "+00:00:00.000001"; +#endif + ss.str(""); + ss << td7 - td8; + check("time_duration sign bit always: " + ss.str(), result == ss.str()); + + f->time_duration_format("%-%H hours and %-%M minutes"); + ss.str(""); + ss << td4 - td3; + result = "-00 hours and -01 minutes"; + check("Negative time_duration two sign flags" + ss.str(), result == ss.str()); + ss.str(""); + + // Longer time durations + f->time_duration_format("%-%H:%M:%S"); + ss << -longer_td; + check("Longer negative time durations", ss.str() == std::string("-10:22:15")); + ss.str(""); + + // Long time durations + f->time_duration_format("%-%O:%M:%S"); + ss << -long_td; + check("Long negative time durations", ss.str() == std::string("-300:02:01")); + ss.str(""); + } + + // The test verifies that #2698 is fixed. That is, the time and date facet should + // not dereference end() iterator for the format string in do_put_tm. + { + boost::gregorian::date date(2009, 1, 1); + boost::posix_time::time_duration tdx(0, 0, 0, 0); + boost::posix_time::ptime boost_time(date, tdx); + std::stringstream sstr; + + boost::posix_time::time_facet* pFacet = new boost::posix_time::time_facet(""); + sstr.imbue(std::locale(std::locale::classic(), pFacet)); + + sstr << boost_time; + } + +#if !defined(BOOST_NO_STD_WSTRING) + std::copy(&short_month_names[0], + &short_month_names[12], + std::back_inserter(de_short_month_names)); + + std::copy(&long_month_names[0], + &long_month_names[12], + std::back_inserter(de_long_month_names)); + + + { + wtime_facet *timefacet = new wtime_facet(wtime_facet::standard_format); + teststreaming("widestream default classic time", t, + //std::wstring(L"Wed Oct 13 18:01:56 2004"), + std::wstring(L"10/13/04 18:01:56"), + std::locale(std::locale::classic(), timefacet)); + } + { + wtime_facet *timefacet = new wtime_facet(wtime_facet::standard_format); + teststreaming("widestream default classic time with fractional seconds truncated", t, + //std::wstring(L"Wed Oct 13 18:01:56 2004"), + std::wstring(L"10/13/04 18:01:56"), + std::locale(std::locale::classic(), timefacet)); + } + { + wtime_facet *timefacet = new wtime_facet(wtime_facet::standard_format); + teststreaming("widestream default time period with fractional seconds truncated", tp, + //std::wstring(L"[Wed Oct 13 18:01:56 2004/Wed Oct 20 19:02:57 2004]"), + std::wstring(L"[10/13/04 18:01:56/10/20/04 19:02:57]"), + std::locale(std::locale::classic(), timefacet)); + } + { + wtime_facet *timefacet = new wtime_facet(L"%Y-%b-%d %I:%M:%S %p"); + teststreaming("widestream time in 12 hours format w/ (AM/PM)", tp.begin(), + std::wstring(L"2004-Oct-13 06:01:56 PM"), + std::locale(std::locale::classic(), timefacet)); + } + { + wtime_facet *timefacet = new wtime_facet(wtime_facet::standard_format); +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + teststreaming("widestream time duration", td, + std::wstring(L"03:02:01.009000000"), + std::locale(std::locale::classic(), timefacet)); +#else + teststreaming("widestream time duration", td, + std::wstring(L"03:02:01.009000"), + std::locale(std::locale::classic(), timefacet)); +#endif // BOOST_DATE_TIME_HAS_NANOSECONDS + } + +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + teststreaming("widestream time duration", td, + std::wstring(L"03:02:01.009000000")); +#else + teststreaming("widestream time duration", td, + std::wstring(L"03:02:01.009000")); +#endif // BOOST_DATE_TIME_HAS_NANOSECONDS + + //wtime_facet *timefacet = new wtime_facet(); + //std::locale cloc = std::locale(std::locale::classic(), timefacet); + //ss.imbue(cloc); +// ss << L"classic date: " << d << std::endl; +// ss << L"classic dateperiod: " << dp << std::endl; + //ss << L"classic time: " << t << std::endl; + //ss << L"classic timefrac: " << tf << std::endl; + //ss << L"classic timeperiod: " << tp << std::endl; + + { + wtime_facet* wtimefacet = new wtime_facet(L"day: %j date: %Y-%b-%d weekday: %A time: %H:%M:%s"); +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + teststreaming("widestream custom time facet narly format", t, + std::wstring(L"day: 287 date: 2004-Oct-13 weekday: Wednesday time: 18:01:56.000000000"), + std::locale(std::locale::classic(), wtimefacet)); +#else + teststreaming("widestream custom time facet narly format", t, + std::wstring(L"day: 287 date: 2004-Oct-13 weekday: Wednesday time: 18:01:56.000000"), + std::locale(std::locale::classic(), wtimefacet)); +#endif + } + { + wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S,%f"); +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + teststreaming("widestream custom time fractional seconds: %Y-%b-%d %H:%M:%S,%f", t, + std::wstring(L"2004-Oct-13 18:01:56,000000000"), + std::locale(std::locale::classic(), wtimefacet)); +#else + teststreaming("widestream custom time fractional seconds: %Y-%b-%d %H:%M:%S,%f", t, + std::wstring(L"2004-Oct-13 18:01:56,000000"), + std::locale(std::locale::classic(), wtimefacet)); +#endif + } + + { + wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S"); + teststreaming("widestream custom time no frac seconds: %Y-%b-%d %H:%M:%S", t, + std::wstring(L"2004-Oct-13 18:01:56"), + std::locale(std::locale::classic(), wtimefacet)); + } + + { + wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S"); + wtimefacet->short_month_names(de_short_month_names); + teststreaming("widestream custom time no frac seconds, german months: %Y-%b-%d %H:%M:%S", t, + std::wstring(L"2004-Okt-13 18:01:56"), + std::locale(std::locale::classic(), wtimefacet)); + } + + { + wtime_facet* wtimefacet = new wtime_facet(); + wtimefacet->format(L"%B %b %Y"); + wtimefacet->short_month_names(de_short_month_names); + wtimefacet->long_month_names(de_long_month_names); + teststreaming("widestream custom time no frac seconds, german months: %B %b %Y", t, + std::wstring(L"Oktober Okt 2004"), + std::locale(std::locale::classic(), wtimefacet)); + } + + { + wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S" L"%F"); + teststreaming("widestream custom time no frac seconds %F operator: %Y-%b-%d %H:%M:%S""%F", t, + std::wstring(L"2004-Oct-13 18:01:56"), + std::locale(std::locale::classic(), wtimefacet)); + } + + { + wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S" L"%F"); +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + teststreaming("widestream custom time with frac seconds %F operator: %Y-%b-%d %H:%M:%S""%F", tf, + std::wstring(L"2004-Oct-13 18:01:56.000003000"), + std::locale(std::locale::classic(), wtimefacet)); +#else + teststreaming("widestream custom time with frac seconds %F operator: %Y-%b-%d %H:%M:%S""%F", tf, + std::wstring(L"2004-Oct-13 18:01:56.000003"), + std::locale(std::locale::classic(), wtimefacet)); +#endif // BOOST_DATE_TIME_HAS_NANOSECONDS + } + { + wtime_facet* wtimefacet = new wtime_facet(); + wtimefacet->set_iso_format(); +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + teststreaming("widestream custom time iso format", tf, + std::wstring(L"20041013T180156.000003000"), + std::locale(std::locale::classic(), wtimefacet)); +#else + teststreaming("widestream custom time iso format", tf, + std::wstring(L"20041013T180156.000003"), + std::locale(std::locale::classic(), wtimefacet)); +#endif // BOOST_DATE_TIME_HAS_NANOSECONDS + } + { + wtime_facet* wtimefacet = new wtime_facet(); + wtimefacet->set_iso_extended_format(); +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + teststreaming("widestream custom time iso extended format", tf, + std::wstring(L"2004-10-13 18:01:56.000003000"), + std::locale(std::locale::classic(), wtimefacet)); +#else + teststreaming("widestream custom time iso extended format", tf, + std::wstring(L"2004-10-13 18:01:56.000003"), + std::locale(std::locale::classic(), wtimefacet)); +#endif // BOOST_DATE_TIME_HAS_NANOSECONDS + } + + + { + wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%S" L"%F"); +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + teststreaming("widestream time period frac seconds %F operator: %Y-%b-%d %H:%M:%S""%F", tp, + std::wstring(L"[2004-Oct-13 18:01:56/2004-Oct-20 19:02:57.000002999]"), + std::locale(std::locale::classic(), wtimefacet)); +#else + teststreaming("widestream time period frac seconds %F operator: %Y-%b-%d %H:%M:%S""%F", tp, + std::wstring(L"[2004-Oct-13 18:01:56/2004-Oct-20 19:02:57.000002]"), + std::locale(std::locale::classic(), wtimefacet)); +#endif // BOOST_DATE_TIME_HAS_NANOSECONDS + } + + { + wtime_facet* wtimefacet = new wtime_facet(L"%Y-%b-%d %H:%M:%s"); + wperiod_formatter pf(wperiod_formatter::AS_OPEN_RANGE, L" / ", L"[ ", L" )", L" ]"); + wtimefacet->period_formatter(pf); + +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + teststreaming("widestream custom time : %Y-%b-%d %H:%M:%s", tp, + std::wstring(L"[ 2004-Oct-13 18:01:56.000000000 / 2004-Oct-20 19:02:57.000003000 )"), + std::locale(std::locale::classic(), wtimefacet)); +#else + teststreaming("widestream custom time : %Y-%b-%d %H:%M:%s", tp, + std::wstring(L"[ 2004-Oct-13 18:01:56.000000 / 2004-Oct-20 19:02:57.000003 )"), + std::locale(std::locale::classic(), wtimefacet)); +#endif // BOOST_DATE_TIME_HAS_NANOSECONDS + } + + + { + ptime nt(not_a_date_time); + teststreaming("widestream custom time : not a datetime", nt, + std::wstring(L"not-a-date-time")); + } + + + + +// //Denmark English has iso extended default format... +// std::locale gloc("en_DK"); +// ss.imbue(gloc); +// ss << L"default english-denmark date: " << d << std::endl; +// ss << L"default english-denmark dateperiod: " << dp << std::endl; +// ss << L"default english-denmark time: " << t << std::endl; +// ss << L"default english-denmark timefrac: " << tf << std::endl; +// ss << L"default english-denmark timeperiod: " << tp << std::endl; + + + +#endif + } + catch(std::exception& e) { + std::cout << "Caught std::exception: " << e.what() << std::endl; + } + catch(...) { + std::cout << "bad exception" << std::endl; + } + + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/posix_time/testtime_formatters.cpp b/src/boost/libs/date_time/test/posix_time/testtime_formatters.cpp new file mode 100644 index 000000000..bf628d11b --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testtime_formatters.cpp @@ -0,0 +1,116 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/posix_time/posix_time.hpp" +#include "../testfrmwk.hpp" + +#define CHECK_ROUNDTRIP(_PT) check_equal("from_iso_string(to_iso_string()) roundtrip of \"" + to_iso_string(_PT) + "\"", from_iso_string(to_iso_string(_PT)), _PT) + +int +main() +{ + + using namespace boost::posix_time; + using namespace boost::gregorian; + date d1(2002,Jan,1); + std::string d1_string("2002-Jan-01"); + std::string t1_string("01:02:03"); + std::string t1_result = d1_string + " " + t1_string; + ptime t1(d1,time_duration(1,2,3)); //2002-Jan-1 01:02:03 + std::cout << to_simple_string(t1) << std::endl; + check("simple: " + t1_result, t1_result == to_simple_string(t1)); + std::string iso_result = "20020101T010203"; + check("iso: " + iso_result, iso_result == to_iso_string(t1)); + std::string iso_ext_result = "2002-01-01T01:02:03"; + check("iso ext: " + iso_ext_result, iso_ext_result == to_iso_extended_string(t1)); + + CHECK_ROUNDTRIP(t1); + + if (time_duration::resolution() == boost::date_time::milli) { + ptime t4(d1,hours(1)+minutes(2)+seconds(3)+millisec(4)); + std::string r3 = to_simple_string(t4); + check("simple subsecond: "+r3 , + std::string("2002-Jan-01 01:02:03.004000") == r3); + CHECK_ROUNDTRIP(t4); + } + + + if (time_duration::resolution() == boost::date_time::micro) { + ptime t3(d1,hours(1)+minutes(2)+seconds(3)+microsec(4)); + std::string result = to_simple_string(t3); + check("microsecond: "+result , + std::string("2002-Jan-01 01:02:03.000004") == to_simple_string(t3)); + + time_duration td2 = hours(-12)+minutes(4)+seconds(2)+microsec(1); + // time_duration td2 = hours(-12)+minutes(4)+seconds(2)+millisec(1); + std::string r2 = to_simple_string(td2); + check("microseond neg subsecond duration: "+r2 , + std::string("-11:55:57.999999") == r2); + + std::string s1("-01:25:00"), s2("-00:40:00"), is1("-012500"), is2("-004000"); + time_duration td1(-1,25,0); + time_duration tds2(0,-40,0); + check("to string: " + to_simple_string(td1), to_simple_string(td1) == s1); + check("to string: " + to_simple_string(tds2), to_simple_string(tds2) == s2); + check("to string: " + to_iso_string(td1), to_iso_string(td1) == is1); + check("to string: " + to_iso_string(tds2), to_iso_string(tds2) == is2); + + CHECK_ROUNDTRIP(t3); + } + + + + if (time_duration::resolution() == boost::date_time::nano) { + ptime t2(d1,hours(12) + minutes(5) + seconds(1)); + time_period p1(t1,t2); //last value in period is 12:05:00 1/10000 sec less than t2 + std::string period_result("["+t1_result + "/" + d1_string + " " + "12:05:00.999999999]" ); + check("simple: " + period_result + "==" + to_simple_string(p1), period_result == to_simple_string(p1)); + + ptime t3(d1,hours(1)+minutes(2)+seconds(3)+nanosec(4)); + std::string result = to_simple_string(t3); + check("simple subsecond: "+result , + std::string("2002-Jan-01 01:02:03.000000004") == to_simple_string(t3)); + + + std::string s1("-01:25:00"), s2("-00:40:00"), is1("-012500"), is2("-004000"); + time_duration td1(-1,25,0); + time_duration tds2(0,-40,0); + check("to string: " + to_simple_string(td1), to_simple_string(td1) == s1); + check("to string: " + to_simple_string(tds2), to_simple_string(tds2) == s2); + check("to string: " + to_iso_string(td1), to_iso_string(td1) == is1); + check("to string: " + to_iso_string(tds2), to_iso_string(tds2) == is2); + + time_duration td2 = hours(-12)+minutes(4)+seconds(2)+nanosec(100); + std::string r2 = to_simple_string(td2); + check("neg subsecond duration: "+r2 , + std::string("-11:55:57.999999900") == r2); + + ptime t4(d1,hours(1)+minutes(2)+seconds(3)+millisec(4)); + std::string r3 = to_simple_string(t4); + check("simple subsecond: "+r3 , + std::string("2002-Jan-01 01:02:03.004000000") == r3); + + CHECK_ROUNDTRIP(t3); +} + + + // Boost Trac 1078 (https://svn.boost.org/trac10/ticket/1078) + // from_iso_string should be able to parse output of to_iso_string + CHECK_ROUNDTRIP(ptime()); + CHECK_ROUNDTRIP(ptime(not_a_date_time)); // should be same as previous + CHECK_ROUNDTRIP(ptime(pos_infin)); + CHECK_ROUNDTRIP(ptime(neg_infin)); + + // when min_date_time is formatted out, it is done so as an actual date/time + // i.e. it is not "special" in that sense + check_equal("from_iso_string(\"minimum-date-time\")", from_iso_string("minimum-date-time"), ptime(min_date_time)); + check_equal("from_iso_string(\"maximum-date-time\")", from_iso_string("maximum-date-time"), ptime(max_date_time)); + + return printTestStats(); +} + + diff --git a/src/boost/libs/date_time/test/posix_time/testtime_input_facet.cpp b/src/boost/libs/date_time/test/posix_time/testtime_input_facet.cpp new file mode 100644 index 000000000..126810c62 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testtime_input_facet.cpp @@ -0,0 +1,453 @@ +/* Copyright (c) 2005 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + * $Date$ + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include "boost/date_time/posix_time/posix_time.hpp" +#include "../testfrmwk.hpp" +#include +#include +#include +#include + +// for tests that are expected to fail and throw exceptions +template +bool failure_test(temporal_type component, + const std::string& input, + exception_type const& /*except*/, + boost::posix_time::time_input_facet* facet) +{ + using namespace boost::posix_time; + bool result = false; + std::istringstream iss(input); + iss.exceptions(std::ios_base::failbit); // turn on exceptions + iss.imbue(std::locale(std::locale::classic(), facet)); + try { + iss >> component; + } + catch(exception_type& e) { + std::cout << "Expected exception caught: \"" + << e.what() << "\"" << std::endl; + result = iss.fail(); // failbit must be set to pass test + } + catch(...) { + result = false; + } + + return result; +} + +// for tests that are expected to fail quietly +template +bool failure_test(temporal_type& component, + const std::string& input, + boost::posix_time::time_input_facet* facet) +{ + using namespace boost::posix_time; + std::istringstream iss(input); + /* leave exceptions turned off + * iss.exceptions(std::ios_base::failbit); */ + iss.imbue(std::locale(std::locale::classic(), facet)); + try { + iss >> component; + } + catch(...) { + std::cout << "Caught unexpected exception" << std::endl; + return false; + } + + return iss.fail(); // failbit must be set to pass test +} + +using namespace boost::gregorian; +using namespace boost::posix_time; + + +void +do_all_tests() +{ + +#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO) // skip this file + check("No tests run for this compiler. Incompatible IO", true); +#else + + // set up initial objects + time_duration td = hours(0); + ptime pt(not_a_date_time); + time_period tp(pt, td); + // exceptions for failure_tests + std::ios_base::failure e_failure("default"); + + /* test ptime, time_duration, time_period. + * test all formats. + * test for bad input. + * test special values. + * do not test custom names (done in gregorian). + * + * format flags to test H,M,S,s,F,f,j + */ + + // default format tests: time_duration, ptime + std::istringstream iss("09:59:01.321987654321 2005-Jan-15 10:15:03.123456789123"); + iss >> td; + iss >> pt; +#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG) + check_equal("Default format time_duration", td, time_duration(9,59,1,321987654)); + check_equal("Default format ptime", pt, ptime(date(2005,01,15),time_duration(10,15,3,123456789))); +#else + check_equal("Default format time_duration", td, time_duration(9,59,1,321987)); + check_equal("Default format ptime", pt, ptime(date(2005,01,15),time_duration(10,15,3,123456))); +#endif + + // test all flags that appear in time_input_facet + iss.str("12:34:56 2005-Jan-15 12:34:56"); + iss >> td; + iss >> pt; + check_equal("Default format time_duration no frac_sec", td, time_duration(12,34,56)); + // the following test insures %F parsing stops at the appropriate point + check_equal("Default format ptime", pt, ptime(date(2005,01,15),time_duration(12,34,56))); + + iss.str("14:13:12 extra stuff"); // using default %H:%M:%S%F format + iss >> td; + check_equal("Default frac_sec format time_duration", td, time_duration(14,13,12)); + + time_input_facet* facet = new time_input_facet(); + std::locale loc(std::locale::classic(), facet); + facet->time_duration_format("%H:%M:%S""%f"); + iss.imbue(loc); + + iss.str("14:13:12.0 extra stuff"); + iss >> td; + check_equal("Required-frac_sec format time_duration", td, time_duration(14,13,12)); + + iss.str("12"); + facet->time_duration_format("%H"); + iss >> td; + check_equal("Hours format", td, hours(12)); + + iss.str("05"); + facet->time_duration_format("%M"); + iss >> td; + check_equal("Minutes format", td, minutes(5)); + + iss.str("45"); + facet->time_duration_format("%S"); + iss >> td; + check_equal("Seconds w/o frac_sec format", td, seconds(45)); + + iss.str("10.01"); + facet->time_duration_format("%s"); + iss >> td; +#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG) + check_equal("Seconds w/ frac_sec format", td, time_duration(0,0,10,10000000)); +#else + check_equal("Seconds w/ frac_sec format", td, time_duration(0,0,10,10000)); +#endif + + iss.str("2005-105T23:59"); + facet->format("%Y-%jT%H:%M"); // extended ordinal format + iss >> pt; + check_equal("Extended Ordinal format", pt, ptime(date(2005,4,15),time_duration(23,59,0))); + + /* this is not implemented yet. The flags: %I & %p are not parsed + iss.str("2005-Jun-14 03:15:00 PM"); + facet->format("%Y-%b-%d %I:%M:%S %p"); + iss >> pt; + check_equal("12 hour time format (AM/PM)", pt, ptime(date(2005,6,14),time_duration(15,15,0))); + */ + + iss.str("2005-Jun-14 15:15:00 %d"); + facet->format("%Y-%b-%d %H:%M:%S %%d"); + iss >> pt; + check_equal("Literal '%' in format", pt, ptime(date(2005,6,14),time_duration(15,15,0))); + iss.str("15:15:00 %d"); + facet->time_duration_format("%H:%M:%S %%d"); + iss >> td; + check_equal("Literal '%' in time_duration format", td, time_duration(15,15,0)); + iss.str("2005-Jun-14 15:15:00 %14"); + facet->format("%Y-%b-%d %H:%M:%S %%%d"); // %% => % & %d => day_of_month + iss >> pt; + check_equal("Multiple literal '%'s in format", pt, ptime(date(2005,6,14),time_duration(15,15,0))); + iss.str("15:15:00 %15"); + facet->time_duration_format("%H:%M:%S %%%M"); + iss >> td; + check_equal("Multiple literal '%'s in time_duration format", td, time_duration(15,15,0)); + + { /****** iso format tests (and custom 'scrunched-together formats) ******/ + time_input_facet *facet2 = new time_input_facet(); + facet2->set_iso_format(); + facet2->time_duration_format("%H""%M""%S""%F"); // iso format + std::stringstream ss; + ss.imbue(std::locale(std::locale::classic(), facet2)); + ptime pt2(not_a_date_time); + time_duration tdx(not_a_date_time); + date dx(2002,Oct,17); +#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG) + time_duration td2(23,12,17,123450000); +#else + time_duration td2(23,12,17,123450); +#endif + ptime result(dx, td2); + + ss.str("20021017T231217.12345"); + ss >> pt2; + check_equal("iso_format ptime", pt2, result); + ss.str(""); + facet2->set_iso_extended_format(); + ss.str("2002-10-17 23:12:17.12345"); + ss >> pt2; + check_equal("iso_extended_format ptime", pt2, result); + ss.str(""); + ss.str("231217.12345"); + ss >> tdx; + check_equal("iso_format time_duration", tdx, td2); + ss.str(""); + ss.str("-infinity"); + ss >> tdx; + check_equal("iso_format time_duration (special_value)", + tdx, time_duration(neg_infin)); + ss.str(""); + // the above tests prove correct parsing of time values in these formats. + // these tests show they also handle special_values & exceptions properly + time_duration nadt(not_a_date_time); + ss.exceptions(std::ios_base::failbit); // we need exceptions turned on here + int count = 0; + try { + facet2->time_duration_format("%H""%M""%S""%F"); + ss.str("not-a-date-time"); + ++count; + ss >> tdx; + check_equal("special value w/ hours flag", tdx, nadt); + ss.str(""); + facet2->time_duration_format("%M""%S""%F"); + ss.str("not-a-date-time"); + ++count; + ss >> tdx; + check_equal("special value w/ minutes flag", tdx, nadt); + ss.str(""); + facet2->time_duration_format("%S""%F"); + ss.str("not-a-date-time"); + ++count; + ss >> tdx; + check_equal("special value w/ seconds flag", tdx, nadt); + ss.str(""); + facet2->time_duration_format("%s"); + ss.str("not-a-date-time"); + ++count; + ss >> tdx; + check_equal("special value w/ sec w/frac_sec (always) flag", tdx, nadt); + ss.str(""); + facet2->time_duration_format("%f"); + ss.str("not-a-date-time"); + ++count; + ss >> tdx; + check_equal("special value w/ frac_sec (always) flag", tdx, nadt); + ss.str(""); + } + catch(...) { + // any exception is a failure + std::stringstream msg; + msg << "special_values with scrunched formats failed at test" << count; + check(msg.str(), false); + } + // exception tests + std::ios_base::failure exc("failure"); + check("failure test w/ hours flag", + failure_test(td, "bad_input", exc, new time_input_facet("%H""%M""%S""%F"))); + check("silent failure test w/ hours flag", + failure_test(td, "bad_input", new time_input_facet("%H""%M""%S""%F"))); + check("failure test w/ minute flag", + failure_test(td, "bad_input", exc, new time_input_facet("%M""%S""%F"))); + check("silent failure test w/ minute flag", + failure_test(td, "bad_input", new time_input_facet("%M""%S""%F"))); + check("failure test w/ second flag", + failure_test(td, "bad_input", exc, new time_input_facet("%S""%F"))); + check("silent failure test w/ second flag", + failure_test(td, "bad_input", new time_input_facet("%S""%F"))); + check("failure test w/ sec w/frac (always) flag", + failure_test(td, "bad_input", exc, new time_input_facet("%s"))); + check("silent failure test w/ sec w/frac (always) flag", + failure_test(td, "bad_input", new time_input_facet("%s"))); + check("failure test w/ frac_sec flag", + failure_test(td, "bad_input", exc, new time_input_facet("%f"))); + check("silent failure test w/ frac_sec flag", + failure_test(td, "bad_input", new time_input_facet("%f"))); + + } + // special_values tests. prove the individual flags catch special_values + // NOTE: these flags all by themselves will not parse a complete ptime, + // these are *specific* special_values tests + iss.str("+infinity -infinity"); + facet->format("%H"); + facet->time_duration_format("%H"); + iss >> pt; + iss >> td; + check_equal("Special value: ptime %H flag", pt, ptime(pos_infin)); + check_equal("Special value: time_duration %H flag", td, time_duration(neg_infin)); + + iss.str("not-a-date-time +infinity"); + facet->format("%M"); + facet->time_duration_format("%M"); + iss >> pt; + iss >> td; + check_equal("Special value: ptime %M flag", pt, ptime(not_a_date_time)); + check_equal("Special value: time_duration %M flag", td, time_duration(pos_infin)); + + iss.str("-infinity not-a-date-time "); + facet->format("%S"); + facet->time_duration_format("%S"); + iss >> pt; + iss >> td; + check_equal("Special value: ptime %S flag", pt, ptime(neg_infin)); + check_equal("Special value: time_duration %S flag", td, time_duration(not_a_date_time)); + + iss.str("+infinity -infinity"); + facet->format("%s"); + facet->time_duration_format("%s"); + iss >> pt; + iss >> td; + check_equal("Special value: ptime %s flag", pt, ptime(pos_infin)); + check_equal("Special value: time_duration %s flag", td, time_duration(neg_infin)); + + iss.str("not-a-date-time +infinity"); + facet->format("%j"); + facet->time_duration_format("%f"); + iss >> pt; + iss >> td; + check_equal("Special value: ptime %j flag", pt, ptime(not_a_date_time)); + check_equal("Special value: time_duration %f flag", td, time_duration(pos_infin)); + + // time_period tests - the time_period_parser is thoroughly tested in gregorian tests + // default period format is closed range so last ptime is included in peiod + iss.str("[2005-Jan-01 00:00:00/2005-Dec-31 23:59:59]"); + facet->format(time_input_facet::default_time_input_format); // reset format + iss >> tp; + check("Time period, default formats", + (tp.begin() == ptime(date(2005,1,1),hours(0))) && + (tp.last() == ptime(date(2005,12,31),time_duration(23,59,59))) && + (tp.end() == ptime(date(2005,12,31),time_duration(23,59,59,1))) ); + { + std::stringstream ss; + ptime ptx(not_a_date_time); + ptime pt2 = second_clock::local_time(); + ptime pt3(neg_infin); + ptime pt4(pos_infin); + time_period tpx(pt2, ptx); // ptime/nadt + time_period tp2(ptx, ptx); // nadt/nadt + time_period tp3(pt3, pt4); + ss << tpx; + ss >> tp2; + check_equal("Special values period (reversibility test)", tpx, tp2); + ss.str("[-infinity/+infinity]"); + ss >> tp2; + check_equal("Special values period (infinities)", tp3, tp2); + } + + // Failure tests + // faliure tests for date elements tested in gregorian tests + time_input_facet* facet2 = new time_input_facet(); + facet2->time_duration_format("%H:%M:%S""%f"); + check("Failure test: Missing frac_sec with %f flag (w/exceptions)", + failure_test(td, "14:13:12 extra stuff", e_failure, facet2)); + time_input_facet* facet3 = new time_input_facet(); + facet3->time_duration_format("%H:%M:%S""%f"); + check("Failure test: Missing frac_sec with %f flag (no exceptions)", + failure_test(td, "14:13:12 extra stuff", facet3)); + + // Reversable format tests + time_duration td_io(10,11,12,1234567); + ptime pt_io(date(2004,03,15), td_io); + time_facet* otp_facet = new time_facet(); + time_input_facet* inp_facet = new time_input_facet(); + std::stringstream ss; + std::locale loc2(std::locale::classic(), otp_facet); + ss.imbue(std::locale(loc2, inp_facet)); // imbue locale containing both facets + + ss.str(""); + ss << pt_io; // stream out pt_io + ss >> pt; + check_equal("Stream out one ptime then into another: default format", pt_io, pt); + ss.str(""); + ss << td_io; // stream out td_io + ss >> td; + check_equal("Stream out one time_duration then into another: default format", td_io, td); + + td_io = time_duration(1,29,59); // no frac_sec, default format has %F + pt_io = ptime(date(2004,2,29), td_io); // leap year + ss.str(""); + ss << pt_io; // stream out pt_io + ss >> pt; + check_equal("Stream out one ptime then into another: default format", pt_io, pt); + ss.str(""); + ss << td_io; // stream out td_io + ss >> td; + check_equal("Stream out one time_duration then into another: default format", td_io, td); + + td_io = time_duration(13,05,0); // no seconds as the next formats won't use them + pt_io = ptime(date(2004,2,29), td_io); // leap year + otp_facet->format("%Y-%jT%H:%M"); // extended ordinal + inp_facet->format("%Y-%jT%H:%M"); + ss.str(""); + ss << pt_io; // stream out pt_io + ss >> pt; + check_equal("Stream out one ptime then into another: extended ordinal format", pt_io, pt); + + otp_facet->format("Time: %H:%M, Date: %B %d, %Y"); // custom format with extra words + inp_facet->format("Time: %H:%M, Date: %B %d, %Y"); + ss.str(""); + ss << pt_io; // stream out pt_io + ss >> pt; + check_equal("Stream out one ptime then into another: custom format (" + ss.str() + ")", pt_io, pt); + + { + // fully parameterized constructor - compile only test, all other features tested in gregorian + boost::date_time::format_date_parser fdp("%Y-%b-%d", std::locale::classic()); + special_values_parser svp; // default constructor + period_parser pp; // default constructor + boost::date_time::date_generator_parser dgp; // default constructor + time_input_facet tif("%Y-%m-%d %H:%M:%s", fdp, svp, pp, dgp); + } + + // trac 13194 (https://svn.boost.org/trac10/ticket/13194) + { + const std::string value = "December 07:27:10.435945 5 2017"; + boost::posix_time::time_input_facet* facet4 = new boost::posix_time::time_input_facet("%B %H:%M:%s %e %Y"); + boost::posix_time::ptime ptx; + check("trac 13194 %e on \"5\" failbit set", !failure_test(ptx, value, facet4)); // proves failbit was not set + check_equal("trac 13194 %e on \" 5\" valid value", "2017-12-05T07:27:10.435945000", to_iso_extended_string(ptx)); + } + + // trac 12910 + { + const std::string value = "263-08:09:10"; + boost::posix_time::time_input_facet* facet = new boost::posix_time::time_input_facet("%j-%H:%M:%S"); + boost::posix_time::ptime pt; + check("trac 12910 %j without %Y no failbit", !failure_test(pt, value, facet)); // proves failbit was not set + check_equal("trac 12910 %j without %Y value", "1400-09-20T08:09:10", to_iso_extended_string(pt)); + } + +#endif // USE_DATE_TIME_PRE_1_33_FACET_IO +} + + + +int main(){ + + try { //wrap all the tests -- we don't expect an exception + do_all_tests(); + } + catch(std::exception& e) { + std::string failure("std::exception caught: "); + failure += e.what(); + check(failure, false); + } + catch(...) { + check("Unknown exception caught -- failing", false); + } + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/posix_time/testtime_period.cpp b/src/boost/libs/date_time/test/posix_time/testtime_period.cpp new file mode 100644 index 000000000..72b065277 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testtime_period.cpp @@ -0,0 +1,77 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include +#include "boost/date_time/posix_time/posix_time.hpp" +#include "boost/date_time/posix_time/time_period.hpp" +#include "../testfrmwk.hpp" + +int main() +{ + using namespace boost::gregorian; + using namespace boost::posix_time; + date d1(2001,Jan, 1); + ptime t1 (d1,hours(2));//2001-Jan-1 02:00:00 + ptime t2 (d1,hours(3));//2001-Jan-1 03:00:00 + time_period p1(t1,t2); //2001-Jan-1 02:59:59 + time_period p2(p1); + check("copy construct & ==", p1 == p2); + time_period p3 = p2; + check("assignment", p3 == p2); + time_period p4(t1,hours(1)); + check("length", p4.length() == hours(1)); + std::cout << t1 << std::endl; + std::cout << p4 << std::endl; + std::cout << p1 << std::endl; + check("construction and ==", p1 == p4); + check("begin", p1.begin() == t1); + check("last", p1.end() == t2); + check("end", p1.last() == t2-time_duration::unit()); + + std::cout << p1 << std::endl; + // check("last", p1.() == t2); + check("contains begin", p1.contains(t1)); + check("contains end-not", !p1.contains(t2)); + check("contains last", p1.contains(t2-seconds(1))); + ptime t3(date(2001,Jan,1),hours(4)); + time_period p5(t2,t3); + check("check contains", !p1.contains(p5.begin())); + check("check contains", !p5.contains(p1.begin())); + check("operator== not equal case", !(p1 == p5)); + check("less than order", p1 < p5); + check("greater than order", p5 > p1); + check("not equal", p5 != p1); + check("intersects with myself", p1.intersects(p1)); + check("not intersects", !(p1.intersects(p5))); + check("not intersects", !(p5.intersects(p1))); + + time_period p6(p5); + p6.shift(minutes(30)); + std::cout << p5 << std::endl; + std::cout << p6 << std::endl; + check("shifted intersects", p5.intersects(p6)); + check("shifted intersects", p6.intersects(p5)); + check("contains begin", p5.contains(p6.begin())); + p6.shift(minutes(30)); + std::cout << p5 << std::endl; + std::cout << p6 << std::endl; + check("shifted !intersects", !p5.intersects(p6)); + check("shifted !intersects", !p6.intersects(p5)); + p6.shift(minutes(-30)); + std::cout << p5 << std::endl; + std::cout << p6 << std::endl; + time_period p7 = p5.intersection(p6); + std::cout << p7 << std::endl; + check("shifted intersection", + p7 == time_period(ptime(d1,time_duration(3,30,0)), + ptime(d1,time_duration(4,0,0)))); + + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/posix_time/testtime_serialize.cpp b/src/boost/libs/date_time/test/posix_time/testtime_serialize.cpp new file mode 100644 index 000000000..4d50534a0 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testtime_serialize.cpp @@ -0,0 +1,125 @@ +/* Copyright (c) 2002-2005 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include +#include +#include +#include +#include +#include +#include "../testfrmwk.hpp" +#include + +using namespace boost; +using namespace posix_time; +using namespace gregorian; + +template +void save_to(archive_type& ar, const temporal_type& tt) +{ + ar << tt; +} + +int main(){ + // originals + date d(2002, Feb, 14); +#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG) + time_duration td(12,13,52,123456789); +#else + time_duration td(12,13,52,123456); +#endif + ptime pt(d, td); + time_period tp(pt, ptime(date(2002, Oct, 31), hours(19))); + ptime sv_pt1(not_a_date_time); + ptime sv_pt2(pos_infin); + time_duration sv_td(neg_infin); + + // for loading in from archive + date d2(not_a_date_time); + time_duration td2(1,0,0); + ptime pt2(d2, td2); + time_period tp2(pt2, hours(1)); + ptime sv_pt3(min_date_time); + ptime sv_pt4(min_date_time); + time_duration sv_td2(0,0,0); + + std::ostringstream oss; + + { + // NOTE: DATE_TIME_XML_SERIALIZE is only used in testing and is + // defined in the testing Jamfile +#if defined(DATE_TIME_XML_SERIALIZE) + std::cout << "Running xml archive tests" << std::endl; + archive::xml_oarchive oa(oss); +#else + std::cout << "Running text archive tests" << std::endl; + archive::text_oarchive oa(oss); +#endif // DATE_TIME_XML_SERIALIZE + + try{ +#if defined(DATE_TIME_XML_SERIALIZE) + save_to(oa, BOOST_SERIALIZATION_NVP(pt)); + save_to(oa, BOOST_SERIALIZATION_NVP(sv_pt1)); + save_to(oa, BOOST_SERIALIZATION_NVP(sv_pt2)); + save_to(oa, BOOST_SERIALIZATION_NVP(tp)); + save_to(oa, BOOST_SERIALIZATION_NVP(td)); + save_to(oa, BOOST_SERIALIZATION_NVP(sv_td)); +#else + save_to(oa, pt); + save_to(oa, sv_pt1); + save_to(oa, sv_pt2); + save_to(oa, tp); + save_to(oa, td); + save_to(oa, sv_td); +#endif // DATE_TIME_XML_SERIALIZE + }catch(archive::archive_exception& ae){ + std::string s(ae.what()); + check("Error writing to archive: " + s + "\nWritten data: \"" + oss.str() + "\"", false); + return printTestStats(); + } + } + + { + std::istringstream iss(oss.str()); +#if defined(DATE_TIME_XML_SERIALIZE) + archive::xml_iarchive ia(iss); +#else + archive::text_iarchive ia(iss); +#endif // DATE_TIME_XML_SERIALIZE + + try{ +#if defined(DATE_TIME_XML_SERIALIZE) + ia >> BOOST_SERIALIZATION_NVP(pt2); + ia >> BOOST_SERIALIZATION_NVP(sv_pt3); + ia >> BOOST_SERIALIZATION_NVP(sv_pt4); + ia >> BOOST_SERIALIZATION_NVP(tp2); + ia >> BOOST_SERIALIZATION_NVP(td2); + ia >> BOOST_SERIALIZATION_NVP(sv_td2); +#else + ia >> pt2; + ia >> sv_pt3; + ia >> sv_pt4; + ia >> tp2; + ia >> td2; + ia >> sv_td2; +#endif // DATE_TIME_XML_SERIALIZE + }catch(archive::archive_exception& ae){ + std::string s(ae.what()); + check("Error readng from archive: " + s + "\nWritten data: \"" + oss.str() + "\"", false); + return printTestStats(); + } + } + + check("ptime", pt == pt2); + check("special_values ptime (nadt)", sv_pt1 == sv_pt3); + check("special_values ptime (pos_infin)", sv_pt2 == sv_pt4); + check("time_period", tp == tp2); + check("time_duration", td == td2); + check("special_values time_duration (neg_infin)", sv_td == sv_td2); + + return printTestStats(); +} diff --git a/src/boost/libs/date_time/test/posix_time/testtime_serialize_versioning.cpp b/src/boost/libs/date_time/test/posix_time/testtime_serialize_versioning.cpp new file mode 100644 index 000000000..157627793 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testtime_serialize_versioning.cpp @@ -0,0 +1,64 @@ +/* Copyright (c) 2017 James E. King III + * Use, modification and distribution is 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) + */ + +#include +#include +#include +#include +#include +#include "../testfrmwk.hpp" +#include + +using namespace boost; +using namespace posix_time; + +void check_filesize(const std::string& filename, std::ifstream::pos_type expectedSize) +{ + std::ifstream in(filename.c_str(), std::ifstream::ate | std::ifstream::binary); + check_equal("check file size is " + boost::lexical_cast(expectedSize), in.tellg(), expectedSize); +} + +std::string get_fname(int version) +{ + return "time_duration_serialization." + + std::string((sizeof(size_t) == 4) ? "x32" : "x64") + + ".v" + boost::lexical_cast(version); +} + +int main() { + time_duration td(12, 13, 52, 123456); + +#if BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION == 0 + std::ofstream ofs(get_fname(0).c_str(), std::ios_base::binary | std::ios_base::out | std::ios_base::trunc); + boost::archive::binary_oarchive oa(ofs); + oa << td; + ofs.close(); + +#if defined(_MSC_VER) + check_filesize(get_fname(0), 58 + sizeof(size_t)); +#endif + +#else // BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION > 0 + std::ifstream ifs(get_fname(0).c_str(), std::ios_base::binary | std::ios_base::in); + boost::archive::binary_iarchive ia(ifs); + time_duration tmp; + ia >> tmp; + ifs.close(); + check_equal("read older version structure ok", td, tmp); + + std::ofstream ofs(get_fname(1).c_str(), std::ios_base::binary | std::ios_base::out | std::ios_base::trunc); + boost::archive::binary_oarchive oa(ofs); + oa << td; + ofs.close(); + +#if defined(_MSC_VER) + check_filesize(get_fname(1), 70 + sizeof(size_t)); +#endif + +#endif // BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION + + return printTestStats(); +} diff --git a/src/boost/libs/date_time/test/posix_time/testtime_wstream.cpp b/src/boost/libs/date_time/test/posix_time/testtime_wstream.cpp new file mode 100644 index 000000000..f2b0c45c0 --- /dev/null +++ b/src/boost/libs/date_time/test/posix_time/testtime_wstream.cpp @@ -0,0 +1,89 @@ +/* Copyright (c) 2003-2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Bart Garst + * $Date$ + */ +#include +#include +#include +#include +#include "../testfrmwk.hpp" +#include + +using namespace boost::gregorian; +using namespace boost::posix_time; +using boost::lexical_cast; + +int main(){ +#if defined(BOOST_NO_STD_WSTRING) || \ + defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS) + check("No wstring/wstream support for this compiler", false); +#else + + std::wstring res, ws; + std::wstringstream wss; + /* time_period was used because all the time-type objects + * that have operator<< can be easily accessed from it. + * Tose are: ptime, time_duration, time_period */ + date d1(2003,Jan,20), d2(2003,May,10); + time_period tp(ptime(d1,hours(1)), ptime(d2,hours(15))); + + // ptime + wss << tp.begin(); + res = L"2003-Jan-20 01:00:00"; + check("ptime op<<", res == wss.str()); + wss.str(L""); + ws = to_simple_wstring(tp.begin()); + check("ptime to_simple_wstring", res == ws); + res = L"20030120T010000"; + ws = to_iso_wstring(tp.begin()); + check("ptime to_iso_wstring", res == ws); + res = L"2003-01-20T01:00:00"; + ws = to_iso_extended_wstring(tp.begin()); + check("ptime to_iso_extended_wstring", res == ws); + + // time_duration + wss << tp.length(); + res = L"2654:00:00"; + check("time_duration", res == wss.str()); + wss.str(L""); + ws = to_simple_wstring(tp.length()); + check("time_duration to_simple_wstring", res == ws); + res = L"26540000"; + ws = to_iso_wstring(tp.length()); + check("time_duration to_iso_wstring", res == ws); + + // time_period + wss << tp; +#ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + res = L"[2003-Jan-20 01:00:00/2003-May-10 14:59:59.999999999]"; +#else + res = L"[2003-Jan-20 01:00:00/2003-May-10 14:59:59.999999]"; +#endif + check("time_period", res == wss.str()); + wss.str(L""); + ws = to_simple_wstring(tp); + check("time_period to_simple_wstring", res == ws); + + // special values + time_duration sv_td(neg_infin); + date sv_d(pos_infin); + ptime sv_tp(sv_d,hours(1)); + res = L"+infinity"; + wss << sv_tp; + check("ptime op<< special value", res == wss.str()); + wss.str(L""); + ws = to_simple_wstring(sv_tp); + check("ptime to_simple_wstring special value", res == ws); + res = L"-infinity"; + wss << sv_td; + check("time_duration op<< special value", res == wss.str()); + wss.str(L""); + ws = to_simple_wstring(sv_td); + check("time_duration to_simple_wstring special value", res == ws); + +#endif + return printTestStats(); +} diff --git a/src/boost/libs/date_time/test/self_contained_header.cpp b/src/boost/libs/date_time/test/self_contained_header.cpp new file mode 100644 index 000000000..3ff1abf4b --- /dev/null +++ b/src/boost/libs/date_time/test/self_contained_header.cpp @@ -0,0 +1,22 @@ +/* + * Copyright Andrey Semashev 2020. + * Distributed under the Boost Software License, Version 1.0. + * (See accompanying file LICENSE_1_0.txt or copy at + * http://www.boost.org/LICENSE_1_0.txt) + */ +/*! + * \file self_contained_header.cpp + * \author Andrey Semashev + * \date 04.04.2020 + * + * \brief This file contains a test boilerplate for checking that every public header is self-contained and does not have any missing #includes. + */ + +#define BOOST_DATE_TIME_TEST_INCLUDE_HEADER() + +#include BOOST_DATE_TIME_TEST_INCLUDE_HEADER() + +int main(int, char*[]) +{ + return 0; +} diff --git a/src/boost/libs/date_time/test/testconstrained_value.cpp b/src/boost/libs/date_time/test/testconstrained_value.cpp new file mode 100644 index 000000000..f8567f031 --- /dev/null +++ b/src/boost/libs/date_time/test/testconstrained_value.cpp @@ -0,0 +1,74 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/config.hpp" +#include "boost/date_time/constrained_value.hpp" +#include "testfrmwk.hpp" +#include + +class bad_day {}; //exception type + + +class day_value_policies +{ +public: + typedef unsigned int value_type; + static unsigned int min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; }; + static unsigned int max BOOST_PREVENT_MACRO_SUBSTITUTION () { return 31;}; + static void on_error(unsigned int&, unsigned int, boost::CV::violation_enum) + { + throw bad_day(); + } +}; + +struct range_error {}; //exception type +typedef boost::CV::simple_exception_policy one_to_ten_range_policy; + +int main() +{ + using namespace boost::CV; + constrained_value cv1(0), cv2(31); + check("not equal", cv1 != cv2); + check("equal", cv1 == cv1); + check("greater", cv2 > cv1); + check("greater or equal ", cv2 >= cv1); + //various running of the conversion operator + std::cout << cv1 << std::endl; + unsigned int i = cv1; + check("test conversion", i == cv1); + + + try { + constrained_value cv3(11); + std::cout << "Not Reachable: " << cv3 << " "; + check("got range exception max", false); + } + catch(range_error&) { + check("got range exception max", true); + } + + try { + constrained_value cv3(0); + std::cout << "Not Reachable: " << cv3 << " "; + check("got range exception min", false); + } + catch(range_error&) { + check("got range exception min", true); + } + + try { + constrained_value cv4(1); + cv4 = 12; + check("range exception on assign", false); + } + catch(range_error&) { + check("range exception on assign", true); + } + + return printTestStats(); +} + diff --git a/src/boost/libs/date_time/test/testfrmwk.hpp b/src/boost/libs/date_time/test/testfrmwk.hpp new file mode 100644 index 000000000..fde39ab66 --- /dev/null +++ b/src/boost/libs/date_time/test/testfrmwk.hpp @@ -0,0 +1,113 @@ + +#ifndef TEST_FRMWK_HPP___ +#define TEST_FRMWK_HPP___ + +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * $Date$ + */ + + +#include +#include +#include + +//! Really simple test framework for counting and printing +class TestStats +{ +public: + static TestStats& instance() {static TestStats ts; return ts;} + void addPassingTest() {testcount_++; passcount_++;} + void addFailingTest() {testcount_++;} + unsigned int testcount() const {return testcount_;} + unsigned int passcount() const {return passcount_;} + void print(std::ostream& out = std::cout) const + { + out << testcount_ << " Tests Executed: " ; + if (passcount() != testcount()) { + out << (testcount() - passcount()) << " FAILURES"; + } + else { + out << "All Succeeded" << std::endl; + } + out << std::endl; + } +private: + TestStats() : testcount_(0), passcount_(0) {} + unsigned int testcount_; + unsigned int passcount_; +}; + + +inline bool check(const std::string& testname, bool testcond) +{ + TestStats& stat = TestStats::instance(); + if (testcond) { + std::cout << "Pass :: " << testname << " " << std::endl; + stat.addPassingTest(); + return true; + } + else { + stat.addFailingTest(); + std::cout << "FAIL :: " << testname << " " << std::endl; + return false; + } +} + +// In the comparisons below, it is possible that T and U are signed and unsigned integer types, which generates warnings in some compilers. +#if defined(BOOST_MSVC) +# pragma warning(push) +# pragma warning(disable: 4389) +#elif defined(BOOST_CLANG) && defined(__has_warning) +# if __has_warning("-Wsign-compare") +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wsign-compare" +# endif +#elif defined(BOOST_GCC) && (BOOST_GCC+0) >= 40600 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wsign-compare" +#endif + +template< typename T, typename U > +inline bool check_equal(const std::string& testname, T const& left, U const& right) +{ + bool res = check(testname, left == right); + if (!res) + { + std::cout << " left = " << left << ", right = " << right << std::endl; + } + return res; +} + +#if defined(BOOST_MSVC) +# pragma warning(pop) +#elif defined(BOOST_CLANG) && defined(__has_warning) +# if __has_warning("-Wsign-compare") +# pragma clang diagnostic pop +# endif +#elif defined(BOOST_GCC) && (BOOST_GCC+0) >= 40600 +# pragma GCC diagnostic pop +#endif + +#ifndef BOOST_NO_STD_WSTRING +inline bool check_equal(const std::string& testname, std::wstring const& left, std::wstring const& right) +{ + bool res = check(testname, left == right); + if (!res) + { + std::wcout << L" left = " << left << L", right = " << right << std::endl; + } + return res; +} +#endif + +inline int printTestStats() +{ + TestStats& stat = TestStats::instance(); + stat.print(); + return stat.testcount() - stat.passcount(); +} + +#endif diff --git a/src/boost/libs/date_time/test/testfrom_facet.cpp b/src/boost/libs/date_time/test/testfrom_facet.cpp new file mode 100644 index 000000000..79faafe2e --- /dev/null +++ b/src/boost/libs/date_time/test/testfrom_facet.cpp @@ -0,0 +1,50 @@ +/* Copyright (c) 2004 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + * $Date$ + * + * This file isn't part of the official regression test suite at + * the moment, but it is a basic test of the strings_from_facet.hpp + * infrastructure that can be compiled trivially. + */ + + +#include +#include +#include +#include +#include + +#include "boost/date_time/strings_from_facet.hpp" +#include "algorithm_ext/container_print.hpp" + + + +int +main() +{ + using boost::date_time::gather_month_strings; + using boost::date_time::gather_weekday_strings; + + std::vector data; + std::vector wdata; + + data = gather_month_strings(std::locale::classic()); + print(data, std::cout); + data = gather_month_strings(std::locale::classic(), false); + print(data, std::cout); + data = gather_weekday_strings(std::locale::classic()); + print(data, std::cout); + data = gather_weekday_strings(std::locale::classic(), false); + print(data, std::cout); + + wdata = gather_month_strings(std::locale::classic()); + std::wofstream wof("from_facet_test.out"); + int i=0; + while (i < wdata.size()) { + wof << wdata[i] << std::endl; + i++; + } +} diff --git a/src/boost/libs/date_time/test/testgeneric_period.cpp b/src/boost/libs/date_time/test/testgeneric_period.cpp new file mode 100644 index 000000000..64c1ff56a --- /dev/null +++ b/src/boost/libs/date_time/test/testgeneric_period.cpp @@ -0,0 +1,273 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Bart Garst + */ + +#include +#include "boost/date_time/period.hpp" +#include "testfrmwk.hpp" + +/*! duration_rep parameter for period requires a func unit() that + * returns the smallest unit of measure for this type. This minimal + * class fulfills that, and other, requirements */ +template +class duration_type { + public: + duration_type(int_type a = 0) : _val(a) {} + static int_type unit() { return 1; } + int_type get_rep() { return _val; } + bool operator==(duration_type rhs) { return _val == rhs._val; } + bool operator<(duration_type rhs) { return _val < rhs._val; } + bool operator>(duration_type rhs) { return _val > rhs._val; } + private: + int_type _val; +}; +//! To enable things like "cout << period.length()" +template +inline +std::ostream& operator<<(std::ostream& os, duration_type dt){ + os << dt.get_rep(); + return os; +} +//! this operator is needed because period adds a duration_rep to a point_rep +template +inline +int_type operator+(int i, duration_type dt){ + return i + dt.get_rep(); +} + +//! this operator is needed because period adds a duration_rep to a point_rep +template +inline +int_type operator-(int i, duration_type dt){ + return i - dt.get_rep(); +} + + +int main(){ + using namespace boost::date_time; + typedef period > a_period; + + /*** check all functions - normal periods ***/ + + a_period p1(1, duration_type(9)); + check("Different constructors", p1 == a_period(1, 10)); + check("First", p1.begin() == 1); + check("Last", p1.last() == 9); + check("End", p1.end() == 10); + check("Length", p1.length() == 9); + check("is_null (not)", !p1.is_null()); + + a_period p2(5, 30); + check("First", p2.begin() == 5); + check("Last", p2.last() == 29); + check("End", p2.end() == 30); + check("Length", p2.length() == 25); + check("is_null (not)", !p2.is_null()); + + a_period p3(35, 81); + check("Operator ==", p1 == a_period(1,10)); + check("Operator !=", p1 != p2); + check("Operator <", p1 < p3); + check("Operator >", p3 > p2); + + { + a_period p(1,10); + p.shift(5); + check("Shift (right)", p == a_period(6,15)); + p.shift(-15); + check("Shift (left)", p == a_period(-9,0)); + } + + check("Contains rep", p2.contains(20)); + check("Contains rep (not)", !p2.contains(2)); + check("Contains period", p1.contains(a_period(2,8))); + check("Contains period (not)", !p1.contains(p3)); + + check("Intersects", p1.intersects(p2)); + check("Intersects", p2.intersects(p1)); + + check("Adjacent", p1.is_adjacent(a_period(-5,1))); + check("Adjacent", p1.is_adjacent(a_period(10,20))); + check("Adjacent (not)", !p1.is_adjacent(p3)); + + check("Is before", p1.is_before(15)); + check("Is after", p3.is_after(15)); + + check("Intersection", (p1.intersection(p2) == a_period(5,10))); + check("Intersection", (p1.intersection(p3).is_null())); + + check("Merge", p1.merge(p2) == a_period(1,30) ); + check("Merge", p1.merge(p3).is_null()); + + check("Span", p3.span(p1) == a_period(1, 81)); + + /*** zero length period ***/ + + // treat a zero length period as a point + a_period zero_len(3,duration_type(0)); + check("Same beg & end == zero_length", + a_period(1,1) == a_period(1, duration_type(0))); + check("2 point (zero length) == 1 point zero duration", + a_period(3,3) == zero_len); + + // zero_length period always returns false for is_before & is_after + check("Is Before zero period", !zero_len.is_before(5)); + check("Is After zero period (not)", !zero_len.is_after(5)); + check("Is Before zero period (not)", !zero_len.is_before(-5)); + check("Is After zero period", !zero_len.is_after(-5)); + + check("is_null", zero_len.is_null()); + check("Contains rep (not)", !zero_len.contains(20)); + // a null_period cannot contain any points + check("Contains rep", !zero_len.contains(3)); + check("Contains period (not)", !zero_len.contains(a_period(5,8))); + check("Contains period", p1.contains(zero_len)); + check("Intersects", zero_len.intersects(p1)); + check("Intersects", p1.intersects(zero_len)); + check("Adjacent", zero_len.is_adjacent(a_period(-10,3))); + check("Adjacent", a_period(-10,3).is_adjacent(zero_len)); + check("Intersection", (zero_len.intersection(p1) == zero_len)); + check("Span", zero_len.span(p2) == a_period(3,30)); + + /*** invalid period ***/ + + a_period null_per(5,1); + + check("Is Before invalid period (always false)", !null_per.is_before(7)); + check("Is After invalid period (always false)", !null_per.is_after(7)); + check("Is Before invalid period (always false)", !null_per.is_before(-5)); + check("Is After invalid period (always false)", !null_per.is_after(-5)); + + check("is_null", null_per.is_null()); + check("Contains rep larger (always false)", !null_per.contains(20)); + check("Contains rep in-between (always false)", !null_per.contains(3)); + check("Contains period (not)", !null_per.contains(a_period(7,9))); + check("Contains period", p1.contains(null_per)); + check("Intersects", null_per.intersects(p1)); + check("Intersects", p1.intersects(null_per)); + check("Adjacent", null_per.is_adjacent(a_period(-10,5))); + check("Adjacent", null_per.is_adjacent(a_period(1,10))); + + // what should this next one do? + //check("Intersection", (null_per.intersection(p1) == zero_len)); + check("Span", null_per.span(p3) == a_period(5,81)); + + { + std::cout << std::endl; + a_period p1x(0, -2); + check("First", p1x.begin() == 0); + check("Last", p1x.last() == -3); + check("End", p1x.end() == -2); + check("Length", p1x.length() == -2); + check("is_null", p1x.is_null()); + } + { + std::cout << std::endl; + a_period p1x(0, -1); + check("First", p1x.begin() == 0); + check("Last", p1x.last() == -2); + check("End", p1x.end() == -1); + check("Length", p1x.length() == -1); + check("is_null", p1x.is_null()); + } + { + std::cout << std::endl; + a_period p1x(0, 0); + check("First", p1x.begin() == 0); + check("Last", p1x.last() == -1); + check("End", p1x.end() == 0); + check("Length", p1x.length() == 0); + check("is_null", p1x.is_null()); + } + { + std::cout << std::endl; + a_period p1x(0, 1); + check("First", p1x.begin() == 0); + check("Last", p1x.last() == 0); + check("End", p1x.end() == 1); + check("Length", p1x.length() == 1); + check("is_null", !p1x.is_null()); + } + { + std::cout << std::endl; + a_period p1x(0, 2); + check("First", p1x.begin() == 0); + check("Last", p1x.last() == 1); + check("End", p1x.end() == 2); + check("Length", p1x.length() == 2); + check("is_null", !p1x.is_null()); + } + { + std::cout << std::endl; + a_period p1x(0, duration_type(-1)); + check("First", p1x.begin() == 0); + check("Last", p1x.last() == -2); + check("End", p1x.end() == -1); + check("Length", p1x.length() == -1); + check("is_null", p1x.is_null()); + } + { + std::cout << std::endl; + a_period p1x(0, duration_type(-2)); + check("First", p1x.begin() == 0); + check("Last", p1x.last() == -3); + check("End", p1x.end() == -2); + check("Length", p1x.length() == -2); + check("is_null", p1x.is_null()); + } + { + std::cout << std::endl; + a_period p1x(0, duration_type(0)); + check("First", p1x.begin() == 0); + check("Last", p1x.last() == -1); + check("End", p1x.end() == 0); + check("Length", p1x.length() == 0); + check("is_null", p1x.is_null()); + } + { + std::cout << std::endl; + a_period p1x(0, duration_type(1)); + check("First", p1x.begin() == 0); + check("Last", p1x.last() == 0); + check("End", p1x.end() == 1); + check("Length", p1x.length() == 1); + check("is_null", !p1x.is_null()); + } + { + std::cout << std::endl; + a_period p1x(0, duration_type(2)); + check("First", p1x.begin() == 0); + check("Last", p1x.last() == 1); + check("End", p1x.end() == 2); + check("Length", p1x.length() == 2); + check("is_null", !p1x.is_null()); + } + { + std::cout << std::endl; + a_period p1x(1,1); // length should be 0 + a_period p2x(1,2); // length should be 1 + a_period p3x(1,3); // length should be 2 + check("Length p1", p1x.length() == 0); + check("Length p2", p2x.length() == 1); + check("Length p3", p3x.length() == 2); + check("is_null p1 (not)", p1x.is_null()); + check("is_null p2 (not)", !p2x.is_null()); + } + + { + a_period p1x(1,2); // length should be 1 + p1x.shift(duration_type(1)); + a_period p2x(2,3); // shifted result + check("shift", p1x == p2x); + } + { + a_period p1x(5,duration_type(3)); + a_period p2x(3,10); // expanded result + p1x.expand(duration_type(2)); //from 2000-Jan-01--2000-Jan-04 + check("expand", p1x == p2x); + } + return printTestStats(); +} diff --git a/src/boost/libs/date_time/test/testgregorian_calendar.cpp b/src/boost/libs/date_time/test/testgregorian_calendar.cpp new file mode 100644 index 000000000..c0fedac09 --- /dev/null +++ b/src/boost/libs/date_time/test/testgregorian_calendar.cpp @@ -0,0 +1,253 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/gregorian_calendar.hpp" +#include "boost/date_time/year_month_day.hpp" +#include "testfrmwk.hpp" +#include + +int +main() +{ + typedef boost::date_time::year_month_day_base simple_ymd_type; + + typedef boost::date_time::gregorian_calendar_base + gregorian_calendar; + + // using namespace boost::gregorian; + check("Day of week 2000-09-24 == 0 (Sun)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,24))==0); + check("Day of week 2000-09-25 == 1 (Mon)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,25))==1); + check("Day of week 2000-09-26 == 2 (Tue)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,26))==2); + check("Day of week 2000-09-27 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,27))==3); + check("Day of week 2000-09-28 == 4 (Thu)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,28))==4); + check("Day of week 2000-09-29 == 5 (Fri)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,29))==5); + check("Day of week 2000-09-30 == 6 (Sat)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2000,9,30))==6); + //see calendar FAQ 2.2 for reference + check("Day of week 1953-08-02 == 0 (Sun)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,2))==0); + check("Day of week 1953-08-03 == 1 (Mon)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,3))==1); + check("Day of week 1953-08-04 == 2 (Tue)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,4))==2); + check("Day of week 1953-08-05 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,5))==3); + check("Day of week 1953-08-06 == 4 (Thu)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,6))==4); + check("Day of week 1953-08-07 == 5 (Fri)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,7))==5); + check("Day of week 1953-08-08 == 6 (Sat)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1953,8,8))==6); + check("Day of week 2001-08-31 == 5 (Fri)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2001,8,31))==5); + + //Checked against Caledrical Calc M. Edition p 396 and www site + check("Day of week 1400-01-01 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1400,1,1))==3); + check("Day of week 1436-02-03 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1436,2,3))==3); + check("Day of week 1492-04-9 == 6 (Sat)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1492,4,9))==6); + check("Day of week 1560-03-5 == 6 (Sat)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1560,3,5))==6); + check("Day of week 1716-07-24 == 5 (Fri)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1716,7,24))==5); + check("Day of week 1768-06-19 == 0 (Sun)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1768,6,19))==0); + check("Day of week 1839-03-27 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1839,3,27))==3); + check("Day of week 1819-08-02 == 1 (Mon)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1819,8,2))==1); + check("Day of week 1903-04-19 == 0 (Sun)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1903,4,19))==0); + check("Day of week 1929-08-25 == 0 (Sun)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(1929,8,25))==0); + check("Day of week 2038-11-10 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2038,11,10))==3); + check("Day of week 2094-07-18 == 0 (Sun)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(2094,7,18))==0); + //verified against website applet + check("Day of week 3002-07-10 == 6 (Sat)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(3002,7,10))==6); + //verified against website applet + check("Day of week 4002-07-10 == 3 (Wed)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(4002,7,10))==3); + //verified against website applet + check("Day of week 5002-07-10 == 6 (Sat)", + gregorian_calendar::day_of_week(gregorian_calendar::ymd_type(5002,7,10))==6); + + check("1404 is a leap year", gregorian_calendar::is_leap_year(1404)); + check("2000 is a leap year", gregorian_calendar::is_leap_year(2000)); + check("2004 is a leap year", gregorian_calendar::is_leap_year(2004)); + check("2400 is a leap year", gregorian_calendar::is_leap_year(2400)); + check("4000 is a leap year", gregorian_calendar::is_leap_year(4000)); + check("1400 is NOT a leap year", !gregorian_calendar::is_leap_year(1400)); + check("1900 is NOT a leap year", !gregorian_calendar::is_leap_year(1900)); + check("2100 is NOT a leap year", !gregorian_calendar::is_leap_year(2100)); + check("1999 is NOT a leap year", !gregorian_calendar::is_leap_year(1999)); + check("5000 is NOT a leap year", !gregorian_calendar::is_leap_year(5000)); + + int weeknum1 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(2004,10,18)); + check("ToWeekNumber 2004-10-18 is week 43", weeknum1 == 43); + + int weeknum2 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(2002,1,1)); + check("ToWeekNumber 2002-1-1 is week 1", weeknum2 == 1); + + int weeknum3 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(2000,12,31)); + check("ToWeekNumber 2000-12-31 is week 52", weeknum3 == 52); + + //check for week when week==0. + int weeknum4 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(2000,1,1)); + check("ToWeekNumber 2000-1-1 is week 52", weeknum4 == 52); + + //check for week when week==53 and day==6. + int weeknum5 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(1998,12,31)); + check("ToWeekNumber 1998-12-31 is week 53", weeknum5 == 53); + + //check for week when week==53 day==5 and the year is a leap year. + int weeknum6 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(1992,12,31)); + check("ToWeekNumber 1992-12-31 is week 53", weeknum6 == 53); + + //check for week when week==53 1993-Jan-1 + int weeknum7 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(1993,1,1)); + check("ToWeekNumber 1993-1-1 is week 53", weeknum7 == 53); + + //check for week when week==53 1993-Jan-2 + int weeknum8 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(1993,1,2)); + check("ToWeekNumber 1993-Jan-2 is week 53", weeknum8 == 53); + + //check for week when week==53 1993-Jan-3 + int weeknum9 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(1993,1,3)); + check("ToWeekNumber 1993-Jan-3 is week 53", weeknum9 == 53); + + //check for week when week==1 1993-Jan-4 + int weeknum10 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(1993,1,4)); + check("ToWeekNumber 1993-Jan-4 is week 1", weeknum10 == 1); + + //check for week when week=53 and day != 6 and != 5. + int weeknum11 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(2001,12,31)); + check("ToWeekNumber 2001-12-31 is week 1", weeknum11 == 1); + + //test the boundaries of week_number + int weeknum12 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(1400,1,1)); + check("ToWeekNumber 1400-1-1 is week 1", weeknum12 == 1); + + int weeknum13 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(9999,12,31)); + check("ToWeekNumber 9999-12-31 is week 52", weeknum13 == 52); + + int weeknum14 = gregorian_calendar::week_number(gregorian_calendar::ymd_type(2003,12,29)); + check("ToWeekNumber 2003-12-29 is week 1", weeknum14 == 1); + + + unsigned long jday1 = gregorian_calendar::day_number(gregorian_calendar::ymd_type(2000,1,1)); + unsigned long jday2 = gregorian_calendar::day_number(gregorian_calendar::ymd_type(2001,1,1)); +// unsigned short year, month, day; +// //2451545 is 2000-1-1 + check("ToDayNumber 2000-1-1 is day 2451545", jday1 == 2451545); + check("ToDayNumber 2001-1-1 is day 2451911", jday2 == 2451911); + gregorian_calendar::ymd_type ymd = gregorian_calendar::from_day_number(jday1); + check("from_day_number test 2000-1-1", (ymd.year==2000)&& + (ymd.month==1) && + (ymd.day==1) ); + + unsigned long julianday1 = gregorian_calendar::julian_day_number(gregorian_calendar::ymd_type(2000,12,31)); + check("ToJulianDayNumber 2000-12-31 is day 2451910", julianday1 == 2451910); + gregorian_calendar::ymd_type ymd1 = gregorian_calendar::from_julian_day_number(julianday1); + std::cout << ymd1.year << "-" << ymd1.month << "-" << ymd1.day << std::endl; + check("from_julian_day_number test 2000-12-31", (ymd1.year==2000) && + (ymd1.month==12) && + (ymd1.day==31) ); + unsigned long julianday2 = gregorian_calendar::modjulian_day_number(gregorian_calendar::ymd_type(2000,12,31)); + std::cout << julianday2 << std::endl; + check("TomodJulianDayNumber 2000-12-31 is day 51909", julianday2 == 51909); + gregorian_calendar::ymd_type ymd2 = gregorian_calendar::from_modjulian_day_number(julianday2); + check("from_modjulian_day_number test 2000-12-31", (ymd2.year==2000) && + (ymd2.month==12) && + (ymd2.day==31) ); + unsigned long julianday3 = gregorian_calendar::julian_day_number(gregorian_calendar::ymd_type(1400,1,1)); + check("ToJulianDayNumber 1400-1-1 is day 2232400", julianday3 == 2232400); + gregorian_calendar::ymd_type ymd3 = gregorian_calendar::from_julian_day_number(julianday3); + check("from_julian_day_number test 1400-1-1", (ymd3.year==1400) && + (ymd3.month==1) && + (ymd3.day==1) ); + long mjd3 = gregorian_calendar::modjulian_day_number(gregorian_calendar::ymd_type(1400,1,1)); + std::cout << "mjd3: " << mjd3 << std::endl; + check("mod julian day 1400-1-1 is day -167601", mjd3 == -167601); + gregorian_calendar::ymd_type mjd_ymd3 = gregorian_calendar::from_modjulian_day_number(mjd3); + check("from_julian_day_number test 1400-1-1", (mjd_ymd3.year==1400) && + (mjd_ymd3.month==1) && + (mjd_ymd3.day==1) ); + + + unsigned long julianday4 = gregorian_calendar::julian_day_number(gregorian_calendar::ymd_type(1900,2,28)); + check("ToJulianDayNumber 1900-2-28 is day 2415079", julianday4 == 2415079); + gregorian_calendar::ymd_type ymd4 = gregorian_calendar::from_julian_day_number(julianday4); + check("from_julian_day_number test 1900-2-28", (ymd4.year==1900) && + (ymd4.month==2) && + (ymd4.day==28) ); + + unsigned long julianday5 = gregorian_calendar::julian_day_number(gregorian_calendar::ymd_type(1436,2,3)); + check("ToJulianDayNumber 1436-2-3 is day 2245581", julianday5 == 2245581); + gregorian_calendar::ymd_type ymd5 = gregorian_calendar::from_julian_day_number(julianday5); + check("from_julian_day_number test 1436-2-3", (ymd5.year==1436) && + (ymd5.month==2) && + (ymd5.day==3) ); + + unsigned long julianday6 = gregorian_calendar::julian_day_number(gregorian_calendar::ymd_type(1996,2,25)); + check("ToJulianDayNumber 1996-2-25 is day 2450139", julianday6 == 2450139); + gregorian_calendar::ymd_type ymd6 = gregorian_calendar::from_julian_day_number(julianday6); + check("from_julian_day_number test 1996-2-25", (ymd6.year==1996) && + (ymd6.month==2) && + (ymd6.day==25) ); + long mjd6 = gregorian_calendar::modjulian_day_number(gregorian_calendar::ymd_type(1996,2,25)); + check("ToJulianDayNumber 1996-2-25 is day 50138", mjd6 == 50138); + gregorian_calendar::ymd_type mjd_ymd6 = gregorian_calendar::from_modjulian_day_number(mjd6); + check("from_julian_day_number test 1996-2-25", (mjd_ymd6.year==1996) && + (mjd_ymd6.month==2) && + (mjd_ymd6.day==25) ); + + + unsigned long jday3 = gregorian_calendar::day_number(gregorian_calendar::ymd_type(1999,1,1)); + check("366 days between 2000-1-1 and 2001-1-1", (jday2-jday1) == 366); + check("731 days between 1999-1-1 and 2001-1-1 ",(jday2-jday3) == 731); + + unsigned long jday4 = gregorian_calendar::day_number(gregorian_calendar::ymd_type(2000,2,28)); + unsigned long jday5 = gregorian_calendar::day_number(gregorian_calendar::ymd_type(2000,3,1)); + check("2 days between 2000-2-28 and 2000-3-1 ",(jday5-jday4) == 2); + + check("31 days in month Jan 2000", gregorian_calendar::end_of_month_day(2000,1) == 31); + check("29 days in month Feb 2000", gregorian_calendar::end_of_month_day(2000,2) == 29); + check("28 days in month Feb 1999", gregorian_calendar::end_of_month_day(1999,2) == 28); + check("28 days in month Feb 2001", gregorian_calendar::end_of_month_day(2001,2) == 28); + check("31 days in month Mar 2000", gregorian_calendar::end_of_month_day(2000,3) == 31); + check("30 days in month Apr 2000", gregorian_calendar::end_of_month_day(2000,4) == 30); + check("31 days in month May 2000", gregorian_calendar::end_of_month_day(2000,5) == 31); + check("30 days in month Jun 2000", gregorian_calendar::end_of_month_day(2000,6) == 30); + check("31 days in month Jul 2000", gregorian_calendar::end_of_month_day(2000,7) == 31); + check("31 days in month Aug 2000", gregorian_calendar::end_of_month_day(2000,8) == 31); + check("30 days in month Sep 2000", gregorian_calendar::end_of_month_day(2000,9) == 30); + check("31 days in month Oct 2000", gregorian_calendar::end_of_month_day(2000,10) == 31); + check("30 days in month Nov 2000", gregorian_calendar::end_of_month_day(2000,11) == 30); + check("31 days in month Dec 2000", gregorian_calendar::end_of_month_day(2000,12) == 31); + + + std::cout << gregorian_calendar::epoch().year << std::endl; + + + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/testint64_range.cpp b/src/boost/libs/date_time/test/testint64_range.cpp new file mode 100644 index 000000000..fe4266348 --- /dev/null +++ b/src/boost/libs/date_time/test/testint64_range.cpp @@ -0,0 +1,95 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +//#include "date_time/testfrmwk.hpp" +#include +#include "boost/date_time/gregorian/gregorian.hpp" +#include "boost/cstdint.hpp" + +int +main() +{ +#if (defined(BOOST_MSVC) && (_MSC_VER < 1300)) + //skipping tests here due to lack of operator<< support in msvc6 + // TODO: this is a bit misleading: using STLport, this should work. + std::cout << "Skipping tests on MSVC6" << std::endl; + +#else + + std::cout << "int64_t max: " + << (std::numeric_limits::max)() + << std::endl; + std::cout << "uint64_t max: " + << (std::numeric_limits::max)() + << std::endl; + + + boost::int64_t seconds_per_day = 60*60*24; + boost::int64_t microsec_per_sec = 1000000; + boost::int64_t microsec_per_day = seconds_per_day*microsec_per_sec; + std::cout << "microsec per day: " + << microsec_per_day + << std::endl; + + boost::uint64_t total_days = (std::numeric_limits::max)() / microsec_per_day; + + std::cout << "Representable days: " + << total_days + << std::endl; + + boost::int64_t approx_years = total_days / 366; + + std::cout << "Approximate years: " + << approx_years + << std::endl; + + //getting day count + // usec_count / (seconds_per_day*usec_per_sec); + boost::int64_t day_count = 1000; + boost::int64_t usec_count1000 = day_count*microsec_per_day + 999999; + std::cout << "usec count at day 1000 + 999999: " + << usec_count1000 + << std::endl; + + boost::int64_t day_count_calc = usec_count1000 / microsec_per_day; + std::cout << "calc day count at day 1000: " + << day_count_calc + << std::endl; + + boost::int64_t remaining_usec_count = usec_count1000 % microsec_per_day; + std::cout << "remaining usec count: " + << remaining_usec_count + << std::endl; + + boost::int32_t day_count3M = 3000000; + boost::int64_t usec_count3M = day_count3M*microsec_per_day + 999999; + std::cout << "usec count at day 3M + 999999: " + << usec_count3M + << std::endl; + + boost::int64_t day_count_calc3M = usec_count3M / microsec_per_day; + std::cout << "calc day count at day 3M: " + << day_count_calc3M + << std::endl; + + boost::int64_t remaining_usec_count3M = usec_count3M % microsec_per_day; + std::cout << "remaining usec count 3M: " + << remaining_usec_count3M + << std::endl; + +#endif + +// std::cout << "Days from: " +// << to_simple_string(d1) << " to " +// << to_simple_string(d2) << " = " +// << day_count << std::endl; + + + // printTestStats(); + return 0; +}; + diff --git a/src/boost/libs/date_time/test/testint_adapter.cpp b/src/boost/libs/date_time/test/testint_adapter.cpp new file mode 100644 index 000000000..b5657f6a7 --- /dev/null +++ b/src/boost/libs/date_time/test/testint_adapter.cpp @@ -0,0 +1,158 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/int_adapter.hpp" +#include "testfrmwk.hpp" +#include "boost/cstdint.hpp" +#include +#include + +template +void print() +{ + //MSVC 6 has problems with this, but it's not really important + //so we will just skip them.... +#if (defined(BOOST_DATE_TIME_NO_LOCALE)) || (defined(BOOST_MSVC) && (_MSC_VER < 1300)) + +#else + std::cout << "min: " << (int_type::min)().as_number() << std::endl; + std::cout << "max: " << (int_type::max)().as_number() << std::endl; + std::cout << "neg_infin: " << + int_type::neg_infinity().as_number() << std::endl; + std::cout << "pos_infin: " << + int_type::pos_infinity().as_number() << std::endl; + std::cout << "not a number: " << + int_type::not_a_number().as_number() << std::endl; + std::stringstream ss(""); + std::string s(""); + int_type i = int_type::neg_infinity(); + ss << i; + s = "-infinity"; + check("streaming -infinity", ss.str() == s); + + i = int_type::pos_infinity(); + ss.str(""); + ss << i; + s = "+infinity"; + check("streaming +infinity", ss.str() == s); + + i = int_type::not_a_number(); + ss.str(""); + ss << i; + s = "not-a-number"; + check("streaming nan", ss.str() == s); + + i = 12; + ss.str(""); + ss << i; + s = "12"; + check("streaming digits", ss.str() == s); +#endif +} + + +template +void test_int() +{ + int_type i = int_type::neg_infinity(); + + check("is infinity", i.is_infinity()); + check("is special_value (neg_inf)", i.is_special()); + check("as_special convert", boost::date_time::neg_infin == i.as_special() ); + check("as_special convert", boost::date_time::neg_infin == int_type::to_special(i.as_number()) ); + int_type h = int_type::neg_infinity(); + i = int_type::pos_infinity(); + check("is infinity", i.is_infinity()); + check("as_special convert", boost::date_time::pos_infin == i.as_special() ); + check("infinity less", h < i); + check("infinity less", h < 0); + check("infinity greater", i > h); + check("infinity greater", i > 0); + h = int_type::not_a_number(); + check("nan less", !(h < 0)); + check("nan greater", !(h > 0)); + check("nan equal", h == int_type::not_a_number()); + i = 1; + check("is infinity", !i.is_infinity()); + int_type j = int_type::neg_infinity(); + check("infinity less", j < i); + check("infinity less", !(j < j)); + check("infinity greater", (i > j)); + check("infinity equal", !(j == i)); + check("infinity equal", j == j); + check("infinity equal", !(j == 0)); + check("infinity not equal", j != 0); + + int_type k = 1; + check("as_special convert", boost::date_time::not_special == k.as_special() ); + check("equal", i == k); + check("infinity not equal", i != int_type::neg_infinity()); + check("infinity not equal", i != int_type::pos_infinity()); + int_type l = i + int_type::pos_infinity(); + check("is special_value (pos_inf)", l.is_special()); + check("add infinity" , l == int_type::pos_infinity()); + { // limiting the scope for these tests was easier than recalculating l + int_type m = i - int_type::pos_infinity(); + check("value - +infinity", m == int_type::neg_infinity()); + m = i + int_type::neg_infinity(); + check("value + -infinity", m == int_type::neg_infinity()); + } + check("inf - inf = nan", (l - l) == int_type::not_a_number()); + check("-inf + inf = nan", (j + l) == int_type::not_a_number()); + check("add 2", (i + 2) == 3); + i = int_type::not_a_number(); + check("+inf * integer", (l * 2) == l); + check("+inf / integer", (l / 2) == l); + check("+inf % -integer", (l % -2) == j); + check("+inf % integer", (l % 2) == l); + check("+inf / -integer", (l / -2) == j); + check("+inf * -integer", (l * -2) == j); + check("+inf * -inf", (l * j) == j); + check("+inf / +inf", (l / l) == i); + check("+inf % +inf", (l % l) == i); + check("+inf * zero", (l * 0) == i); + check("is special_value (nan)", i.is_special()); + check("as_special convert", boost::date_time::not_a_date_time == i.as_special() ); + check("add not a number", (i + 2) == int_type::not_a_number()); + check("sub not a number", (i - 2) == int_type::not_a_number()); + check("sub from infin", (l - 2) == int_type::pos_infinity()); + i = 5; + h = 3; + check("add zero ", (i + 0) == 5); + check("sub from 5-2 ", (i - 2) == 3); + check("remainder from 5/2 ", (i % 2) == 1); + check("remainder from 5/3 ", (i % h) == 2); + // std::cout << i.as_number() << std::endl; + check("from special ", + int_type::from_special(boost::date_time::pos_infin) == int_type::pos_infinity()); + check("from special ", + int_type::from_special(boost::date_time::neg_infin) == int_type::neg_infinity()); + check("from special ", + int_type::from_special(boost::date_time::not_a_date_time) == int_type::not_a_number()); + check("from special ", + int_type::from_special(boost::date_time::min_date_time) == (int_type::min)()); + check("from special ", + int_type::from_special(boost::date_time::max_date_time) == (int_type::max)()); +} + +int +main() +{ + using namespace boost::date_time; + + print< int_adapter >(); + test_int< int_adapter >(); + print< int_adapter >(); + test_int< int_adapter >(); + print< int_adapter >(); + test_int< int_adapter >(); + + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/testmisc.cpp b/src/boost/libs/date_time/test/testmisc.cpp new file mode 100644 index 000000000..e648ea8ec --- /dev/null +++ b/src/boost/libs/date_time/test/testmisc.cpp @@ -0,0 +1,59 @@ +/* Copyright (c) 2020 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/wrapping_int.hpp" + +//#include +#include "boost/date_time/posix_time/posix_time_duration.hpp" + +#include "testfrmwk.hpp" +#include + +using std::cout; +using std::endl; + +int +main() +{ + using namespace boost::date_time; + using namespace boost::posix_time; + +#ifdef BOOST_NO_CXX14_CONSTEXPR + check("constexpr not configured", true); +#else + constexpr wrapping_int wi(3599); + static_assert(wi == 3599, "constexpr construction/conversion"); + check("constexpr wrapping construct and equal", true); + + constexpr microseconds ms(1000); + static_assert(ms.is_special() == false, "constexpr duration is_special"); + static_assert(ms.is_positive() == true, "constexpr duration is_positive"); + static_assert(ms.is_negative() == false, "constexpr duration is_negative"); + static_assert(ms.total_microseconds() == 1000, "constexpr total_microseconds"); + check("constexpr microseconds - total_microseconds", true); + +#endif + +#ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG + cout << "Standard Config" << endl; +#else + cout << "NOT Standard Config" << endl; +#endif + +#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS + cout << "Has NANO: " << endl; +#else + cout << "NO NANO: " << endl; +#endif + + check("success", true); + + return printTestStats(); + +} + + diff --git a/src/boost/libs/date_time/test/testtime_resolution_traits.cpp b/src/boost/libs/date_time/test/testtime_resolution_traits.cpp new file mode 100644 index 000000000..20d0ae3e7 --- /dev/null +++ b/src/boost/libs/date_time/test/testtime_resolution_traits.cpp @@ -0,0 +1,72 @@ +/* Copyright (c) 2002,2003 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland + */ + +#include "boost/date_time/time_resolution_traits.hpp" +#include "testfrmwk.hpp" + + +int +main() +{ + using namespace boost::date_time; + check("milli traits num digits", milli_res::num_fractional_digits() == 3); + check("milli traits resolution adjust", + milli_res::res_adjust() == 1000); + check("milli tick calculations", + milli_res::to_tick_count(0,0,0,1) == 1); + check("milli tick calculations", + milli_res::to_tick_count(0,0,1,1) == 1001); + check("milli tick calculations", + milli_res::to_tick_count(0,1,0,0) == 60000); + boost::int64_t one_hour_milli = 3600*1000; + check("milli tick calculations", + milli_res::to_tick_count(1,0,0,0) == one_hour_milli); + + check("micro traits num digits", micro_res::num_fractional_digits() == 6); + check("micro traits resolution adjust", + micro_res::res_adjust() == 1000000); + check("micro tick calculations", + micro_res::to_tick_count(0,0,0,1) == 1); + check("micro tick calculations", + micro_res::to_tick_count(0,0,1,1) == 1000001); + check("micro tick calculations", + micro_res::to_tick_count(0,1,0,0) == 60000000); + boost::int64_t one_hour_micro = 3600*1000; + one_hour_micro = one_hour_micro*1000; //avoid compiler overflow! + check("micro tick calculations", + micro_res::to_tick_count(1,0,0,0) == one_hour_micro); + + check("nano traits num digits", nano_res::num_fractional_digits() == 9); + check("nano traits resolution adjust", + nano_res::res_adjust() == 1000000000); + check("nano tick calculations", + nano_res::to_tick_count(0,0,0,1) == 1); + check("nano tick calculations", + nano_res::to_tick_count(0,0,1,1) == 1000000001); + boost::int64_t one_minute_nano = 60*1000*1000; + one_minute_nano = one_minute_nano*1000; + check("nano tick calculations", + nano_res::to_tick_count(0,1,0,0) == one_minute_nano); + + //skip io on VC6 b/c of lack of operator<< for int64 +#if (defined(BOOST_MSVC) && (_MSC_VER < 1300)) +#else + std::cout << one_hour_micro << std::endl; +#endif + boost::int64_t one_hour_nano = one_hour_micro*1000; +#if (defined(BOOST_MSVC) && (_MSC_VER < 1300)) +#else + std::cout << one_hour_nano << std::endl; +#endif + check("nano tick calculations", + nano_res::to_tick_count(1,0,0,0) == one_hour_nano); + + + return printTestStats(); + +} + diff --git a/src/boost/libs/date_time/test/testwrapping_int.cpp b/src/boost/libs/date_time/test/testwrapping_int.cpp new file mode 100644 index 000000000..b33a9d256 --- /dev/null +++ b/src/boost/libs/date_time/test/testwrapping_int.cpp @@ -0,0 +1,138 @@ +/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc. + * Use, modification and distribution is 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) + * Author: Jeff Garland, Bart Garst + */ + +#include "boost/date_time/wrapping_int.hpp" +//#define BOOST_INCLUDE_MAIN +//#include +#include "testfrmwk.hpp" +#include "boost/cstdint.hpp" +#include + + +int +main() +// int +// test_main(int, char*[]) +{ + using namespace boost::date_time; + + wrapping_int wi(3599); + check("construction/conversion", wi == 3599); + check("add with wrap", wi.add(1) == 1); + check("added value ok", wi == 0); + check("add with 2 wraps", wi.add(7201) == 2); + check("added value ok", wi == 1); + check("add with 3 wraps", wi.add(10800) == 3); + check("added value ok", wi == 1); + check("subtract no wrap", wi.subtract(1) == 0); + check("subtract val ok", wi == 0); + check("subtract no wrap", wi.subtract(3601) == 2); + check("subtract val ok", wi == 3599); + check("add again", (wi.add(2) == 1) && (wi == 1)); + check("subtract again", (wi.subtract(2) == 1) && (wi == 3599)); + check("add again", (wi.add(2) == 1) && (wi == 1)); + check("subtract again", (wi.subtract(3600) == 1) && (wi == 1)); + check("subtract again", (wi.subtract(3599) == 1) && (wi == 2)); + check("subtract again", (wi.subtract(1) == 0) && (wi == 1)); + std::cout << wi << std::endl; + + wrapping_int wi2(0); + check("add with wrap - return", wi2.add(121) == 2); + check("add with wrap - value", wi2 == 1); + + wrapping_int wi3(-5); + check("signed int - add return", wi3.add(5) == 0); + check("signed int - value", wi3 == 0); + + { // subtracting negative values + wrapping_int wi4(5); + check("subtract negative value to cause wrap", + (wi4.subtract(-8) == -1 && wi4 == 3)); + check("reset", wi4.add(2) == 0 && wi4 ==5); + check("add negative value to cause wrap", + (wi4.add(-8) == -1 && wi4 == 7)); + } + + wrapping_int2 wi4(1); + check("construct", wi4 == 1); + check("add up to wrap value", (wi4.add(4) == 0 && wi4 == 5)); + check("add over the wrap value", (wi4.add(1) == 1 && wi4 == 1)); + check("add over the wrap value X 2", (wi4.add(10) == 2 && wi4 == 1)); + check("add over the wrap value X 3", (wi4.add(15) == 3 && wi4 == 1)); + + wrapping_int2 wi5(12); + check("construct", wi5 == 12); + check("add over the wrap value", (wi5.add(1) == 1 && wi5 == 1)); + + check("subtract of the wrap value", (wi5.subtract(1) == -1 && wi5 == 12)); + check("subtract of the wrap value", (wi5.subtract(13) == -1 && wi5 == 11)); + + // min_values other than 1 + wrapping_int2 wi6(2); + check("construct", wi6 == 2); + check("add up to wrap value", (wi6.add(4) == 0 && wi6 == 6)); + check("add over the wrap value", (wi6.add(1) == 1 && wi6 == 2)); + check("add over the wrap value X 2", wi6.add(11) == 2); + check("add over the wrap value X 2", wi6 == 3); + check("sub down to wrap value", wi6.subtract(1) == 0 && wi6 == 2); + check("sub under the wrap value", wi6.subtract(1) == -1 && wi6 == 6); + check("sub under the wrap value X 2", wi6.subtract(11) == -2 && wi6 == 5); + //std::cout << wi6 << std::endl; + + // adding & subtracting negative values + wrapping_int2 wi7(6); + wrapping_int2 wi8(0); + check("add negative value", (wi7.add(-2) == 0 && wi7 == 4)); + check("add negative value", (wi8.add(-2) == 0 && wi8 == -2)); + check("add negative value to cause single wrap", + (wi7.add(-6) == -1 && wi7 == 10)); + check("add negative value to cause single wrap", + (wi8.add(-5) == -1 && wi8 == 4)); + check("add negative value to cause multiple wrap", + (wi7.add(-22) == -2 && wi7 == 12)); + check("add negative value to cause multiple wrap", + (wi8.add(-22) == -2 && wi8 == 4)); + // reset values to mid range + wi7.subtract(6); + check("reset", wi7 == 6); + wi8.subtract(4); + check("reset", wi8 == 0); + check("subtract negative value", (wi7.subtract(-2) == 0 && wi7 == 8)); + check("subtract negative value", (wi8.subtract(-2) == 0 && wi8 == 2)); + check("subtract negative value to cause single wrap", + (wi7.subtract(-6) == 1 && wi7 == 2)); + check("subtract negative value to cause single wrap", + (wi8.subtract(-5) == 1 && wi8 == -4)); + check("subtract negative value to cause multiple wrap", + (wi7.subtract(-23) == 2 && wi7 == 1)); + check("subtract negative value to cause multiple wrap", + (wi8.subtract(-22) == 2 && wi8 == -4)); + +// #ifdef BOOST_HAS_LONG_LONG +// wrapping_int wi4(0); +// check("construction/conversion", wi4 == 0); +// boost::int64_t off2 = 372300000; +// boost::int64_t wrap = 86400LL*100000LL; +// boost::int64_t wrap2 = 86400000000; +// wrapping_int wi5((3600*1 + 60*2 + 3)*100000); +// std::cout << wi5 << std::endl; +// boost::int64_t over = wi4.add(off2); +// std::cout << over << std::endl; +// std::cout << wrap << std::endl; +// std::cout << wrap2 << std::endl; +// // check("construction/conversion", wi4 == 0); +// #endif + +// wrapping_int wi(121); +// check("construction/conversion", wi == 121); +// check("add with wrap", wi.add(1) == 1); + + return printTestStats(); + +} + + diff --git a/src/boost/libs/date_time/xmldoc/Jamfile.v2 b/src/boost/libs/date_time/xmldoc/Jamfile.v2 new file mode 100644 index 000000000..5bfec0b5c --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/Jamfile.v2 @@ -0,0 +1,90 @@ +# Copyright (c) 2002-2006 CrystalClear Software, Inc. +# Use, modification and distribution is 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) +# + +import set ; + +using boostbook ; +using doxygen ; + +boostbook date_time : date_time.xml + : + pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html + date_time_autodoc + gregorian_autodoc + posix_time_autodoc + local_time_autodoc + boost.root=../../../.. + ; + +# boostbook date_time_doc : exclusive_date_time.xml ; + +# file lists take the form of [ set.difference [ glob include/these ] : [ glob but/not/these ] ] + +local date_time_files = [ glob ../../../boost/date_time/*.hpp ] ; + +# local date_time_files = [ set.difference +# [ glob ../../../boost/date_time/*.hpp ] : +# [ glob ../../../boost/date_time/testfrmwk.hpp +# # ../../../boost/date_time/time_zone_base.hpp +# # ../../../boost/date_time/time_zone_names.hpp +# # ../../../boost/date_time/tz_db_base.hpp +# # ../../../boost/date_time/dst_transition_generators.hpp +# ] +# ] ; + +local gregorian_files = [ set.difference + [ glob ../../../boost/date_time/gregorian/*.hpp ] : + [ glob ../../../boost/date_time/gregorian/event_schedule.hpp ] + ] ; + +#ECHO $(date_time_files) ; # useful for debugging + +# to build the autodoc files, run bjam --v2 autodoc_target. copy generated +# file from bin.v2 dir to here. run ref_tag_fix.pl. + +doxygen date_time_autodoc : + $(date_time_files) : + ENABLE_PREPROCESSING=NO + boost.doxygen.reftitle="Date Time Reference" + "Date Time Reference" + "date_time_reference" + ; + +doxygen gregorian_autodoc : + $(gregorian_files) : + ENABLE_PREPROCESSING=NO + boost.doxygen.reftitle="Gregorian Reference" + "Gregorian Reference" + "gregorian_reference" + ; + +doxygen posix_time_autodoc : + [ glob ../../../boost/date_time/posix_time/*.hpp ] : + ENABLE_PREPROCESSING=NO + boost.doxygen.reftitle="Posix Time Reference" + "Posix Time Reference" + "posix_time_reference" + ; + +doxygen local_time_autodoc : + [ glob ../../../boost/date_time/local_time/*.hpp ] : + ENABLE_PREPROCESSING=NO + boost.doxygen.reftitle="Local Time Reference" + "Local Time Reference" + "local_time_reference" + ; + + +# Copyright (c) 2004 +# CrystalClear Software, Inc. +# +# Permission to use, copy, modify, distribute and sell this software +# and its documentation for any purpose is hereby granted without fee, +# provided that the above copyright notice appear in all copies and +# that both that copyright notice and this permission notice appear +# in supporting documentation. CrystalClear Software makes no +# representations about the suitability of this software for any +# purpose. It is provided "as is" without express or implied warranty. diff --git a/src/boost/libs/date_time/xmldoc/README b/src/boost/libs/date_time/xmldoc/README new file mode 100644 index 000000000..145fa97a7 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/README @@ -0,0 +1,38 @@ +I couldn't get the date_time.xml to validate, however, it works anyway. +The build process with fail with adequate error messages to fix +any errors. + +/********************************/ +Do not place a dtd declaration in the doc xml files. +Begin each file with: +
+ +And in subsection/xml: +
+ + ... + + + +/********************************/ +To crosslink use: +optional text + +If you use 'top' the link will automatically +go to the top of the page it ends up in. + +# Copyright (c) 2002-2006 CrystalClear Software, Inc. +# Use, modification and distribution is 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) diff --git a/src/boost/libs/date_time/xmldoc/acknowledgements.xml b/src/boost/libs/date_time/xmldoc/acknowledgements.xml new file mode 100644 index 000000000..36f540164 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/acknowledgements.xml @@ -0,0 +1,16 @@ + + + + + +
+ Acknowledgements + + + Many people have contributed to the development of this library. In particular Hugo Duncan and Joel de Guzman for help with porting to various compilers. For initial development of concepts and design Corwin Joy and Michael Kenniston deserve special thanks. Also extra thanks to Michael for writing up the theory and tradeoffs part of the documentation. Dave Zumbro for initial inspiration and sage thoughts. Many thanks to boost reviewers and users including: William Seymour, Kjell Elster, Beman Dawes, Gary Powell, Andrew Maclean, William Kempf, Peter Dimov, Chris Little, David Moore, Darin Adler, Gennadiy Rozental, Joachim Achtzehnter, Paul Bristow, Jan Langer, Mark Rodgers, Glen Knowles, Matthew Denman, and George Heintzelman. + +
diff --git a/src/boost/libs/date_time/xmldoc/buildinfo.xml b/src/boost/libs/date_time/xmldoc/buildinfo.xml new file mode 100644 index 000000000..3f91a1e2f --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/buildinfo.xml @@ -0,0 +1,153 @@ + + + + + +
+ Build-Compiler Information + + + Overview -- + Compilation Options -- + Compiler/Portability Notes -- + Directory Structure -- + Required Boost Libraries + + + + Overview + + The library has a few functions that require the creation of a library file (mostly to_string, from_string functions). Most library users can make effective use of the library WITHOUT building the library, but simply including the required headers. If the library is needed, the Jamfile in the build directory will produce a "static" library (libboost_date_time) and a "dynamic/shared" library (boost_date_time) that contains these functions. Note that to use the library without the library (particularly on windows) may require using the BOOST_DATE_TIME_NO_LIB flag to the compilation options. + + + + Compilation Options + + By default the posix_time system uses a single 64 bit integer internally to provide a microsecond level resolution. As an alternative, a combination of a 64 bit integer and a 32 bit integer (96 bit resolution) can be used to provide nano-second level resolutions. The default implementation may provide better performance and more compact memory usage for many applications that do not require nano-second resolutions. + + + To use the alternate resolution (96 bit nanosecond) the variable BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG must be defined in the library users project files (ie Makefile, Jamfile, etc). This macro is not used by the Gregorian system and therefore has no effect when building the library. + + As of version 1.33, the date_time library introduced a new IO streaming system. Some compilers are not capable of utilizing this new system. For those compilers the earlier ("legacy") IO system is still available. Non-supported compilers will select the legacy system automatically but the user can force the usage of the legacy system by defining USE_DATE_TIME_PRE_1_33_FACET_IO. + + As a convenience, date_time has provided some additional duration types. Use of these types may have unexpected results due to the snap-to-end-of-month behavior (see Reversibility of Operations Pitfall for complete details and examples). These types are enabled by default. To disable these types, simply undefine BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES in your project file. + + Another convenience is the default constructors for date, and ptime. These constructors are enabled by default. To disable them, simply define DATE_TIME_NO_DEFAULT_CONSTRUCTOR in your project file. + + + Compiler/Portability Notes + + The Boost Date-Time library has been built and tested with many compilers and platforms. However, some compilers and standard libraries have issues. While some of these issues can be worked around, others are difficult to work around. The following compilers are known to fully support all aspects of the library: + + Codewarrior 9.4 Windows + GCC 3.2 - 3.4, 4.x on Linux + GCC 3.3, 4.x on Darwin + GCC 3.3 - 3.4, 4.x on Solaris + GCC 3.3, 4.x on HP-UX + QCC 3.3.5 on QNX + MSVC 7.1 Windows + Intel 8.1-9.x Linux and Windows + + + + + Unfortunately, the VC8 compiler has some issues with date-time code. + The most serious issue is a memory leak which was introduced into the + VC8 standard library basic_stream code. Date-time has code has been changed + to avoid this as much as possible, but if you are using the legacy IO option + (NOT the default with VC8) then the issue can still arise. See the + + mailing list archive for more details. + + + + In addition to the problem above, some versions of the VC8 library have limited + the range of allowed + values in the std::tm structure to positive values. This was a new + restriction added in the VC8. The effect is that dates prior to the year + 1900 will cause exceptions. There is, unfortunately, no easy workaround for + this issue. Note that the new 64bit version of the VC8 compiler + does not appear to have this limitation. + + + + These compilers support all aspects of the library except wstring/wstream + output. + + MinGW 3.2, 3.4, 3.5 * + GCC 3.2 (cygwin) * + + + + + In particular, a lack of support for standard locales limits the ability of the library to support iostream based input output. For these compilers a set of more limited string based input-output is provided. Some compilers/standard libraries with this limitation include: + + Borland 5.6 + + + + + Official support for some older compilers has now been dropped. This includes: + + GCC 2.9x + Borland 5.1.1 + MSVC 7.0 and 6 SP5 + + + + Visual Studio & STLPort + There is a known issue with Visual Studio (7.0 & 7.1) and STLPort. The build errors typically make reference to a type issue or 'no acceptable conversion' and are attempting to instantiate a template with wchar_t. The default build of STLPort does not support wchar_t. There are two possible workarounds for this issue. The simplest is the user can build date_time with no wide stream/string etc. The other is to rebuild STLPort with wchar_t support. + + To build date_time with no wide stream/string etc, execute the following command from $BOOST_ROOT: + bjam -a "-sTOOLS=vc-7_1-stlport" "-sSTLPORT_PATH=..." \ + "-sBUILD=<define>BOOST_NO_STD_WSTRING" \ + --stagedir=... --with-date_time stage + (replace the ellipsis with the correct paths for the build system and adjust the TOOLS to the proper toolset if necessary) + + Rebuilding STLPort with wchar_t support involves placing /Zc:wchar_t in the STLPort makefile. Date_time should then be built with the following command from $BOOST_ROOT: + bjam -a "-sTOOLS=vc-7_1-stlport" "-sSTLPORT_PATH=..." \ + "-sBUILD=&native-wchar_t>on" \ + --stagedir=... --with-date_time stage + (replace the ellipsis with the correct paths for the build system and adjust the TOOLS to the proper toolset if necessary) + + + + Directory Structure + + The directory tree has the following structure: + /boost/date_time -- common headers and template code +/boost/date_time/gregorian -- Gregorian date system header files +/boost/date_time/posix_time -- Posix time system headers +/boost/date_time/local_time -- Local time system headers +/libs/date_time/build -- build files and output directory +/libs/date_time/test -- test battery for generic code +/libs/date_time/test/gregorian -- test battery for the Gregorian system +/libs/date_time/test/posix_time -- test battery for the posix_time system +/libs/date_time/test/local_time -- test battery for the local_time system +/libs/date_time/example/gregorian -- example programs for dates +/libs/date_time/example/posix_time -- time example programs +/libs/date_time/example/local_time -- nifty example programs +/libs/date_time/src/gregorian -- cpp files for libboost_date_time +/libs/date_time/src/posix_time -- empty (one file, but no source code...) + + + + Required Boost Libraries + + Various parts of date-time depend on other boost libraries. These include: + + boost.tokenizer + boost.integer(cstdint) + boost.operators + boost.lexical_cast + boost.smart_ptr (local time only) + boost::string_algorithms + boost::serialize (serialization code only) + + so these libraries need to be installed. + +
diff --git a/src/boost/libs/date_time/xmldoc/calculations.xml b/src/boost/libs/date_time/xmldoc/calculations.xml new file mode 100644 index 000000000..6abe98265 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/calculations.xml @@ -0,0 +1,96 @@ + + + + + +
+ Calculations + + + Timepoints -- + Durations -- + Intervals (Periods) -- + Special Value Handling + + + Timepoints + + This section describes some of basic arithmetic rules that can be performed with timepoints. In general, Timepoints support basic arithmetic in conjunction with Durations as follows: + + Timepoint + Duration --> Timepoint + Timepoint - Duration --> Timepoint + Timepoint - Timepoint --> Duration + + Unlike regular numeric types, the following operations are undefined: + + Duration + Timepoint --> Undefined + Duration - Timepoint --> Undefined + Timepoint + Timepoint --> Undefined + + + + Durations + + Durations represent a length of time and can have positive and negative values. It is frequently useful to be able to perform calculations with other durations and with simple integral values. The following describes these calculations: + + Duration + Duration --> Duration + Duration - Duration --> Duration + + Duration * Integer --> Duration + Integer * Duration --> Duration + Duration / Integer --> Duration (Integer Division rules) + + + + Intervals (Periods) + + Interval logic is extremely useful for simplifying many 'calculations' for dates and times. The following describes the operations provided by periods which are based on half-open range. The following operations calculate new time periods based on two input time periods: + +Timeperiod intersection Timeperiod --> Timeperiod + (null interval if no intersection) +Timeperiod merge Timeperiod --> Timeperiod + (null interval if no intersection) +Timeperiod shift Duration --> Timeperiod + (shift start and end by duration amount) + + In addition, periods support various queries that calculate boolean results. The first set is caluculations with other time periods: + + Timeperiod == Timeperiod --> bool + Timeperiod < Timeperiod --> bool (true if lhs.last <= rhs.begin) + Timeperiod intersects Timeperiod --> bool + Timeperiod contains Timeperiod --> bool + Timeperiod is_adjacent Timeperiod --> bool + + The following calculations are performed versus the Timepoint. + + Timeperiod contains Timepoint --> bool + Timeperiod is_before Timepoint --> bool + Timeperiod is_after Timepoint --> bool + + + + Special Value Handling + + For many temporal problems it is useful for Duration and Timepoint types to support special values such as Not A Date Time (NADT) and infinity. In general special values such as Not A Date Time (NADT) and infinity should follow rules like floating point values. Note that it should be possible to configure NADT based systems to throw an exception instead of result in NADT. + + Timepoint(NADT) + Duration --> Timepoint(NADT) + Timepoint(∞) + Duration --> Timepoint(∞) + Timepoint + Duration(∞) --> Timepoint(∞) + Timepoint - Duration(∞) --> Timepoint(-∞) + + When performing operations on both positive and negative infinities, the library will produce results consistent with the following. + + Timepoint(+∞) + Duration(-∞) --> NADT + Duration(+∞) + Duration(-∞) --> NADT + Duration(±∞) * Zero --> NADT + + Duration(∞) * Integer(Not Zero) --> Duration(∞) + Duration(+∞) * -Integer --> Duration(-∞) + Duration(∞) / Integer --> Duration(∞) + + +
diff --git a/src/boost/libs/date_time/xmldoc/changes.xml b/src/boost/libs/date_time/xmldoc/changes.xml new file mode 100644 index 000000000..e03f5d438 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/changes.xml @@ -0,0 +1,863 @@ + + + + + +
+ Change History + + + + Changes from Boost 1.72 to 1.73 + + + + + Type + Description + + + + + + Enhancement + + Make date_time all inline. Users no longer need to link the library for any library functions. + Note that an empty stub library is maintained for backward compatibility. Resolves: + (github issue #134) and + (github issue #85). + +Remove the link library to resolve linking/visibility concerns + + + + + Enhancement + + Support for constexpr has been added when in c++14 mode and above. For example: + + constexpr microseconds ms(1000); + static_assert(ms.total_microseconds() == 1000, "constexpr total_microseconds"); + + (github issue #123). + + + + + Enhancement + + C++20 ambiguous comparison operator warning with clang 10 + (github issue #132). + + + + + Cleanup + + Deprecated support for legacy io and USE_DATE_TIME_PRE_1_33_FACET_IO macro + (github issue #61). + + + + + Bug Fix + + Documentation clarifications for gettimeofday, day_number, and from_iso_extended_string. + github issue #127 + github issue #125, and + github issue #116 + + + + + + + + + + Changes from Boost 1.41 to 1.44 (date_time 1.08 to 1.09) + + + + + Type + Description + + + + + + Bug fix + + The "%T" and "%R" format specifiers are now processed by the library rather than underlying standard facet. + This fixes the cases when the placeholders are not supported by the facet + (#3876). + + + + + + + + Changes from Boost 1.40 to 1.41 (date_time 1.07 to 1.08) + + + + + Type + Description + + + + + + Change + + The default format for time durations is now "%-%O:%M:%S%F" instead of "%-%H:%M:%S%F" that was used previously. In order to retain the old behavior, the format string has to be specified explicitly during the time IO facet construction (#1861). + + + + + Bug fix + + Gregorian dates now use 32-bit integer type internally on 64-bit platforms (#3308). + + + + Bug fix + + Adjusted UTC time zone offset boundaries in order to allow offsets up to +14 hours (#2213). + + + + + + + + Changes from Boost 1.38 to 1.40 (date_time 1.06 to 1.07) + + + + + Type + Description + + + + + + Bug fix + + Minor bug fixes (#2809, + #2824, + #3015, + #3105 and others). + + + + + + + + Changes from Boost 1.34 to 1.38 (date_time 1.05 to 1.06) + + + + + Type + Description + + + + + Feature + + Added support for formatting and reading time durations longer than 24 hours. + A new formatter %O is used indicate such long durations in the + format string. The old %H format specifier is thus restricted + to represent durations that fit into two characters, in order to retain support + for reading durations in ISO format. In case if it is detected that the %H + format specifier is used with longer durations, the results are not specified + (an assertion in debug builds is raised). + + + + + Bug fix + + Added support for GCC 4.3. Several compilation issues were solved, as well as + compiler warnings were taken care of. + + + + + Bug fix + + Added missing streaming operators for the local_time_period class. + + + + + Bug fix + + Added several missing includes in different places. Some includes that are + not needed in some configurations were made conditional. + + + + + Bug fix + + Solved compilation problem that was caused by not finding streaming operators + for gregorian::date_duration via ADL. The type is now made actually + a class rather a typedef for the date_time::date_duration template. + The similar change was done for gregorian::weeks. + + + + + Bug fix + + Added a correctly spelled date_time::hundredth time resolution enum + value. The old one date_time::hundreth is considered deprecated and + to be removed in future releases. + + + + + Bug fix + + Fixed compilation error in format_date_parser.hpp because of incorrect + stream type being used. + + + + + Bug fix + + On Windows platform made inclusion of windows.h optional. The header is only used + when the BOOST_USE_WINDOWS_H macro is defined. Otherwise (and by default), + the library uses internal definitions of symbols from this header. + + + + + Bug fix + + On Windows platform function from_ftime could return incorrect time if + the FILETIME that is being passed to the function contained dates before 1970-Jan-01. + + + + + Bug fix + + Fixed a possible crash in gregorian::special_value_from_string if the string + did not represent a valid special value. + + + + + Bug fix + + Removed the testfrmwk.hpp file from the public include directory. This file + was internal for the library tests and was not documented. + + + + + Bug fix + + Fixed missing include in filetime_functions.hpp + (#2688). + + + + + Bug fix + + Fixed dereferencing end string iterators in different places of code, + which could cause crashes on MSVC + (#2698). + + + + + + + + + + Changes from Boost 1.33 to 1.34 (date_time 1.04 to 1.05) + + + + + Type + Description + + + + + Feature + + Updated the data in the date_time_zonespec.csv file to reflect new US/Canada + daylight savings time rules for 2007. If you upgrade to the new file, be aware + that the library will only give correct answers for current/future date + conversions. So if you are converting dates from earlier years the answers + will reflect current time zone rules not past rules. The library doesn't support + historic timezone rules presently. + + + + Feature + + Two other dst calculation features have also been update to reflect the new + US/Canada timzone rules. This is the boost::date_time::us_dst_rules and + dst_calc_engine. While the us_dst_rules is officially deprecated, a patch + by Graham Bennett has been applied which allows this class to work correctly + for both historical and future dates. The dst_calc_engine was updated to also + work for historical and future times. This allows the various local_adjustor + classes to work correctly. There was an interface change for classes using the + dst_calc_engine with custom dst traits classes. The traits classes signatures + changed to take a 'year' parameter on most of the methods such as end_month. + In addition, 2 new functions are needed on the traits classes: + static date_type local_dst_start_day(year_type year) and + static date_type local_dst_end_day(year_type year). + Implementers should see date_time/local_timezone_defs.hpp for + examples. + + + + + Bug Fix + Fix DST traits for Austrialia (sf# 1672139) to set end of DST at 3:00 am instead of 2:00 am. + + + + + Bug Fix + Fix a problem with potential linking error with multiple definitions due + to I/O code. + + + + Bug Fix + Changed serialization code in both greg_serialize.hpp and time_serialize.hpp + to eliminate warnings due to unused variables for version and file_version. + Thanks to Caleb Epstein for the patch suggestion. + + + + Bug Fix + Fix regression errors that showed up under FreeBSD with GCC and the + LANG environment set to russian -- changed parser to use classic + locale instead of blank locale. + + + + + Bug Fix + Changes for tracker issue 1178092 -- change in convert_to_lower to make + local a const static and speed up parsing. + + + + + Bug Fix + Patches from Ulrich Eckhardt to fix support for EVC++ 4. + + + + + Feature + Reduce the usage of basic_stringstream as much a possible to work around + a bug in the VC8 standard library. See + mailing list archive + for more information. + + + + + + + + + Changes from Boost 1.32 to 1.33 (date_time 1.03 to 1.04) + + + + + Type + Description + + + + + Bug Fix + Period lengths, when beginning and end points are the same, or are consecutive, were being incorrectly calculated. The corrected behavior, where end and beginning points are equal, or a period is created with a zero duration, now return a length of zero. A period where beginning and end points are consecutive will return a length of one. + + + + Bug Fix + Time_input_facet was missing functions to set iso formats. It also failed to parse time values that did not use a separator (%H%M%S). Both these bugs have been corrected. + + + + Feature + Preliminary names of ptime_facet and ptime_input_facet changed to simply time_facet and time_input_facet. The ptime_* versions have been removed all together. + + + + Feature + The from_iso_string function failed to parse fractional digits. We added code that correctly parses when input has more digits, or too few digits, that the compiled library precision. Ptimes with only a decimal are also correctly parsed. + + + + Bug Fix + The parsing mechanism in the new IO would consume the next character after a match was made. This bug presented itself when attempting to parse a period that had special value for it's beginning point. + + + + Bug Fix + The new IO system failed to provide the ability for the user to "turn on" exceptions on the stream. The failbit was also not set when parsing failed. Both of these problems have been fixed. + + + + Bug Fix + Parsing of special values, by means of from_*_string functions, has been fixed. This also effects the libraries ability to serialize special values. Time_duration now serializes as either a string or individual fields (depending on is_special()). + + + + Bug Fix + Previously, output streaming of partial_date would display the day as either a single or double digit integer (ie '1', or '12'). This has been corrected to always display a double digit integer (ie '01'). + + + + Feature + Major new features related to management of local times. + This includes the introduction of a series of new classes to + represent time zones and local times (see Date Time Local Time for complete details). + + + + Feature + Input and output facets have been re-written to support format-based + redefinition of formats (see Date Time IO for complete details). + + + + Feature + Functions have been added to facilitate conversions between tm structs for date, ptime, time_duration, and local_date_time. Functions for converting FILETIME, and time_t to ptime are also provided. See the individual sections for details. + + + + Feature + A universal_time function has been added to the microsec_time_clock (full details of this function can be found here). + + + + Feature + Functions have been added to facilitate conversions between tm structs for date, ptime, time_duration, and local_date_time. Functions for converting FILETIME, and time_t to ptime are also provided. See the individual sections for details. + + + + Feature + A universal_time function has been added to the microsec_time_clock (full details of this function can be found here). + + + + Feature + Date-time now uses reentrant POSIX functions on those platforms that + support them when BOOST_HAS_THREADS is defined. + + + + Bug Fix + Fixed a bug in serialization code where special values + (not-a-date-time, infinities, etc) for + ptime, time_duration would not read back correctly from an archive. + The output serialization code wrote subfields such + as time_duration.seconds() which are invalid for special values and + thus undefined values. Thus when read back the values could cause + strange behavior including execeptions on construction. + + + + Bug Fix + Fixed multiple warnings generated with various platforms/compilers. + + + + Bug Fix + Construction of a ptime with a time_duration beyond the range of 00:00 to 23:59:59.9... now adjusts the date and time to make the time_duration fall within this range (ie ptime(date(2005,2,1), hours(-5)) -> "2005-Jan-31 19:00:00" & ptime(date(2005,2,1), hours(35)) -> "2005-Feb-02 11:00:00"). + + + + Bug Fix + Time parsing now correctly handles excessive digits for fractional seconds. Leading zeros are dropped ("000100" -> 100 frac_sec), and excessive digits are truncated at the proper place ("123456789876" -> 123456 or 123456789 depending on what precision the library was compiled with). + + + + Bug Fix + Changes to the boost::serialization interface broke serialization compatibility for date_time. The user must provide a function to insure date_time objects are const before they are serialized. The function should be similar to: + template<class archive_type, class temporal_type> +void save_to(archive_type& ar, + const temporal_type& tt) +{ + ar << tt; +} + + + + Bug Fix + Use of the depricated boost::tokenizer interface has been updated to the current interface. This fixes compiler errors on some older compilers. + + + + Bug Fix + Templatized formatters in the legacy IO system to accept char type. Also removed calls to boost::lexical_cast. + + + + + + + + Changes from Boost 1.31 to 1.32 (date_time 1.02 to 1.03) + + + + + Type + Description + + + + + Bug Fix + Snap to end of month behavior corrected for year_functor. Previously, starting + from 2000-Feb-28 (leap year and not end of month) and iterating through the next + leap year would result in 2004-Feb-29 instead of 2004-Feb-28. This behavior has + been corrected to produce the correct result of 2004-Feb-28. Thanks to Bart Garst + for this change. + + + + Feature + Free function for creating a ptime object from a FILETIME struct. This function + is only available on platforms that define BOOST_HAS_FTIME. + + + + Feature + Microsecond time clock is now available on most windows compilers as well as + Unix. + + + + Feature + Use of the boost::serialization library is now available with most of the + date_time classes. Classes capable of serialization are: date_generator classes, + date, days, date_period, greg_month, greg_weekday, greg_day, ptime, time_duration, + and time_period. Thanks to Bart Garst for this change. + + + + Feature + Functions added to convert date and time classes to wstring. The library now + provides to_*_wstring as well as to_*_string functions for: simple, iso, + iso_extended, and sql for dates and compilers that support wstrings. Thanks to + Bart Garst for this change. + + + + Feature + Period classes now handle zero length and NULL periods correctly. A NULL period + is a period with a negative length. Thanks to Frank Wolf and Bart Garst for this + change. + + + + Feature + Added end_of_month function to gregorian::date to return the last day of + the current month represented by the date. Result is undefined for + not_a_date_time or infinities. + + + + Bug Fix + Removed incorrect usage of BOOST_NO_CWCHAR macro throughout library. + + + + Feature + New names added for some date classes. Original names are still valid but may + some day be deprecated. Changes are: + + date_duration + is now + days + nth_kday_of_month + is now + nth_day_of_the_week_in_month + first_kday_of_month + is now + first_day_of_the_week_in_month + last_kday_of_month + is now + last_day_of_the_week_in_month + first_kday_after + is now + first_day_of_the_week_after + first_kday_before + is now + first_day_of_the_week_before + + + + + Feature + Free functions for date generators added. Functions are: days_until_weekday, days_before_weekday, next_weekday, and previous_weekday. + days days_until_weekday(date, greg_weekday); +days days_before_weekday(date, greg_weekday); +date next_weekday(date, greg_weekday); +date previous_weekday(date, greg_weekday); + Thanks to Bart Garst for this change. + + + + Feature + New experimental duration types added for months, years, and weeks. These classes + also provide mathematical operators for use with date and time classes. Be aware + that adding of months or years a time or date past the 28th of a month may show + non-normal mathematical properties. This is a result of 'end-of-month' + snapping used in the calculation. The last example below illustrates the + issue. + + months m(12); +years y(1); +m == y; // true +days d(7); +weeks w(1); +d == w; // true +ptime t(...); +t += months(3); +date d(2004,Jan,30); +d += months(1); //2004-Feb-29 +d -= months(1); //2004-Jan-29 + Input streaming is not yet implemented for these types. + Thanks to Bart Garst for this change. + + + + Feature + Unifying base class for date_generators brought in to gregorian namespace. See Print Holidays Example. + + + + Feature + Added constructors for date and ptime that allow for default construction (both) + and special values construction (ptime, both now support this). Default + constructors initialize the objects to not_a_date_time (NADT). + ptime p_nadt(not_a_date_time); +ptime p_posinf(pos_infin); +ptime p; // p == NADT +date d; // d == NADT + Thanks to Bart Garst for this change. + + + + Feature + Output streaming now supports wide stream output on compiler / standard library combinations that support wide streams. This allows code like: + std::wstringstream wss; +date d(2003,Aug,21); +wss << d; + Thanks to Bart Garst for this change. + + + + Feature + Input streaming for date and time types is now supported on both wide and narrow streams: + date d(not_a_date_time); +std::stringstream ss("2000-FEB-29"); +ss >> d; //Feb 29th, 2000 +std::wstringstream ws("2000-FEB-29"); +ws >> d; //Feb 29th, 2000 + Thanks to Bart Garst for this change. + + + + Bug Fix + Fixed bug in duration_from_string() where a string formatted with + less than full amount of fractional digits created an incorrect + time_duration. With microsecond resolution for time durations + the string "1:01:01.010" created a time duration of + 01:01:01.000010 instead of 01:01:01.010000 + + + + Bug Fix + Fixed the special value constructor for gregorian::date and posix_time::ptime + when constructing with min_date_time or max_date_time. The wrong value was + constructed for these. + + + + + + + Changes from Boost 1.30 to 1.31 (date_time 1.01 to 1.02) + + + + + Type + Description + + + + + Bug Fix + Build configuration updated so dll, statically, and dynamically linkable library files are now produced with MSVC compilers. See Build/Compiler Information for more details. + + + Bug Fix + Time_duration from_string is now correctly constructed from a negative value. (ie "-0:39:00.000") Code provided by Bart Garst. + + + Bug Fix + Fixed many MSVC compiler warnings when compiled with warning level 4. + + + Feature + Added prefix decrement operator (--) for date and time iterators. See Time Iterators and Date Iterators for more details. Code provided by Bart Garst. + + + Feature + Special_values functionality added for date_duration, time_duration and time classes. Code provided by Bart Garst. + + + Bug Fix + Fixed time_duration_traits calculation bug which was causing time duration to be limited to 32bit range even when 64 bits were available. Thanks to Joe de Guzman for tracking this down. + + + Bug Fix + Provided additional operators for duration types (eg: date_duration, time_duration). This includes dividable by integer and fixes to allow +=, -= operators. Thanks to Bart Garst for writing this code. Also, the documentation of Calculations has been improved. + + + Bug Fix + Added typedefs to boost::gregorian gregorian_types.hpp various date_generator function classes. + + + Feature + Added from_time_t function to convert time_t to a ptime. + + + Feature + Added a span function for combining periods. See date period and time period docs. + + + Feature + Added a function to time_duration to get the total number of seconds in a + duration truncating any fractional seconds. In addition, other resolutions + were added to allow for easy conversions. For example + seconds(1).total_milliseconds() == 1000 +seconds(1).total_microseconds() == 1000000 +hours(1).total_milliseconds() == 3600*1000 //3600 sec/hour +seconds(1).total_nanoseconds() == 1000000000 + + + + + Feature + Added output streaming operators for the date generator classes - partial_date, first_kday_after, first_kday_before, etc. Thanks to Bart Garst for this work. + + + Feature + Added unary- operators for durations for reversing the sign of a time duration. For example: + time_duration td(5,0,0); //5 hours +td = -td; //-5 hours + Thanks to Bart Garst for this work. + + + Feature + Added support for parsing strings with 'month names'. Thus creating a date object from string now accepts multiple formats ("2003-10-31","2003-Oct-31", and "2003-October-31"). Thus, date d = from_simple_string("2003-Feb-27") is now allowed. A bad month name string ( from_simple_string("2003-SomeBogusMonthName-27")) will cause a bad_month exception. On most compilers the string compare is case insensitive. Thanks to Bart Garst for this work. + + + Feature + In addition to support for month names or numbers, functions have been added to create date objects from multi-ordered date strings. Ex: "January-21-2002", "2002-Jan-21", and "21-Jan-2003". See Date Class for more details. + + + Bug-Fix + Various documentation fixes. Thanks to Bart Garst for updates. + + + + + + Changes from Boost 1.29 to 1.30 (date_time 1.00 to 1.01) + + Notice: The interface to the partial_date class (see date_algorithms) was changed. The order of construction parameters was changed which will cause some code to fail execution. This change was made to facilitate more generic local time adjustment code. Thus instead of specifying partial_date pd(Dec,25) the code needs to be changed to partial_date pd(25, Dec); + + + + + + Type + Description + + + + + Bug Fix + Added new experimental feature for Daylight Savings Time calculations. This allows traits based specification of dst rules. + + + Feature + Added new interfaces to calculate julian day and modified julian day to the gregorian date class. See boost::gregorian::date. + + + Feature + Add new interface to calculate iso 8601 week number for a date. See boost::gregorian::date. + + + Feature + Add an iso 8601 time date-time format (eg: YYYYMMDDTHHHMMSS) parsing function. See Class ptime for more information. + + + Feature + Added a length function to the period template so that both date_periods and time_periods will now support this function. + + + Bug Fix + Split Jamfiles so that libs/date_time/build/Jamfile only builds library and /libs/date_time/libs/test/Jamfile which runs tests. + + + Bug Fix + Fixed many minor documentation issues. + + + Bug Fix + Removed the DATE_TIME_INLINE macro which was causing link errors. This macro is no longer needed in projects using the library. + + + Bug Fix + Added missing typedef for year_iterator to gregorian_types.hpp + + + Bug Fix + Fixed problem with gregorian ostream operators that prevented the use of wide streams. + + + Bug-Fix + Tighten error handling for dates so that date(2002, 2, 29) will throw a bad_day_of_month exception. Previously the date would be incorrectly constructed. Reported by sourceforge bug: 628054 among others. + + + + +
diff --git a/src/boost/libs/date_time/xmldoc/conceptual.xml b/src/boost/libs/date_time/xmldoc/conceptual.xml new file mode 100644 index 000000000..d0130a352 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/conceptual.xml @@ -0,0 +1,19 @@ + + + + + +
+ Conceptual + + + + + + +
+ diff --git a/src/boost/libs/date_time/xmldoc/custom_time_zone.xml b/src/boost/libs/date_time/xmldoc/custom_time_zone.xml new file mode 100644 index 000000000..c0d919492 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/custom_time_zone.xml @@ -0,0 +1,376 @@ + + + + + +
+ Custom Time Zone + + Introduction -- + Header -- + Construction -- + Accessors -- + Dependent Types + + + Introduction + + A custom_time_zone object is a set of data and rules that provide information about a time zone. Information such as the offset from UTC, it's name and abbreviation, as well as daylight savings rules, called dst_calc_rules. These rules are handled via a boost::shared_ptr<dst_calc_rules>. Not all time zones utilize daylight savings, therefore, time_zone objects can be used with a NULL-assigned shared_ptr. + + + As a convenience, a typedef for shared_ptr<dst_calc_rules> is provided. + typedef boost::shared_ptr<dst_calc_rules> local_time::dst_calc_rule_ptr; + + + + The time_zone objects are used via a boost::shared_ptr<local_time::time_zone>. As a convenience, a typedef for boost::shared_ptr<local_time::time_zone> is provided: + typedef boost::shared_ptr<time_zone> local_time::time_zone_ptr; + + + + Header + + The inclusion of a single header will bring in all boost::local_time types, functions, and IO operators. + #include "boost/date_time/local_time/local_time.hpp" + + + + Construction + + Construction of a custom_time_zone is dependent on four objects: a + time_duration, a time_zone_names, a dst_adjustment_offsets, and a shared_ptr to a dst_calc_rule. + + + + + + + Syntax + Example + + + + + custom_time_zone(...) + Parameters: + names, + gmt_offset, + dst_offsets, + dst_rules + See simple_time_zone example for time_zone usage + + + + + + + + Accessors + + + + + + Syntax + Description + + + Example + + + + + std::string dst_zone_abbrev() + Returns the daylight savings abbreviation for the represented time zone. + + + nyc_zone_sh_ptr->dst_zone_abbrev(); +// "EDT" + + + + std::string std_zone_abbrev() + Returns the standard abbreviation for the represented time zone. + + + nyc_zone_sh_ptr->std_zone_abbrev(); +// "EST" + + + + std::string dst_zone_name() + Returns the daylight savings name for the represented time zone. + + + nyc_zone_sh_ptr->dst_zone_name(); +// "Eastern Daylight Time" + + + + std::string std_zone_name() + Returns the standard name for the represented time zone. + + + nyc_zone_sh_ptr->std_zone_name(); +// "Eastern Standard Time" + + + + bool has_dst() + Returns true when custom_time_zone's shared_ptr to dst_calc_rules is not NULL. + + + nyc_zone_sh_ptr->has_dst(); +// true +phx_zone_sh_ptr->has_dst(); +// false + + + + + dst_local_start_time(...) + Return Type: + ptime + Parameter: + greg_year + The date and time daylight savings time begins in given year. Returns not_a_date_time if this zone has no daylight savings. + + + nyc_ptr->dst_local_start_time(2004); +// 2004-Apr-04 02:00 + + + + dst_local_end_time(...) + Return Type: + ptime + Parameter: + greg_year + The date and time daylight savings time ends in given year. Returns not_a_date_time if this zone has no daylight savings. + + + nyc_ptr->dst_local_end_time(2004); +// 2004-Oct-31 02:00 + + + + time_duration base_utc_offset() + The amount of time offset from UTC (typically in hours). + + + nyc_ptr->base_utc_offset(); +// -05:00 + + + + time_duration dst_offset() + The amount of time shifted during daylight savings. + + + nyc_zone_sh_ptr->dst_offset(); +// 01:00 + + + + std::string to_posix_string() + Returns a posix time zone string representation of this time_zone object. Depending on how the time_zone object was created, the date-spec format of the string will be in either 'M' notation or 'n' notation. Every possible date-spec that can be represented in 'J' notation can also be represented in 'n' notation. The reverse is not true so only 'n' notation is used for these types of date-specs. For a detailed description of a posix time zone string see posix_time_zone. + + + nyc_ptr->to_posix_string(); +// "EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00" +phx_ptr->to_posix_string(); +// "MST-07" + + + + + + + + + Dependent Types + Time Zone Names -- + Dst Adjustment Offsets -- + Daylight Savings Calc Rules + + Time Zone Names + + The time_zone_names_base type is an immutable template class of four strings. One each for the name and abbreviation in standard time and daylight savings time. The time_zone_names type is a typedef of time_zone_names_base<char>. + + + + + + + Syntax + Description + + + Example + + + + + time_zone_names(...) + Parameters: + string std_name + string std_abbrev + string dst_name + string dst_abbrev + The only constructor, all four strings must be provided. + + + string sn("Eastern Standard Time"); +string sa("EST"); +string dn("Eastern Daylight Time"); +string da("EDT"); +time_zone_names nyc_names(sn, sa, + dn, da); + + + + + std::string std_zone_name() + Returns the standard zone name + + + nyc_names.std_zone_name(); +// "Eastern Standard Time" + + + + std::string std_zone_abbrev() + Returns the standard zone abbreviation + + + nyc_names.std_zone_abbrev(); +// "EST" + + + + std::string dst_zone_name() + Returns the daylight savings zone name + + + nyc_names.std_zone_name(); +// "Eastern Daylight Time" + + + + std::string dst_zone_abbrev() + Returns the daylight savings zone abbreviation + + + nyc_names.std_zone_abbrev(); +// "EDT" + + + + + + + + Dst Adjustment Offsets + + The dst_adjustment_offsets type is a collection of three time_duration objects. + + + + + + + Syntax + Description + + + Example + + + + + dst_adjustment_offsets(...) + Parameters: + time_duration dst_adjust + time_duration start_offset + time_duration end_offset + The first time_duration is the daylight savings adjustment. The second is the time which daylight savings starts on the start day. The third is the time daylight savings ends on the ending day. + + + +dst_adjustment_offsets(hours(1), + hours(2), + hours(2)); + + + + + + + + Daylight Savings Calc Rules + + Daylight savings calc rules, named dst_calc_rules, are a series of objects that group appropriate date_generators together to form rule sets. The individual rules objects are used via dst_calc_rule_ptr. + + + For a complete example of all five dst_calc_rule types, see: calc_rules example. + + + + + + + Syntax + Description + + + + + partial_date_dst_rule(...) + Parameters: + start_rule + end_rule + Both the start and end rules are of type gregorian::partial_date. + + + first_last_dst_rule(...) + Parameters: + start_rule + end_rule + The DST start rule is of type gregorian::first_day_of_the_week_in_month and the end rule is of type gregorian::last_day_of_the_week_in_month. + + + last_last_dst_rule(...) + Parameters: + start_rule + end_rule + Both the start and end rules are of type gregorian::last_day_of_the_week_in_month. + + + nth_last_dst_rule(...) + Parameters: + start_rule + end_rule + The DST start rule is of type gregorian::nth_day_of_the_week_in_month and the end rule is of type gregorian::last_day_of_the_week_in_month. + + + nth_kday_dst_rule(...) + Parameters: + start_rule + end_rule) +(see note* below) + + Both rules are of type gregorian::nth_day_of_the_week_in_month. + + + + + + * Note: The name "nth_kday_dst_rule" is a bit cryptic. Therefore, a more descriptive name, "nth_day_of_the_week_in_month_dst_rule", is also provided. + + + +
diff --git a/src/boost/libs/date_time/xmldoc/date_algorithms.xml b/src/boost/libs/date_time/xmldoc/date_algorithms.xml new file mode 100644 index 000000000..a30f1374b --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_algorithms.xml @@ -0,0 +1,208 @@ + + + + + +
+ Date Generators/Algorithms + Date Generators/Algorithms + Introduction -- + Header -- + Class Overview -- + Function Overview + + + Introduction + + Date algorithms or generators are tools for generating other dates or schedules of dates. A generator function starts with some part of a date such as a month and day and is supplied another part to then generate a concrete date. This allows the programmer to represent concepts such as "The first Sunday in February" and then create a concrete set of dates when provided with one or more years. + Note: As of boost version 1_31_0, date generator names have been changed. Old names are still available but are no longer documented and may someday be deprecated + + Also provided are stand-alone functions for generating a date, or calculation a duration of days. These functions take a date object and a weekday object as parameters. + + All date generator classes and functions are in the boost::gregorian namespace. + + + The print holidays example shows a detailed usage example. + + + + Header + #include "boost/date_time/gregorian/gregorian.hpp" + + + + Overview + + + + + Class and get_date Parameter + Description + + + Example + + + + + year_based_generator +date get_date(greg_year year) + A unifying (abstract) date_generator base type for: partial_date, nth_day_of_the_week_in_month, first_day_of_the_week_in_month, and last_day_of_the_week_in_month. + + + The print holidays example shows a detailed usage example. + + + + last_day_of_the_week_in_month(greg_weekday, + greg_month) +date get_date(greg_year year) + Calculate something like last Monday of January + + + last_day_of_the_week_in_month lwdm(Monday,Jan); +date d = lwdm.get_date(2002); +//2002-Jan-28 + + + + + first_day_of_the_week_in_month(greg_weekday, + greg_month) +date get_date(greg_year year) + Calculate something like first Monday of January + + + first_day_of_the_week_in_month fdm(Monday,Jan); +date d = fdm.get_date(2002); +//2002-Jan-07 + + + + + nth_day_of_the_week_in_month(week_num, + greg_weekday, + greg_month) +date get_date(greg_year year) + week_num is a public enum member of nth_day_of_the_week_in_month. Calculate something like first Monday of January, second Tuesday of March, Third Sunday of December, etc. (first through fifth are provided, fifth is the equivalent of last) + + + typedef nth_day_of_the_week_in_month nth_dow; +nth_dow ndm(nth_dow::third, Monday,Jan); +date d = ndm.get_date(2002); +//2002-Jan-21 + + + + + partial_date(greg_day, greg_month) +date get_date(greg_year year) + Generates a date by applying the year to the given month and day. + + + partial_date pd(1,Jan); +date d = pd.get_date(2002); +//2002-Jan-01 + + + + + first_day_of_the_week_after(greg_weekday) +date get_date(date d) + Calculate something like First Sunday after Jan 1,2002 + + + first_day_of_the_week_after fdaf(Monday); +date d = fdaf.get_date(date(2002,Jan,1)); +//2002-Jan-07 + + + + + first_day_of_the_week_before(greg_weekday) +date get_date(date d) + Calculate something like First Monday before Feb 1,2002 + + + first_day_of_the_week_before fdbf(Monday); +date d = fdbf.get_date(date(2002,Feb,1)); +//2002-Jan-28 + + + + + + + + + Function Overview + + + + + Function Prototype + Description + + + Example + + + + + days days_until_weekday date, greg_weekday) + Calculates the number of days from given date until given weekday. + + + date d(2004,Jun,1); // Tuesday +greg_weekday gw(Friday); +days_until_weekday(d, gw); // 3 days + + + + + days days_before_weekday(date, greg_weekday) + Calculates the number of day from given date to previous given weekday. + + + date d(2004,Jun,1); // Tuesday +greg_weekday gw(Friday); +days_before_weekday(d, gw); // 4 days + + + + + date next_weekday(date, greg_weekday) + Generates a date object representing the date of the following weekday from the given date. Can return the given date. + + + date d(2004,Jun,1); // Tuesday +greg_weekday gw1(Friday); +greg_weekday gw2(Tuesday); +next_weekday(d, gw1); // 2004-Jun-4 +next_weekday(d, gw2); // 2004-Jun-1 + + + + + + date previous_weekday(date, greg_weekday) + Generates a date object representing the date of the previous weekday from the given date. Can return the given date. + + + date d(2004,Jun,1); // Tuesday +greg_weekday gw1(Friday); +greg_weekday gw2(Tuesday); +previous_weekday(d, gw1); // 2004-May-28 +previous_weekday(d, gw2); // 2004-Jun-1 + + + + + + + +
diff --git a/src/boost/libs/date_time/xmldoc/date_class.xml b/src/boost/libs/date_time/xmldoc/date_class.xml new file mode 100644 index 000000000..3a1dda74f --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_class.xml @@ -0,0 +1,524 @@ + + + + + +
+ Date + + Introduction -- + Header -- + Construction -- + Construct from String -- + Construct from Clock -- + Accessors -- + Convert to String -- + Operators -- + Struct tm Functions + + + Introduction + + The class boost::gregorian::date is the primary interface for date programming. In general, + the date class is immutable once constructed although it does allow assignment from another + date. + Techniques for creating dates include reading the + current date from the clock, + using date iterators, and + date algorithms or generators. + + + + Internally boost::gregorian::date is stored as a 32 bit integer type. The class is specifically + designed to NOT contain virtual functions. This design allows for efficient + calculation and memory usage with large collections of dates. + + + + The construction of a date validates all input so that it is not possible to + construct an 'invalid' date. That is 2001-Feb-29 cannot be constructed as a date. + Various exceptions derived from std::out_of_range are thrown to indicate which aspect + of the date input is invalid. Note that the + special value not-a-date-time can be used as 'invalid' or 'null' date if so desired. + + + + Header + + #include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o +or +#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types + + + + Construction + + + + + Syntax + Description + + + Example + + + + + date(greg_year, greg_month, greg_day) + Construct from parts of date. Throws bad_year, bad_day_of_month, or bad_day_month (derivatives of std::out_of_range) if the year, month or day are out of range. + + + date d(2002,Jan,10); + + + + date(date d) + Copy constructor + + + date d1(d); + + + + date(special_values sv) + Constructor for infinities, not-a-date-time, max_date_time, and min_date_time + + + date d1(neg_infin); +date d2(pos_infin); +date d3(not_a_date_time); +date d4(max_date_time); +date d5(min_date_time); + + + + date() + Default constructor. Creates a date object initialized to not_a_date_time. NOTE: this constructor can be disabled by defining DATE_TIME_NO_DEFAULT_CONSTRUCTOR (see compiler_config.hpp) + + + date d; // d => not_a_date_time + + + + + + + Construct from String + + + + + Syntax + Description + + + Example + + + + + date from_string(std::string) + From delimited date string where with order year-month-day eg: 2002-1-25 + + + std::string ds("2002/1/25"); +date d(from_string(ds)); + + + + date from_undelimited_string(std::string) + From iso type date string where with order year-month-day eg: 20020125 + + + std::string ds("20020125"); +date d(from_undelimited_string(ds)); + + + + + + + Construct from Clock + + + + + Syntax + Description + + + Example + + + + + day_clock::local_day() + Get the local day based on the time zone settings of the computer. + + + date d(day_clock::local_day()); + + + + day_clock::universal_day() + Get the UTC day. + + + date d(day_clock::universal_day()); + + + + + + + Accessors + + + + + Syntax + Description + + + Example + + + + + greg_year year() const + Get the year part of the date. + + + date d(2002,Jan,10); +d.year(); // --> 2002 + + + + greg_month month() const + Get the month part of the date. + + + date d(2002,Jan,10); +d.month(); // --> 1 + + + + greg_day day() const + Get the day part of the date. + + + date d(2002,Jan,10); +d.day(); // --> 10 + + + + greg_ymd year_month_day() const + Return a year_month_day struct. More efficient when all 3 parts of the date are needed. + + + date d(2002,Jan,10); +date::ymd_type ymd = d.year_month_day(); +// ymd.year --> 2002, +// ymd.month --> 1, +// ymd.day --> 10 + + + + greg_day_of_week day_of_week() const + Get the day of the week (Sunday, Monday, etc.) + + + date d(2002,Jan,10); +d.day_of_week(); // --> Thursday + + + + greg_day_of_year day_of_year() const + Get the day of the year. Number from 1 to 366 + + + date d(2000,Jan,10); +d.day_of_year(); // --> 10 + + + + date end_of_month() const + Returns a date object set to the last day of the calling objects current month. + + + date d(2000,Jan,10); +d.end_of_month(); // --> 2000-Jan-31 + + + + bool is_infinity() const + Returns true if date is either positive or negative infinity + + + date d(pos_infin); +d.is_infinity(); // --> true + + + + bool is_neg_infinity() const + Returns true if date is negative infinity + + + date d(neg_infin); +d.is_neg_infinity(); // --> true + + + + bool is_pos_infinity() const + Returns true if date is positive infinity + + + date d(pos_infin); +d.is_pos_infinity(); // --> true + + + + bool is_not_a_date() const + Returns true if value is not a date + + + date d(not_a_date_time); +d.is_not_a_date(); // --> true + + + + bool is_special() const + Returns true if date is any special_value + + + date d(pos_infin); +date d2(not_a_date_time); +date d3(2005,Mar,1); +d.is_special(); // --> true +d2.is_special(); // --> true +d3.is_special(); // --> false + + + + special_value as_special() const + Returns represented special_value or not_special if the represented date is a normal date. + + + + + + + long modjulian_day() const + Returns the modified julian day for the date. + + + + + + + long julian_day() const + Returns the julian day for the date. + + + + + + + int week_number() const + Returns the ISO 8601 week number for the date. + + + + + + date end_of_month() const + Returns the last day of the month for the date. + + + date d(2000,Feb,1); +//gets Feb 29 -- 2000 was leap year +date eom = d.end_of_month(); + + + + + + + Convert to String + + + + + Syntax + Description + + + Example + + + + + std::string to_simple_string(date d) + To YYYY-mmm-DD string where mmm is a 3 char month name. + + + "2002-Jan-01" + + + + std::string to_iso_string(date d) + To YYYYMMDD where all components are integers. + + + "20020131" + + + + std::string to_iso_extended_string(date d) + To YYYY-MM-DD where all components are integers. + + + "2002-01-31" + + + + + + + Operators + + + + + Syntax + Description + + + Example + + + + + operator<< + Stream output operator + + + date d(2002,Jan,1); +std::cout << d << std::endl; + + + + + operator>> + Stream input operator. Note: As of version 1.33, streaming operations have been greatly improved. See Date Time IO System for details on exceptions and error conditions. + + + date d(not_a_date_time); +stringstream ss("2002-Jan-01"); +ss >> d; + + + + + operator==, operator!=, +operator>, operator<, +operator>=, operator<= + A full complement of comparison operators + + + d1 == d2, etc + + + + date operator+(date_duration) const + Return a date adding a day offset + + + date d(2002,Jan,1); +date_duration dd(1); +date d2 = d + dd; + + + + + date operator-(date_duration) const + Return a date by substracting a day offset + + + date d(2002,Jan,1); +date_duration dd(1); +date d2 = d - dd; + + + + + date_duration operator-(date) const + Return a date_duration by subtracting two dates + + + date d1(2002,Jan,1); +date d2(2002,Jan,2); +date_duration dd = d2-d1; + + + + + + + + Struct tm Functions + Functions for converting a date object to, and from, a tm struct are provided. + + + + + Syntax + Description + + + Example + + + + + tm to_tm(date) + A function for converting a date object to a tm struct. The fields: tm_hour, tm_min, and tm_sec are set to zero. The tm_isdst field is set to -1. + + + date d(2005,Jan,1); +tm d_tm = to_tm(d); +/* tm_year => 105 + tm_mon => 0 + tm_mday => 1 + tm_wday => 6 (Saturday) + tm_yday => 0 + tm_hour => 0 + tm_min => 0 + tm_sec => 0 + tm_isdst => -1 */ + + + + + date date_from_tm(tm datetm) + A function for converting a tm struct to a date object. The fields: tm_wday , tm_yday , tm_hour, tm_min, tm_sec, and tm_isdst are ignored. + + + tm d_tm; +d_tm.tm_year = 105; +d_tm.tm_mon = 0; +d_tm.tm_mday = 1; +date d = date_from_tm(d_tm); +// d => 2005-Jan-01 + + + + + + +
diff --git a/src/boost/libs/date_time/xmldoc/date_duration.xml b/src/boost/libs/date_time/xmldoc/date_duration.xml new file mode 100644 index 000000000..12d22ebca --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_duration.xml @@ -0,0 +1,250 @@ + + + + + +
+ Date Duration (aka Days) + + Introduction -- + Header -- + Construction -- + Accessors -- + Operators -- + Additional Duration Types + + + Introduction + + The class boost::gregorian::date_duration is a simple day count used for arithmetic with gregorian::date. A duration can be either positive or negative. + + + As of version 1_32 the date_duration class has been typedef'd as days in the boost::gregorian namespace. Throughout the examples you will find days used instead of date_duration. + + + + Header + + #include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o +or +#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types + + + + Construction + + + + + Syntax + Description + + + Example + + + + + date_duration(long) + Create a duration count. + + + date_duration dd(3); //3 days + + + + days(special_values sv) + Constructor for infinities, not-a-date-time, max_date_time, and min_date_time + + + days dd1(neg_infin); +days dd2(pos_infin); +days dd3(not_a_date_time); +days dd4(max_date_time); +days dd5(min_date_time); + + + + + + + + Accessors + + + + + Syntax + Description + + + Example + + + + + long days() const + Get the day count. + + + date_duration dd(3); dd.days() --> 3 + + + + bool is_negative() const + True if number of days is less than zero. + + + date_duration dd(-1); dd.is_negative() --> true + + + + static date_duration unit() + Return smallest possible unit of duration type. + + + date_duration::unit() --> date_duration(1) + + + + bool is_special() const + Returns true if days is any special_value + + + days dd(pos_infin); +days dd2(not_a_date_time); +days dd3(25); +dd.is_special(); // --> true +dd2.is_special(); // --> true +dd3.is_special(); // --> false + + + + + + + + Operators + + + + + Syntax + Description + + + Example + + + + + operator<<, operator>> + Streaming operators. Note: As of version 1.33, streaming operations have been greatly improved. See Date Time IO System for more details (including exceptions and error conditions). + + + date d(not_a_date_time); +stringstream ss("2002-Jan-01"); +ss >> d; +std::cout << d; // "2002-Jan-01" + + + + + + operator==, operator!=, +operator>, operator<, +operator>=, operator<= + + A full complement of comparison operators + + + dd1 == dd2, etc + + + + date_duration operator+(date_duration) const + Add date durations. + + + date_duration dd1(3); +date_duration dd2(5); +date_duration dd3 = dd1 + dd2; + + + + + date_duration operator-(date_duration) const + Subtract durations. + + + date_duration dd1(3); +date_duration dd2(5); +date_duration dd3 = dd1 - dd2; + + + + + + + + Additional Duration Types + These additional types are logical representations of spans of days. + + + + + Syntax + Description + + + Example + + + + + months(int num_of_months) + A logical month representation. Depending on the usage, this months object may cover a span of 28 to 31 days. The objects also use a snap to end-of-month behavior when used in conjunction with a date that is the last day of a given month. WARNING: this behavior may lead to unexpected results. See: Reversibility of Operations Pitfall for complete details and alternatives. + + + months single(1); +date leap_year(2004,Jan,31); +date norm_year(2005,Jan,31); +leap_year + single; // => 2004-Feb-29 +norm_year + single; // => 2005-Feb-28 +date(2005,Jan,1) + single; // => 2005-Feb-01 +date(2005,Feb,1) + single; // => 2005-Mar-01 +date(2005,Feb,28) + single; // => 2005-Mar-31 + + + + years(int num_of_years) + A logical representation of a year. The years object has the same behavior as the months objects with regards to the end-of-the-month. + + + years single(1); +date(2003,Feb,28) + single; +// results in => 2004-Feb-29 +date(2004,Feb,29) + single; +// results in => 2005-Feb-28 + + + + weeks(int num_of_weeks) + A duration type representing a number of n * 7 days. + + + weeks single(1); +date(2005,Jan,1) + single; // => 2005-Jan-08 + + + + + + + + +
diff --git a/src/boost/libs/date_time/xmldoc/date_facet.xml b/src/boost/libs/date_time/xmldoc/date_facet.xml new file mode 100644 index 000000000..9721e3800 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_facet.xml @@ -0,0 +1,319 @@ + + + + + +
+ Date Facet + + Introduction - + Construction - + Accessors + + + Introduction + The boost::date_time::date_facet enables users to have significant control over the output streaming of dates (and other gregorian objects). The date_facet is typedef'd in the gregorian namespace as date_facet and wdate_facet. + + + + Construction + + + + + + Syntax + Description + + + + + date_facet() + Default constructor + + + date_facet(...) + Parameters: + char_type* format + input_collection_type + Format given will be used for date output. All other formats will use their defaults. Collection is the set of short names to be used for months. All other name collections will use their defaults. + + + date_facet(...) + Parameters: + char_type* format + period_formatter_type + special_values_formatter_type + date_gen_formatter_type + Format given will be used for date output. The remaining parameters are formatter objects. Further details on these objects can be found here. This constructor also provides default arguments for all parameters except the format. Therefore, date_facet("%m %d %Y") will work. + + + + + + + + Accessors + + + + + + Syntax + Description + + + Example + + + + + void format(char_type*) + Set the format for dates. + + + date_facet* f = new date_facet(); +f->format("%m %d %Y"); + + + + void set_iso_format() + Sets the date format to ISO + + + f->set_iso_format(); +// "%Y%m%d" + + + + void set_iso_extended_format() + Sets the date format to ISO Extended + + + f->set_iso_extended_format(); +// "%Y-%m-%d" + + + + void month_format(char_type*) + Set the format for months when they are 'put' individually. + + + f->month_format("%B"); +ss << greg_month(12); // "December" + + + + void weekday_format(char_type*) + Set the format for weekdays when they are 'put' individually. + + + f->weekday_format("%a"); +ss << greg_weekday(2); // "Tue" + + + + void period_formatter(...) + Parameter: + period_formatter_type + Replaces the period formatter object with a user created one. + + + see the tutorial for a complete example. + + + + void special_values_formatter(...) + Parameter: + special_values_formatter_type + Replaces the special_values formatter object with a user created one. + + + see the tutorial for a complete example. + + + + void date_gen_phrase_strings(...) + Parameters: + input_collection_type + date_gen_formatter_type:: + phrase_elements + Sets new date generator phrase strings in date_gen_formatter. The input collection is a vector of strings (for details on these strings see date generator formatter/parser documentation). The phrase_elements parameter is an enum, defined in the date_generator_formatter object, that has a default value of 'first'. It is used to indicate what the position of the first string in the collection will be. + + + + + + + void short_weekday_names(...) + Parameter: + input_collection_type + Replace strings used when 'putting' short weekdays. + + + see the tutorial for a complete example. + + + + void long_weekday_names(...) + Parameter: + input_collection_type + Replace strings used when 'putting' long weekdays. + + + see the tutorial for a complete example. + + + + void short_month_names(...) + Parameter: + input_collection_type + Replace strings used when 'putting' short months. + + + see the tutorial for a complete example. + + + + void long_month_names(...) + Parameter: + input_collection_type + Replace strings used when 'putting' long months. + + + see the tutorial for a complete example. + + + + OutItrT put(...) + Common parameters for all + 'put' functions: + OutItrT + ios_base + char_type + Unique parameter for 'put' funcs: + gregorian object + There are 12 put functions in the date_facet. The common paraeters are: an iterator pointing to the next item in the stream, an ios_base object, and the fill character. Each unique gregorian object has it's own put function. Each unique put function is described below. + + + + + + + OutItrT put(..., date) + Puts a date object into the stream using the format set by format(...) or the default. + + + + + + + OutItrT put(..., days) + Puts a days object into the stream as a number. + + + + + + + OutItrT put(..., month) + Puts a month object into the stream using the format set by month_format(...) or the default. + + + + + + + OutItrT put(..., day) + Puts a day of month object into the stream as a two digit number. + + + "01" // January 1st + + + + OutItrT put(..., day_of_week) + Puts a day of week object into the stream using the format set by weekday_format(...) or the default. + + + + + + + OutItrT put(..., date_period) + Puts a date_period into the stream. The format of the dates will use the format set by format(..) or the default date format. The type of period (open or closed range) and the delimiters used are those used by the period_formatter. + + + + + + + OutItrT put(..., partial_date) + Puts a partial_date date_generator object into the stream. The month format used is set by month_format(..) or the default. The day of month is represented as a two digit number. + + + "01 Jan" // default formats +"01 January" // long month format + + + + OutItrT put(..., date_generator) + Date Generator Type: + nth_day_of_the_week_in_month + Puts a nth_day_of_the_week_in_month object into the stream. The month format is set by month_format(...) or the default. The weekday format is set by weekday_format(...) or the default. The remaining phrase elements are set in the date_generator_formatter. + + + "third Fri in May" // defaults + + + + OutItrT put(..., date_generator) + Date Generator Type: + first_day_of_the_week_in_month + Puts a first_day_of_the_week_in_month object into the stream. The month format is set by month_format(...) or the default. The weekday format is set by weekday_format(...) or the default. The remaining phrase elements are set in the date_generator_formatter. + + + "first Wed of Jun" // defaults + + + + OutItrT put(..., date_generator) + Date Generator Type: + last_day_of_the_week_in_month + Puts a last_day_of_the_week_in_month object into the stream. The month format is set by month_format(...) or the default. The weekday format is set by weekday_format(...) or the default. The remaining phrase elements are set in the date_generator_formatter. + + + "last Tue of Mar" // defaults + + + + OutItrT put(..., date_generator) + Date Generator Type: + first_day_of_the_week_after + Puts a first_day_of_the_week_after object into the stream. The weekday format is set by weekday_format(...) or the default. The remaining phrase elements are set in the date_generator_formatter. + + + "first Sat after" // defaults + + + + OutItrT put(..., date_generator) + Date Generator Type: + first_day_of_the_week_before + Puts a first_day_of_the_week_before object into the stream. The weekday format is set by weekday_format(...) or the default. The remaining phrase elements are set in the date_generator_formatter. + + + "first Mon before" // defaults + + + + + + +
+ + diff --git a/src/boost/libs/date_time/xmldoc/date_input_facet.xml b/src/boost/libs/date_time/xmldoc/date_input_facet.xml new file mode 100644 index 000000000..3eea356c0 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_input_facet.xml @@ -0,0 +1,340 @@ + + + + + +
+ Date Input Facet + + Introduction - + Construction - + Accessors + + + Introduction + The boost::date_time::date_input_facet enables users to have significant control how dates (and other gregorian objects) are streamed in. The date_input_facet is typedef'd in the gregorian namespace as date_input_facet and wdate_input_facet. + + + + Construction + + + + + + Syntax + Description + + + + + date_input_facet() + Default constructor + + + date_input_facet(string_type format) + Format given will be used for date input. All other formats will use their defaults. + + + date_input_facet(...) + Parameters: + string_type format + format_date_parser_type + special_values_parser_type + period_parser_type + date_gen_parser_type + Format given will be used for date input. The remaining parameters are parser objects. Further details on these objects can be found here. + + + + + + + + Accessors + + + + + + Syntax + Description + + + Example + + + + + void format(char_type*) + Set the format for dates. + + + date_input_facet* f = + new date_input_facet(); +f->format("%m %d %Y"); + + + + void set_iso_format() + Sets the date format to ISO + + + f->set_iso_format(); +// "%Y%m%d" + + + + void set_iso_extended_format() + Sets the date format to ISO Extended + + + f->set_iso_extended_format(); +// "%Y-%m-%d" + + + + void month_format(char_type*) + Set the format when 'get'ing months individually. + + + f->month_format("%B"); +ss.str("March"); +ss >> m; // March + + + + void weekday_format(char_type*) + Set the format when 'get'ing weekdays individually. + + + f->weekday_format("%a"); +ss.str("Sun"); +ss >> wd; // Sunday + + + + void year_format(char_type*) + Set the format when 'get'ing years individually. + + + f->weekday_format("%y"); +ss.str("04"); +ss >> year; // 2004 + + + + void period_parser(...) + Parameter: + period_parser_type + Replaces the period parser object with a user created one. + + + see the tutorial for a complete example. + + + + void special_values_parser(...) + Parameter: + special_values_parser_type + Replaces the special_values parser object with a user created one. + + + see the tutorial for a complete example. + + + + void date_gen_phrase_strings(...) + Parameters: + input_collection_type + Sets new date generator phrase strings in date_gen_parser. The input collection is a vector of strings (for details on these strings see date generator formatter/parser documentation). + + + + + + + void short_weekday_names(...) + Parameter: + input_collection_type + Replace strings used when 'getting' short weekdays. + + + see the tutorial for a complete example. + + + + void long_weekday_names(...) + Parameter: + input_collection_type + Replace strings used when 'getting' long weekdays. + + + see the tutorial for a complete example. + + + + void short_month_names(...) + Parameter: + input_collection_type + Replace strings used when 'getting' short months. + + + see the tutorial for a complete example. + + + + void long_month_names(...) + Parameter: + input_collection_type + Replace strings used when 'getting' long months. + + + see the tutorial for a complete example. + + + + InItrT get(...) + Common parameters for all + 'get' functions: + InItrT from + InItrT to + ios_base + Unique parameter for 'get' funcs: + gregorian object + There are 13 get functions in the date_input_facet. The common parameters are: an iterator pointing to the begining of the stream, an iterator pointing to the end of the stream, and an ios_base object. Each unique gregorian object has it's own get function. Each unique get function is described below. + + + + + + + InItrT get(..., date) + Gets a date object from the stream using the format set by format(...) or the default. + + + ss.str("2005-Jan-01"); +ss >> d; // default format + + + + InItrT get(..., month) + Gets a month object from the stream using the format set by month_format(...) or the default. + + + ss.str("Feb"); +ss >> m; // default format + + + + InItrT get(..., day_of_week) + Gets a day of week object from the stream using the format set by weekday_format(...) or the default. + + + ss.str("Sun"); +ss >> dow; // default format + + + + InItrT get(..., day) + Gets a day of month object from the stream as a two digit number. + + + "01" // January 1st + + + + InItrT get(..., year) + Gets a year object from the stream as a number. The number of expected digits depends on the year format. + + + ss/str("2005"); +ss >> y; // default format + + + + InItrT get(..., days) + Gets a days object from the stream as a number. + + + ss.str("356"); +ss >> dys; // a full year + + + + InItrT get(..., date_period) + Gets a date_period from the stream. The format of the dates will use the format set by format(..) or the default date format. The type of period (open or closed range) and the delimiters used are those used by the period_parser. + + + see the tutorial for a complete example. + + + + InItrT get(..., partial_date) + Gets a partial_date date_generator object from the stream. The month format used is set by month_format(..) or the default. The day of month is represented as a two digit number. + + + "01 Jan" // default formats +"01 January" // long month format + + + + InItrT get(..., date_generator) + Date Generator Type: + nth_day_of_the_week_in_month + Gets a nth_day_of_the_week_in_month object from the stream. The month format is set by month_format(...) or the default. The weekday format is set by weekday_format(...) or the default. The remaining phrase elements are set in the date_generator_parser. + + + "third Fri in May" // defaults + + + + InItrT get(..., date_generator) + Date Generator Type: + first_day_of_the_week_in_month + Gets a first_day_of_the_week_in_month object from the stream. The month format is set by month_format(...) or the default. The weekday format is set by weekday_format(...) or the default. The remaining phrase elements are set in the date_generator_parser. + + + "first Wed of Jun" // defaults + + + + InItrT get(..., date_generator) + Date Generator Type: + last_day_of_the_week_in_month + Gets a last_day_of_the_week_in_month object from the stream. The month format is set by month_format(...) or the default. The weekday format is set by weekday_format(...) or the default. The remaining phrase elements are set in the date_generator_parser. + + + "last Tue of Mar" // defaults + + + + InItrT get(..., date_generator) + Date Generator Type: + first_day_of_the_week_after + Gets a first_day_of_the_week_after object from the stream. The weekday format is set by weekday_format(...) or the default. The remaining phrase elements are set in the date_generator_parser. + + + "first Sat after" // defaults + + + + InItrT get(..., date_generator) + Date Generator Type: + first_day_of_the_week_before + Gets a first_day_of_the_week_before object from the stream. The weekday format is set by weekday_format(...) or the default. The remaining phrase elements are set in the date_generator_parser. + + + "first Mon before" // defaults + + + + + + + +
diff --git a/src/boost/libs/date_time/xmldoc/date_iterators.xml b/src/boost/libs/date_time/xmldoc/date_iterators.xml new file mode 100644 index 000000000..fbe42674f --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_iterators.xml @@ -0,0 +1,113 @@ + + + + + +
+ Date Iterators + + Introduction -- + Header -- + Overview + + + Introduction + + Date iterators provide a standard mechanism for iteration through dates. Date iterators are a model of Bidirectional Iterator and can be used to populate collections with dates and other date generation tasks. For example, the print month example iterates through all the days in a month and prints them. + + + All of the iterators here derive from boost::gregorian::date_iterator. + + + + Header + + #include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o +or +#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types + + + + Overview + + + + + Syntax + Description + + + Example + + + + + date_iterator + Common (abstract) base class for all day level iterators. + + + + + + + day_iterator(date start_date, int day_count=1) + Iterate day_count days at a time. This iterator does not provide postfix increment/decrement operators. Only prefix operators are provided. + + + day_iterator day_itr(date(2005,Jan,1)); +++d_itr; // 2005-Jan-02 +day_iterator 2day_itr(date(2005,Feb,1),2); +++2d_itr; // 2005-Feb-03 + + + + week_iterator(...) + Parameters: + date start_date + int week_offset (defaults to 1) + Iterate week_offset weeks at a time. This iterator does not provide postfix increment/decrement operators. Only prefix operators are provided. + + + week_iterator wk_itr(date(2005,Jan,1)); +++wk_itr; // 2005-Jan-08 +week_iterator 2wk_itr(date(2005,Jan,1),2); +++2wk_itr; // 2005-Feb-15 + + + + month_iterator(...) + Parameters: + date start_date + int month_offset (defaults to 1) +Iterate month_offset months. There are special rules for handling the end of the month. These are: if start date is last day of the month, always adjust to last day of the month. If date is beyond the end of the month (e.g. Jan 31 + 1 month) adjust back to end of month (for more details and examples of this, see Reversibility of Operations Pitfall. NOTE: the month_iterator is not effected by this pitfall.) This iterator does not provide postfix increment/decrement operators. Only prefix operators are provided. + + + month_iterator m_itr(date(2005,Jan,1)); +++m_itr; // 2005-Feb-01 +month_iterator 2m_itr(date(2005,Feb,1),2); +++2m_itr; // 2005-Apr-01 + + + + year_iterator(...) + Parameters: + date start_date + int year_offset (defaults to 1) + Iterate year_offset years. The year_iterator will always land on the day of the date parameter except when date is Feb 28 in a non-leap year. In this case the iterator will return Feb 29 for leap years (eg: 2003-Feb-28, 2004-Feb-29, 2005-Feb-28). This iterator does not provide postfix increment/decrement operators. Only prefix operators are provided. + + + year_iterator y_itr(date(2005,Jan,1)); +++y_itr; // 2006-Jan-01 +year_iterator 2y_itr(date(2005,Feb,1),2); +++2y_itr; // 2007-Feb-01 + + + + + + +
diff --git a/src/boost/libs/date_time/xmldoc/date_period.xml b/src/boost/libs/date_time/xmldoc/date_period.xml new file mode 100644 index 000000000..e720e02b4 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_period.xml @@ -0,0 +1,434 @@ + + + + + +
+ Date Period + + Introduction -- + Header -- + Construction -- + Mutators -- + Accessors -- + Convert to String -- + Operators + + + Introduction + + The class boost::gregorian::date_period provides direct representation for ranges between two dates. Periods provide the ability to simplify some types of calculations by simplifying the conditional logic of the program. For example, testing if a date is within an irregular schedule such as a weekend or holiday can be accomplished using collections of date periods. This is facilitated by several methods that allow evaluation if a date_period intersects with another date period, and to generate the period resulting from the intersection. The date period calculation example provides an example of this. + + + A period that is created with beginning and end points being equal, or with a duration of zero, is known as a zero length period. Zero length periods are considered invalid (it is perfectly legal to construct an invalid period). For these periods, the last point will always be one unit less that the begin point. + + + Date periods used in combination with infinity values have the ability to represent complex concepts such as 'until further notice'. + + + + Header + + #include "boost/date_time/gregorian/gregorian.hpp" //include all types plus i/o +or +#include "boost/date_time/gregorian/gregorian_types.hpp" //no i/o just types + + + + Construction + + + + + Syntax + Description + + + Example + + + + + date_period(date, date) + Create a period as [begin, end). If end is <= begin then the period will be invalid. + + + date_period dp(date(2002,Jan,10), + date(2002,Jan,12)); + + + + date_period(date, days) + Create a period as [begin, begin+len) where end point would be begin+len. If len is <= zero then the period will be defined as invalid. + + + date_period dp(date(2002,Jan,10), + days(2)); + + + + date_period(date_period) + Copy constructor + + + date_period dp1(dp); + + + + + + + + Mutators + + + + + + Syntax + Description + + + Example + + + + + date_period shift(days) + Add duration to both begin and end. + + + + +date_period dp(date(2005,Jan,1), days(3)); +dp.shift(days(3)); +// dp == 2005-Jan-04 to 2005-Jan-07 + + + + + + date_period expand(days) + Subtract duration from begin and add duration to end. + + + + +date_period dp(date(2005,Jan,2), days(2)); +dp.expand(days(1)); +// dp == 2005-Jan-01 to 2005-Jan-04 + + + + + + + + + + + + Accessors + + + + + Syntax + Description + + + Example + + + + + date begin() + Return first day of period. + + + date_period dp(date(2002,Jan,1), + date(2002,Jan,10)); +dp.begin() --> 2002-Jan-01 + + + + + date last() + Return last date in the period + + + date_period dp(date(2002,Jan,1), + date(2002,Jan,10)); +dp.last() --> 2002-Jan-09 + + + + + date end() + Return one past the last in period + + + date_period dp(date(2002,Jan,1), + date(2002,Jan,10)); +dp.end() --> 2002-Jan-10 + + + + + days length() + Return the length of the date_period + + + date_period dp(date(2002,Jan,1), + days(2)); +dp.length() --> 2 + + + + + bool is_null() + True if period is not well formed. eg: end less than or equal to begin. + + + date_period dp(date(2002,Jan,10), + date(2002,Jan,1)); +dp.is_null() --> true + + + + + bool contains(date) + True if date is within the period. Zero length periods cannot contain any points + + + date d(2002,Jan,1); +date_period dp(d, date(2002,Jan,10)); +dp.contains(date(2002,Jan,2));// true +date_period dp2(d, d); +dp.contains(date(2002,Jan,1));// false + + + + + bool contains(date_period) + True if date period is within the period + + + date_period dp1(date(2002,Jan,1), + date(2002,Jan,10)); +date_period dp2(date(2002,Jan,2), + date(2002,Jan,3)); +dp1.contains(dp2) --> true +dp2.contains(dp1) --> false + + + + + bool intersects(date_period) + True if periods overlap + + + date_period dp1(date(2002,Jan,1), + date(2002,Jan,10)); +date_period dp2(date(2002,Jan,2), + date(2002,Jan,3)); +dp2.intersects(dp1) --> true + + + + + date_period intersection(date_period) + Calculate the intersection of 2 periods. Null if no intersection. + + + date_period dp1(date(2002,Jan,1), + date(2002,Jan,10)); +date_period dp2(date(2002,Jan,2), + date(2002,Jan,3)); +dp2.intersection(dp1) --> dp2 + + + + + date_period is_adjacent(date_period) + Check if two periods are adjacent, but not overlapping. + + + date_period dp1(date(2002,Jan,1), + date(2002,Jan,3)); +date_period dp2(date(2002,Jan,3), + date(2002,Jan,10)); +dp2.is_adjacent(dp1) --> true + + + + + date_period is_after(date) + Determine the period is after a given date. + + + date_period dp1(date(2002,Jan,10), + date(2002,Jan,30)); +date d(2002,Jan,3); +dp1.is_after(d) --> true + + + + + date_period is_before(date) + Determine the period is before a given date. + + + date_period dp1(date(2002,Jan,1), + date(2002,Jan,3)); +date d(2002,Jan,10); +dp1.is_before(d) --> true + + + + + date_period merge(date_period) + Returns union of two periods. Null if no intersection. + + + date_period dp1(date(2002,Jan,1), + date(2002,Jan,10)); +date_period dp2(date(2002,Jan,9), + date(2002,Jan,31)); +dp2.merge(dp1) +// 2002-Jan-01/2002-Jan-31 + + + + + date_period span(date_period) + Combines two periods and any gap between them such that begin = min(p1.begin, p2.begin) and end = max(p1.end , p2.end) + + + +date_period dp1(date(2002,Jan,1), + date(2002,Jan,5)); +date_period dp2(date(2002,Jan,9), + date(2002,Jan,31)); +dp2.span(dp1); // 2002-Jan-01/2002-Jan-31 + + + + + date_period shift(days) + Add duration to both begin and end. + + + date_period dp1(date(2002,Jan,1), + date(2002,Jan,10)); +dp1.shift(days(1)); +// 2002-Jan-02/2002-Jan-11 + + + + + date_period expand(days) + Subtract duration from begin and add duration to end. + + + date_period dp1(date(2002,Jan,4), + date(2002,Jan,10)); +dp1.expand(days(2)); +// 2002-Jan-02/2002-Jan-12 + + + + + + + + + Convert to String + + + + + Syntax + Description + + + Example + + + + + std::string to_simple_string(date_period dp) + To [YYYY-mmm-DD/YYYY-mmm-DD] string where mmm is 3 char month name. + + + [2002-Jan-01/2002-Jan-31] + + + + + + + + Operators + + + + + Syntax + Description + + + Example + + + + + operator<< + ostream operator for date_period. Uses facet to format time points. Typical output: [2002-Jan-01/2002-Jan-31]. + + + std::cout << dp << std::endl; + + + + operator>> + istream operator for date_period. Uses facet to parse time points. + + + "[2002-Jan-01/2002-Jan-31]" + + + + operator==, operator!=, +operator>, operator< + + A full complement of comparison operators + + + dp1 == dp2, etc + + + + operator< + True if dp1.end() less than dp2.begin() + + + dp1 < dp2, etc + + + + operator> + True if dp1.begin() greater than dp2.end() + + + dp1 > dp2, etc + + + + + +
diff --git a/src/boost/libs/date_time/xmldoc/date_time.xml b/src/boost/libs/date_time/xmldoc/date_time.xml new file mode 100644 index 000000000..6a6f69679 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_time.xml @@ -0,0 +1,70 @@ + + + + + + + Jeff + Garland + + + + 2001 + 2002 + 2003 + 2004 + 2005 + CrystalClear Software, Inc + + + + Subject to the Boost Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + + A set of facilities to ease programming with dates and times. + + + + +Boost.Date_Time + + Introduction + + + A set of date-time libraries based on generic programming concepts. + + + This documentation is also available in PDF format. It can be found at: + + + + In addition, a full doxygen reference can be found at: + + + + The most current version of the documentation can be found at: + + + + + + + + + + + + + + + + + + + + diff --git a/src/boost/libs/date_time/xmldoc/date_time_autodoc.xml b/src/boost/libs/date_time/xmldoc/date_time_autodoc.xml new file mode 100644 index 000000000..2e257d457 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_time_autodoc.xml @@ -0,0 +1,4344 @@ + +Date Time Reference
+ + +Functor to iterate a fixed number of days. date_type::duration_type + +duration_typeconst date_type & +duration_typeconst date_type & + +int +Provides calculation to find next nth month given a date. This adjustment function provides the logic for 'month-based' advancement on a ymd based calendar. The policy it uses to handle the non existant end of month days is to back up to the last day of the month. Also, if the starting date is the last day of a month, this functor will attempt to adjust to the end of the month. date_type::duration_type +date_type::calendar_type +cal_type::ymd_type +cal_type::day_type + +duration_typeconst date_type & +duration_typeconst date_type &Returns a negative duration_type. + +int +Functor to iterate a over weeks. date_type::duration_type +date_type::calendar_type + +duration_typeconst date_type & +duration_typeconst date_type & + +int +Functor to iterate by a year adjusting for leap years. date_type::duration_type + +duration_typeconst date_type & +duration_typeconst date_type & + +int + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+Time adjustment calculations based on machine + +Adjust to / from utc using the C API. Warning!!! This class assumes that timezone settings of the machine are correct. This can be a very dangerous assumption. time_type::time_duration_type +time_type::date_type +date_type::duration_type + +time_typeconst time_type &Convert a utc time to local time. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+Provide workarounds related to the ctime header + + + +Provides a uniform interface to some 'ctime' functions. Provides a uniform interface to some ctime functions and their '_r' counterparts. The '_r' functions require a pointer to a user created std::tm struct whereas the regular functions use a staticly created struct and return a pointer to that. These wrapper functions require the user to create a std::tm struct and send in a pointer to it. This struct may be used to store the resulting time. The returned pointer may or may not point to this struct, however, it will point to the result of the corresponding function. All functions do proper checking of the C function results and throw exceptions on error. Therefore the functions will never return NULL. +std::tm *const std::time_t *std::tm *requires a pointer to a user created std::tm struct +std::tm *const std::time_t *std::tm *requires a pointer to a user created std::tm struct +std::tm *const std::time_t *std::tm *requires a pointer to a user created std::tm struct +std::tm *const std::time_t *std::tm *requires a pointer to a user created std::tm struct + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+
+ + +A template to specify a constrained basic value type. This template provides a quick way to generate an integer type with a constrained range. The type provides for the ability to specify the min, max, and and error handling policy.value policies A class that provides the range limits via the min and max functions as well as a function on_error that determines how errors are handled. A common strategy would be to assert or throw and exception. The on_error is passed both the current value and the new value that is in error. value_policies::value_type + +BOOST_CXX14_CONSTEXPRCoerce into the representation type. + +value_type +BOOST_CXX14_CONSTEXPR constrained_value &value_type + +BOOST_CONSTEXPR value_type maxReturn the max allowed value (traits method) +BOOST_CONSTEXPR value_type minReturn the min allowed value (traits method) + + +voidvalue_type + +Template to shortcut the constrained_value policy creation process. exception_type +std::out_of_range + +rep_type + +BOOST_CONSTEXPR rep_type min +BOOST_CONSTEXPR rep_type max +voidrep_typerep_typeviolation_enum + +Represent a min or max violation type. + + +
+
+ + +boost::less_than_comparable< T, boost::equality_comparable< T > >Representation of timepoint at the one day level resolution. The date template represents an interface shell for a date class that is based on a year-month-day system such as the gregorian or iso systems. It provides basic operations to enable calculation and comparisons.TheoryThis date representation fundamentally departs from the C tm struct approach. The goal for this type is to provide efficient date operations (add, subtract) and storage (minimize space to represent) in a concrete class. Thus, the date uses a count internally to represent a particular date. The calendar parameter defines the policies for converting the the year-month-day and internal counted form here. Applications that need to perform heavy formatting of the same date repeatedly will perform better by using the year-month-day representation.Internally the date uses a day number to represent the date. This is a monotonic time representation. This representation allows for fast comparison as well as simplifying the creation of writing numeric operations. Essentially, the internal day number is like adjusted julian day. The adjustment is determined by the Epoch date which is represented as day 1 of the calendar. Day 0 is reserved for negative infinity so that any actual date is automatically greater than negative infinity. When a date is constructed from a date or formatted for output, the appropriate conversions are applied to create the year, month, day representations. T +calendar +calendar::date_traits_type +duration_type_ +calendar::year_type +calendar::month_type +calendar::day_type +calendar::ymd_type +calendar::date_rep_type +calendar::date_int_type +calendar::day_of_week_type + +BOOST_CXX14_CONSTEXPR year_type +BOOST_CXX14_CONSTEXPR month_type +BOOST_CXX14_CONSTEXPR day_type +BOOST_CXX14_CONSTEXPR day_of_week_type +BOOST_CXX14_CONSTEXPR ymd_type +BOOST_CONSTEXPR boolconst date_type & +BOOST_CONSTEXPR boolconst date_type & +BOOST_CONSTEXPR boolcheck to see if date is a special value +BOOST_CONSTEXPR boolcheck to see if date is not a value +BOOST_CONSTEXPR boolcheck to see if date is one of the infinity values +BOOST_CONSTEXPR boolcheck to see if date is greater than all possible dates +BOOST_CONSTEXPR boolcheck to see if date is greater than all possible dates +BOOST_CXX14_CONSTEXPR special_valuesreturn as a special value or a not_special if a normal date +BOOST_CXX14_CONSTEXPR duration_typeconst date_type & +BOOST_CXX14_CONSTEXPR date_typeconst duration_type & +BOOST_CXX14_CONSTEXPR date_typeconst duration_type & +BOOST_CONSTEXPR date_rep_type +BOOST_CXX14_CONSTEXPR date_typeconst duration_type & +BOOST_CXX14_CONSTEXPR date_typeconst duration_type & + +year_typemonth_typeday_type +const ymd_type & + + +date_int_typeThis is a private constructor which allows for the creation of new dates. It is not exposed to users since that would require class users to understand the inner workings of the date class. +date_rep_type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +A clock providing day level services based on C time_t capabilities. This clock uses Posix interfaces as its implementation and hence uses the timezone settings of the operating system. Incorrect user settings will result in incorrect results for the calls to local_day. date_type::ymd_type + +date_typeGet the local day as a date type. +date_type::ymd_typeGet the local day as a ymd_type. +date_type::ymd_typeGet the current day in universal date as a ymd_type. +date_typeGet the UTC day as a date type. + + +::std::tm *std::tm & +::std::tm *std::tm & + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +An enumeration of weekday names. +=1Simple enum to allow for nice programming with Jan, Feb, etc. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +boost::less_than_comparable1< date_duration< duration_rep_traits >, boost::equality_comparable1< date_duration< duration_rep_traits >, boost::addable1< date_duration< duration_rep_traits >, boost::subtractable1< date_duration< duration_rep_traits >, boost::dividable2< date_duration< duration_rep_traits >, int > > > > >Duration type with date level resolution. duration_rep_traits::int_type +duration_rep_traits::impl_type + +BOOST_CXX14_CONSTEXPR duration_repreturns days_ as it's instantiated type - used for streaming +BOOST_CXX14_CONSTEXPR special_values +BOOST_CXX14_CONSTEXPR bool +BOOST_CXX14_CONSTEXPR duration_rep_typereturns days as value, not object. +BOOST_CXX14_CONSTEXPR boolconst date_duration &Equality. +BOOST_CXX14_CONSTEXPR boolconst date_duration &Less. +BOOST_CXX14_CONSTEXPR date_duration &const date_duration &Subtract another duration – result is signed. +BOOST_CXX14_CONSTEXPR date_duration &const date_duration &Add a duration – result is signed. +BOOST_CXX14_CONSTEXPR date_durationunary- Allows for dd = -date_duration(2); -> dd == -2 +BOOST_CXX14_CONSTEXPR date_duration &intDivision operations on a duration with an integer. +BOOST_CXX14_CONSTEXPR boolreturn sign information + +duration_repConstruct from a day count. +special_valuesconstruct from special_values - only works when instantiated with duration_traits_adapted +const date_duration< duration_rep_traits > &Construct from another date_duration (Copy Constructor) + +BOOST_CXX14_CONSTEXPR date_durationReturns the smallest duration – used by to calculate 'end'. + +Struct for instantiating date_duration WITH special values functionality. Allows for transparent implementation of either date_duration<long> or date_duration<int_adapter<long> > long +boost::date_time::int_adapter< long > + +BOOST_CXX14_CONSTEXPR int_typeimpl_type + +Struct for instantiating date_duration with NO special values functionality. Allows for transparent implementation of either date_duration<long> or date_duration<int_adapter<long> > long +long + +BOOST_CXX14_CONSTEXPR int_typeimpl_type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +additional duration type that represents a logical month A logical month enables things like: "date(2002,Mar,2) + months(2) -> +2002-May2". If the date is a last day-of-the-month, the result will also be a last-day-of-the-month. +int_rep +BOOST_CXX14_CONSTEXPR duration_typeconst date_type &returns a negative duration +BOOST_CXX14_CONSTEXPR duration_typeconst date_type & +BOOST_CONSTEXPR boolconst months_type & +BOOST_CONSTEXPR boolconst months_type & +BOOST_CXX14_CONSTEXPR months_typeconst months_type & +BOOST_CXX14_CONSTEXPR months_type &const months_type & +BOOST_CXX14_CONSTEXPR months_typeconst months_type & +BOOST_CXX14_CONSTEXPR months_type &const months_type & +BOOST_CXX14_CONSTEXPR months_typeconst int_type +BOOST_CXX14_CONSTEXPR months_type &const int_type +BOOST_CXX14_CONSTEXPR months_typeconst int_type +BOOST_CXX14_CONSTEXPR months_type &const int_type +BOOST_CXX14_CONSTEXPR months_typeconst years_type & +BOOST_CXX14_CONSTEXPR months_type &const years_type & +BOOST_CXX14_CONSTEXPR months_typeconst years_type & +BOOST_CXX14_CONSTEXPR months_type &const years_type & + +int_rep +special_values +boost::date_time::date_duration< duration_config >Additional duration type that represents a number of n*7 days. + +typename duration_config::impl_type +special_values +additional duration type that represents a logical year A logical year enables things like: "date(2002,Mar,2) + years(2) -> +2004-Mar-2". If the date is a last day-of-the-month, the result will also be a last-day-of-the-month (ie date(2001-Feb-28) + years(3) -> 2004-Feb-29). +BOOST_CXX14_CONSTEXPR int_rep +BOOST_CXX14_CONSTEXPR duration_typeconst date_type &returns a negative duration +BOOST_CXX14_CONSTEXPR duration_typeconst date_type & +BOOST_CXX14_CONSTEXPR boolconst years_type & +boolconst years_type & +BOOST_CXX14_CONSTEXPR years_typeconst years_type & +BOOST_CXX14_CONSTEXPR years_type &const years_type & +BOOST_CXX14_CONSTEXPR years_typeconst years_type & +BOOST_CXX14_CONSTEXPR years_type &const years_type & +BOOST_CXX14_CONSTEXPR years_typeconst int_type +BOOST_CXX14_CONSTEXPR years_type &const int_type +BOOST_CXX14_CONSTEXPR years_typeconst int_type +BOOST_CXX14_CONSTEXPR years_type &const int_type +BOOST_CXX14_CONSTEXPR months_typeconst months_type & +BOOST_CXX14_CONSTEXPR months_typeconst months_type & + +int_rep +special_values +class BOOST_SYMBOL_VISIBLE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +facetClass that provides format based I/O facet for date types.This class allows the formatting of dates by using format string. Format strings are: +A => long_weekday_format - Full name Ex: Tuesday +a => short_weekday_format - Three letter abbreviation Ex: Tue +B => long_month_format - Full name Ex: October +b => short_month_format - Three letter abbreviation Ex: Oct +x => standard_format_specifier - defined by the locale +Y-b-d => default_date_format - YYYY-Mon-dd + +Default month format == b Default weekday format == a date_type::duration_type +date_type::day_of_week_type +date_type::day_type +date_type::month_type +boost::date_time::period< date_type, duration_type > +std::basic_string< CharT > +CharT +boost::date_time::period_formatter< CharT > +boost::date_time::special_values_formatter< CharT > +std::vector< std::basic_string< CharT > > +date_generator_formatter< date_type, CharT > +partial_date< date_type > +nth_kday_of_month< date_type > +first_kday_of_month< date_type > +last_kday_of_month< date_type > +first_kday_after< date_type > +first_kday_before< date_type > +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +std::locale::id + +std::locale::id &void +voidconst char_type *const +void +void +voidconst char_type *const +voidconst char_type *const +voidperiod_formatter_type +voidconst special_values_formatter_type & +voidconst input_collection_type & +voidconst input_collection_type & +voidconst input_collection_type & +voidconst input_collection_type & +voidconst input_collection_type &typename date_gen_formatter_type::phrase_elementsdate_gen_formatter_type::first +OutItrTOutItrTstd::ios_base &char_typeconst date_type & +OutItrTOutItrTstd::ios_base &char_typeconst duration_type & +OutItrTOutItrTstd::ios_base &char_typeconst month_type & +OutItrTOutItrTstd::ios_base &char_typeconst day_type &puts the day of month +OutItrTOutItrTstd::ios_base &char_typeconst day_of_week_type & +OutItrTOutItrTstd::ios_base &char_typeconst period_type & +OutItrTOutItrTstd::ios_base &char_typeconst partial_date_type & +OutItrTOutItrTstd::ios_base &char_typeconst nth_kday_type & +OutItrTOutItrTstd::ios_base &char_typeconst first_kday_type & +OutItrTOutItrTstd::ios_base &char_typeconst last_kday_type & +OutItrTOutItrTstd::ios_base &char_typeconst kday_before_type & +OutItrTOutItrTstd::ios_base &char_typeconst kday_after_type & + +::size_t0 +const char_type *const input_collection_type &::size_t0 +const char_type *period_formatter_typeperiod_formatter_type()special_values_formatter_typespecial_values_formatter_type()date_gen_formatter_typedate_gen_formatter_type()::size_t0 + +OutItrTOutItrTstd::ios_base &char_typeconst boost::date_time::special_values +OutItrTOutItrTstd::ios_base &char_typeconst tm &string_type + +facetInput facet. date_type::duration_type +date_type::day_of_week_type +date_type::day_type +date_type::month_type +date_type::year_type +boost::date_time::period< date_type, duration_type > +std::basic_string< CharT > +CharT +boost::date_time::period_parser< date_type, CharT > +boost::date_time::special_values_parser< date_type, CharT > +std::vector< std::basic_string< CharT > > +format_date_parser< date_type, CharT > +date_generator_parser< date_type, CharT > +partial_date< date_type > +nth_kday_of_month< date_type > +first_kday_of_month< date_type > +last_kday_of_month< date_type > +first_kday_after< date_type > +first_kday_before< date_type > +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +std::locale::id + +voidconst char_type *const +void +void +voidconst char_type *const +voidconst char_type *const +voidconst char_type *const +voidperiod_parser_type +voidconst input_collection_type & +voidconst input_collection_type & +voidconst input_collection_type & +voidconst input_collection_type & +voidconst input_collection_type & +voidconst string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type & +voidspecial_values_parser_type +InItrTInItrT &InItrT &std::ios_base &date_type & +InItrTInItrT &InItrT &std::ios_base &month_type & +InItrTInItrT &InItrT &std::ios_base &day_of_week_type & +InItrTInItrT &InItrT &std::ios_base &day_type &Expects 1 or 2 digit day range: 1-31. +InItrTInItrT &InItrT &std::ios_base &year_type & +InItrTInItrT &InItrT &std::ios_base &duration_type & +InItrTInItrT &InItrT &std::ios_base &period_type & +InItrTInItrT &InItrT &std::ios_base &nth_kday_type & +InItrTInItrT &InItrT &std::ios_base &partial_date_type & +InItrTInItrT &InItrT &std::ios_base &first_kday_type & +InItrTInItrT &InItrT &std::ios_base &last_kday_type & +InItrTInItrT &InItrT &std::ios_base &kday_before_type & +InItrTInItrT &InItrT &std::ios_base &kday_after_type & + +::size_t0 +const string_type &::size_t0 +const string_type &const format_date_parser_type &const special_values_parser_type &const period_parser_type &const date_gen_parser_type &::size_t0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Class to provide simple basic formatting rules. +const charT *String used printed is date is invalid. +const charT *String used to for positive infinity value. +const charT *String used to for positive infinity value. +month_format_specDescribe month format. +ymd_order_spec +boolThis format uses '-' to separate date elements. +charTChar to sep? +charTchar between year-month +charTChar to separate month-day. +charTchar between date-hours +charTchar between hour and minute +charTchar for second + +wchar_tSpecialization of formmating rules for wchar_t. +const wchar_t *String used printed is date is invalid. +const wchar_t *String used to for positive infinity value. +const wchar_t *String used to for positive infinity value. +month_format_specDescribe month format. +ymd_order_spec +boolThis format uses '-' to separate date elements. +wchar_tChar to sep? +wchar_tchar between year-month +wchar_tChar to separate month-day. +wchar_tchar between date-hours +wchar_tchar between hour and minute +wchar_tchar for second + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Convert a date to string using format policies. +std::stringdate_typeConvert to a date to standard string using format policies. +string_typedate_typeConvert to a date to standard string using format policies. + +Formats a month as as string into an ostream. +std::ostream &const month_type &std::ostream &Formats a month as as string into an ostream. This function demands that month_type provide functions for converting to short and long strings if that capability is used. +ostream_type &const month_type &ostream_type &Formats a month as as string into an ostream. This function demands that month_type provide functions for converting to short and long strings if that capability is used. + +Convert ymd to a standard string formatting policies. +std::stringymd_typeConvert ymd to a standard string formatting policies. This is standard code for handling date formatting with year-month-day based date information. This function uses the format_type to control whether the string will contain separator characters, and if so what the character will be. In addtion, it can format the month as either an integer or a string as controled by the formatting policy +std::basic_string< charT >ymd_typeConvert ymd to a standard string formatting policies. This is standard code for handling date formatting with year-month-day based date information. This function uses the format_type to control whether the string will contain separator characters, and if so what the character will be. In addtion, it can format the month as either an integer or a string as controled by the formatting policy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Convert a date to string using format policies. std::basic_ostream< charT > +date_type::ymd_type + +voidconst date_type &ostream_type &const facet_type &Put date into an ostream. +voidconst date_type &ostream_type &Put date into an ostream. + +Formats a month as as string into an ostream. facet_type::month_type +std::basic_ostream< charT > + +voidconst month_type &ostream_type &const facet_type &Formats a month as as string into an output iterator. + +Formats a weekday. facet_type::month_type +std::basic_ostream< charT > + +voidconst weekday_type &ostream_type &const facet_type &boolFormats a month as as string into an output iterator. + +Convert ymd to a standard string formatting policies. ymd_type::month_type +ostream_month_formatter< facet_type, charT > +std::basic_ostream< charT > +std::basic_string< charT > + +voidymd_typeostream_type &const facet_type &Convert ymd to a standard string formatting policies. This is standard code for handling date formatting with year-month-day based date information. This function uses the format_type to control whether the string will contain separator characters, and if so what the character will be. In addtion, it can format the month as either an integer or a string as controled by the formatting policy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Formats date_generators for output. Formatting of date_generators follows specific orders for the various types of date_generators. +partial_date => "dd Month" +nth_day_of_the_week_in_month => "nth weekday of month" +first_day_of_the_week_in_month => "first weekday of month" +last_day_of_the_week_in_month => "last weekday of month" +first_day_of_the_week_after => "weekday after" +first_day_of_the_week_before => "weekday before" While the order of the elements in these phrases cannot be changed, the elements themselves can be. Weekday and Month get their formats and names from the date_facet. The remaining elements are stored in the date_generator_formatter and can be customized upon construction or via a member function. The default elements are those shown in the examples above. + +=0 +partial_date< date_type > +nth_kday_of_month< date_type > +first_kday_of_month< date_type > +last_kday_of_month< date_type > +first_kday_after< date_type > +first_kday_before< date_type > +CharT +std::basic_string< char_type > +std::vector< string_type > +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type + +voidconst collection_type &phrase_elementsfirstReplace the set of phrase elements with those contained in new_strings. The order of the strings in the given collection is important. They must follow: +first, second, third, fourth, fifth, last, before, after, of. + +It is not necessary to send in a complete set if only a few elements are to be replaced as long as the correct beg_pos is used.Ex: To keep the default first through fifth elements, but replace the rest with a collection of: +"final", "prior", "following", "in". The beg_pos of date_generator_formatter::last would be used. + + +OutItrTOutItrTstd::ios_base &CharTconst partial_date_type &const facet_type &Put a partial_date => "dd Month". +OutItrTOutItrTstd::ios_base &CharTconst nth_kday_type &const facet_type &Put an nth_day_of_the_week_in_month => "nth weekday of month". +OutItrTOutItrTstd::ios_base &CharTconst first_kday_type &const facet_type &Put a first_day_of_the_week_in_month => "first weekday of month". +OutItrTOutItrTstd::ios_base &CharTconst last_kday_type &const facet_type &Put a last_day_of_the_week_in_month => "last weekday of month". +OutItrTOutItrTstd::ios_base &CharTconst kday_before_type &const facet_type &Put a first_day_of_the_week_before => "weekday before". +OutItrTOutItrTstd::ios_base &CharTconst kday_after_type &const facet_type &Put a first_day_of_the_week_after => "weekday after". + +Default format elements used. +const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &Constructor that allows for a custom set of phrase elements. + +OutItrTOutItrTconst string_type &helper function to put the various member string into stream + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Class for date_generator parsing. The elements of a date_generator "phrase" are parsed from the input stream in a particular order. All elements are required and the order in which they appear cannot change, however, the elements themselves can be changed. The default elements and their order are as follows: +partial_date => "dd Month" +nth_day_of_the_week_in_month => "nth weekday of month" +first_day_of_the_week_in_month => "first weekday of month" +last_day_of_the_week_in_month => "last weekday of month" +first_day_of_the_week_after => "weekday after" +first_day_of_the_week_before => "weekday before" + +Weekday and Month names and formats are handled via the date_input_facet. =0 +std::basic_string< charT > +std::istreambuf_iterator< charT > +date_type::month_type +date_type::day_of_week_type +date_type::day_type +string_parse_tree< charT > +parse_tree_type::parse_match_result_type +std::vector< std::basic_string< charT > > +partial_date< date_type > +nth_kday_of_month< date_type > +first_kday_of_month< date_type > +last_kday_of_month< date_type > +first_kday_after< date_type > +first_kday_before< date_type > +charT +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type + +voidconst string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &Replace strings that determine nth week for generator. +voidconst collection_type & +partial_date_typestream_itr_type &stream_itr_type &std::ios_base &const facet_type &returns partial_date parsed from stream +nth_kday_typestream_itr_type &stream_itr_type &std::ios_base &const facet_type &returns nth_kday_of_week parsed from stream +first_kday_typestream_itr_type &stream_itr_type &std::ios_base &const facet_type &returns first_kday_of_week parsed from stream +last_kday_typestream_itr_type &stream_itr_type &std::ios_base &const facet_type &returns last_kday_of_week parsed from stream +kday_before_typestream_itr_type &stream_itr_type &std::ios_base &const facet_type &returns first_kday_of_week parsed from stream +kday_after_typestream_itr_type &stream_itr_type &std::ios_base &const facet_type &returns first_kday_of_week parsed from stream + +Creates a date_generator_parser with the default set of "element_strings". +const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &const string_type &Creates a date_generator_parser using a user defined set of element strings. + +voidstream_itr_type &stream_itr_type &typename date_generator_parser::phrase_elementsExtracts phrase element from input. Throws ios_base::failure on error. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+Definition and implementation of date algorithm templates + +Calculate something like "First Sunday after Jan 1,2002. Date generator that takes a date and finds kday after typedef boost::date_time::first_kday_after<date> firstkdayafter; +firstkdayafter fkaf(Monday); +fkaf.get_date(date(2002,Feb,1)); + date_type::calendar_type +calendar_type::day_of_week_type +date_type::duration_type + +date_typedate_typeReturn next kday given. +day_of_week_type + +day_of_week_type +Calculate something like "First Sunday before Jan 1,2002. Date generator that takes a date and finds kday after typedef boost::date_time::first_kday_before<date> firstkdaybefore; +firstkdaybefore fkbf(Monday); +fkbf.get_date(date(2002,Feb,1)); + date_type::calendar_type +calendar_type::day_of_week_type +date_type::duration_type + +date_typedate_typeReturn next kday given. +day_of_week_type + +day_of_week_type +boost::date_time::year_based_generator< date_type >Useful generator functor for finding holidays and daylight savings. Similar to nth_kday_of_month, but requires less paramters date_type::calendar_type +calendar_type::day_of_week_type +calendar_type::month_type +calendar_type::year_type +date_type::duration_type + +date_typeyear_typeReturn a concrete date when provided with a year specific year. +month_type +day_of_week_type +std::stringReturns string suitable for use in POSIX time zone string. Returns a string formatted as "M4.1.0" ==> 1st Sunday in April. + +day_of_week_typeThe day of week, eg: Sunday, Monday, etc month_typeThe month of the year, eg: Jan, Feb, Mar, etc Specify the first 'Sunday' in 'April' spec. + +boost::date_time::year_based_generator< date_type >Calculate something like Last Sunday of January. Useful generator functor for finding holidays and daylight savings Get the last day of the month and then calculate the difference to the last previous day. +date_type::calendar_type +calendar_type::day_of_week_type +calendar_type::month_type +calendar_type::year_type +date_type::duration_type + +date_typeyear_typeReturn a concrete date when provided with a year specific year. +month_type +day_of_week_type +std::stringReturns string suitable for use in POSIX time zone string. Returns a string formatted as "M4.5.0" ==> last Sunday in April. + +day_of_week_typeThe day of week, eg: Sunday, Monday, etc month_typeThe month of the year, eg: Jan, Feb, Mar, etc Specify the date spec like last 'Sunday' in 'April' spec. + +boost::date_time::year_based_generator< date_type >Useful generator functor for finding holidays. Based on the idea in Cal. Calc. for finding holidays that are the 'first Monday of September'. When instantiated with 'fifth' kday of month, the result will be the last kday of month which can be the fourth or fifth depending on the structure of the month.The algorithm here basically guesses for the first day of the month. Then finds the first day of the correct type. That is, if the first of the month is a Tuesday and it needs Wenesday then we simply increment by a day and then we can add the length of a week until we get to the 'nth kday'. There are probably more efficient algorithms based on using a mod 7, but this one works reasonably well for basic applications. =1 +date_type::calendar_type +calendar_type::day_of_week_type +calendar_type::month_type +calendar_type::year_type +date_type::duration_type + +date_typeyear_typeReturn a concrete date when provided with a year specific year. +month_type +week_num +day_of_week_type +const char * +std::stringReturns string suitable for use in POSIX time zone string. Returns a string formatted as "M4.3.0" ==> 3rd Sunday in April. + +week_numday_of_week_typemonth_type +boost::date_time::year_based_generator< date_type >Generates a date by applying the year to the given month and day. Example usage: partial_date pd(1, Jan); +partial_date pd2(70); +date d = pd.get_date(2002); //2002-Jan-01 +date d2 = pd2.get_date(2002); //2002-Mar-10 + date_type::calendar_type +calendar_type::day_type +calendar_type::month_type +calendar_type::year_type +date_type::duration_type +duration_type::duration_rep + +date_typeyear_typeReturn a concrete date when provided with a year specific year. Will throw an 'invalid_argument' exception if a partial_date object, instantiated with Feb-29, has get_date called with a non-leap year. Example: partial_date pd(29, Feb); +pd.get_date(2003); // throws invalid_argument exception +pg.get_date(2000); // returns 2000-2-29 + +date_typeyear_type +boolconst partial_date & +boolconst partial_date & +month_type +day_type +std::stringReturns string suitable for use in POSIX time zone string. Returns string formatted with up to 3 digits: Jan-01 == "0" Feb-29 == "58" Dec-31 == "365" + +day_typemonth_type +duration_repPartial date created from number of days into year. Range 1-366. Allowable values range from 1 to 366. 1=Jan1, 366=Dec31. If argument exceeds range, partial_date will be created with closest in-range value. 60 will always be Feb29, if get_date() is called with a non-leap year an exception will be thrown +Base class for all generators that take a year and produce a date. This class is a base class for polymorphic function objects that take a year and produce a concrete date. +date_type::calendar_type +calendar_type::year_type + +date_typeyear_type +std::stringReturns a string for use in a POSIX time_zone string. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +const char *intReturns nth arg as string. 1 -> "first", 2 -> "second", max is 5. +date_type::duration_typeconst date_type &const weekday_type &Calculates the number of days until the next weekday. Calculates the number of days until the next weekday. If the date given falls on a Sunday and the given weekday is Tuesday the result will be 2 days +date_type::duration_typeconst date_type &const weekday_type &Calculates the number of days since the previous weekday. Calculates the number of days since the previous weekday If the date given falls on a Sunday and the given weekday is Tuesday the result will be 5 days. The answer will be a positive number because Tuesday is 5 days before Sunday, not -5 days before. +date_typeconst date_type &const weekday_type &Generates a date object representing the date of the following weekday from the given date. Generates a date object representing the date of the following weekday from the given date. If the date given is 2004-May-9 (a Sunday) and the given weekday is Tuesday then the resulting date will be 2004-May-11. +date_typeconst date_type &const weekday_type &Generates a date object representing the date of the previous weekday from the given date. Generates a date object representing the date of the previous weekday from the given date. If the date given is 2004-May-9 (a Sunday) and the given weekday is Tuesday then the resulting date will be 2004-May-4. + + +
+
+ + +boost::date_time::date_itr_base< date_type >Overrides the base date iterator providing hook for functors. date_type::duration_type + + +date_typeint1 + +duration_typeconst date_type & +duration_typeconst date_type & + +Base date iterator type. This class provides the skeleton for the creation of iterators. New and interesting interators can be created by plugging in a new function that derives the next value from the current state. generation of various types of -based information.Template Parametersdate_typeThe date_type is a concrete date_type. The date_type must define a duration_type and a calendar_type. date_type::duration_type +date_type +std::input_iterator_tag + +date_itr_base & +date_itr_base & +duration_typeconst date_type & +duration_typeconst date_type & +date_type +date_type * +boolconst date_type & +boolconst date_type & +boolconst date_type & +boolconst date_type & +boolconst date_type & +boolconst date_type & + +date_type + +An iterator over dates with varying resolution (day, week, month, year, etc) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +boost::date_time::date_names_put< Config, charT, OutputIterator >A date name output facet that takes an array of char* to define strings. OutputIterator +Config::month_enum +Config::weekday_enum +Config::special_value_enum + +const charT *const * +const charT *const * +const charT *const * +const charT *const * +const charT *const * + +const charT *constconst charT *constconst charT *constconst charT *constconst charT *constcharT'-'ymd_order_specymd_order_isomonth_format_specmonth_as_short_string + +voiditer_type &month_enumGeneric facet that takes array of chars. +voiditer_type &month_enumLong month names. +voiditer_type &special_value_enumSpecial values names. +voiditer_type &weekday_enum +voiditer_type &weekday_enum +voiditer_type &char between year-month +voiditer_type &Char to separate month-day. +ymd_order_specSet the date ordering. +month_format_specSet the date ordering. + +facetOutput facet base class for gregorian dates. This class is a base class for date facets used to localize the names of months and the names of days in the week.Requirements of Config +define an enumeration month_enum that enumerates the months. The enumeration should be '1' based eg: Jan==1 +define as_short_string and as_long_string + +(see langer & kreft p334). OutputIterator +Config::month_type +Config::month_enum +Config::weekday_enum +Config::special_value_enum +std::basic_string< charT > +charT +const char_type +const char_type +std::locale::idGenerate storage location for a std::locale::id. + +std::locale::id &void +voiditer_type &special_value_enum +voiditer_type &month_enum +voiditer_type &month_enum +voiditer_type &weekday_enum +voiditer_type &weekday_enum +bool +voiditer_type & +voiditer_type &char between year-month +voiditer_type &Char to separate month-day. +ymd_order_specDetermines the order to put the date elements. +month_format_specDetermines if month is displayed as integer, short or long string. + + + +voiditer_type &month_enumDefault facet implementation uses month_type defaults. +voiditer_type &month_enumDefault facet implementation uses month_type defaults. +voiditer_type &special_value_enumDefault facet implementation for special value types. +voiditer_type &weekday_enum +voiditer_type &weekday_enum +bool +voiditer_type & +voiditer_type &char between year-month +voiditer_type &Char to separate month-day. +ymd_order_specDefault for date order. +month_format_specDefault month format. +voiditer_type &const charT *const +voiditer_type &const string_type & + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + +std::stringstd::stringA function to replace the std::transform( , , ,tolower) construct. This function simply takes a string, and changes all the characters in that string to lowercase (according to the default system locale). In the event that a compiler does not support locales, the old C style tolower() is used. +unsigned shortstd::string const &Helper function for parse_date. +date_typeconst std::string &intymd_order_isoGeneric function to parse a delimited date (eg: 2002-02-10) Accepted formats are: "2003-02-10" or " 2003-Feb-10" or "2003-Feburary-10" The order in which the Month, Day, & Year appear in the argument string can be accomodated by passing in the appropriate ymd_order_spec +date_typeconst std::string &Generic function to parse undelimited date (eg: 20020201) +date_typeiterator_type &iterator_type const &charHelper function for 'date gregorian::from_stream()'. Creates a string from the iterators that reference the begining & end of a char[] or string. All elements are used in output string +date_typeiterator_type &iterator_type const &std::string const &Helper function for 'date gregorian::from_stream()'. Returns the first string found in the stream referenced by the begining & end iterators +date_typeiterator_type &iterator_type const &wchar_tHelper function for 'date gregorian::from_stream()'. Creates a string from the iterators that reference the begining & end of a wstring. All elements are used in output string +date_typeiterator_type &iterator_type const &std::wstring const &Helper function for 'date gregorian::from_stream()'. Creates a string from the first wstring found in the stream referenced by the begining & end iterators +period< date_type, typename date_type::duration_type >const std::basic_string< charT > &function called by wrapper functions: date_period_from_(w)string() + + + + + + + +
+
+Contains template class to provide static dst rule calculations + +Compile-time configurable daylight savings time calculation engine. date_type::year_type +date_type::calendar_type +dst_calculator< date_type, time_duration_type > + +time_is_dst_resultconst date_type &const time_duration_type &Calculates if the given local time is dst or not. Determines if the time is really in DST or not. Also checks for invalid and ambiguous. + +booldate_type +time_duration_typeThe time of day for the dst transition (eg: typically 01:00:00 or 02:00:00) +date_typeyear_type +date_typeyear_type + +Dynamic class used to caluclate dst transition information. time_duration_type_ +date_type_ + +time_is_dst_resultconst time_duration_type &Time offset in the day for the local time unsigned intLocal day offset for start of dst longNumber of minutes to adjust clock forward Check the local time offset when on dst start day. On this dst transition, the time label between the transition boundary and the boudary + the offset are invalid times. If before the boundary then still not in dst. + + +time_is_dst_resultconst time_duration_type &Time offset in the day for the local time unsigned intLocal time of day for end of dst longCheck the local time offset when on the last day of dst. This is the calculation for the DST end day. On that day times prior to the conversion time - dst_length (1 am in US) are still in dst. Times between the above and the switch time are ambiguous. Times after the start_offset are not in dst. + + +time_is_dst_resultconst date_type &The day to check for dst const time_duration_type &Time offset within the day to check const date_type &Starting day of dst for the given locality const time_duration_type &Time offset within day for dst boundary const date_type &Ending day of dst for the given locality const time_duration_type &Time offset within day given in dst for dst boundary const time_duration_type &Calculates if the given local time is dst or not. Determines if the time is really in DST or not. Also checks for invalid and ambiguous. + + +time_is_dst_resultconst date_type &The day to check for dst const time_duration_type &Time offset within the day to check const date_type &Starting day of dst for the given locality unsigned intOffset within day for dst boundary (eg 120 for US which is 02:00:00) const date_type &Ending day of dst for the given locality unsigned intOffset within day given in dst for dst boundary (eg 120 for US which is 02:00:00) longLength of dst adjusment (eg: 60 for US) Calculates if the given local time is dst or not. Determines if the time is really in DST or not. Also checks for invalid and ambiguous. + + + +Used for local time adjustments in places that don't use dst. time_duration_type_ +date_type_ + +time_is_dst_resultconst date_type &const time_duration_type &Calculates if the given local time is dst or not. + +time_is_dst_resultconst date_type &const time_duration_type &Calculates if the given utc time is in dst. +booldate_type +time_duration_type + +Depricated: Class to calculate dst boundaries for US time zones. time_duration_type_ +date_type_ +date_type::year_type +date_type::calendar_type +date_time::last_kday_of_month< date_type > +date_time::first_kday_of_month< date_type > +date_time::nth_kday_of_month< date_type > +dst_calculator< date_type, time_duration_type > + +time_is_dst_resultconst date_type &const time_duration_type &Calculates if the given local time is dst or not. Determines if the time is really in DST or not. Also checks for invalid and ambiguous. + +booldate_type +date_typeyear_type +date_typeyear_type +time_duration_type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +boost::date_time::dst_day_calc_rule< spec::date_type >Canonical form for a class that provides day rule calculation. This class is used to generate specific sets of dst rules +spec::date_type +date_type::year_type +spec::start_rule +spec::end_rule + +date_typeyear_type +std::string +date_typeyear_type +std::string + +start_ruleend_rule +Defines base interface for calculating start and end date of daylight savings. date_type::year_type + +date_typeyear_type +std::string +date_typeyear_type +std::string + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+Function(s) for converting between a FILETIME structure and a time object. This file is only available on systems that have BOOST_HAS_FTIME defined. + + + + + + + + + + + + + + + + + + + +TimeTconst FileTimeT &Create a time object from an initialized FILETIME struct. Create a time object from an initialized FILETIME struct. A FILETIME struct holds 100-nanosecond units (0.0000001). When built with microsecond resolution the file_time's sub second value will be truncated. Nanosecond resolution has no truncation.The function is templated on the FILETIME type, so that it can be used with both native FILETIME and the ad-hoc boost::detail::winapi::FILETIME_ type. + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + +shortconst charT *const *const charT *const *shortconst std::basic_string< charT > &Find index of a string in either of 2 arrays. find_match searches both arrays for a match to 's'. Both arrays must contain 'size' elements. The index of the match is returned. If no match is found, 'size' is returned. Ex. "Jan" returns 0, "Dec" returns 11, "Tue" returns 2. 'size' can be sent in with: (greg_month::max)() (which 12), (greg_weekday::max)() + 1 (which is 7) or date_time::NumSpecialValues + + + + + + + + + + + + + + + + + +
+
+ + + + +Class with generic date parsing using a format string. The following is the set of recognized format specifiers +a - Short weekday name +A - Long weekday name +b - Abbreviated month name +B - Full month name +d - Day of the month as decimal 01 to 31 +j - Day of year as decimal from 001 to 366 +m - Month name as a decimal 01 to 12 +U - Week number 00 to 53 with first Sunday as the first day of week 1? +w - Weekday as decimal number 0 to 6 where Sunday == 0 +W - Week number 00 to 53 where Monday is first day of week 1 +x - facet default date representation +y - Year without the century - eg: 04 for 2004 +Y - Year with century + +The weekday specifiers (a and A) do not add to the date construction, but they provide a way to skip over the weekday names for formats that provide them.todo – Another interesting feature that this approach could provide is an option to fill in any missing fields with the current values from the clock. So if you have m-d the parser would detect the missing year value and fill it in using the clock.todo – What to do with the x. x in the classic facet is just bad... std::basic_string< charT > +std::basic_istringstream< charT > +std::istreambuf_iterator< charT > +string_type::const_iterator +date_type::year_type +date_type::month_type +date_type::day_type +date_type::duration_type +date_type::day_of_week_type +date_type::day_of_year_type +string_parse_tree< charT > +parse_tree_type::parse_match_result_type +std::vector< std::basic_string< charT > > + +string_type +voidstring_type +voidconst input_collection_type & +voidconst input_collection_type & +voidconst input_collection_type & +voidconst input_collection_type & +date_typeconst string_type &const string_type &const special_values_parser< date_type, charT > & +date_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &const special_values_parser< date_type, charT > & +date_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &string_typeconst special_values_parser< date_type, charT > &Of all the objects that the format_date_parser can parse, only a date can be a special value. Therefore, only parse_date checks for special_values. +month_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &string_typeThrows bad_month if unable to parse. +month_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &string_typematch_results &Throws bad_month if unable to parse. +day_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &Expects 1 or 2 digits 1-31. Throws bad_day_of_month if unable to parse. +day_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &Expects 2 digits 01-31. Throws bad_day_of_month if unable to parse. +day_of_week_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &string_type +day_of_week_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &string_typematch_results & +year_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &string_typethrows bad_year if unable to parse +year_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &string_typematch_results &throws bad_year if unable to parse + +const string_type &const input_collection_type &const input_collection_type &const input_collection_type &const input_collection_type & +const string_type &const std::locale & +const format_date_parser< date_type, charT > & + + + + + + + + + + + + + + +int_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &parse_match_result< charT > &unsigned intconst charT &Helper function for parsing fixed length strings into integers. Will consume 'length' number of characters from stream. Consumed character are transfered to parse_match_result struct. Returns '-1' if no number can be parsed or incorrect number of digits in stream. +int_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &parse_match_result< charT > &unsigned intHelper function for parsing fixed length strings into integers. Will consume 'length' number of characters from stream. Consumed character are transfered to parse_match_result struct. Returns '-1' if no number can be parsed or incorrect number of digits in stream. +int_typestd::istreambuf_iterator< charT > &const std::istreambuf_iterator< charT > &unsigned intHelper function for parsing varied length strings into integers. Will consume 'max_length' characters from stream only if those characters are digits. Returns '-1' if no number can be parsed. Will not parse a number preceeded by a '+' or '-'. + + + + + + + + + + + + + + + + + + +
+
+ + +An implementation of the Gregorian calendar. This is a parameterized implementation of a proleptic Gregorian Calendar that can be used in the creation of date systems or just to perform calculations. All the methods of this class are static functions, so the intent is to never create instances of this class. +define a type a date split into components ymd_type_ +define a type for representing months ymd_type::month_type +define a type for representing days ymd_type::day_type +Type to hold a stand alone year value (eg: 2002) ymd_type::year_type +Define the integer type to use for internal calculations. date_int_type_ + +BOOST_CXX14_CONSTEXPR unsigned shortconst ymd_type & +BOOST_CXX14_CONSTEXPR intconst ymd_type & +BOOST_CXX14_CONSTEXPR date_int_typeconst ymd_type & +BOOST_CXX14_CONSTEXPR date_int_typeconst ymd_type & +BOOST_CXX14_CONSTEXPR date_int_typeconst ymd_type & +BOOST_CXX14_CONSTEXPR ymd_typedate_int_type +BOOST_CXX14_CONSTEXPR ymd_typedate_int_type +BOOST_CXX14_CONSTEXPR ymd_typedate_int_type +BOOST_CXX14_CONSTEXPR boolyear_type +BOOST_CXX14_CONSTEXPR unsigned shortyear_typemonth_type +BOOST_CXX14_CONSTEXPR ymd_type +BOOST_CXX14_CONSTEXPR unsigned short + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Adapter to create integer types with +-infinity, and not a value. This class is used internally in counted date/time representations. It adds the floating point like features of infinities and not a number. It also provides mathmatical operations with consideration to special values following these rules: +infinity - infinity == Not A Number (NAN) + infinity * non-zero == infinity + infinity * zero == NAN ++infinity * -integer == -infinity + infinity / infinity == NAN + infinity * infinity == infinity + int_type_ + +BOOST_CONSTEXPR bool +BOOST_CONSTEXPR bool +BOOST_CONSTEXPR bool +BOOST_CONSTEXPR bool +BOOST_CONSTEXPR bool +BOOST_CONSTEXPR boolconst int_adapter & +BOOST_CXX14_CONSTEXPR boolconst int & +BOOST_CONSTEXPR boolconst int_adapter & +BOOST_CXX14_CONSTEXPR boolconst int & +BOOST_CONSTEXPR boolconst int_adapter & +BOOST_CXX14_CONSTEXPR boolconst int & +BOOST_CONSTEXPR boolconst int_adapter & +BOOST_CONSTEXPR int_type +BOOST_CONSTEXPR special_valuesReturns either special value type or is_not_special. +BOOST_CXX14_CONSTEXPR int_adapterconst int_adapter< rhs_type > &Operator allows for adding dissimilar int_adapter types. The return type will match that of the the calling object's type +BOOST_CXX14_CONSTEXPR int_adapterconst int_type +BOOST_CXX14_CONSTEXPR int_adapterconst int_adapter< rhs_type > &Operator allows for subtracting dissimilar int_adapter types. The return type will match that of the the calling object's type +BOOST_CXX14_CONSTEXPR int_adapterconst int_type +BOOST_CXX14_CONSTEXPR int_adapterconst int_adapter & +BOOST_CXX14_CONSTEXPR int_adapterconst intProvided for cases when automatic conversion from 'int' to 'int_adapter' causes incorrect results. +BOOST_CXX14_CONSTEXPR int_adapterconst int_adapter & +BOOST_CXX14_CONSTEXPR int_adapterconst intProvided for cases when automatic conversion from 'int' to 'int_adapter' causes incorrect results. +BOOST_CXX14_CONSTEXPR int_adapterconst int_adapter & +BOOST_CXX14_CONSTEXPR int_adapterconst intProvided for cases when automatic conversion from 'int' to 'int_adapter' causes incorrect results. + +int_type + +BOOST_CONSTEXPR bool +BOOST_CONSTEXPR int_adapter +BOOST_CONSTEXPR int_adapter +BOOST_CONSTEXPR int_adapter +BOOST_CONSTEXPR int_adapter max +BOOST_CONSTEXPR int_adapter min +BOOST_CXX14_CONSTEXPR int_adapterspecial_values +BOOST_CONSTEXPR boolint_type +BOOST_CXX14_CONSTEXPR boolint_type +BOOST_CXX14_CONSTEXPR boolint_type +BOOST_CXX14_CONSTEXPR boolint_type +BOOST_CXX14_CONSTEXPR special_valuesint_typeReturns either special value type or is_not_special. +BOOST_CONSTEXPR int_type + + +BOOST_CXX14_CONSTEXPR intconst int_adapter &returns -1, 0, 1, or 2 if 'this' is <, ==, >, or 'nan comparison' rhs +BOOST_CXX14_CONSTEXPR int_adapterconst int_adapter &Assumes at least 'this' or 'rhs' is a special value. +BOOST_CXX14_CONSTEXPR int_adapterconst int &Assumes 'this' is a special value. + + + + + + + + + + + + + + +std::basic_ostream< charT, traits > &std::basic_ostream< charT, traits > &const int_adapter< int_type > &Expected output is either a numeric representation or a special values representation. + Ex. "12", "+infinity", "not-a-number", etc. + + + + + + + + + + + + + + + + + + + + + +
+
+ + +boost::date_time::iso_format_base< charT >Extended format uses seperators YYYY-MM-DD. +boolExtended format needs char separators. + +boost::date_time::iso_format_base< charT >Format description for iso normal YYYYMMDD. +boolThe ios standard format doesn't use char separators. + +Class to provide common iso formatting spec. +month_format_specDescribe month format – its an integer in iso format. +const charT *String used printed is date is invalid. +const charT *String used to for positive infinity value. +const charT *String used to for positive infinity value. +charTISO char for a year – used in durations. +charTISO char for a month. +charTISO char for a day. +charTchar for minute +charTchar for minute +charTchar for second +charTISO char for a period. +charTUsed in time in mixed strings to set start of time. +charTUsed in mixed strings to identify start of a week number. +charTSeparators for periods. +charTSeparator for hh:mm:ss. +charTPreferred Separator for hh:mm:ss,decimal_fraction. +boolcharT +boolcharT +boolcharT +charT + +wchar_tClass to provide common iso formatting spec. +month_format_specDescribe month format – its an integer in iso format. +const wchar_t *String used printed is date is invalid. +const wchar_t *String used to for positive infinity value. +const wchar_t *String used to for positive infinity value. +wchar_tISO char for a year – used in durations. +wchar_tISO char for a month. +wchar_tISO char for a day. +wchar_tchar for minute +wchar_tchar for minute +wchar_tchar for second +wchar_tISO char for a period. +wchar_tUsed in time in mixed strings to set start of time. +wchar_tUsed in mixed strings to identify start of a week number. +wchar_tSeparators for periods. +wchar_tSeparator for hh:mm:ss. +wchar_tPreferred Separator for hh:mm:ss,decimal_fraction. +boolwchar_t +boolwchar_t +boolwchar_t +wchar_t + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+Time adjustment calculations for local times + +dst_rulesAllow sliding utc adjustment with fixed dst rules. time_type::time_duration_type +time_type::date_type + +time_duration_typeboolPresumes local time. + +time_duration_type +Template that simplifies the creation of local time calculator. Use this template to create the timezone to utc convertors as required.This class will also work for other regions that don't use dst and have a utc offset which is an integral number of hours.Template Parameters -time_type – Time class to use -utc_offset – Number hours local time is adjust from utc -use_dst – true (default) if region uses dst, false otherwise For example: //eastern timezone is utc-5 +typedef date_time::local_adjustor<ptime, -5, us_dst> us_eastern; +typedef date_time::local_adjustor<ptime, -6, us_dst> us_central; +typedef date_time::local_adjustor<ptime, -7, us_dst> us_mountain; +typedef date_time::local_adjustor<ptime, -8, us_dst> us_pacific; +typedef date_time::local_adjustor<ptime, -7, no_dst> us_arizona; + time_type::time_duration_type +time_type::date_type +static_local_time_adjustor< time_type, dst_rule, utc_adjustment< time_duration_type, utc_offset > > + +time_typeconst time_type &Convert a utc time to local time. +time_typeconst time_type &date_time::dst_flagsdate_time::calculateConvert a local time to utc. + +dst_rulesutc_offset_rulesEmbed the rules for local time adjustments at compile time. time_type::time_duration_type +time_type::date_type + +time_duration_typeconst time_type &UTC time to calculate offset to local time This adjustment depends on the following observations about the workings of the DST boundary offset. Since UTC time labels are monotonically increasing we can determine if a given local time is in DST or not and therefore adjust the offset appropriately.Calculates the offset from a utc time to local based on dst and utc offset. +The logic is as follows. Starting with UTC time use the offset to create a label for an non-dst adjusted local time. Then call dst_rules::local_is_dst with the non adjust local time. The results of this function will either unabiguously decide that the initial local time is in dst or return an illegal or ambiguous result. An illegal result only occurs at the end of dst (where labels are skipped) and indicates that dst has ended. An ambiguous result means that we need to recheck by making a dst adjustment and then rechecking. If the dst offset is added to the utc time and the recheck proves non-ambiguous then we are past the boundary. If it is still ambiguous then we are ahead of the boundary and dst is still in effect.TODO – check if all dst offsets are positive. If not then the algorithm needs to check for this and reverse the illegal/ambiguous logic. +time_duration_typeconst time_type &date_time::dst_flagsdate_time::calculateGet the offset to UTC given a local time. + +Provides a base offset adjustment from utc. +time_duration_type +time_duration_type + + + + + + + + + + + + + +void + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +date_type::day_of_week_type +date_type::month_type +date_type::year_type +date_time::last_kday_of_month< date_type > +date_time::last_kday_of_month< date_type > + +day_of_week_typeyear_type +month_typeyear_type +day_of_week_typeyear_type +month_typeyear_type +int +int +int +date_typeyear_type +date_typeyear_type + +Rules for daylight savings start in the EU (Last Sun in Mar) These amount to the following: +Start of dst day is last Sunday in March +End day of dst is last Sunday in Oct +Going forward switch time is 2:00 am (offset 120 minutes) +Going back switch time is 3:00 am (off set 180 minutes) +Shift duration is one hour (60 minutes) + +date_type::day_of_week_type +date_type::month_type +date_type::year_type +date_time::last_kday_of_month< date_type > +date_time::last_kday_of_month< date_type > + +day_of_week_typeyear_type +month_typeyear_type +day_of_week_typeyear_type +month_typeyear_type +int +int +int +date_typeyear_type +date_typeyear_type + +boost::date_time::eu_dst_trait< date_type >Alternative dst traits for some parts of the United Kingdom. +int +int +int + +Specification for daylight savings start rules in US. This class is used to configure dst_calc_engine template typically as follows: using namespace boost::gregorian; +using namespace boost::posix_time; +typedef us_dst_trait<date> us_dst_traits; +typedef boost::date_time::dst_calc_engine<date, time_duration, + us_dst_traits> + us_dst_calc; +//calculate the 2002 transition day of USA April 7 2002 +date dst_start = us_dst_calc::local_dst_start_day(2002); + +//calculate the 2002 transition day of USA Oct 27 2002 +date dst_end = us_dst_calc::local_dst_end_day(2002); + +//check if a local time is in dst or not -- posible answers +//are yes, no, invalid time label, ambiguous +ptime t(...some time...); +if (us_dst::local_is_dst(t.date(), t.time_of_day()) + == boost::date_time::is_not_in_dst) +{ + +} + This generates a type suitable for the calculation of dst transitions for the United States. Of course other templates can be used for other locales. date_type::day_of_week_type +date_type::month_type +date_type::year_type +date_time::nth_kday_of_month< date_type > +date_time::first_kday_of_month< date_type > +date_time::first_kday_of_month< date_type > +date_time::last_kday_of_month< date_type > + +day_of_week_typeyear_type +month_typeyear_type +day_of_week_typeyear_type +month_typeyear_type +date_typeyear_type +date_typeyear_type +int +int +int + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+This file contains a high resolution time clock implementation. + +A clock providing microsecond level resolution. A high precision clock that measures the local time at a resolution up to microseconds and adjusts to the resolution of the time system. For example, for the a library configuration with nano second resolution, the last 3 places of the fractional seconds will always be 000 since there are 1000 nano-seconds in a micro second. time_type::date_type +time_type::time_duration_type +time_duration_type::rep_type + +time_typeshared_ptr< time_zone_type >return a local time object for the given zone, based on computer clock +time_typeReturns the local time based on computer clock settings. +time_typeReturns the UTC time based on computer settings. + + +time_typetime_converter +boost::uint64_tboost::winapi::FILETIME_ const &The function converts file_time into number of microseconds elapsed since 1970-Jan-01Only dates after 1970-Jan-01 are supported. Dates before will be wrapped. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Enum for distinguishing parsing and formatting options. +Enum for distinguishing the order of Month, Day, & Year. Enum for distinguishing the order in which Month, Day, & Year will appear in a date string + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+This file contain the implementation of the period abstraction. This is basically the same idea as a range. Although this class is intended for use in the time library, it is pretty close to general enough for other numeric uses. + +boost::less_than_comparable< period< point_rep, duration_rep >, boost::equality_comparable< period< point_rep, duration_rep > > >Provides generalized period type useful in date-time systems. This template uses a class to represent a time point within the period and another class to represent a duration. As a result, this class is not appropriate for use when the number and duration representation are the same (eg: in the regular number domain).A period can be specified by providing either the begining point and a duration or the begining point and the end point( end is NOT part of the period but 1 unit past it. A period will be "invalid" if either end_point <= begin_point or the given duration is <= 0. Any valid period will return false for is_null().Zero length periods are also considered invalid. Zero length periods are periods where the begining and end points are the same, or, the given duration is zero. For a zero length period, the last point will be one unit less than the begining point.In the case that the begin and last are the same, the period has a length of one unit.The best way to handle periods is usually to provide a begining point and a duration. So, day1 + 7 days is a week period which includes all of the first day and 6 more days (eg: Sun to Sat). point_rep +duration_rep + +BOOST_CXX14_CONSTEXPR point_repReturn the first element in the period. +BOOST_CXX14_CONSTEXPR point_repReturn one past the last element. +BOOST_CXX14_CONSTEXPR point_repReturn the last item in the period. +BOOST_CXX14_CONSTEXPR duration_repReturn the length of the period. +BOOST_CXX14_CONSTEXPR boolTrue if period is ill formed (length is zero or less) +BOOST_CXX14_CONSTEXPR boolconst period &Equality operator. +BOOST_CXX14_CONSTEXPR boolconst period &Strict as defined by rhs.last <= lhs.last. +BOOST_CXX14_CONSTEXPR voidconst duration_rep &Shift the start and end by the specified amount. +BOOST_CXX14_CONSTEXPR voidconst duration_rep &Expands the size of the period by the duration on both ends.So before expand [-------] +^ ^ ^ ^ ^ ^ ^ +1 2 3 4 5 6 7 + After expand(2) [----------------------] +^ ^ ^ ^ ^ ^ ^ +1 2 3 4 5 6 7 + +BOOST_CXX14_CONSTEXPR boolconst point_rep &True if the point is inside the period, zero length periods contain no points. +BOOST_CXX14_CONSTEXPR boolconst period &True if this period fully contains (or equals) the other period. +BOOST_CXX14_CONSTEXPR boolconst period &True if the periods overlap in any way. +BOOST_CXX14_CONSTEXPR boolconst period &True if periods are next to each other without a gap. +BOOST_CXX14_CONSTEXPR boolconst point_rep &True if all of the period is prior to the passed point or end <= t. +BOOST_CXX14_CONSTEXPR boolconst point_rep &True if all of the period is prior or t < start. +BOOST_CXX14_CONSTEXPR periodconst period &Returns the period of intersection or invalid range no intersection. +BOOST_CXX14_CONSTEXPR periodconst period &Returns the union of intersecting periods – or null period. +BOOST_CXX14_CONSTEXPR periodconst period &Combine two periods with earliest start and latest end. Combines two periods and any gap between them such that start = min(p1.start, p2.start) end = max(p1.end , p2.end) [---p1---) + [---p2---) +result: + [-----------p3----------) + + +point_reppoint_repcreate a period from begin to last eg: [begin,end) If end <= begin then the period will be invalid +point_repduration_repcreate a period as [begin, begin+len) If len is <= 0 then the period will be invalid + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Not a facet, but a class used to specify and control period formats. Provides settings for the following: +period_separator – default '/' +period_open_start_delimeter – default '[' +period_open_range_end_delimeter – default ')' +period_closed_range_end_delimeter – default ']' +display_as_open_range, display_as_closed_range – default closed_range + +Thus the default formatting for a period is as follows: [period.start()/period.last()] + So for a typical date_period this would be [2004-Jan-04/2004-Feb-01] + where the date formatting is controlled by the date facet +std::basic_string< CharT > +CharT +std::basic_string< char_type >::const_iterator +std::vector< std::basic_string< CharT > > +const char_type +const char_type +const char_type +const char_type + +OutItrTOutItrT &Puts the characters between period elements into stream – default is /. +OutItrTOutItrT &Puts the period start characters into stream – default is [. +OutItrTOutItrT &Puts the period end characters into stream as controled by open/closed range setting. +range_display_options +voidrange_display_optionsReset the range_option control. +voidconst string_type &const string_type &const string_type &const string_type &Change the delimiter strings. +OutItrTOutItrTstd::ios_base &char_typeconst period_type &const facet_type &Generic code to output a period – no matter the period type. This generic code will output any period using a facet to to output the 'elements'. For example, in the case of a date_period the elements will be instances of a date which will be formatted according the to setup in the passed facet parameter.The steps for formatting a period are always the same: +put the start delimiter +put start element +put the separator +put either last or end element depending on range settings +put end delimeter depending on range settings + +Thus for a typical date period the result might look like this: [March 01, 2004/June 07, 2004] <-- closed range +[March 01, 2004/June 08, 2004) <-- open range + + +range_display_optionsAS_CLOSED_RANGEconst char_type *constdefault_period_separatorconst char_type *constdefault_period_start_delimeterconst char_type *constdefault_period_open_range_end_delimeterconst char_type *constdefault_period_closed_range_end_delimeterConstructor that sets up period formatter options – default should suffice most cases. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Not a facet, but a class used to specify and control period parsing. Provides settings for the following: +period_separator – default '/' +period_open_start_delimeter – default '[' +period_open_range_end_delimeter – default ')' +period_closed_range_end_delimeter – default ']' +display_as_open_range, display_as_closed_range – default closed_range + +For a typical date_period, the contents of the input stream would be [2004-Jan-04/2004-Feb-01] + where the date format is controlled by the date facet +std::basic_string< CharT > +CharT +std::istreambuf_iterator< CharT > +string_parse_tree< CharT > +parse_tree_type::parse_match_result_type +std::vector< std::basic_string< CharT > > +const char_type +const char_type +const char_type +const char_type + +period_range_option +voidperiod_range_option +collection_type +voidconst string_type &const string_type &const string_type &const string_type & +period_typestream_itr_type &stream_itr_type &std::ios_base &const period_type &const duration_type &const facet_type &Generic code to parse a period – no matter the period type. This generic code will parse any period using a facet to to get the 'elements'. For example, in the case of a date_period the elements will be instances of a date which will be parsed according the to setup in the passed facet parameter.The steps for parsing a period are always the same: +consume the start delimiter +get start element +consume the separator +get either last or end element depending on range settings +consume the end delimeter depending on range settings + +Thus for a typical date period the contents of the input stream might look like this: [March 01, 2004/June 07, 2004] <-- closed range +[March 01, 2004/June 08, 2004) <-- open range + + +period_range_optionAS_CLOSED_RANGEconst char_type *constdefault_period_separatorconst char_type *constdefault_period_start_delimeterconst char_type *constdefault_period_open_range_end_delimeterconst char_type *constdefault_period_closed_range_end_delimeterConstructor that sets up period parser options. +const period_parser< date_type, CharT > & + +voidstream_itr_type &stream_itr_type &const string_type &throws ios_base::failure if delimiter and parsed data do not match + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Class that provides generic formmatting ostream formatting for special values. This class provides for the formmating of special values to an output stream. In particular, it produces strings for the values of negative and positive infinity as well as not_a_date_time.While not a facet, this class is used by the date and time facets for formatting special value types. std::basic_string< CharT > +CharT +std::vector< string_type > +const char_typeStorage for the strings used to indicate special values. + +OutItrTOutItrTconst boost::date_time::special_values & + +Construct special values formatter using default strings. Default strings are not-a-date-time -infinity +infinity +const char_type *const *const char_type *const *Construct special values formatter from array of strings. This constructor will take pair of iterators from an array of strings that represent the special values and copy them for use in formatting special values. const char* const special_value_names[]={"nadt","-inf","+inf" }; + +special_value_formatter svf(&special_value_names[0], &special_value_names[3]); + +typename collection_type::iteratortypename collection_type::iterator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Class for special_value parsing. TODO: add doc-comments for which elements can be changed Parses input stream for strings representing special_values. Special values parsed are: +not_a_date_time +neg_infin +pod_infin +min_date_time +max_date_time + +std::basic_string< charT > +std::basic_stringstream< charT > +std::istreambuf_iterator< charT > +date_type::duration_type +string_parse_tree< charT > +parse_tree_type::parse_match_result_type +std::vector< std::basic_string< charT > > +charT +const char_type +const char_type +const char_type +const char_type +const char_type + +voidconst string_type &const string_type &const string_type &const string_type &const string_type &Replace special value strings. +boolstream_itr_type &the start iterator stream_itr_type &the end iterator match_results &the match result: mr.current_match is set to the corresponding special_value or -1 Given an input iterator, attempt to match it to a known special value + +whether something matched + + +Creates a special_values_parser with the default set of "sv_strings". +const string_type &const string_type &const string_type &const string_type &const string_type &Creates a special_values_parser using a user defined set of element strings. +typename collection_type::iteratortypename collection_type::iterator +const special_values_parser< date_type, charT > & + +boolconst string_type &the string to check The parser is expensive to create, and not thread-safe so it cannot be static therefore given a string, determine if it is likely to be a special value. A negative response is a definite no, whereas a positive is only likely and match() should be called and return value checked. + +false if it is definitely not a special value + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + +std::basic_string< OutputT >const std::basic_string< InputT > &Converts a string from one value_type to another. Converts a wstring to a string (or a string to wstring). If both template parameters are of same type, a copy of the input string is returned. + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + += -1 +std::basic_string< charT > +string_type +unsigned short +short + +string_type +charT +boolReturns true if more characters were parsed than was necessary. Should be used in conjunction with last_char() to get the remaining character. + + +Recursive data structure to allow efficient parsing of various strings. This class provides a quick lookup by building what amounts to a tree data structure. It also features a match function which can can handle nasty input interators by caching values as it recurses the tree so that it can backtrack as needed. std::multimap< charT, string_parse_tree< charT > > +std::multimap< charT, string_parse_tree > +ptree_coll::value_type +ptree_coll::iterator +ptree_coll::const_iterator +std::basic_string< charT > +std::vector< std::basic_string< charT > > +parse_match_result< charT > +ptree_coll +short + +voidconst string_type &unsigned short +shortstd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &parse_match_result_type &unsigned int &Recursive function that finds a matching string in the tree. Must check match_results::has_remaining() after match() is called. This is required so the user can determine if stream iterator is already pointing to the expected character or not (match() might advance sitr to next char in stream).A parse_match_result that has been returned from a failed match attempt can be sent in to the match function of a different string_parse_tree to attempt a match there. Use the iterators for the partially consumed stream, the parse_match_result object, and '0' for the level parameter. +parse_match_result_typestd::istreambuf_iterator< charT > &std::istreambuf_iterator< charT > &Must check match_results::has_remaining() after match() is called. This is required so the user can determine if stream iterator is already pointing to the expected character or not (match() might advance sitr to next char in stream). +voidstd::ostream &int & +voidstd::ostream & +voidstd::ostream &charT + +collection_typeunsigned int0Parameter "starting_point" designates where the numbering begins. A starting_point of zero will start the numbering at zero (Sun=0, Mon=1, ...) were a starting_point of one starts the numbering at one (Jan=1, Feb=2, ...). The default is zero, negative vaules are not allowed +shortparse_match_result_type::PARSE_ERROR + + + + + + + + + + +std::basic_ostream< charT > &std::basic_ostream< charT > &parse_match_result< charT > & + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + +std::vector< std::basic_string< charT > >const std::locale &The locale to use when gathering the strings booltrueTrue(default) to gather short strings, false for long strings. This function gathers up all the month strings from a std::locale. Using the time_put facet, this function creates a collection of all the month strings from a locale. This is handy when building custom date parsers or formatters that need to be localized. + +A vector of strings containing the strings in order. eg: Jan, Feb, Mar, etc. + +std::vector< std::basic_string< charT > >const std::locale &The locale to use when gathering the strings booltrueTrue(default) to gather short strings, false for long strings. This function gathers up all the weekday strings from a std::locale. Using the time_put facet, this function creates a collection of all the weekday strings from a locale starting with the string for 'Sunday'. This is handy when building custom date parsers or formatters that need to be localized. + +A vector of strings containing the weekdays in order. eg: Sun, Mon, Tue, Wed, Thu, Fri, Sat + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+This file contains the interface for the time associated classes. + +boost::less_than_comparable< T, boost::equality_comparable< T > >Representation of a precise moment in time, including the date. This class is a skeleton for the interface of a temporal type with a resolution that is higher than a day. It is intended that this class be the base class and that the actual time class be derived using the BN pattern. In this way, the derived class can make decisions such as 'should there be a default constructor' and what should it set its value to, should there be optional constructors say allowing only an time_durations that generate a time from a clock,etc. So, in fact multiple time types can be created for a time_system with different construction policies, and all of them can perform basic operations by only writing a copy constructor. Finally, compiler errors are also shorter.The real behavior of the time class is provided by the time_system template parameter. This class must provide all the logic for addition, subtraction, as well as define all the interface types. void +T +time_system::time_rep_type +time_system::date_type +time_system::date_duration_type +time_system::time_duration_type + +BOOST_CXX14_CONSTEXPR date_type +BOOST_CXX14_CONSTEXPR time_duration_type +std::stringboolfalseOptional bool parameter will return time zone as an offset (ie "+07:00"). Empty string is returned for classes that do not use a time_zone +std::stringboolfalseOptional bool parameter will return time zone as an offset (ie "+07:00"). Empty string is returned for classes that do not use a time_zone +std::stringAn empty string is returned for classes that do not use a time_zone. +BOOST_CXX14_CONSTEXPR boolcheck to see if date is not a value +BOOST_CXX14_CONSTEXPR boolcheck to see if date is one of the infinity values +BOOST_CXX14_CONSTEXPR boolcheck to see if date is greater than all possible dates +BOOST_CXX14_CONSTEXPR boolcheck to see if date is greater than all possible dates +BOOST_CXX14_CONSTEXPR boolcheck to see if time is a special value +BOOST_CXX14_CONSTEXPR boolconst time_type &Equality operator – others generated by boost::equality_comparable. +BOOST_CXX14_CONSTEXPR boolconst time_type &Equality operator – others generated by boost::less_than_comparable. +BOOST_CXX14_CONSTEXPR time_duration_typeconst time_type &difference between two times +BOOST_CXX14_CONSTEXPR time_typeconst date_duration_type &add date durations +BOOST_CXX14_CONSTEXPR time_typeconst date_duration_type & +BOOST_CXX14_CONSTEXPR time_typeconst date_duration_type &subtract date durations +BOOST_CXX14_CONSTEXPR time_typeconst date_duration_type & +BOOST_CXX14_CONSTEXPR time_typeconst time_duration_type &add time durations +BOOST_CXX14_CONSTEXPR time_typeconst time_duration_type & +BOOST_CXX14_CONSTEXPR time_typeconst time_duration_type &subtract time durations +BOOST_CXX14_CONSTEXPR time_typeconst time_duration_type & + +const date_type &const time_duration_type &dst_flagsnot_dst +special_values +const time_rep_type & + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+This file contains the interface for clock devices. + +A clock providing time level services based on C time_t capabilities. This clock provides resolution to the 1 second level time_type::date_type +time_type::time_duration_type + +time_type +time_typeGet the current day in universal date as a ymd_type. +time_typeboost::shared_ptr< time_zone_type > + + +time_type::std::tm * + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+This file contains nice definitions for handling the resoluion of various time reprsentations. + += hundrethDefines some nice types for handling time level resolutions. +Flags for daylight savings or summer time. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +base_durationTemplate for instantiating derived adjusting durations. base_duration::impl_type +base_duration::traits_type + +(traits_type::ticks_per_second >=frac_of_second ? traits_type::ticks_per_second % frac_of_second :frac_of_second % traits_type::ticks_per_second)=0\ "The base duration resolution must be a multiple of the subsecond duration resolution" +boost::int64_tadjustment_ratio(traits_type::ticks_per_second >=frac_of_second ? traits_type::ticks_per_second/frac_of_second :frac_of_second/traits_type::ticks_per_second) + + + +T const &typename boost::enable_if< boost::is_integral< T >, void >::type *BOOST_DATE_TIME_NULLPTR +boost::less_than_comparable< T, boost::equality_comparable< T > >Represents some amount of elapsed time measure to a given resolution. This class represents a standard set of capabilities for all counted time durations. Time duration implementations should derive from this class passing their type as the first template parameter. This design allows the subclass duration types to provide custom construction policies or other custom features not provided here. +void +T +rep_type +rep_type::day_type +rep_type::hour_type +rep_type::min_type +rep_type::sec_type +rep_type::fractional_seconds_type +rep_type::tick_type +rep_type::impl_type + +BOOST_CXX14_CONSTEXPR hour_typeReturns number of hours in the duration. +BOOST_CXX14_CONSTEXPR min_typeReturns normalized number of minutes. +BOOST_CXX14_CONSTEXPR sec_typeReturns normalized number of seconds (0..60) +BOOST_CXX14_CONSTEXPR sec_typeReturns total number of seconds truncating any fractional seconds. +BOOST_CXX14_CONSTEXPR tick_typeReturns total number of milliseconds truncating any fractional seconds. +BOOST_CXX14_CONSTEXPR tick_typeReturns total number of nanoseconds truncating any sub millisecond values. +BOOST_CXX14_CONSTEXPR tick_typeReturns total number of microseconds truncating any sub microsecond values. +BOOST_CXX14_CONSTEXPR fractional_seconds_typeReturns count of fractional seconds at given resolution. +BOOST_CXX14_CONSTEXPR duration_type +BOOST_CXX14_CONSTEXPR duration_type +BOOST_CONSTEXPR bool +BOOST_CONSTEXPR bool +BOOST_CONSTEXPR bool +BOOST_CONSTEXPR boolconst time_duration & +BOOST_CONSTEXPR boolconst time_duration & +BOOST_CONSTEXPR duration_typeunary- Allows for time_duration td = -td1 +BOOST_CONSTEXPR duration_typeconst duration_type & +BOOST_CONSTEXPR duration_typeconst duration_type & +BOOST_CONSTEXPR duration_typeint +BOOST_CXX14_CONSTEXPR duration_typeconst duration_type & +BOOST_CXX14_CONSTEXPR duration_typeconst duration_type & +BOOST_CXX14_CONSTEXPR duration_typeintDivision operations on a duration with an integer. +BOOST_CXX14_CONSTEXPR duration_typeintMultiplication operations an a duration with an integer. +BOOST_CXX14_CONSTEXPR duration_typeint +BOOST_CXX14_CONSTEXPR tick_type +BOOST_CXX14_CONSTEXPR boolIs ticks_ a special value? +BOOST_CXX14_CONSTEXPR boolIs duration pos-infinity. +BOOST_CXX14_CONSTEXPR boolIs duration neg-infinity. +BOOST_CXX14_CONSTEXPR boolIs duration not-a-date-time. +BOOST_CONSTEXPR impl_typeUsed for special_values output. + + +hour_typemin_typesec_type0fractional_seconds_type0 +const time_duration< T, rep_type > &Construct from another time_duration (Copy constructor) +special_valuesConstruct from special_values. + +BOOST_CXX14_CONSTEXPR duration_typeReturns smallest representable duration. +BOOST_CXX14_CONSTEXPR tick_typeReturn the number of ticks in a second. +BOOST_CXX14_CONSTEXPR time_resolutionsProvide the resolution of this duration type. +BOOST_CXX14_CONSTEXPR unsigned shortReturns number of possible digits in fractional seconds. + + + +impl_type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +boost::date_time::date_facet< time_type::date_type, CharT, OutItrT >Facet used for format-based output of time types This class provides for the use of format strings to output times. In addition to the flags for formatting date elements, the following are the allowed format flags: +x X => default format - enables addition of more flags to default (ie. "%x %X %z") +f => fractional seconds ".123456" +F => fractional seconds or none: like frac sec but empty if frac sec == 0 +s => seconds w/ fractional sec "02.123" (this is the same as "%S%f) + - %S => seconds "02" + - %z => abbreviated time zone "EDT" + - %Z => full time zone name "Eastern Daylight Time" + +time_type::date_type +time_type::time_duration_type +boost::date_time::period< time_type, time_duration_type > +boost::date_time::date_facet< typename time_type::date_type, CharT, OutItrT > +base_type::string_type +base_type::char_type +base_type::period_formatter_type +base_type::special_values_formatter_type +base_type::date_gen_formatter_type +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +std::locale::id + +std::locale::id &void +voidconst char_type *constChanges format for time_duration. +void +void +OutItrTOutItrTstd::ios_base &char_typeconst time_type & +OutItrTOutItrTstd::ios_base &char_typeconst time_duration_type &put function for time_duration +OutItrTOutItrTstd::ios_base &char_typeconst period_type & + +::size_t0sets default formats for ptime, local_date_time, and time_duration +const char_type *period_formatter_typeperiod_formatter_type()const special_values_formatter_type &special_values_formatter_type()date_gen_formatter_typedate_gen_formatter_type()::size_t0Construct the facet with an explicitly specified format. + +string_typeconst time_duration_type &bool +string_typeconst time_duration_type &int2 +string_typeIntTint2 + +CharT +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +const char_type +boost::date_time::date_input_facet< time_type::date_type, CharT, InItrT >Facet for format-based input. time_type::date_type +time_type::time_duration_type +time_duration_type::fractional_seconds_type +boost::date_time::period< time_type, time_duration_type > +boost::date_time::date_input_facet< typename time_type::date_type, CharT, InItrT > +base_type::duration_type +base_type::year_type +base_type::month_type +base_type::day_type +base_type::string_type +string_type::const_iterator +base_type::char_type +base_type::format_date_parser_type +base_type::period_parser_type +base_type::special_values_parser_type +base_type::date_gen_parser_type +base_type::special_values_parser_type::match_results +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +const char_type * +std::locale::id + +voidconst char_type *constSet the format for time_duration. +void +void +InItrTInItrT &InItrT &std::ios_base &period_type & +InItrTInItrT &InItrT &std::ios_base &time_duration_type & +InItrTInItrT &InItrT &std::ios_base &time_type &Parses a time object from the input stream. +InItrTInItrT &InItrT &std::ios_base &time_type &string_type &Expects a time_zone in the input stream. + +const string_type &::size_t0Constructor that takes a format string for a ptime. +const string_type &const format_date_parser_type &const special_values_parser_type &const period_parser_type &const date_gen_parser_type &::size_t0 +::size_t0sets default formats for ptime, local_date_time, and time_duration + +InItrTInItrT &InItrT &std::ios_base &time_type &string_type &bool +InItrTInItrT &InItrT &temporal_type &char_type'\0'Helper function to check for special_value. First character may have been consumed during original parse attempt. Parameter 'c' should be a copy of that character. Throws ios_base::failure if parse fails. +voidInItrT &InItrT &fracional_seconds_type &Helper function for parsing a fractional second type from the stream. + + +int_typeint_typeconst unsigned shortHelper function to adjust trailing zeros when parsing fractional digits. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Put a time type into a stream using appropriate facets. std::basic_ostream< charT > +time_duration_type::fractional_seconds_type + +voidconst time_duration_type &ostream_type &Put time into an ostream. + +Put a time type into a stream using appropriate facets. std::basic_ostream< charT > +time_type::date_type +time_type::time_duration_type +ostream_time_duration_formatter< time_duration_type, charT > + +voidconst time_type &ostream_type &Put time into an ostream. + +Put a time period into a stream using appropriate facets. std::basic_ostream< charT > +time_period_type::point_type +ostream_time_formatter< time_type, charT > + +voidconst time_period_type &ostream_type &Put time into an ostream. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Simple time iterator skeleton class. time_type::time_duration_type + +time_itr & +time_itr & +time_type +time_type * +boolconst time_type & +boolconst time_type & +boolconst time_type & +boolconst time_type & +boolconst time_type & +boolconst time_type & + +time_typetime_duration_type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + +int_typeint_typeint_typecomputes exponential math like 2^8 => 256, only works with positive integers +time_durationconst std::basic_string< char_type > &Creates a time_duration object from a delimited string. Expected format for string is "[-]h[h][:mm][:ss][.fff]". If the number of fractional digits provided is greater than the precision of the time duration type then the extra digits are truncated.A negative duration will be created if the first character in string is a '-', all other '-' will be treated as delimiters. Accepted delimiters are "-:,.". +time_durationconst std::string &Creates a time_duration object from a delimited string. Expected format for string is "[-]h[h][:mm][:ss][.fff]". If the number of fractional digits provided is greater than the precision of the time duration type then the extra digits are truncated.A negative duration will be created if the first character in string is a '-', all other '-' will be treated as delimiters. Accepted delimiters are "-:,.". +boolconst std::string &charstd::string &std::string &Utility function to split appart string. +time_typeconst std::string &char +time_durationconst std::string &Parse time duration part of an iso time of form: [-]hhmmss.fff... +time_typeconst std::string &charParse time string of form YYYYMMDDThhmmss where T is delimeter between date and time. + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +frac_sec_type::int_type +frac_sec_type::int_type +frac_sec_type::impl_type +var_type +var_type +var_type +var_type + +BOOST_CXX14_CONSTEXPR fractional_seconds_typeimpl_type +BOOST_CXX14_CONSTEXPR bool +BOOST_CXX14_CONSTEXPR time_resolutions +BOOST_CXX14_CONSTEXPR unsigned short +BOOST_CXX14_CONSTEXPR fractional_seconds_type +BOOST_CXX14_CONSTEXPR tick_typehour_typemin_typesec_typefractional_seconds_typeAny negative argument results in a negative tick_count. + + +boost::int64_tticks_per_secondresolution_adjust +fractional_seconds_typeticks_per_secondresolution_adjust + +traits struct for time_resolution_traits implementation type boost::int32_t +boost::date_time::int_adapter< boost::int32_t > + +BOOST_CXX14_CONSTEXPR int_typeimpl_type +BOOST_CXX14_CONSTEXPR boolUsed to determine if implemented type is int_adapter or int. + +traits struct for time_resolution_traits implementation type boost::int64_t +boost::date_time::int_adapter< boost::int64_t > + +BOOST_CXX14_CONSTEXPR int_typeimpl_type +BOOST_CXX14_CONSTEXPR boolUsed to determine if implemented type is int_adapter or int. + +traits struct for time_resolution_traits implementation type boost::int32_t +boost::int32_t + +BOOST_CXX14_CONSTEXPR int_typeimpl_type +BOOST_CXX14_CONSTEXPR boolUsed to determine if implemented type is int_adapter or int. + +traits struct for time_resolution_traits implementation type boost::int64_t +boost::int64_t + +BOOST_CXX14_CONSTEXPR int_typeimpl_type +BOOST_CXX14_CONSTEXPR boolUsed to determine if implemented type is int_adapter or int. + +time_resolution_traits< time_resolution_traits_adapted32_impl, milli, 1000, 3 > +time_resolution_traits< time_resolution_traits_adapted64_impl, micro, 1000000, 6 > +time_resolution_traits< time_resolution_traits_adapted64_impl, nano, 1000000000, 9 > +BOOST_CXX14_CONSTEXPR TTSimple function to calculate absolute value of a numeric type. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Time representation that uses a single integer count. config::int_type +config::date_type +config::impl_type +date_type::duration_type +date_type::calendar_type +date_type::ymd_type +config::time_duration_type +config::resolution_traits + +BOOST_CXX14_CONSTEXPR date_type +BOOST_CXX14_CONSTEXPR unsigned long +BOOST_CXX14_CONSTEXPR int_type +BOOST_CXX14_CONSTEXPR int_type +BOOST_CXX14_CONSTEXPR bool +BOOST_CXX14_CONSTEXPR bool +BOOST_CXX14_CONSTEXPR bool +BOOST_CXX14_CONSTEXPR bool +BOOST_CXX14_CONSTEXPR impl_type + +const date_type &const time_duration_type & +int_type +impl_type + +BOOST_CXX14_CONSTEXPR int_type + +An unadjusted time system implementation. time_rep +time_rep_type::impl_type +time_rep_type::time_duration_type +time_duration_type::fractional_seconds_type +time_rep_type::date_type +time_rep_type::date_duration_type + +BOOST_CXX14_CONSTEXPR voidconst T & +BOOST_CXX14_CONSTEXPR time_rep_typeconst date_type &const time_duration_type &date_time::dst_flagsnot_dst +BOOST_CXX14_CONSTEXPR time_rep_typespecial_values +BOOST_CXX14_CONSTEXPR date_typeconst time_rep_type & +BOOST_CXX14_CONSTEXPR time_duration_typeconst time_rep_type & +std::stringconst time_rep_type & +BOOST_CXX14_CONSTEXPR boolconst time_rep_type &const time_rep_type & +BOOST_CXX14_CONSTEXPR boolconst time_rep_type &const time_rep_type & +BOOST_CXX14_CONSTEXPR time_rep_typeconst time_rep_type &const date_duration_type & +BOOST_CXX14_CONSTEXPR time_rep_typeconst time_rep_type &const date_duration_type & +BOOST_CXX14_CONSTEXPR time_rep_typeconst time_rep_type &const time_duration_type & +BOOST_CXX14_CONSTEXPR time_rep_typeconst time_rep_type &time_duration_type +BOOST_CXX14_CONSTEXPR time_duration_typeconst time_rep_type &const time_rep_type & + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +An unadjusted time system implementation. config::time_rep_type +config::date_type +config::time_duration_type +config::date_duration_type +config::int_type +config::resolution_traits +date_time::wrapping_int< int_type, INT64_C(86400) *ticks_per_second > +date_time::wrapping_int< split_timedate_system::int_type, split_timedate_system::ticks_per_day > +date_time::wrapping_int< int_type, ticks_per_day > + +int_typeticks_per_dayINT64_C(86400) *config::tick_per_second + + +BOOST_CXX14_CONSTEXPR time_rep_typespecial_values +BOOST_CXX14_CONSTEXPR time_rep_typeconst date_type &const time_duration_type &date_time::dst_flagsnot_dst +BOOST_CONSTEXPR date_typeconst time_rep_type & +BOOST_CONSTEXPR time_duration_typeconst time_rep_type & +std::stringconst time_rep_type & +BOOST_CONSTEXPR boolconst time_rep_type &const time_rep_type & +BOOST_CXX14_CONSTEXPR boolconst time_rep_type &const time_rep_type & +BOOST_CXX14_CONSTEXPR time_rep_typeconst time_rep_type &const date_duration_type & +BOOST_CXX14_CONSTEXPR time_rep_typeconst time_rep_type &const date_duration_type & +BOOST_CXX14_CONSTEXPR time_rep_typeconst time_rep_type &const time_duration_type & +BOOST_CXX14_CONSTEXPR time_rep_typeconst time_rep_type &time_duration_type +BOOST_CXX14_CONSTEXPR time_duration_typeconst time_rep_type &const time_rep_type & + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Structure which holds the time offsets associated with daylight savings time. +time_duration_typeAmount DST adjusts the clock eg: plus one hour. +time_duration_typeTime past midnight on start transition day that dst starts. +time_duration_typeTime past midnight on end transition day that dst ends. + + +const time_duration_type &const time_duration_type &const time_duration_type & +Interface class for dynamic time zones. This class represents the base interface for all timezone representations. Subclasses may provide different systems for identifying a particular zone. For example some may provide a geographical based zone construction while others may specify the offset from GMT. Another possible implementation would be to convert from POSIX timezone strings. Regardless of the construction technique, this is the interface that these time zone types must provide.Note that this class is intended to be used as a shared resource (hence the derivation from boost::counted_base. CharT +std::basic_string< CharT > +std::basic_ostringstream< CharT > +time_type::date_type::year_type +time_type::time_duration_type + +string_typeString for the timezone when in daylight savings (eg: EDT) +string_typeString for the zone when not in daylight savings (eg: EST) +string_typeString for the timezone when in daylight savings (eg: Eastern Daylight Time) +string_typeString for the zone when not in daylight savings (eg: Eastern Standard Time) +boolTrue if zone uses daylight savings adjustments otherwise false. +time_typeyear_typeLocal time that DST starts – undefined if has_dst is false. +time_typeyear_typeLocal time that DST ends – undefined if has_dst is false. +time_duration_typeBase offset from UTC for zone (eg: -07:30:00) +time_duration_typeAdjustment forward or back made while DST is in effect. +string_typeReturns a POSIX time_zone string for this object. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +CharT +const char_type +const char_type +const char_type +Base type that holds various string names for timezone output. Class that holds various types of strings used for timezones. For example, for the western United States there is the full name: Pacific Standard Time and the abbreviated name: PST. During daylight savings there are additional names: Pacific Daylight Time and PDT. +std::basic_string< CharT > + +string_type +string_type +string_type +string_type + + +const string_type &const string_type &const string_type &const string_type & + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +out_of_rangeException thrown when tz database locates incorrect field structure in data file. + +const std::string & +logic_errorException thrown when tz database cannot locate requested data file. + + +const std::string & +Creates a database of time_zones from csv datafile. The csv file containing the zone_specs used by the tz_db_base is intended to be customized by the library user. When customizing this file (or creating your own) the file must follow a specific format.This first line is expected to contain column headings and is therefore not processed by the tz_db_base.Each record (line) must have eleven fields. Some of those fields can be empty. Every field (even empty ones) must be enclosed in double-quotes. Ex: "America/Phoenix" <- string enclosed in quotes +"" <- empty field +Some fields represent a length of time. The format of these fields must be: "{+|-}hh:mm[:ss]" <- length-of-time format + Where the plus or minus is mandatory and the seconds are optional.Since some time zones do not use daylight savings it is not always necessary for every field in a zone_spec to contain a value. All zone_specs must have at least ID and GMT offset. Zones that use daylight savings must have all fields filled except: STD ABBR, STD NAME, DST NAME. You should take note that DST ABBR is mandatory for zones that use daylight savings (see field descriptions for further details).******* Fields and their description/details *********ID: Contains the identifying string for the zone_spec. Any string will do as long as it's unique. No two ID's can be the same.STD ABBR: STD NAME: DST ABBR: DST NAME: These four are all the names and abbreviations used by the time zone being described. While any string will do in these fields, care should be taken. These fields hold the strings that will be used in the output of many of the local_time classes. Ex: time_zone nyc = tz_db.time_zone_from_region("America/New_York"); +local_time ny_time(date(2004, Aug, 30), IS_DST, nyc); +cout << ny_time.to_long_string() << endl; +// 2004-Aug-30 00:00:00 Eastern Daylight Time +cout << ny_time.to_short_string() << endl; +// 2004-Aug-30 00:00:00 EDT +NOTE: The exact format/function names may vary - see local_time documentation for further details.GMT offset: This is the number of hours added to utc to get the local time before any daylight savings adjustments are made. Some examples are: America/New_York offset -5 hours, & Africa/Cairo offset +2 hours. The format must follow the length-of-time format described above.DST adjustment: The amount of time added to gmt_offset when daylight savings is in effect. The format must follow the length-of-time format described above.DST Start Date rule: This is a specially formatted string that describes the day of year in which the transition take place. It holds three fields of it's own, separated by semicolons. The first field indicates the "nth" weekday of the month. The possible values are: 1 (first), 2 (second), 3 (third), 4 (fourth), 5 (fifth), and -1 (last). The second field indicates the day-of-week from 0-6 (Sun=0). The third field indicates the month from 1-12 (Jan=1).Examples are: "-1;5;9"="Last Friday of September", "2;1;3"="Second Monday of March"Start time: Start time is the number of hours past midnight, on the day of the start transition, the transition takes place. More simply put, the time of day the transition is made (in 24 hours format). The format must follow the length-of-time format described above with the exception that it must always be positive.DST End date rule: See DST Start date rule. The difference here is this is the day daylight savings ends (transition to STD).End time: Same as Start time. char +time_zone_type::base_type +time_zone_type::time_duration_type +time_zone_names_base< char_type > +boost::date_time::dst_adjustment_offsets< time_duration_type > +std::basic_string< char_type > + +voidstd::istream &Process csv data file, may throw exceptions. May throw bad_field_count exceptions +voidconst std::string &Process csv data file, may throw exceptions. May throw data_not_accessible, or bad_field_count exceptions +boolconst string_type &boost::shared_ptr< time_zone_base_type >returns true if record successfully added to map Takes a region name in the form of "America/Phoenix", and a time_zone object for that region. The id string must be a unique name that does not already exist in the database. +boost::shared_ptr< time_zone_base_type >const string_type &Returns a time_zone object built from the specs for the given region. Returns a time_zone object built from the specs for the given region. If region does not exist a local_time::record_not_found exception will be thrown +std::vector< std::string >Returns a vector of strings holding the time zone regions in the database. + +Constructs an empty database. + +rule_type *const string_type &const string_type &parses rule specs for transition day rules +week_numinthelper function for parse_rules() +voidint &int &int &string_typesplits the [start|end]_date_rule string into 3 ints +boolstring_type &Take a line from the csv, turn it into a time_zone_type. Take a line from the csv, turn it into a time_zone_type, and add it to the map. Zone_specs in csv file are expected to have eleven fields that describe the time zone. Returns true if zone_spec successfully added to database + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +A wrapping integer used to support time durations (WARNING: only instantiate with a signed type) In composite date and time types this type is used to wrap at the day boundary. Ex: A wrapping_int<short, 10> will roll over after nine, and roll under below zero. This gives a range of [0,9]NOTE: it is strongly recommended that wrapping_int2 be used instead of wrapping_int as wrapping_int is to be depricated at some point soon.Also Note that warnings will occur if instantiated with an unsigned type. Only a signed type should be used! int_type_ + +BOOST_CONSTEXPR int_type + + +BOOST_CONSTEXPR int_typeExplicit converion method. +BOOST_CONSTEXPR +BOOST_CXX14_CONSTEXPR IntTIntTAdd, return number of wraps performed. The sign of the returned value will indicate which direction the wraps went. Ex: add a negative number and wrapping under could occur, this would be indicated by a negative return value. If wrapping over took place, a positive value would be returned +BOOST_CXX14_CONSTEXPR IntTIntTSubtract will return '+d' if wrapping under took place ('d' is the number of wraps) The sign of the returned value will indicate which direction the wraps went (positive indicates wrap under, negative indicates wrap over). Ex: subtract a negative number and wrapping over could occur, this would be indicated by a negative return value. If wrapping under took place, a positive value would be returned. + +int_typeAdd, return true if wrapped. + +BOOST_CXX14_CONSTEXPR IntTIntT + +A wrapping integer used to wrap around at the top (WARNING: only instantiate with a signed type) Bad name, quick impl to fix a bug – fix later!! This allows the wrap to restart at a value other than 0. int_type_ + +BOOST_CONSTEXPR int_type +BOOST_CONSTEXPR int_type + + +BOOST_CONSTEXPR int_typeExplicit converion method. +BOOST_CONSTEXPR +BOOST_CXX14_CONSTEXPR IntTIntTAdd, return number of wraps performed. The sign of the returned value will indicate which direction the wraps went. Ex: add a negative number and wrapping under could occur, this would be indicated by a negative return value. If wrapping over took place, a positive value would be returned +BOOST_CXX14_CONSTEXPR IntTIntTSubtract will return '-d' if wrapping under took place ('d' is the number of wraps) The sign of the returned value will indicate which direction the wraps went. Ex: subtract a negative number and wrapping over could occur, this would be indicated by a positive return value. If wrapping under took place, a negative value would be returned + +int_typeIf initializing value is out of range of [wrap_min, wrap_max], value will be initialized to closest of min or max + +BOOST_CXX14_CONSTEXPR IntTIntT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +Allow rapid creation of ymd triples of different types. YearType +MonthType +DayType +YearType +MonthType +DayType + + +YearTypeMonthTypeDayTypeA basic constructor. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/src/boost/libs/date_time/xmldoc/date_time_docs_howto.html b/src/boost/libs/date_time/xmldoc/date_time_docs_howto.html new file mode 100644 index 000000000..ab451b381 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_time_docs_howto.html @@ -0,0 +1,82 @@ + + + + + Date Time Documentation Howto + + + + +

Date Time Documentation Howto

+

Instructions for:

+
    +
  1. Building Exclusive Date Time HTML Documentation
  2. +
  3. Building Exclusive Date Time PDF
  4. +
  5. Generating Date Time Doxygen Reference
  6. +
  7. Making further changes to the date_time_fo_stylesheet
  8. +
+
+

Building Exclusive Date Time HTML Documentation

+

No modifications are necessary to build an exclusive set of date time html documentation. Simply run bjam:
+

bjam --v2 date_time_doc

+ The resulting html can be found in xmldoc/html. NOTE: the stylesheet may not be present. It can be copied from the $BOOST_ROOT/doc/html directory.

+
+

Building Exclusive Date Time PDF

+

Prerequisite: bjam must be able to build documentation for 'fo' output (necessary aditions must have been added to user-config.jam).

+ +

Necessary modifications to build the date time pdf are: +

    +
  1. Add the new stylesheet to boostbook.jam.
    +
    +rule docbook-to-fo ( target : source : properties * )
    +{
    +  #local native-path = [ path.native $(.boostbook-xsl-dir) ] ;
    +  #local stylesheet = $(native-path:B=fo:S=.xsl) ;
    +  local boost-root =  [ modules.peek : BOOST_ROOT ];
    +  local stylesheet = "$(boost-root)/libs/date_time/xmldoc/date_time_fo_stylesheet.xsl" ;
    +  xslt $(target) : $(source) $(stylesheet) : $(properties) ;
    +}
  2. +
  3. Build exclusive_date_time.fo. +
    bjam --v2 date_time_doc fo
  4. +
  5. Build the pdf.
    fop ../../../bin.v2/libs/date_time/.../exclusive_date_time.fo date_time.pdf
  6. +
+

+

BUILD ERRORS: During the fo->pdf step, an error stating that an id already exists may appear. This error appears to be introduced during the xml->fo step. There are two possible workarounds for this (depending on where the duplicated id apears). If the duplicate id appears in the reference section, find the offending id and change it manually (ex: "id2534038" -> "id2534039"). If the id appears in the documentation generated from the xml, change one of the anchor names in one of the xml files. Note: This does not mean there is an error in the xml. The anchor and link that is known to have an effect is date_input_facet_intro (change the 'd' to a 'f', or back, should do the trick).

+
+

Generating Date Time Doxygen Reference

+

Each doxygen reference file must be built, copied, and modified seperately. The steps to build all four *.boostbook reference files are: +

    +
  1. Generate the *.boostbook files.
  2. +
  3. Copy the *.boostbook files to the xmldoc directory.
  4. +
  5. Fix the section tags and add copyright statement.
  6. +
+
+bjam --v2 date_time_autodoc  \
+          gregorian_autodoc  \
+          posix_time_autodoc \
+          local_time_autodoc
+cp ../../../bin.v2/libs/.../*.boostbook .
+./ref_tag_fix.pl
+

+
+

Making further changes to the date_time_fo_stylesheet

+

The stylesheet currently sets the left, right, and bottom margins. It also reduces the font-size for table cells that have the <screen> tags in them. The font-size reduction is accomplished by breaking the entire string (between the <screen> tags) into segments delimited by '\n'. Each of these segment's lengths are checked and the longest segment is used in calculating the amount of font-size reduction.

+

There are two variables used in adjusting the font-size: char-per-cell & min-reduction. These hold the number of characters that can fit into a cell and the minimum percentage of reduction allowed (expressed as an integer).

+

Determining the number of characters that will fit into a cell is not the most gracefull of operations. Simply put, the minimum reduction must be set to 100 (no reduction allowed) and the pdf must be built. From there the number of characters that will fit must be manually counted.

+
+
+
+

Subject to the Boost Software License, Version 1.0. http://www.boost.org/LICENSE_1_0.txt

+ + diff --git a/src/boost/libs/date_time/xmldoc/date_time_fo_stylesheet.xsl b/src/boost/libs/date_time/xmldoc/date_time_fo_stylesheet.xsl new file mode 100644 index 000000000..d72b0db22 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_time_fo_stylesheet.xsl @@ -0,0 +1,180 @@ + + + + + + + + + + + 1.25in + 0.65in + + + + + 0.75in + 0.65in + + + + + + + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 100 + + + + + + + + + + + 100 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/boost/libs/date_time/xmldoc/date_time_io.xml b/src/boost/libs/date_time/xmldoc/date_time_io.xml new file mode 100644 index 000000000..e9f719c28 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/date_time_io.xml @@ -0,0 +1,133 @@ + + + + + +
+ Date Time Input/Output + + + Date Time IO System + + Exception Handling on Streams + + + As of version 1.33, the date_time library utilizes a new IO streaming system. This new system gives the user great control over how dates and times can be represented. The customization options can be broken down into two groups: format flags and string elements. Format flags provide flexibility in the order of the date elements as well as the type. Customizing the string elements allows the replacement of built in strings from month names, weekday names, and other strings used in the IO. + + The output system is based on a date_facet (derived from std::facet), while the input system is based on a date_input_facet (also derived from std::facet). The time and local_time facets are derived from these base types. The output system utilizes three formatter objects, whereas the input system uses four parser objects. These formatter and parser objetcs are also customizable. + + It is important to note, that while all the examples shown here use narrow streams, there are wide stream facets available as well (see IO Objects for a complete list). + + It should be further noted that not all compilers are capable of using this IO system. For those compilers the IO system used in previous date_time versions is still available. The "legacy IO" is automatically selected for these compilers, however, the legacy IO system can be manually selected by defining USE_DATE_TIME_PRE_1_33_FACET_IO. See the Build-Compiler Information for more information. + + + Exception Handling on Streams + When an error occurs during the input streaming process, the std::ios_base::failbit will (always) be set on the stream. It is also possible to have exceptions thrown when an error occurs. To "turn on" these exceptions, call the stream's exceptions function with a parameter of std::ios_base::failbit. + // "Turning on" exceptions +date d(not_a_date_time); +std::stringstream ss; +ss.exceptions(std::ios_base::failbit); +ss.str("204-Jan-01"); +ss >> d; // throws bad_year exception AND sets failbit on stream + + A simple example of this new system: + //example to customize output to be "LongWeekday LongMonthname day, year" +// "%A %b %d, %Y" +date d(2005,Jun,25); +date_facet* facet(new date_facet("%A %B %d, %Y")); +std::cout.imbue(std::locale(std::cout.getloc(), facet)); +std::cout << d << std::endl; +// "Saturday June 25, 2005" + + + + The following table lists the available facets. + + + IO Objects + + + + + + Output + Input + + + + + date_facet + date_input_facet + + + wdate_facet + wdate_input_facet + + + time_facet + time_input_facet + + + wtime_facet + wtime_input_facet + + + local_time_facet* + local_time_input_facet* + + + wlocal_time_facet* + wlocal_time_input_facet* + + + + + * These links lead to the time_facet and time_input_facet reference sections. They are not actual classes but typedefs. + + + Formatter/Parser Objects + To implement the new i/o facets the date-time library uses a number of new parsers and formatters. These classes are available for users that want to implement specialized input/output routines. + + + + + + Output + Input + + + + + period_formatter + period_parser + + + date_generator_formatter + date_generator_parser + + + special_values_formatter + special_values_parser + + + + format_date_parser + + + + + + + + + + + + + +
diff --git a/src/boost/libs/date_time/xmldoc/design_concepts.xml b/src/boost/libs/date_time/xmldoc/design_concepts.xml new file mode 100644 index 000000000..e6429ba4c --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/design_concepts.xml @@ -0,0 +1,22 @@ + + + + + +
+ Design Concepts + + + A large part of the genesis of this library has been the observation that few date-time libraries are built in a fashion that allows customization and extension. A typical example, the calendar logic is built directly into the date class. Or the clock retrieval functions are built directly into the time class. These design decisions usually make it impossible to extend or change the library behavior. At a more fundamental level, there are usually assumptions about the resolution of time representation or the gregorian calendar. + + + Often times, the result is that a project must settle for a less than complete library because of a requirement for high resolution time representation or other assumptions that do not match the implementation of the library. This is extremely unfortunate because development of a library of this sort is far from a trivial task. + + + While the design is far from perfect the current design is far more flexible than any date-time library the author is aware of. It is expected that the various aspects of extensibility will be better documented in future versions. Information about the design goals of the library is summarized here. + +
diff --git a/src/boost/libs/date_time/xmldoc/design_goals.xml b/src/boost/libs/date_time/xmldoc/design_goals.xml new file mode 100644 index 000000000..3e9000e03 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/design_goals.xml @@ -0,0 +1,126 @@ + + + + + +
+ Design Goals + + + + + + Category + Description + + + Functions + + + + + Interfaces + Provide concrete classes for manipulation of dates and times + + + + + date, time, date_duration, time_duration, date_period, time_period, etc + support for infinity - positive infinity, negative infinity + iterators over time and date ranges + allow date and time implementations to be separate as much as possible + + + + + Calculation + Provide a basis for performing efficient time calculations + + + + + days between dates + durations of times + durations of dates and times together + + + + + + Representation Flexibility + Provide the maximum possible reusability and flexibility + + + + + traits based customization of internal representations for size versus resolution control + Allowing the use of different epochs and resolution (eg: seconds versus microseconds, dates starting at the year 2000 versus dates starting in 1700) + Options for configuring unique calendar representations (Gregorian + others) + the use of Julian Day number and the conversion between this and the Gregorian/Julian calendar date + Allow for flexible adjustments including leap seconds + + + + + + + Date Calculations + Provide tools for date calculations + + + + + provide basis for calculation of complex event specs like holidays + calendar to calendar conversions + provide for ability to extend to new calendar systems + + + + + + Time Calculations + Provide concrete classes for manipulation of time + + + + + provide the ability to handle cross time-zone issues + provide adjustments for daylight savings time (summer time) + + + + + + Clock Interfaces + Provide classes for retrieving time current time + + + + + access to a network / high resolution time sources + retrieving the current date time information to populate classes + + + + + + I/O Interfaces + Provide input and output for time including + + + + + multi-lingual support + provide ISO8601 compliant time facet + use I/O facets for different local behavior + + + + + + +
diff --git a/src/boost/libs/date_time/xmldoc/details.xml b/src/boost/libs/date_time/xmldoc/details.xml new file mode 100644 index 000000000..1eea179ee --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/details.xml @@ -0,0 +1,22 @@ + + + + + +
+ Details + + + + + + + + + + +
diff --git a/src/boost/libs/date_time/xmldoc/domain_concepts.xml b/src/boost/libs/date_time/xmldoc/domain_concepts.xml new file mode 100644 index 000000000..9d6616e9f --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/domain_concepts.xml @@ -0,0 +1,61 @@ + + + + + +
+ Domain Concepts + + + The date time domain is rich in terminology and problems. + The following is a brief introduction to the concepts you + will find reflected in the library. + + + The library supports 3 basic temporal types: + + + Time Point -- Specifier + for a location in the time continuum. + + + Time Duration -- A + length of time unattached to any point on the time continuum. + + + Time Interval -- A duration + of time attached to a specific point in the time continuum. + Also known as a time period. + + + + + Each of these temporal types has a Resolution which is defined by the smallest representable duration. A Time system provides all these categories of temporal types as well as the rules for labeling and calculating with time points. Calendar Systems are simply time systems with a maximum resolution of one day. The Gregorian system is the most widely used calendar system today (the ISO system is basically a derivative of this). However, there are many other calendar systems as well. UTC (Coordinated Universal Time) is a widely used civil time system. UTC is adjusted for earth rotation at longitude 0 by the use of leap seconds (This is not predictable, only as necessary). Most local time systems are based on UTC but are also adjusted for earth rotation so that daylight hours are similar everywhere. In addition, some local times include daylight savings time (DST) adjustments to shift the daylight hours during the summer. + + + A Clock Device is software component (tied to some hardware) that provides the current date or time with respect to a time system. A clock can measure the current time to a known resolution which may be higher or lower than a particular time representation. + + + The library provides support for calculating with dates and times. However, time calculations are not quite the same as calculating with integers. If you are serious about the accuracy of your time calculations need to read about Stability, Predictability, and Approximations. + + + + + Basic Terminology + + + Calculations + + + Stability, Predictability, and Approximations + + + References + + + +
diff --git a/src/boost/libs/date_time/xmldoc/doxy.xml b/src/boost/libs/date_time/xmldoc/doxy.xml new file mode 100644 index 000000000..c12f24674 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/doxy.xml @@ -0,0 +1,22 @@ + + + + + +
+ Library Reference + + + The following is a detailed reference of the date_time library. A click on any of the reference links will take you to a list of the header files found in that section. Following one of those links will take you to a list of the items declared in that header file. Further sublinks take you to detailed descriptions of each individual item. + + + + + + +
+ diff --git a/src/boost/libs/date_time/xmldoc/ex_calc_rules.xml b/src/boost/libs/date_time/xmldoc/ex_calc_rules.xml new file mode 100644 index 000000000..78889ef23 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/ex_calc_rules.xml @@ -0,0 +1,59 @@ + + + + + +
+ Daylight Savings Calc Rules + + + Example of creating various Daylight Savings Calc Rule objects. + + + + + int + main() + { + using namespace boost; + using namespace local_time; + using namespace gregorian; + + /***** create the necessary date_generator objects *****/ + // starting generators + first_day_of_the_week_in_month fd_start(Sunday, May); + last_day_of_the_week_in_month ld_start(Sunday, May); + nth_day_of_the_week_in_month nkd_start(nth_day_of_the_week_in_month::third, + Sunday, May); + partial_date pd_start(1, May); + // ending generators + first_day_of_the_week_in_month fd_end(Sunday, Oct); + last_day_of_the_week_in_month ld_end(Sunday, Oct); + nth_day_of_the_week_in_month nkd_end(nth_day_of_the_week_in_month::third, + Sunday, Oct); + partial_date pd_end(31, Oct); + + /***** create the various dst_calc_rule objects *****/ + dst_calc_rule_ptr pdr(new partial_date_dst_rule(pd_start, pd_end)); + dst_calc_rule_ptr flr(new first_last_dst_rule(fd_start, ld_end)); + dst_calc_rule_ptr llr(new last_last_dst_rule(ld_start, ld_end)); + dst_calc_rule_ptr nlr(new nth_last_dst_rule(nkd_start, ld_end)); + dst_calc_rule_ptr ndr(new nth_day_of_the_week_in_month_dst_rule(nkd_start, + nkd_end)); + + return 0; + } + + ]]> + +
diff --git a/src/boost/libs/date_time/xmldoc/ex_date_period_calc.xml b/src/boost/libs/date_time/xmldoc/ex_date_period_calc.xml new file mode 100644 index 000000000..2c39345ff --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/ex_date_period_calc.xml @@ -0,0 +1,96 @@ + + + + + +
+ Date Period Calculations + + + Calculates if a date is in an 'irregular' collection of periods using period calculation functions. + + + 20020216/20020217 + 20020223/20020224 + + */ + + + #include "boost/date_time/gregorian/gregorian.hpp" + #include + #include + #include + + typedef std::set date_period_set; + + //Simple population of the exclusion set + date_period_set + generateExclusion() + { + using namespace boost::gregorian; + date_period periods_array[] = + { date_period(date(2002,Feb,2), date(2002,Feb,4)),//weekend of 2nd-3rd + date_period(date(2002,Feb,9), date(2002,Feb,11)), + date_period(date(2002,Feb,16), date(2002,Feb,18)), + date_period(date(2002,Feb,23), date(2002,Feb,25)), + date_period(date(2002,Feb,12), date(2002,Feb,13))//a random holiday 2-12 + }; + const int num_periods = sizeof(periods_array)/sizeof(date_period); + + date_period_set ps; + //insert the periods in the set + std::insert_iterator itr(ps, ps.begin()); + std::copy(periods_array, periods_array+num_periods, itr ); + return ps; + + } + + + int main() + { + using namespace boost::gregorian; + + date_period_set ps = generateExclusion(); + std::cout << "Number Excluded Periods: " << ps.size() << std::endl; + + date d(2002,Feb,16); + date_period_set::const_iterator i = ps.begin(); + //print the periods, check for containment + for (;i != ps.end(); i++) { + std::cout << to_iso_string(*i) << std::endl; + //if date is in exclusion period then print it + if (i->contains(d)) { + std::cout << "In Exclusion Period: " + << to_iso_string(d) << " --> " << to_iso_string(*i) + << std::endl; + } + } + + return 0; + + } + + ]]> + +
diff --git a/src/boost/libs/date_time/xmldoc/ex_dates_as_strings.xml b/src/boost/libs/date_time/xmldoc/ex_dates_as_strings.xml new file mode 100644 index 000000000..d6a074f62 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/ex_dates_as_strings.xml @@ -0,0 +1,77 @@ + + + + + +
+ Dates as Strings + + + Various parsing and output of strings. + + + + #include + + int + main() + { + + using namespace boost::gregorian; + + try { + // The following date is in ISO 8601 extended format (CCYY-MM-DD) + std::string s("2001-10-9"); //2001-October-09 + date d(from_simple_string(s)); + std::cout << to_simple_string(d) << std::endl; + + //Read ISO Standard(CCYYMMDD) and output ISO Extended + std::string ud("20011009"); //2001-Oct-09 + date d1(from_undelimited_string(ud)); + std::cout << to_iso_extended_string(d1) << std::endl; + + //Output the parts of the date - Tuesday October 9, 2001 + date::ymd_type ymd = d1.year_month_day(); + greg_weekday wd = d1.day_of_week(); + std::cout << wd.as_long_string() << " " + << ymd.month.as_long_string() << " " + << ymd.day << ", " << ymd.year + << std::endl; + + //Let's send in month 25 by accident and create an exception + std::string bad_date("20012509"); //2001-??-09 + std::cout << "An expected exception is next: " << std::endl; + date wont_construct(from_undelimited_string(bad_date)); + //use wont_construct so compiler doesn't complain, but you wont get here! + std::cout << "oh oh, you shouldn't reach this line: " + << to_iso_string(wont_construct) << std::endl; + } + catch(std::exception& e) { + std::cout << " Exception: " << e.what() << std::endl; + } + + + return 0; + } + + ]]> + +
diff --git a/src/boost/libs/date_time/xmldoc/ex_days_alive.xml b/src/boost/libs/date_time/xmldoc/ex_days_alive.xml new file mode 100644 index 000000000..c940704a0 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/ex_days_alive.xml @@ -0,0 +1,59 @@ + + + + + +
+ Days Alive + + + Calculate the number of days you have been living using durations and dates. + + + +/* Short example that calculates the number of days since user was born. + * Demonstrates comparisons of durations, use of the day_clock, + * and parsing a date from a string. + */ + +#include "boost/date_time/gregorian/gregorian.hpp" +#include <iostream> + +int +main() +{ + + using namespace boost::gregorian; + std::string s; + std::cout << "Enter birth day YYYY-MM-DD (eg: 2002-02-01): "; + std::cin >> s; + try { + date birthday(from_simple_string(s)); + date today = day_clock::local_day(); + days days_alive = today - birthday; + days one_day(1); + if (days_alive == one_day) { + std::cout << "Born yesterday, very funny" << std::endl; + } + else if (days_alive < days(0)) { + std::cout << "Not born yet, hmm: " << days_alive.days() + << " days" <<std::endl; + } + else { + std::cout << "Days alive: " << days_alive.days() << std::endl; + } + + } + catch(...) { + std::cout << "Bad date entered: " << s << std::endl; + } + return 0; +} + + + +
diff --git a/src/boost/libs/date_time/xmldoc/ex_days_between_new_years.xml b/src/boost/libs/date_time/xmldoc/ex_days_between_new_years.xml new file mode 100644 index 000000000..91a236df7 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/ex_days_between_new_years.xml @@ -0,0 +1,49 @@ + + + + + +
+ Days Between New Years + + + Calculate the number of days till new years + + + + #include "boost/date_time/gregorian/gregorian.hpp" + + int + main() + { + + using namespace boost::gregorian; + + date today = day_clock::local_day(); + partial_date new_years_day(1,Jan); + //Subtract two dates to get a duration + days days_since_year_start = today - new_years_day.get_date(today.year()); + std::cout << "Days since Jan 1: " << days_since_year_start.days() + << std::endl; + + days days_until_year_start = new_years_day.get_date(today.year()+1) - today; + std::cout << "Days until next Jan 1: " << days_until_year_start.days() + << std::endl; + return 0; + }; + + ]]> + +
diff --git a/src/boost/libs/date_time/xmldoc/ex_end_of_month_day.xml b/src/boost/libs/date_time/xmldoc/ex_end_of_month_day.xml new file mode 100644 index 000000000..d67dde7e5 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/ex_end_of_month_day.xml @@ -0,0 +1,59 @@ + + + + + +
+ End of the Months + + + Iterates accross the remaining months in a given year, always landing on the last day of the month. + + + + + int + main() + { + using namespace boost::gregorian; + + std::cout << " Enter Year(ex: 2002): "; + int year, month; + std::cin >> year; + std::cout << " Enter Month(1..12): "; + std::cin >> month; + try { + int day = gregorian_calendar::end_of_month_day(year,month); + date end_of_month(year,month,day); + + //Iterate thru by months -- + month_iterator mitr(end_of_month,1); + date start_of_next_year(year+1, Jan, 1); + //loop thru the days and print each one + while (mitr < start_of_next_year){ + std::cout << to_simple_string(*mitr) << std::endl; + ++mitr; + } + + } + catch(...) { + std::cout << "Invalid Date Entered" << std::endl; + } + return 0; + + } + + ]]> + +
diff --git a/src/boost/libs/date_time/xmldoc/ex_find_last_day_of_months.xml b/src/boost/libs/date_time/xmldoc/ex_find_last_day_of_months.xml new file mode 100644 index 000000000..52f8c74fe --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/ex_find_last_day_of_months.xml @@ -0,0 +1,66 @@ + + + + + +
+ Last Day of the Months + + + Example that gets a month and a year from the user and finds the last day of each remaining month of that year. + + + + + int + main() + { + using namespace boost::gregorian; + + greg_year year(1400); + greg_month month(1); + + // get a month and a year from the user + try { + int y, m; + std::cout << " Enter Year(ex: 2002): "; + std::cin >> y; + year = greg_year(y); + std::cout << " Enter Month(1..12): "; + std::cin >> m; + month = greg_month(m); + } + catch(bad_year by) { + std::cout << "Invalid Year Entered: " << by.what() << '\n' + << "Using minimum values for month and year." << std::endl; + } + catch(bad_month bm) { + std::cout << "Invalid Month Entered" << bm.what() << '\n' + << "Using minimum value for month. " << std::endl; + } + + date start_of_next_year(year+1, Jan, 1); + date d(year, month, 1); + + // add another month to d until we enter the next year. + while (d < start_of_next_year){ + std::cout << to_simple_string(d.end_of_month()) << std::endl; + d += months(1); + } + + return 0; + } + + ]]> + +
diff --git a/src/boost/libs/date_time/xmldoc/ex_flight.xml b/src/boost/libs/date_time/xmldoc/ex_flight.xml new file mode 100644 index 000000000..98ec4c4e9 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/ex_flight.xml @@ -0,0 +1,60 @@ + + + + + +
+ Flight Time Example + + This example shows a program that calculates the arrival time of a plane that flys from Phoenix to New York. During the flight New York shifts into daylight savings time (Phoenix doesn't because Arizona doesn't use dst). + + + +#include "boost/date_time/local_time/local_time.hpp" +#include <iostream> + +/* This example shows a program that calculates the arrival time of a plane + * that flys from Phoenix to New York. During the flight New York shifts + * into daylight savings time (Phoenix doesn't because Arizona doesn't use + * dst). + * + * + */ + +int main() +{ + using namespace boost::gregorian; + using namespace boost::local_time; + using namespace boost::posix_time; + + + //setup some timezones for creating and adjusting local times + //This user editable file can be found in libs/date_time/data. + tz_database tz_db; + tz_db.load_from_file("date_time_zonespec.csv"); + time_zone_ptr nyc_tz = tz_db.time_zone_from_region("America/New_York"); + //Use a + time_zone_ptr phx_tz(new posix_time_zone("MST-07:00:00")); + + //local departure time in phoenix is 11 pm on april 2 2005 + // (ny changes to dst on apr 3 at 2 am) + local_date_time phx_departure(date(2005, Apr, 2), hours(23), + phx_tz, + local_date_time::NOT_DATE_TIME_ON_ERROR); + + time_duration flight_length = hours(4) + minutes(30); + local_date_time phx_arrival = phx_departure + flight_length; + local_date_time nyc_arrival = phx_arrival.local_time_in(nyc_tz); + + std::cout << "departure phx time: " << phx_departure << std::endl; + std::cout << "arrival phx time: " << phx_arrival << std::endl; + std::cout << "arrival nyc time: " << nyc_arrival << std::endl; + +} + + +
diff --git a/src/boost/libs/date_time/xmldoc/ex_local_utc_conversion.xml b/src/boost/libs/date_time/xmldoc/ex_local_utc_conversion.xml new file mode 100644 index 000000000..61c8afe5b --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/ex_local_utc_conversion.xml @@ -0,0 +1,103 @@ + + + + + +
+ Local to UTC Conversion + + + Demonstrate utc to local and local to utc calculations including dst. + + + New York while DST is NOT active (5 hours) + * 2001-Dec-31 19:00:00 in New York is 2002-Jan-01 00:00:00 UTC time + * 2002-Jan-01 00:00:00 UTC is 2001-Dec-31 19:00:00 New York time + * + * UTC <--> New York while DST is active (4 hours) + * 2002-May-31 20:00:00 in New York is 2002-Jun-01 00:00:00 UTC time + * 2002-Jun-01 00:00:00 UTC is 2002-May-31 20:00:00 New York time + * + * UTC <--> Arizona (7 hours) + * 2002-May-31 17:00:00 in Arizona is 2002-Jun-01 00:00:00 UTC time + */ + + #include "boost/date_time/posix_time/posix_time.hpp" + #include "boost/date_time/local_time_adjustor.hpp" + #include "boost/date_time/c_local_time_adjustor.hpp" + #include + + int + main() + { + using namespace boost::posix_time; + using namespace boost::gregorian; + + //This local adjustor depends on the machine TZ settings-- highly dangerous! + typedef boost::date_time::c_local_adjustor local_adj; + ptime t10(date(2002,Jan,1), hours(7)); + ptime t11 = local_adj::utc_to_local(t10); + std::cout << "UTC <--> Zone base on TZ setting" << std::endl; + std::cout << to_simple_string(t11) << " in your TZ is " + << to_simple_string(t10) << " UTC time " + << std::endl; + time_duration td = t11 - t10; + std::cout << "A difference of: " + << to_simple_string(td) << std::endl; + + + //eastern timezone is utc-5 + typedef boost::date_time::local_adjustor us_eastern; + + ptime t1(date(2001,Dec,31), hours(19)); //5 hours b/f midnight NY time + + std::cout << "\nUTC <--> New York while DST is NOT active (5 hours)" + << std::endl; + ptime t2 = us_eastern::local_to_utc(t1); + std::cout << to_simple_string(t1) << " in New York is " + << to_simple_string(t2) << " UTC time " + << std::endl; + + ptime t3 = us_eastern::utc_to_local(t2);//back should be the same + std::cout << to_simple_string(t2) << " UTC is " + << to_simple_string(t3) << " New York time " + << "\n\n"; + + ptime t4(date(2002,May,31), hours(20)); //4 hours b/f midnight NY time + std::cout << "UTC <--> New York while DST is active (4 hours)" << std::endl; + ptime t5 = us_eastern::local_to_utc(t4); + std::cout << to_simple_string(t4) << " in New York is " + << to_simple_string(t5) << " UTC time " + << std::endl; + + ptime t6 = us_eastern::utc_to_local(t5);//back should be the same + std::cout << to_simple_string(t5) << " UTC is " + << to_simple_string(t6) << " New York time " + << "\n" << std::endl; + + + //Arizona timezone is utc-7 with no dst + typedef boost::date_time::local_adjustor us_arizona; + + ptime t7(date(2002,May,31), hours(17)); + std::cout << "UTC <--> Arizona (7 hours)" << std::endl; + ptime t8 = us_arizona::local_to_utc(t7); + std::cout << to_simple_string(t7) << " in Arizona is " + << to_simple_string(t8) << " UTC time " + << std::endl; + + return 0; + } + + ]]> + +
diff --git a/src/boost/libs/date_time/xmldoc/ex_localization.xml b/src/boost/libs/date_time/xmldoc/ex_localization.xml new file mode 100644 index 000000000..2fb872e18 --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/ex_localization.xml @@ -0,0 +1,115 @@ + + + + + +
+ Localization Demonstration + + + The boost::date_time library provides the ability to create customized locale facets. Date ordering, language, seperators, and abbreviations can be customized. + + + + + #include + + /* Define a series of char arrays for short and long name strings + * to be associated with German date output (US names will be + * retrieved from the locale). */ + const char* const de_short_month_names[] = + { + "Jan", "Feb", "Mar", "Apr", "Mai", "Jun", + "Jul", "Aug", "Sep", "Okt", "Nov", "Dez", "NAM" + }; + const char* const de_long_month_names[] = + { + "Januar", "Februar", "Marz", "April", "Mai", + "Juni", "Juli", "August", "September", "Oktober", + "November", "Dezember", "NichtDerMonat" + }; + const char* const de_long_weekday_names[] = + { + "Sonntag", "Montag", "Dienstag", "Mittwoch", + "Donnerstag", "Freitag", "Samstag" + }; + const char* const de_short_weekday_names[] = + { + "Son", "Mon", "Die","Mit", "Don", "Fre", "Sam" + }; + + + int main() + { + using namespace boost::gregorian; + + // create some gregorian objects to output + date d1(2002, Oct, 1); + greg_month m = d1.month(); + greg_weekday wd = d1.day_of_week(); + + // create a facet and a locale for German dates + date_facet* german_facet = new date_facet(); + std::cout.imbue(std::locale(std::locale::classic(), german_facet)); + + // create the German name collections + date_facet::input_collection_type short_months, long_months, + short_weekdays, long_weekdays; + std::copy(&de_short_month_names[0], &de_short_month_names[11], + std::back_inserter(short_months)); + std::copy(&de_long_month_names[0], &de_long_month_names[11], + std::back_inserter(long_months)); + std::copy(&de_short_weekday_names[0], &de_short_weekday_names[6], + std::back_inserter(short_weekdays)); + std::copy(&de_long_weekday_names[0], &de_long_weekday_names[6], + std::back_inserter(long_weekdays)); + + // replace the default names with ours + // NOTE: date_generators and special_values were not replaced as + // they are not used in this example + german_facet->short_month_names(short_months); + german_facet->long_month_names(long_months); + german_facet->short_weekday_names(short_weekdays); + german_facet->long_weekday_names(long_weekdays); + + // output the date in German using short month names + german_facet->format("%d.%m.%Y"); + std::cout << d1 << std::endl; //01.10.2002 + + german_facet->month_format("%B"); + std::cout << m << std::endl; //Oktober + + german_facet->weekday_format("%A"); + std::cout << wd << std::endl; //Dienstag + + + // Output the same gregorian objects using US names + date_facet* us_facet = new date_facet(); + std::cout.imbue(std::locale(std::locale::classic(), us_facet)); + + us_facet->format("%m/%d/%Y"); + std::cout << d1 << std::endl; // 10/01/2002 + + // English names, iso order (year-month-day), '-' separator + us_facet->format("%Y-%b-%d"); + std::cout << d1 << std::endl; // 2002-Oct-01 + + return 0; + + } + ]]> + +
diff --git a/src/boost/libs/date_time/xmldoc/ex_meeting_planner.xml b/src/boost/libs/date_time/xmldoc/ex_meeting_planner.xml new file mode 100644 index 000000000..a838a1e4c --- /dev/null +++ b/src/boost/libs/date_time/xmldoc/ex_meeting_planner.xml @@ -0,0 +1,187 @@ + + + + + +
+ Teleconference Scheduler (partial listing) + + + The Teleconference Scheduler is a Qt based example (found in the examples/qt directory). Partial listings of meeting_planner.hpp and planner_form.cpp are provided to illustrate techniques for using the local_date_time and tz_database objects. + + + + + The planner_form class is derived from a QDialog. This listing illustrates the initialization of a tz_database object and using it to populate combo boxes with region lists. Only the init function is listed here for the sake of brevity. + + + vect; + vect regions = tz_db.region_list(); + vect::const_iterator itr = regions.begin(); + while(itr != regions.end()) { + comboBox1->insertItem(*itr); + comboBox2->insertItem(*itr); + comboBox3->insertItem(*itr); + ++itr; + } + comboBox1->insertItem("", 0); + comboBox3->insertItem("