Boost logo

Boost-Commit :

From: chankwanting_at_[hidden]
Date: 2008-05-04 12:55:54


Author: ktchan
Date: 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
New Revision: 45115
URL: http://svn.boost.org/trac/boost/changeset/45115

Log:
Add files from 2008-05-04 trunk.
Added:
   sandbox/SOC/2008/calendar/boost/date_time/
   sandbox/SOC/2008/calendar/boost/date_time.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/adjust_functors.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/c_local_time_adjustor.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/c_time.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/compiler_config.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/constrained_value.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_clock_device.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_defs.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_duration.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_duration_types.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_facet.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_format_simple.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_formatting.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_formatting_limited.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_formatting_locales.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_generator_formatter.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_generator_parser.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_generators.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_iterator.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_names_put.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/date_parsing.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/dst_rules.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/dst_transition_generators.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/filetime_functions.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/format_date_parser.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/conversion.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/formatters.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/formatters_limited.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_calendar.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_date.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_day.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_day_of_year.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration_types.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_facet.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_month.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_serialize.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_weekday.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_year.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_ymd.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian_io.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian_types.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian/parsers.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian_calendar.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/gregorian_calendar.ipp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/int_adapter.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/iso_format.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_time/
   sandbox/SOC/2008/calendar/boost/date_time/local_time/conversion.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_time/custom_time_zone.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_time/date_duration_operators.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_time/dst_transition_day_rules.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_time/local_date_time.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time_io.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time_types.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_time/posix_time_zone.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_time/tz_database.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_time_adjustor.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/local_timezone_defs.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/locale_config.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/microsec_time_clock.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/parse_format_base.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/period.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/period_formatter.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/period_parser.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/conversion.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/date_duration_operators.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_config.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_duration.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_io.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_legacy_io.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_system.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_types.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/ptime.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_formatters.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_formatters_limited.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_parsers.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_period.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_serialize.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/special_defs.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/special_values_formatter.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/special_values_parser.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/string_convert.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/string_parse_tree.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/strings_from_facet.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/testfrmwk.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_clock.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_defs.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_duration.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_facet.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_formatting_streams.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_iterator.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_parsing.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_resolution_traits.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_system_counted.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_system_split.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_zone_base.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/time_zone_names.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/tz_db_base.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/wrapping_int.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/boost/date_time/year_month_day.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/
   sandbox/SOC/2008/calendar/libs/date_time/build/
   sandbox/SOC/2008/calendar/libs/date_time/build/Jamfile.v2 (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/data/
   sandbox/SOC/2008/calendar/libs/date_time/data/README.zone_spec_csv_file (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/data/date_time_zonespec.csv (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/doc/
   sandbox/SOC/2008/calendar/libs/date_time/doc/index.html (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/doc/time_duration_inherit.png (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/
   sandbox/SOC/2008/calendar/libs/date_time/example/Jamfile (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/Jamfile.v2 (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/date_serialization_demo.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/dates_as_strings.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_alive.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_between_new_years.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_since_year_start.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_till_new_year.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/end_of_month_day.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/find_last_day_of_months.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/localization.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/month_add.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/period_calc.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/print_holidays.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/print_month.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/local_time/
   sandbox/SOC/2008/calendar/libs/date_time/example/local_time/calc_rules.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/local_time/flight.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/local_time/local_date_time.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/local_time/seconds_since_epoch.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/local_time/simple_time_zone.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/
   sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/Jamfile.v2 (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/local_utc_conversion.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/print_hours.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/time_math.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/time_periods.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/example/tutorial/
   sandbox/SOC/2008/calendar/libs/date_time/example/tutorial/io_tutorial.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/index.html (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/src/
   sandbox/SOC/2008/calendar/libs/date_time/src/date_time.doc (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/
   sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/date_generators.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_month.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_names.hpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_weekday.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/gregorian_types.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/src/posix_time/
   sandbox/SOC/2008/calendar/libs/date_time/src/posix_time/posix_time_types.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/
   sandbox/SOC/2008/calendar/libs/date_time/test/Jamfile.v2 (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testcurrent_day.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_duration.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_facet_new.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_input_facet.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_iterator.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testfacet.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformat_date_parser.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformatters.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgenerators.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_cal.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_day.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_durations.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_month.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_serialize.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_wstream.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_year.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testparse_date.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testperiod.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/README.poorly_formed_zonespec (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/poorly_formed_zonespec.csv (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testclocks.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testcustom_time_zone.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testdst_transition_day_rule.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_facet.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_input_facet.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_iterator.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_period.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testposix_time_zone.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testtz_database.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwcustom_time_zone.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwposix_time_zone.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testc_local_adjustor.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testclock.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testdst_rules.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testduration.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testfiletime_functions.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testformatters.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testgreg_duration_operators.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testiterator.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testlocal_adjustor.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testparse_time.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testperiod.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/teststreams.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_facet.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_formatters.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_input_facet.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_period.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_serialize.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_wstream.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/testconstrained_value.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/testfrom_facet.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/testgeneric_period.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/testgregorian_calendar.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/testint64_range.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/testint_adapter.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/testtime_resolution_traits.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/test/testwrapping_int.cpp (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/Jamfile.v2 (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/README (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/acknowledgements.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/buildinfo.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/calculations.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/changes.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/conceptual.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/custom_time_zone.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_algorithms.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_class.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_duration.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_facet.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_input_facet.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_iterators.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_period.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time_docs_howto.html (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time_fo_stylesheet.xsl (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time_io.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/design_concepts.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/design_goals.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/details.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/domain_concepts.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/doxy.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_calc_rules.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_date_period_calc.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_dates_as_strings.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_days_alive.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_days_between_new_years.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_end_of_month_day.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_find_last_day_of_months.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_flight.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_local_utc_conversion.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_localization.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_meeting_planner.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_month_add.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_print_holidays.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_print_hours.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_print_month.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_seconds_since_epoch.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_simple_time_zone.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_time_math.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_time_periods.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/examples.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/exclusive_date_time.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/format_flags.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/gregorian.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/gregorian_calendar.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/io_objects.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/io_tutorial.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/license.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/local_date_time.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/local_time.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/local_time_period.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/motivation.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/posix_time.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/posix_time_zone.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ptime_class.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ref_tag_fix.pl (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/references.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/serialization.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/snap_to_details.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/table_template.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/terminology.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/tests.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_duration.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_facet.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_input_facet.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_iterators.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_period.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_zone_base.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/tradeoffs.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/tz_database.xml (contents, props changed)
   sandbox/SOC/2008/calendar/libs/date_time/xmldoc/usage_examples.xml (contents, props changed)

Added: sandbox/SOC/2008/calendar/boost/date_time.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,17 @@
+#ifndef BOOST_DATE_TIME_ALL_HPP___
+#define BOOST_DATE_TIME_ALL_HPP___
+
+/* Copyright (c) 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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+ // See www.boost.org/libs/date_time for documentation.
+
+//gregorian and posix time included by indirectly
+#include "boost/date_time/local_time/local_time.hpp"
+
+#endif // BOOST_DATE_TIME_ALL_HPP___

Added: sandbox/SOC/2008/calendar/boost/date_time/adjust_functors.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/adjust_functors.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,178 @@
+#ifndef _DATE_TIME_ADJUST_FUNCTORS_HPP___
+#define _DATE_TIME_ADJUST_FUNCTORS_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/date.hpp"
+#include "boost/date_time/wrapping_int.hpp"
+
+namespace boost {
+namespace date_time {
+
+
+ //! Functor to iterate a fixed number of days
+ template<class date_type>
+ class day_functor
+ {
+ public:
+ typedef typename date_type::duration_type duration_type;
+ day_functor(int f) : f_(f) {}
+ duration_type get_offset(const date_type& d) const
+ {
+ // why is 'd' a parameter???
+ // fix compiler warnings
+ d.year();
+ return duration_type(f_);
+ }
+ duration_type get_neg_offset(const date_type& d) const
+ {
+ // fix compiler warnings
+ d.year();
+ return duration_type(-f_);
+ }
+ private:
+ int f_;
+ };
+
+
+ //! 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.
+
+ */
+ template<class date_type>
+ class month_functor
+ {
+ public:
+ typedef typename date_type::duration_type duration_type;
+ typedef typename date_type::calendar_type cal_type;
+ typedef typename cal_type::ymd_type ymd_type;
+ typedef typename cal_type::day_type day_type;
+
+ month_functor(int f) : f_(f), origDayOfMonth_(0) {}
+ duration_type get_offset(const date_type& d) const
+ {
+ ymd_type ymd(d.year_month_day());
+ if (origDayOfMonth_ == 0) {
+ origDayOfMonth_ = ymd.day;
+ day_type endOfMonthDay(cal_type::end_of_month_day(ymd.year,ymd.month));
+ if (endOfMonthDay == ymd.day) {
+ origDayOfMonth_ = -1; //force the value to the end of month
+ }
+ }
+ typedef date_time::wrapping_int2<short,1,12> wrap_int2;
+ typedef typename wrap_int2::int_type int_type;
+ wrap_int2 wi(ymd.month);
+ //calc the year wrap around, add() returns 0 or 1 if wrapped
+ int_type year = wi.add(static_cast<int_type>(f_));
+ year = static_cast<int_type>(year + ymd.year); //calculate resulting year
+// std::cout << "trace wi: " << wi.as_int() << std::endl;
+// std::cout << "trace year: " << year << std::endl;
+ //find the last day for the new month
+ day_type resultingEndOfMonthDay(cal_type::end_of_month_day(year, wi.as_int()));
+ //original was the end of month -- force to last day of month
+ if (origDayOfMonth_ == -1) {
+ return date_type(year, wi.as_int(), resultingEndOfMonthDay) - d;
+ }
+ day_type dayOfMonth = origDayOfMonth_;
+ if (dayOfMonth > resultingEndOfMonthDay) {
+ dayOfMonth = resultingEndOfMonthDay;
+ }
+ return date_type(year, wi.as_int(), dayOfMonth) - d;
+ }
+ //! Returns a negative duration_type
+ duration_type get_neg_offset(const date_type& d) const
+ {
+ ymd_type ymd(d.year_month_day());
+ if (origDayOfMonth_ == 0) {
+ origDayOfMonth_ = ymd.day;
+ day_type endOfMonthDay(cal_type::end_of_month_day(ymd.year,ymd.month));
+ if (endOfMonthDay == ymd.day) {
+ origDayOfMonth_ = -1; //force the value to the end of month
+ }
+ }
+ typedef date_time::wrapping_int2<short,1,12> wrap_int2;
+ typedef typename wrap_int2::int_type int_type;
+ wrap_int2 wi(ymd.month);
+ //calc the year wrap around, add() returns 0 or 1 if wrapped
+ int_type year = wi.subtract(static_cast<int_type>(f_));
+ year = static_cast<int_type>(year + ymd.year); //calculate resulting year
+ //find the last day for the new month
+ day_type resultingEndOfMonthDay(cal_type::end_of_month_day(year, wi.as_int()));
+ //original was the end of month -- force to last day of month
+ if (origDayOfMonth_ == -1) {
+ return date_type(year, wi.as_int(), resultingEndOfMonthDay) - d;
+ }
+ day_type dayOfMonth = origDayOfMonth_;
+ if (dayOfMonth > resultingEndOfMonthDay) {
+ dayOfMonth = resultingEndOfMonthDay;
+ }
+ return date_type(year, wi.as_int(), dayOfMonth) - d;
+ }
+ private:
+ int f_;
+ mutable short origDayOfMonth_;
+ };
+
+
+ //! Functor to iterate a over weeks
+ template<class date_type>
+ class week_functor
+ {
+ public:
+ typedef typename date_type::duration_type duration_type;
+ typedef typename date_type::calendar_type calendar_type;
+ week_functor(int f) : f_(f) {}
+ duration_type get_offset(const date_type& d) const
+ {
+ // why is 'd' a parameter???
+ // fix compiler warnings
+ d.year();
+ return duration_type(f_*calendar_type::days_in_week());
+ }
+ duration_type get_neg_offset(const date_type& d) const
+ {
+ // fix compiler warnings
+ d.year();
+ return duration_type(-f_*calendar_type::days_in_week());
+ }
+ private:
+ int f_;
+ };
+
+ //! Functor to iterate by a year adjusting for leap years
+ template<class date_type>
+ class year_functor
+ {
+ public:
+ //typedef typename date_type::year_type year_type;
+ typedef typename date_type::duration_type duration_type;
+ year_functor(int f) : _mf(f * 12) {}
+ duration_type get_offset(const date_type& d) const
+ {
+ return _mf.get_offset(d);
+ }
+ duration_type get_neg_offset(const date_type& d) const
+ {
+ return _mf.get_neg_offset(d);
+ }
+ private:
+ month_functor<date_type> _mf;
+ };
+
+
+} }//namespace date_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/c_local_time_adjustor.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/c_local_time_adjustor.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,64 @@
+#ifndef DATE_TIME_C_LOCAL_TIME_ADJUSTOR_HPP__
+#define DATE_TIME_C_LOCAL_TIME_ADJUSTOR_HPP__
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+/*! @file c_local_time_adjustor.hpp
+ Time adjustment calculations based on machine
+*/
+
+#include <stdexcept>
+#include "boost/date_time/c_time.hpp"
+
+namespace boost {
+namespace date_time {
+
+ //! 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.
+ */
+ template<class time_type>
+ class c_local_adjustor {
+ public:
+ typedef typename time_type::time_duration_type time_duration_type;
+ typedef typename time_type::date_type date_type;
+ typedef typename date_type::duration_type date_duration_type;
+ //! Convert a utc time to local time
+ static time_type utc_to_local(const time_type& t)
+ {
+ date_type time_t_start_day(1970,1,1);
+ time_type time_t_start_time(time_t_start_day,time_duration_type(0,0,0));
+ if (t < time_t_start_time) {
+ throw std::out_of_range("Cannot convert dates prior to Jan 1, 1970");
+ }
+ date_duration_type dd = t.date() - time_t_start_day;
+ time_duration_type td = t.time_of_day();
+ std::time_t t2 = dd.days()*86400 + td.hours()*3600 + td.minutes()*60 + td.seconds();
+ std::tm tms, *tms_ptr;
+ tms_ptr = c_time::localtime(&t2, &tms);
+ //tms_ptr = std::localtime(&t2);
+ date_type d(static_cast<unsigned short>(tms_ptr->tm_year + 1900),
+ static_cast<unsigned short>(tms_ptr->tm_mon + 1),
+ static_cast<unsigned short>(tms_ptr->tm_mday));
+ time_duration_type td2(tms_ptr->tm_hour,
+ tms_ptr->tm_min,
+ tms_ptr->tm_sec,
+ t.time_of_day().fractional_seconds());
+
+ return time_type(d,td2);
+ }
+ };
+
+
+
+} } //namespace date_time
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/c_time.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/c_time.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,91 @@
+#ifndef DATE_TIME_C_TIME_HPP___
+#define DATE_TIME_C_TIME_HPP___
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+/*! @file c_time.hpp
+ Provide workarounds related to the ctime header
+*/
+
+#include "boost/date_time/compiler_config.hpp"
+#include <ctime>
+//Work around libraries that don't put time_t and time in namespace std
+
+#ifdef BOOST_NO_STDC_NAMESPACE
+namespace std { using ::time_t; using ::time; using ::localtime;
+ using ::tm; using ::gmtime; }
+#endif // BOOST_NO_STDC_NAMESPACE
+
+//The following is used to support high precision time clocks
+#ifdef BOOST_HAS_GETTIMEOFDAY
+#include <sys/time.h>
+#endif
+
+#ifdef BOOST_HAS_FTIME
+#include <time.h>
+#endif
+
+namespace boost {
+namespace date_time {
+ //! 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. A pointer to the user created struct will be returned. */
+ struct c_time {
+ public:
+#if defined(BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS)
+ //! requires a pointer to a user created std::tm struct
+ inline
+ static std::tm* localtime(const std::time_t* t, std::tm* result)
+ {
+ // localtime_r() not in namespace std???
+ result = localtime_r(t, result);
+ return result;
+ }
+ //! requires a pointer to a user created std::tm struct
+ inline
+ static std::tm* gmtime(const std::time_t* t, std::tm* result)
+ {
+ // gmtime_r() not in namespace std???
+ result = gmtime_r(t, result);
+ return result;
+ }
+#else // BOOST_HAS_THREADS
+
+#if (defined(_MSC_VER) && (_MSC_VER >= 1400))
+#pragma warning(push) // preserve warning settings
+#pragma warning(disable : 4996) // disable depricated localtime/gmtime warning on vc8
+#endif // _MSC_VER >= 1400
+ //! requires a pointer to a user created std::tm struct
+ inline
+ static std::tm* localtime(const std::time_t* t, std::tm* result)
+ {
+ result = std::localtime(t);
+ return result;
+ }
+ //! requires a pointer to a user created std::tm struct
+ inline
+ static std::tm* gmtime(const std::time_t* t, std::tm* result)
+ {
+ result = std::gmtime(t);
+ return result;
+ }
+#if (defined(_MSC_VER) && (_MSC_VER >= 1400))
+#pragma warning(pop) // restore warnings to previous state
+#endif // _MSC_VER >= 1400
+
+#endif // BOOST_HAS_THREADS
+ };
+}} // namespaces
+
+#endif // DATE_TIME_C_TIME_HPP___

Added: sandbox/SOC/2008/calendar/boost/date_time/compiler_config.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/compiler_config.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,149 @@
+#ifndef DATE_TIME_COMPILER_CONFIG_HPP___
+#define DATE_TIME_COMPILER_CONFIG_HPP___
+
+/* Copyright (c) 2002-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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+ #include "boost/detail/workaround.hpp"
+
+// With boost release 1.33, date_time will be using a different,
+// more flexible, IO system. This new system is not compatible with
+// old compilers. The original date_time IO system remains for those
+// compilers. They must define this macro to use the legacy IO.
+// (defined(__BORLANDC__) && (__BORLANDC__ <= 0x0581) ) ) &&
+ #if( BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) ) \
+ || BOOST_WORKAROUND( __GNUC__, < 3) \
+ || (BOOST_WORKAROUND( _MSC_VER, <= 1300) ) \
+ ) \
+ && !defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
+# define USE_DATE_TIME_PRE_1_33_FACET_IO
+#endif
+
+
+// This file performs some local compiler configurations
+
+#include "boost/date_time/locale_config.hpp" //set up locale configurations
+
+//Set up a configuration parameter for platforms that have
+//GetTimeOfDay
+#if defined(BOOST_HAS_GETTIMEOFDAY) || defined(BOOST_HAS_FTIME)
+#define BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
+#endif
+
+// To Force no default constructors for date & ptime, un-comment following
+//#define DATE_TIME_NO_DEFAULT_CONSTRUCTOR
+
+// Include extensions to date_duration - comment out to remove this feature
+#define BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES
+// these extensions are known to cause problems with gcc295
+#if defined(__GNUC__) && (__GNUC__ < 3)
+#undef BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES
+#endif
+
+#if (defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) || BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) ) )
+#define BOOST_DATE_TIME_NO_MEMBER_INIT
+#endif
+
+// include these types before we try to re-define them
+#include "boost/cstdint.hpp"
+
+//Define INT64_C for compilers that don't have it
+#if (!defined(INT64_C))
+#define INT64_C(value) int64_t(value)
+#endif
+
+
+/* Workaround for Borland iterator error. Error was "Cannot convert 'istream *' to 'wistream *' in function istream_iterator<>::istream_iterator() */
+#if defined(__BORLANDC__) && defined(BOOST_BCB_WITH_RW_LIB)
+#define BOOST_DATE_TIME_NO_WISTREAM_ITERATOR
+#endif
+
+
+// Borland v5.64 does not have the following in std namespace; v5.5.1 does
+#if defined(__BORLANDC__) && defined(BOOST_BCB_WITH_STLPORT)
+#include <locale>
+namespace std {
+ using stlport::tolower;
+ using stlport::ctype;
+ using stlport::use_facet;
+}
+#endif
+
+// workaround for errors associated with output for date classes
+// modifications and input streaming for time classes.
+// Compilers affected are:
+// gcc295, msvc (neither with STLPort), any borland
+//
+#if (((defined(__GNUC__) && (__GNUC__ < 3)) || \
+ (defined(_MSC_VER) && (_MSC_VER < 1300)) ) && \
+ !defined(_STLP_OWN_IOSTREAMS) ) || \
+ BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
+#define BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS
+#endif
+
+/* The following handles the definition of the necessary macros
+ * for dll building on Win32 platforms.
+ *
+ * For code that will be placed in the date_time .dll,
+ * it must be properly prefixed with BOOST_DATE_TIME_DECL.
+ * The corresponding .cpp file must have BOOST_DATE_TIME_SOURCES
+ * defined before including its header. For examples see:
+ * greg_month.hpp & greg_month.cpp
+ *
+ */
+
+#ifdef BOOST_HAS_DECLSPEC // defined in config system
+ // we need to import/export our code only if the user has specifically
+ // asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
+ // libraries to be dynamically linked, or BOOST_DATE_TIME_DYN_LINK
+ // if they want just this one to be dynamically liked:
+# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK)
+ // export if this is our own source, otherwise import:
+# ifdef BOOST_DATE_TIME_SOURCE
+# define BOOST_DATE_TIME_DECL __declspec(dllexport)
+# else
+# define BOOST_DATE_TIME_DECL __declspec(dllimport)
+# endif // BOOST_DATE_TIME_SOURCE
+# endif // DYN_LINK
+#endif // BOOST_HAS_DECLSPEC
+//
+// if BOOST_WHATEVER_DECL isn't defined yet define it now:
+#ifndef BOOST_DATE_TIME_DECL
+# define BOOST_DATE_TIME_DECL
+#endif
+
+//
+// Automatically link to the correct build variant where possible.
+//
+#if !defined(BOOST_ALL_NO_LIB) && !defined(BOOST_DATE_TIME_NO_LIB) && !defined(BOOST_DATE_TIME_SOURCE)
+//
+// Set the name of our library, this will get undef'ed by auto_link.hpp
+// once it's done with it:
+//
+#define BOOST_LIB_NAME boost_date_time
+//
+// If we're importing code from a dll, then tell auto_link.hpp about it:
+//
+#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK)
+# define BOOST_DYN_LINK
+#endif
+//
+// And include the header that does the work:
+//
+#include <boost/config/auto_link.hpp>
+#endif // auto-linking disabled
+
+#if defined(BOOST_HAS_THREADS)
+# if defined(_MSC_VER) || defined(__MWERKS__) || defined(__MINGW32__) || defined(__BORLANDC__)
+ //no reentrant posix functions (eg: localtime_r)
+# elif (!defined(__hpux) || (defined(__hpux) && defined(_REENTRANT)))
+# define BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS
+# endif
+#endif
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/constrained_value.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/constrained_value.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,98 @@
+#ifndef CONSTRAINED_VALUE_HPP___
+#define CONSTRAINED_VALUE_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <boost/config.hpp>
+
+namespace boost {
+
+//! Namespace containing constrained_value template and types
+namespace CV {
+ //! Represent a min or max violation type
+ enum violation_enum {min_violation, max_violation};
+
+ //! 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.
+ *
+ * <b>value policies</b>
+ * 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.
+ *
+ */
+ template<class value_policies>
+ class constrained_value {
+ public:
+ typedef typename value_policies::value_type value_type;
+ // typedef except_type exception_type;
+ constrained_value(value_type value)
+ {
+ assign(value);
+ };
+ constrained_value& operator=(value_type v)
+ {
+ assign(v);
+ return *this;
+ }
+ //! Return the max allowed value (traits method)
+ static value_type max BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::max)();};
+ //! Return the min allowed value (traits method)
+ static value_type min BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::min)();};
+ //! Coerce into the representation type
+ operator value_type() const {return value_;};
+ protected:
+ value_type value_;
+ private:
+ void assign(value_type value)
+ {
+ //adding 1 below gets rid of a compiler warning which occurs when the
+ //min_value is 0 and the type is unsigned....
+ if (value+1 < (min)()+1) {
+ value_policies::on_error(value_, value, min_violation);
+ return;
+ }
+ if (value > (max)()) {
+ value_policies::on_error(value_, value, max_violation);
+ return;
+ }
+ value_ = value;
+
+ }
+};
+
+ //! Template to shortcut the constrained_value policy creation process
+ template<typename rep_type, rep_type min_value,
+ rep_type max_value, class exception_type>
+ class simple_exception_policy
+ {
+ public:
+ typedef rep_type value_type;
+ static rep_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return min_value; };
+ static rep_type max BOOST_PREVENT_MACRO_SUBSTITUTION () { return max_value;};
+ static void on_error(rep_type, rep_type, violation_enum)
+ {
+ throw exception_type();
+ }
+ };
+
+
+
+} } //namespace CV
+
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/date.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,197 @@
+#ifndef DATE_TIME_DATE_HPP___
+#define DATE_TIME_DATE_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/year_month_day.hpp"
+#include "boost/date_time/special_defs.hpp"
+#include "boost/operators.hpp"
+
+namespace boost {
+namespace date_time {
+
+ //!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.
+
+ <b>Theory</b>
+
+ This 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.
+ */
+
+
+ template<class T, class calendar, class duration_type_>
+ class date : private
+ boost::less_than_comparable<T
+ , boost::equality_comparable<T
+ > >
+ {
+ public:
+ typedef T date_type;
+ typedef calendar calendar_type;
+ typedef typename calendar::date_traits_type traits_type;
+ typedef duration_type_ duration_type;
+ typedef typename calendar::year_type year_type;
+ typedef typename calendar::month_type month_type;
+ typedef typename calendar::day_type day_type;
+ typedef typename calendar::ymd_type ymd_type;
+ typedef typename calendar::date_rep_type date_rep_type;
+ typedef typename calendar::date_int_type date_int_type;
+ typedef typename calendar::day_of_week_type day_of_week_type;
+ date(year_type y, month_type m, day_type d)
+ : days_(calendar::day_number(ymd_type(y, m, d)))
+ {}
+ date(const ymd_type& ymd)
+ : days_(calendar::day_number(ymd))
+ {}
+ //let the compiler write copy, assignment, and destructor
+ year_type year() const
+ {
+ ymd_type ymd = calendar::from_day_number(days_);
+ return ymd.year;
+ }
+ month_type month() const
+ {
+ ymd_type ymd = calendar::from_day_number(days_);
+ return ymd.month;
+ }
+ day_type day() const
+ {
+ ymd_type ymd = calendar::from_day_number(days_);
+ return ymd.day;
+ }
+ day_of_week_type day_of_week() const
+ {
+ ymd_type ymd = calendar::from_day_number(days_);
+ return calendar::day_of_week(ymd);
+ }
+ ymd_type year_month_day() const
+ {
+ return calendar::from_day_number(days_);
+ }
+ bool operator<(const date_type& rhs) const
+ {
+ return days_ < rhs.days_;
+ }
+ bool operator==(const date_type& rhs) const
+ {
+ return days_ == rhs.days_;
+ }
+ //! check to see if date is a special value
+ bool is_special()const
+ {
+ return(is_not_a_date() || is_infinity());
+ }
+ //! check to see if date is not a value
+ bool is_not_a_date() const
+ {
+ return traits_type::is_not_a_number(days_);
+ }
+ //! check to see if date is one of the infinity values
+ bool is_infinity() const
+ {
+ return traits_type::is_inf(days_);
+ }
+ //! check to see if date is greater than all possible dates
+ bool is_pos_infinity() const
+ {
+ return traits_type::is_pos_inf(days_);
+ }
+ //! check to see if date is greater than all possible dates
+ bool is_neg_infinity() const
+ {
+ return traits_type::is_neg_inf(days_);
+ }
+ //! return as a special value or a not_special if a normal date
+ special_values as_special() const
+ {
+ return traits_type::to_special(days_);
+ }
+ duration_type operator-(const date_type& d) const
+ {
+ date_rep_type val = date_rep_type(days_) - date_rep_type(d.days_);
+ return duration_type(val.as_number());
+ }
+
+ date_type operator-(const duration_type& dd) const
+ {
+ if(dd.is_special())
+ {
+ return date_type(date_rep_type(days_) - dd.get_rep());
+ }
+ return date_type(date_rep_type(days_) - dd.days());
+ }
+ date_type operator-=(const duration_type& dd)
+ {
+ *this = *this - dd;
+ return date_type(days_);
+ }
+ date_rep_type day_count() const
+ {
+ return days_;
+ };
+ //allow internal access from operators
+ date_type operator+(const duration_type& dd) const
+ {
+ if(dd.is_special())
+ {
+ return date_type(date_rep_type(days_) + dd.get_rep());
+ }
+ return date_type(date_rep_type(days_) + dd.days());
+ }
+ date_type operator+=(const duration_type& dd)
+ {
+ *this = *this + dd;
+ return date_type(days_);
+ }
+
+ //see reference
+ protected:
+ /*! This 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.
+ */
+ explicit date(date_int_type days) : days_(days) {};
+ explicit date(date_rep_type days) : days_(days.as_number()) {};
+ date_int_type days_;
+
+ };
+
+
+
+
+} } // namespace date_time
+
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/date_clock_device.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_clock_device.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,77 @@
+#ifndef DATE_CLOCK_DEVICE_HPP___
+#define DATE_CLOCK_DEVICE_HPP___
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/c_time.hpp"
+
+
+namespace boost {
+namespace date_time {
+
+ //! 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.
+ */
+ template<class date_type>
+ class day_clock
+ {
+ public:
+ typedef typename date_type::ymd_type ymd_type;
+ //! Get the local day as a date type
+ static date_type local_day()
+ {
+ return date_type(local_day_ymd());
+ }
+ //! Get the local day as a ymd_type
+ static typename date_type::ymd_type local_day_ymd()
+ {
+ ::std::tm result;
+ ::std::tm* curr = get_local_time(result);
+ return ymd_type(curr->tm_year + 1900,
+ curr->tm_mon + 1,
+ curr->tm_mday);
+ }
+ //! Get the current day in universal date as a ymd_type
+ static typename date_type::ymd_type universal_day_ymd()
+ {
+ ::std::tm result;
+ ::std::tm* curr = get_universal_time(result);
+ return ymd_type(curr->tm_year + 1900,
+ curr->tm_mon + 1,
+ curr->tm_mday);
+ }
+ //! Get the UTC day as a date type
+ static date_type universal_day()
+ {
+ return date_type(universal_day_ymd());
+ }
+
+ private:
+ static ::std::tm* get_local_time(std::tm& result)
+ {
+ ::std::time_t t;
+ ::std::time(&t);
+ return c_time::localtime(&t, &result);
+ }
+ static ::std::tm* get_universal_time(std::tm& result)
+ {
+ ::std::time_t t;
+ ::std::time(&t);
+ return c_time::gmtime(&t, &result);
+ }
+
+ };
+
+} } //namespace date_time
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/date_defs.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_defs.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,26 @@
+#ifndef DATE_TIME_DATE_DEFS_HPP
+#define DATE_TIME_DATE_DEFS_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+namespace boost {
+namespace date_time {
+
+ //! An enumeration of weekday names
+ enum weekdays {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday};
+
+ //! Simple enum to allow for nice programming with Jan, Feb, etc
+ enum months_of_year {Jan=1,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,NotAMonth,NumMonths};
+
+} } //namespace date_time
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/date_duration.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_duration.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,147 @@
+#ifndef DATE_TIME_DATE_DURATION__
+#define DATE_TIME_DATE_DURATION__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include <boost/operators.hpp>
+
+namespace boost {
+namespace date_time {
+
+
+ //! Duration type with date level resolution
+ template<class duration_rep_traits>
+ class date_duration : private
+ boost::less_than_comparable<date_duration< duration_rep_traits>
+ , boost::equality_comparable< date_duration< duration_rep_traits>
+ , boost::addable< date_duration< duration_rep_traits>
+ , boost::subtractable< date_duration< duration_rep_traits>
+ > > > >
+ {
+ public:
+ typedef typename duration_rep_traits::int_type duration_rep_type;
+ typedef typename duration_rep_traits::impl_type duration_rep;
+
+ //! Construct from a day count
+ explicit date_duration(duration_rep day_count) : days_(day_count) {};
+
+ /*! construct from special_values - only works when
+ * instantiated with duration_traits_adapted */
+ date_duration(special_values sv) :
+ days_(duration_rep::from_special(sv))
+ {}
+
+ // copy constructor required for addable<> & subtractable<>
+ //! Construct from another date_duration (Copy Constructor)
+ date_duration(const date_duration<duration_rep_traits>& other) :
+ days_(other.days_)
+ {}
+
+ //! returns days_ as it's instantiated type - used for streaming
+ duration_rep get_rep()const
+ {
+ return days_;
+ }
+ bool is_special()const
+ {
+ return days_.is_special();
+ }
+ //! returns days as value, not object.
+ duration_rep_type days() const
+ {
+ return duration_rep_traits::as_number(days_);
+ }
+ //! Returns the smallest duration -- used by to calculate 'end'
+ static date_duration unit()
+ {
+ return date_duration<duration_rep_traits>(1);
+ }
+ //! Equality
+ bool operator==(const date_duration& rhs) const
+ {
+ return days_ == rhs.days_;
+ }
+ //! Less
+ bool operator<(const date_duration& rhs) const
+ {
+ return days_ < rhs.days_;
+ }
+
+ /* For shortcut operators (+=, -=, etc) simply using
+ * "days_ += days_" may not work. If instantiated with
+ * an int_adapter, shortcut operators are not present,
+ * so this will not compile */
+
+ //! Subtract another duration -- result is signed
+ date_duration operator-=(const date_duration& rhs)
+ {
+ //days_ -= rhs.days_;
+ days_ = days_ - rhs.days_;
+ return *this;
+ }
+ //! Add a duration -- result is signed
+ date_duration operator+=(const date_duration& rhs)
+ {
+ days_ = days_ + rhs.days_;
+ return *this;
+ }
+
+ //! unary- Allows for dd = -date_duration(2); -> dd == -2
+ date_duration operator-()const
+ {
+ return date_duration<duration_rep_traits>(get_rep() * (-1));
+ }
+ //! Division operations on a duration with an integer.
+ date_duration<duration_rep_traits> operator/=(int divisor)
+ {
+ days_ = days_ / divisor;
+ return *this;
+ }
+ date_duration<duration_rep_traits> operator/(int divisor)
+ {
+ return date_duration<duration_rep_traits>(days_ / divisor);
+ }
+
+ //! return sign information
+ bool is_negative() const
+ {
+ return days_ < 0;
+ }
+ private:
+ duration_rep days_;
+ };
+
+
+ /*! Struct for instantiating date_duration with <b>NO</b> special values
+ * functionality. Allows for transparent implementation of either
+ * date_duration<long> or date_duration<int_adapter<long> > */
+ struct duration_traits_long
+ {
+ typedef long int_type;
+ typedef long impl_type;
+ static int_type as_number(impl_type i) { return i; };
+ };
+
+ /*! Struct for instantiating date_duration <b>WITH</b> special values
+ * functionality. Allows for transparent implementation of either
+ * date_duration<long> or date_duration<int_adapter<long> > */
+ struct duration_traits_adapted
+ {
+ typedef long int_type;
+ typedef boost::date_time::int_adapter<long> impl_type;
+ static int_type as_number(impl_type i) { return i.as_number(); };
+ };
+
+
+} } //namspace date_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/date_duration_types.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_duration_types.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,269 @@
+#ifndef DATE_DURATION_TYPES_HPP___
+#define DATE_DURATION_TYPES_HPP___
+
+/* Copyright (c) 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <boost/date_time/int_adapter.hpp>
+#include <boost/date_time/special_defs.hpp>
+#include <boost/date_time/date_duration.hpp>
+
+namespace boost {
+namespace date_time {
+
+
+ //! Additional duration type that represents a number of n*7 days
+ template <class duration_config>
+ class weeks_duration : public date_duration<duration_config> {
+ public:
+ weeks_duration(typename duration_config::impl_type w)
+ : date_duration<duration_config>(w * 7) {}
+ weeks_duration(special_values sv)
+ : date_duration<duration_config>(sv) {}
+ };
+
+ // predeclare
+ template<class t>
+ class years_duration;
+
+ //! 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.
+ */
+ template<class base_config>
+ class months_duration
+ {
+ private:
+ typedef typename base_config::int_rep int_rep;
+ typedef typename int_rep::int_type int_type;
+ typedef typename base_config::date_type date_type;
+ typedef typename date_type::duration_type duration_type;
+ typedef typename base_config::month_adjustor_type month_adjustor_type;
+ typedef months_duration<base_config> months_type;
+ typedef years_duration<base_config> years_type;
+ public:
+ months_duration(int_rep num) : _m(num) {}
+ months_duration(special_values sv) : _m(sv)
+ {
+ _m = int_rep::from_special(sv);
+ }
+ int_rep number_of_months() const { return _m; }
+ //! returns a negative duration
+ duration_type get_neg_offset(const date_type& d) const
+ {
+ month_adjustor_type m_adj(_m.as_number());
+ return duration_type(m_adj.get_neg_offset(d));
+ }
+ duration_type get_offset(const date_type& d) const
+ {
+ month_adjustor_type m_adj(_m.as_number());
+ return duration_type(m_adj.get_offset(d));
+ }
+ bool operator==(const months_type& rhs) const
+ {
+ return(_m == rhs._m);
+ }
+ bool operator!=(const months_type& rhs) const
+ {
+ return(_m != rhs._m);
+ }
+ months_type operator+(const months_type& rhs)const
+ {
+ return months_type(_m + rhs._m);
+ }
+ months_type& operator+=(const months_type& rhs)
+ {
+ _m = _m + rhs._m;
+ return *this;
+ }
+ months_type operator-(const months_type& rhs)const
+ {
+ return months_type(_m - rhs._m);
+ }
+ months_type& operator-=(const months_type& rhs)
+ {
+ _m = _m - rhs._m;
+ return *this;
+ }
+ months_type operator*(const int_type rhs)const
+ {
+ return months_type(_m * rhs);
+ }
+ months_type& operator*=(const int_type rhs)
+ {
+ _m = _m * rhs;
+ return *this;
+ }
+ months_type operator/(const int_type rhs)const
+ {
+ return months_type(_m / rhs);
+ }
+ months_type& operator/=(const int_type rhs)
+ {
+ _m = _m / rhs;
+ return *this;
+ }
+ months_type operator+(const years_type& y)const
+ {
+ return months_type(y.number_of_years() * 12 + _m);
+ }
+ months_type& operator+=(const years_type& y)
+ {
+ _m = y.number_of_years() * 12 + _m;
+ return *this;
+ }
+ months_type operator-(const years_type& y) const
+ {
+ return months_type(_m - y.number_of_years() * 12);
+ }
+ months_type& operator-=(const years_type& y)
+ {
+ _m = _m - y.number_of_years() * 12;
+ return *this;
+ }
+
+ //
+ friend date_type operator+(const date_type& d, const months_type& m)
+ {
+ return d + m.get_offset(d);
+ }
+ friend date_type operator+=(date_type& d, const months_type& m)
+ {
+ return d += m.get_offset(d);
+ }
+ friend date_type operator-(const date_type& d, const months_type& m)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return d + m.get_neg_offset(d);
+ }
+ friend date_type operator-=(date_type& d, const months_type& m)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return d += m.get_neg_offset(d);
+ }
+
+ private:
+ int_rep _m;
+ };
+
+ //! 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).
+ */
+ template<class base_config>
+ class years_duration
+ {
+ private:
+ typedef typename base_config::int_rep int_rep;
+ typedef typename int_rep::int_type int_type;
+ typedef typename base_config::date_type date_type;
+ typedef typename date_type::duration_type duration_type;
+ typedef typename base_config::month_adjustor_type month_adjustor_type;
+ typedef years_duration<base_config> years_type;
+ typedef months_duration<base_config> months_type;
+ public:
+ years_duration(int_rep num) : _y(num) {}
+ years_duration(special_values sv) : _y(sv)
+ {
+ _y = int_rep::from_special(sv);
+ }
+ int_rep number_of_years() const { return _y; }
+ //! returns a negative duration
+ duration_type get_neg_offset(const date_type& d) const
+ {
+ month_adjustor_type m_adj(_y.as_number() * 12);
+ return duration_type(m_adj.get_neg_offset(d));
+ }
+ duration_type get_offset(const date_type& d) const
+ {
+ month_adjustor_type m_adj(_y.as_number() * 12);
+ return duration_type(m_adj.get_offset(d));
+ }
+ bool operator==(const years_type& rhs) const
+ {
+ return(_y == rhs._y);
+ }
+ bool operator!=(const years_type& rhs) const
+ {
+ return(_y != rhs._y);
+ }
+ years_type operator+(const years_type& rhs)const
+ {
+ return years_type(_y + rhs._y);
+ }
+ years_type& operator+=(const years_type& rhs)
+ {
+ _y = _y + rhs._y;
+ return *this;
+ }
+ years_type operator-(const years_type& rhs)const
+ {
+ return years_type(_y - rhs._y);
+ }
+ years_type& operator-=(const years_type& rhs)
+ {
+ _y = _y - rhs._y;
+ return *this;
+ }
+ years_type operator*(const int_type rhs)const
+ {
+ return years_type(_y * rhs);
+ }
+ years_type& operator*=(const int_type rhs)
+ {
+ _y = _y * rhs;
+ return *this;
+ }
+ years_type operator/(const int_type rhs)const
+ {
+ return years_type(_y / rhs);
+ }
+ years_type& operator/=(const int_type rhs)
+ {
+ _y = _y / rhs;
+ return *this;
+ }
+ months_type operator+(const months_type& m) const
+ {
+ return(months_type(_y * 12 + m.number_of_months()));
+ }
+ months_type operator-(const months_type& m) const
+ {
+ return(months_type(_y * 12 - m.number_of_months()));
+ }
+
+ //
+ friend date_type operator+(const date_type& d, const years_type& y)
+ {
+ return d + y.get_offset(d);
+ }
+ friend date_type operator+=(date_type& d, const years_type& y)
+ {
+ return d += y.get_offset(d);
+ }
+ friend date_type operator-(const date_type& d, const years_type& y)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return d + y.get_neg_offset(d);
+ }
+ friend date_type operator-=(date_type& d, const years_type& y)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return d += y.get_neg_offset(d);
+ }
+
+ private:
+ int_rep _y;
+ };
+
+}} // namespace boost::date_time
+
+#endif // DATE_DURATION_TYPES_HPP___

Added: sandbox/SOC/2008/calendar/boost/date_time/date_facet.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_facet.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,775 @@
+#ifndef _DATE_TIME_DATE_FACET__HPP___
+#define _DATE_TIME_DATE_FACET__HPP___
+
+/* Copyright (c) 2004-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: Martin Andrian, Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/algorithm/string/replace.hpp"
+#include "boost/date_time/period.hpp"
+#include "boost/date_time/special_values_formatter.hpp"
+#include "boost/date_time/period_formatter.hpp"
+#include "boost/date_time/period_parser.hpp"
+#include "boost/date_time/date_generator_formatter.hpp"
+#include "boost/date_time/date_generator_parser.hpp"
+#include "boost/date_time/format_date_parser.hpp"
+#include <string>
+#include <vector>
+
+namespace boost { namespace date_time {
+
+
+ /*! Class 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
+ */
+ template <class date_type,
+ class CharT,
+ class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
+ class date_facet : public std::locale::facet {
+ public:
+ typedef typename date_type::duration_type duration_type;
+ // greg_weekday is gregorian_calendar::day_of_week_type
+ typedef typename date_type::day_of_week_type day_of_week_type;
+ typedef typename date_type::day_type day_type;
+ typedef typename date_type::month_type month_type;
+ typedef boost::date_time::period<date_type,duration_type> period_type;
+ typedef std::basic_string<CharT> string_type;
+ typedef CharT char_type;
+ typedef boost::date_time::period_formatter<CharT> period_formatter_type;
+ typedef boost::date_time::special_values_formatter<CharT> special_values_formatter_type;
+ typedef std::vector<std::basic_string<CharT> > input_collection_type;
+ // used for the output of the date_generators
+ typedef date_generator_formatter<date_type, CharT> date_gen_formatter_type;
+ typedef partial_date<date_type> partial_date_type;
+ typedef nth_kday_of_month<date_type> nth_kday_type;
+ typedef first_kday_of_month<date_type> first_kday_type;
+ typedef last_kday_of_month<date_type> last_kday_type;
+ typedef first_kday_after<date_type> kday_after_type;
+ typedef first_kday_before<date_type> kday_before_type;
+ static const char_type long_weekday_format[3];
+ static const char_type short_weekday_format[3];
+ static const char_type long_month_format[3];
+ static const char_type short_month_format[3];
+ static const char_type default_period_separator[4];
+ static const char_type standard_format_specifier[3];
+ static const char_type iso_format_specifier[7];
+ static const char_type iso_format_extended_specifier[9];
+ static const char_type default_date_format[9]; // YYYY-Mon-DD
+ static std::locale::id id;
+
+#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
+ std::locale::id& __get_id (void) const { return id; }
+#endif
+
+ explicit date_facet(::size_t a_ref = 0)
+ : std::locale::facet(a_ref),
+ //m_format(standard_format_specifier)
+ m_format(default_date_format),
+ m_month_format(short_month_format),
+ m_weekday_format(short_weekday_format)
+ {}
+
+ explicit date_facet(const char_type* format_str,
+ const input_collection_type& short_names,
+ ::size_t ref_count = 0)
+ : std::locale::facet(ref_count),
+ m_format(format_str),
+ m_month_format(short_month_format),
+ m_weekday_format(short_weekday_format),
+ m_month_short_names(short_names)
+ {}
+
+
+ explicit date_facet(const char_type* format_str,
+ period_formatter_type per_formatter = period_formatter_type(),
+ special_values_formatter_type sv_formatter = special_values_formatter_type(),
+ date_gen_formatter_type dg_formatter = date_gen_formatter_type(),
+ ::size_t ref_count = 0)
+ : std::locale::facet(ref_count),
+ m_format(format_str),
+ m_month_format(short_month_format),
+ m_weekday_format(short_weekday_format),
+ m_period_formatter(per_formatter),
+ m_date_gen_formatter(dg_formatter),
+ m_special_values_formatter(sv_formatter)
+ {}
+ void format(const char_type* const format_str) {
+ m_format = format_str;
+ }
+ virtual void set_iso_format()
+ {
+ m_format = iso_format_specifier;
+ }
+ virtual void set_iso_extended_format()
+ {
+ m_format = iso_format_extended_specifier;
+ }
+ void month_format(const char_type* const format_str) {
+ m_month_format = format_str;
+ }
+ void weekday_format(const char_type* const format_str) {
+ m_weekday_format = format_str;
+ }
+
+ void period_formatter(period_formatter_type per_formatter) {
+ m_period_formatter= per_formatter;
+ }
+ void special_values_formatter(const special_values_formatter_type& svf)
+ {
+ m_special_values_formatter = svf;
+ }
+ void short_weekday_names(const input_collection_type& short_names)
+ {
+ m_weekday_short_names = short_names;
+ }
+ void long_weekday_names(const input_collection_type& long_names)
+ {
+ m_weekday_long_names = long_names;
+ }
+
+ void short_month_names(const input_collection_type& short_names)
+ {
+ m_month_short_names = short_names;
+ }
+
+ void long_month_names(const input_collection_type& long_names)
+ {
+ m_month_long_names = long_names;
+ }
+
+ void date_gen_phrase_strings(const input_collection_type& new_strings,
+ typename date_gen_formatter_type::phrase_elements beg_pos=date_gen_formatter_type::first)
+ {
+ m_date_gen_formatter.elements(new_strings, beg_pos);
+ }
+
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const date_type& d) const
+ {
+ if (d.is_special()) {
+ return do_put_special(next, a_ios, fill_char, d.as_special());
+ }
+ //The following line of code required the date to support a to_tm function
+ return do_put_tm(next, a_ios, fill_char, to_tm(d), m_format);
+ }
+
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const duration_type& dd) const
+ {
+ if (dd.is_special()) {
+ return do_put_special(next, a_ios, fill_char, dd.get_rep().as_special());
+ }
+
+ typedef std::num_put<CharT, OutItrT> num_put;
+ if (std::has_facet<num_put>(a_ios.getloc())) {
+ return std::use_facet<num_put>(a_ios.getloc()).put(next, a_ios, fill_char, dd.get_rep().as_number());
+ }
+ else {
+ num_put* f = new num_put();
+ std::locale l = std::locale(a_ios.getloc(), f);
+ a_ios.imbue(l);
+ return f->put(next, a_ios, fill_char, dd.get_rep().as_number());
+ }
+
+ }
+
+
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const month_type& m) const
+ {
+ //if (d.is_special()) {
+ // return do_put_special(next, a_ios, fill_char, d.as_special());
+ //}
+ //The following line of code required the date to support a to_tm function
+ tm dtm;
+ init_tm(dtm);
+ dtm.tm_mon = m -1;
+ return do_put_tm(next, a_ios, fill_char, dtm, m_month_format);
+ }
+
+ //! puts the day of month
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const day_type& day) const
+ {
+ tm dtm;
+ init_tm(dtm);
+ dtm.tm_mday = day.as_number();
+ char_type tmp[3] = {'%','d'};
+ string_type temp_format(tmp);
+ return do_put_tm(next, a_ios, fill_char, dtm, temp_format);
+ }
+
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const day_of_week_type& dow) const
+ {
+ //if (d.is_special()) {
+ // return do_put_special(next, a_ios, fill_char, d.as_special());
+ //}
+ //The following line of code required the date to support a to_tm function
+ tm dtm;
+ init_tm(dtm);
+ dtm.tm_wday = dow;
+ return do_put_tm(next, a_ios, fill_char, dtm, m_weekday_format);
+ }
+
+
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const period_type& p) const
+ {
+ return m_period_formatter.put_period(next, a_ios, fill_char, p, *this);
+ }
+
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const partial_date_type& pd) const
+ {
+ return m_date_gen_formatter.put_partial_date(next, a_ios, fill_char, pd, *this);
+ }
+
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const nth_kday_type& nkd) const
+ {
+ return m_date_gen_formatter.put_nth_kday(next, a_ios, fill_char, nkd, *this);
+ }
+
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const first_kday_type& fkd) const
+ {
+ return m_date_gen_formatter.put_first_kday(next, a_ios, fill_char, fkd, *this);
+ }
+
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const last_kday_type& lkd) const
+ {
+ return m_date_gen_formatter.put_last_kday(next, a_ios, fill_char, lkd, *this);
+ }
+
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const kday_before_type& fkb) const
+ {
+ return m_date_gen_formatter.put_kday_before(next, a_ios, fill_char, fkb, *this);
+ }
+
+ OutItrT put(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const kday_after_type& fka) const
+ {
+ return m_date_gen_formatter.put_kday_after(next, a_ios, fill_char, fka, *this);
+ }
+
+ protected:
+ //! Helper function to initialize all fields in a tm struct
+ tm init_tm(tm& tm_value) const
+ {
+ tm_value.tm_sec = 0; /* seconds */
+ tm_value.tm_min = 0; /* minutes */
+ tm_value.tm_hour = 0; /* hours */
+ tm_value.tm_mday = 0; /* day of the month */
+ tm_value.tm_mon = 0; /* month */
+ tm_value.tm_year = 0; /* year */
+ tm_value.tm_wday = 0; /* day of the week */
+ tm_value.tm_yday = 0; /* day in the year */
+ tm_value.tm_isdst = 0; /* daylight saving time */
+ return tm_value;
+ }
+ virtual OutItrT do_put_special(OutItrT next,
+ std::ios_base& /*a_ios*/,
+ char_type /*fill_char*/,
+ const boost::date_time::special_values sv) const
+ {
+ m_special_values_formatter.put_special(next, sv);
+ return next;
+ }
+ virtual OutItrT do_put_tm(OutItrT next,
+ std::ios_base& a_ios,
+ char_type fill_char,
+ const tm& tm_value,
+ string_type a_format) const
+ {
+ // update format string with custom names
+ if (m_weekday_long_names.size()) {
+ boost::algorithm::replace_all(a_format,
+ long_weekday_format,
+ m_weekday_long_names[tm_value.tm_wday]);
+ }
+ if (m_weekday_short_names.size()) {
+ boost::algorithm::replace_all(a_format,
+ short_weekday_format,
+ m_weekday_short_names[tm_value.tm_wday]);
+
+ }
+ if (m_month_long_names.size()) {
+ boost::algorithm::replace_all(a_format,
+ long_month_format,
+ m_month_long_names[tm_value.tm_mon]);
+ }
+ if (m_month_short_names.size()) {
+ boost::algorithm::replace_all(a_format,
+ short_month_format,
+ m_month_short_names[tm_value.tm_mon]);
+ }
+ // use time_put facet to create final string
+ return std::use_facet<std::time_put<CharT> >(a_ios.getloc()).put(next, a_ios,
+ fill_char,
+ &tm_value,
+ &*a_format.begin(),
+ &*a_format.begin()+a_format.size());
+ }
+ protected:
+ string_type m_format;
+ string_type m_month_format;
+ string_type m_weekday_format;
+ period_formatter_type m_period_formatter;
+ date_gen_formatter_type m_date_gen_formatter;
+ special_values_formatter_type m_special_values_formatter;
+ input_collection_type m_month_short_names;
+ input_collection_type m_month_long_names;
+ input_collection_type m_weekday_short_names;
+ input_collection_type m_weekday_long_names;
+ private:
+ };
+
+ template <class date_type, class CharT, class OutItrT>
+ std::locale::id date_facet<date_type, CharT, OutItrT>::id;
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::long_weekday_format[3] = {'%','A'};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::short_weekday_format[3] = {'%','a'};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::long_month_format[3] = {'%','B'};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::short_month_format[3] = {'%','b'};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::default_period_separator[4] = { ' ', '/', ' '};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::standard_format_specifier[3] =
+ {'%', 'x' };
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::iso_format_specifier[7] =
+ {'%', 'Y', '%', 'm', '%', 'd' };
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::iso_format_extended_specifier[9] =
+ {'%', 'Y', '-', '%', 'm', '-', '%', 'd' };
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_facet<date_type, CharT, OutItrT>::char_type
+ date_facet<date_type, CharT, OutItrT>::default_date_format[9] =
+ {'%','Y','-','%','b','-','%','d'};
+
+
+
+ //! Input facet
+ template <class date_type,
+ class CharT,
+ class InItrT = std::istreambuf_iterator<CharT, std::char_traits<CharT> > >
+ class date_input_facet : public std::locale::facet {
+ public:
+ typedef typename date_type::duration_type duration_type;
+ // greg_weekday is gregorian_calendar::day_of_week_type
+ typedef typename date_type::day_of_week_type day_of_week_type;
+ typedef typename date_type::day_type day_type;
+ typedef typename date_type::month_type month_type;
+ typedef typename date_type::year_type year_type;
+ typedef boost::date_time::period<date_type,duration_type> period_type;
+ typedef std::basic_string<CharT> string_type;
+ typedef CharT char_type;
+ typedef boost::date_time::period_parser<date_type, CharT> period_parser_type;
+ typedef boost::date_time::special_values_parser<date_type,CharT> special_values_parser_type;
+ typedef std::vector<std::basic_string<CharT> > input_collection_type;
+ typedef format_date_parser<date_type, CharT> format_date_parser_type;
+ // date_generators stuff goes here
+ typedef date_generator_parser<date_type, CharT> date_gen_parser_type;
+ typedef partial_date<date_type> partial_date_type;
+ typedef nth_kday_of_month<date_type> nth_kday_type;
+ typedef first_kday_of_month<date_type> first_kday_type;
+ typedef last_kday_of_month<date_type> last_kday_type;
+ typedef first_kday_after<date_type> kday_after_type;
+ typedef first_kday_before<date_type> kday_before_type;
+
+ static const char_type long_weekday_format[3];
+ static const char_type short_weekday_format[3];
+ static const char_type long_month_format[3];
+ static const char_type short_month_format[3];
+ static const char_type four_digit_year_format[3];
+ static const char_type two_digit_year_format[3];
+ static const char_type default_period_separator[4];
+ static const char_type standard_format_specifier[3];
+ static const char_type iso_format_specifier[7];
+ static const char_type iso_format_extended_specifier[9];
+ static const char_type default_date_format[9]; // YYYY-Mon-DD
+ static std::locale::id id;
+
+ explicit date_input_facet(::size_t a_ref = 0)
+ : std::locale::facet(a_ref),
+ m_format(default_date_format),
+ m_month_format(short_month_format),
+ m_weekday_format(short_weekday_format),
+ m_year_format(four_digit_year_format),
+ m_parser(m_format, std::locale::classic())
+ // default period_parser & special_values_parser used
+ {}
+
+ explicit date_input_facet(const string_type& format_str,
+ ::size_t a_ref = 0)
+ : std::locale::facet(a_ref),
+ m_format(format_str),
+ m_month_format(short_month_format),
+ m_weekday_format(short_weekday_format),
+ m_year_format(four_digit_year_format),
+ m_parser(m_format, std::locale::classic())
+ // default period_parser & special_values_parser used
+ {}
+
+ explicit date_input_facet(const string_type& format_str,
+ const format_date_parser_type& date_parser,
+ const special_values_parser_type& sv_parser,
+ const period_parser_type& per_parser,
+ const date_gen_parser_type& date_gen_parser,
+ ::size_t ref_count = 0)
+ : std::locale::facet(ref_count),
+ m_format(format_str),
+ m_month_format(short_month_format),
+ m_weekday_format(short_weekday_format),
+ m_year_format(four_digit_year_format),
+ m_parser(date_parser),
+ m_date_gen_parser(date_gen_parser),
+ m_period_parser(per_parser),
+ m_sv_parser(sv_parser)
+ {}
+
+
+ void format(const char_type* const format_str) {
+ m_format = format_str;
+ }
+ virtual void set_iso_format()
+ {
+ m_format = iso_format_specifier;
+ }
+ virtual void set_iso_extended_format()
+ {
+ m_format = iso_format_extended_specifier;
+ }
+ void month_format(const char_type* const format_str) {
+ m_month_format = format_str;
+ }
+ void weekday_format(const char_type* const format_str) {
+ m_weekday_format = format_str;
+ }
+ void year_format(const char_type* const format_str) {
+ m_year_format = format_str;
+ }
+
+ void period_parser(period_parser_type per_parser) {
+ m_period_parser = per_parser;
+ }
+ void short_weekday_names(const input_collection_type& weekday_names)
+ {
+ m_parser.short_weekday_names(weekday_names);
+ }
+ void long_weekday_names(const input_collection_type& weekday_names)
+ {
+ m_parser.long_weekday_names(weekday_names);
+ }
+
+ void short_month_names(const input_collection_type& month_names)
+ {
+ m_parser.short_month_names(month_names);
+ }
+
+ void long_month_names(const input_collection_type& month_names)
+ {
+ m_parser.long_month_names(month_names);
+ }
+
+ void date_gen_element_strings(const input_collection_type& col)
+ {
+ m_date_gen_parser.element_strings(col);
+ }
+ void date_gen_element_strings(const string_type& first,
+ const string_type& second,
+ const string_type& third,
+ const string_type& fourth,
+ const string_type& fifth,
+ const string_type& last,
+ const string_type& before,
+ const string_type& after,
+ const string_type& of)
+
+ {
+ m_date_gen_parser.element_strings(first,second,third,fourth,fifth,last,before,after,of);
+ }
+
+ void special_values_parser(special_values_parser_type sv_parser)
+ {
+ m_sv_parser = sv_parser;
+ }
+
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& /*a_ios*/,
+ date_type& d) const
+ {
+ d = m_parser.parse_date(from, to, m_format, m_sv_parser);
+ return from;
+ }
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& /*a_ios*/,
+ month_type& m) const
+ {
+ m = m_parser.parse_month(from, to, m_month_format);
+ return from;
+ }
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& /*a_ios*/,
+ day_of_week_type& wd) const
+ {
+ wd = m_parser.parse_weekday(from, to, m_weekday_format);
+ return from;
+ }
+ //! Expects 1 or 2 digit day range: 1-31
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& /*a_ios*/,
+ day_type& d) const
+ {
+ d = m_parser.parse_var_day_of_month(from, to);
+ return from;
+ }
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& /*a_ios*/,
+ year_type& y) const
+ {
+ y = m_parser.parse_year(from, to, m_year_format);
+ return from;
+ }
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
+ duration_type& dd) const
+ {
+ // skip leading whitespace
+ while(std::isspace(*from) && from != to) { ++from; }
+
+ /* num_get.get() will always consume the first character if it
+ * is a sign indicator (+/-). Special value strings may begin
+ * with one of these signs so we'll need a copy of it
+ * in case num_get.get() fails. */
+ char_type c = '\0';
+ // TODO Are these characters somewhere in the locale?
+ if(*from == '-' || *from == '+') {
+ c = *from;
+ }
+ typedef std::num_get<CharT, InItrT> num_get;
+ typename duration_type::duration_rep_type val = 0;
+ std::ios_base::iostate err = std::ios_base::goodbit;
+
+ if (std::has_facet<num_get>(a_ios.getloc())) {
+ from = std::use_facet<num_get>(a_ios.getloc()).get(from, to, a_ios, err, val);
+ }
+ else {
+ num_get* ng = new num_get();
+ std::locale l = std::locale(a_ios.getloc(), ng);
+ a_ios.imbue(l);
+ from = ng->get(from, to, a_ios, err, val);
+ }
+ if(err & std::ios_base::failbit){
+ typedef typename special_values_parser_type::match_results match_results;
+ match_results mr;
+ if(c == '-' || c == '+') { // was the first character consumed?
+ mr.cache += c;
+ }
+ m_sv_parser.match(from, to, mr);
+ if(mr.current_match == match_results::PARSE_ERROR) {
+ throw std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'");
+ }
+ dd = duration_type(static_cast<special_values>(mr.current_match));
+ }
+ else {
+ dd = duration_type(val);
+ }
+ return from;
+ }
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
+ period_type& p) const
+ {
+ p = m_period_parser.get_period(from, to, a_ios, p, duration_type::unit(), *this);
+ return from;
+ }
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
+ nth_kday_type& nkd) const
+ {
+ nkd = m_date_gen_parser.get_nth_kday_type(from, to, a_ios, *this);
+ return from;
+ }
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
+ partial_date_type& pd) const
+ {
+
+ pd = m_date_gen_parser.get_partial_date_type(from, to, a_ios, *this);
+ return from;
+ }
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
+ first_kday_type& fkd) const
+ {
+ fkd = m_date_gen_parser.get_first_kday_type(from, to, a_ios, *this);
+ return from;
+ }
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
+ last_kday_type& lkd) const
+ {
+ lkd = m_date_gen_parser.get_last_kday_type(from, to, a_ios, *this);
+ return from;
+ }
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
+ kday_before_type& fkb) const
+ {
+ fkb = m_date_gen_parser.get_kday_before_type(from, to, a_ios, *this);
+ return from;
+ }
+ InItrT get(InItrT& from,
+ InItrT& to,
+ std::ios_base& a_ios,
+ kday_after_type& fka) const
+ {
+ fka = m_date_gen_parser.get_kday_after_type(from, to, a_ios, *this);
+ return from;
+ }
+
+ protected:
+ string_type m_format;
+ string_type m_month_format;
+ string_type m_weekday_format;
+ string_type m_year_format;
+ format_date_parser_type m_parser;
+ date_gen_parser_type m_date_gen_parser;
+ period_parser_type m_period_parser;
+ special_values_parser_type m_sv_parser;
+ private:
+ };
+
+
+ template <class date_type, class CharT, class OutItrT>
+ std::locale::id date_input_facet<date_type, CharT, OutItrT>::id;
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::long_weekday_format[3] = {'%','A'};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::short_weekday_format[3] = {'%','a'};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::long_month_format[3] = {'%','B'};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::short_month_format[3] = {'%','b'};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::four_digit_year_format[3] = {'%','Y'};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::two_digit_year_format[3] = {'%','y'};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::default_period_separator[4] = { ' ', '/', ' '};
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::standard_format_specifier[3] =
+ {'%', 'x' };
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::iso_format_specifier[7] =
+ {'%', 'Y', '%', 'm', '%', 'd' };
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::iso_format_extended_specifier[9] =
+ {'%', 'Y', '-', '%', 'm', '-', '%', 'd' };
+
+ template <class date_type, class CharT, class OutItrT>
+ const typename date_input_facet<date_type, CharT, OutItrT>::char_type
+ date_input_facet<date_type, CharT, OutItrT>::default_date_format[9] =
+ {'%','Y','-','%','b','-','%','d'};
+
+} } // namespaces
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/date_format_simple.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_format_simple.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,159 @@
+#ifndef DATE_TIME_SIMPLE_FORMAT_HPP___
+#define DATE_TIME_SIMPLE_FORMAT_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/parse_format_base.hpp"
+
+namespace boost {
+namespace date_time {
+
+//! Class to provide simple basic formatting rules
+template<class charT>
+class simple_format {
+public:
+
+ //! String used printed is date is invalid
+ static const charT* not_a_date()
+ {
+ return "not-a-date-time";
+ }
+ //! String used to for positive infinity value
+ static const charT* pos_infinity()
+ {
+ return "+infinity";
+ }
+ //! String used to for positive infinity value
+ static const charT* neg_infinity()
+ {
+ return "-infinity";
+ }
+ //! Describe month format
+ static month_format_spec month_format()
+ {
+ return month_as_short_string;
+ }
+ static ymd_order_spec date_order()
+ {
+ return ymd_order_iso; //YYYY-MM-DD
+ }
+ //! This format uses '-' to separate date elements
+ static bool has_date_sep_chars()
+ {
+ return true;
+ }
+ //! Char to sep?
+ static charT year_sep_char()
+ {
+ return '-';
+ }
+ //! char between year-month
+ static charT month_sep_char()
+ {
+ return '-';
+ }
+ //! Char to separate month-day
+ static charT day_sep_char()
+ {
+ return '-';
+ }
+ //! char between date-hours
+ static charT hour_sep_char()
+ {
+ return ' ';
+ }
+ //! char between hour and minute
+ static charT minute_sep_char()
+ {
+ return ':';
+ }
+ //! char for second
+ static charT second_sep_char()
+ {
+ return ':';
+ }
+
+};
+
+#ifndef BOOST_NO_STD_WSTRING
+
+//! Specialization of formmating rules for wchar_t
+template<>
+class simple_format<wchar_t> {
+public:
+
+ //! String used printed is date is invalid
+ static const wchar_t* not_a_date()
+ {
+ return L"not-a-date-time";
+ }
+ //! String used to for positive infinity value
+ static const wchar_t* pos_infinity()
+ {
+ return L"+infinity";
+ }
+ //! String used to for positive infinity value
+ static const wchar_t* neg_infinity()
+ {
+ return L"-infinity";
+ }
+ //! Describe month format
+ static month_format_spec month_format()
+ {
+ return month_as_short_string;
+ }
+ static ymd_order_spec date_order()
+ {
+ return ymd_order_iso; //YYYY-MM-DD
+ }
+ //! This format uses '-' to separate date elements
+ static bool has_date_sep_chars()
+ {
+ return true;
+ }
+ //! Char to sep?
+ static wchar_t year_sep_char()
+ {
+ return '-';
+ }
+ //! char between year-month
+ static wchar_t month_sep_char()
+ {
+ return '-';
+ }
+ //! Char to separate month-day
+ static wchar_t day_sep_char()
+ {
+ return '-';
+ }
+ //! char between date-hours
+ static wchar_t hour_sep_char()
+ {
+ return ' ';
+ }
+ //! char between hour and minute
+ static wchar_t minute_sep_char()
+ {
+ return ':';
+ }
+ //! char for second
+ static wchar_t second_sep_char()
+ {
+ return ':';
+ }
+
+};
+
+#endif // BOOST_NO_STD_WSTRING
+} } //namespace date_time
+
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/date_formatting.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_formatting.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,127 @@
+#ifndef DATE_TIME_DATE_FORMATTING_HPP___
+#define DATE_TIME_DATE_FORMATTING_HPP___
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/iso_format.hpp"
+#include "boost/date_time/compiler_config.hpp"
+#include <string>
+#include <sstream>
+#include <iomanip>
+
+/* NOTE: "formatter" code for older compilers, ones that define
+ * BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS, is located in
+ * date_formatting_limited.hpp
+ */
+
+namespace boost {
+namespace date_time {
+
+ //! Formats a month as as string into an ostream
+ template<class month_type, class format_type, class charT=char>
+ class month_formatter
+ {
+ typedef std::basic_ostream<charT> ostream_type;
+ public:
+ //! 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.
+ */
+ static ostream_type& format_month(const month_type& month,
+ ostream_type &os)
+ {
+ switch (format_type::month_format())
+ {
+ case month_as_short_string:
+ {
+ os << month.as_short_string();
+ break;
+ }
+ case month_as_long_string:
+ {
+ os << month.as_long_string();
+ break;
+ }
+ case month_as_integer:
+ {
+ os << std::setw(2) << std::setfill(os.widen('0')) << month.as_number();
+ break;
+ }
+
+ }
+ return os;
+ } // format_month
+ };
+
+
+ //! Convert ymd to a standard string formatting policies
+ template<class ymd_type, class format_type, class charT=char>
+ class ymd_formatter
+ {
+ public:
+ //! 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
+ */
+ static std::basic_string<charT> ymd_to_string(ymd_type ymd)
+ {
+ typedef typename ymd_type::month_type month_type;
+ std::basic_ostringstream<charT> ss;
+ ss << ymd.year;
+ if (format_type::has_date_sep_chars()) {
+ ss << format_type::month_sep_char();
+ }
+ //this name is a bit ugly, oh well....
+ month_formatter<month_type,format_type,charT>::format_month(ymd.month, ss);
+ if (format_type::has_date_sep_chars()) {
+ ss << format_type::day_sep_char();
+ }
+ ss << std::setw(2) << std::setfill(ss.widen('0'))
+ << ymd.day;
+ return ss.str();
+ }
+ };
+
+
+ //! Convert a date to string using format policies
+ template<class date_type, class format_type, class charT=char>
+ class date_formatter
+ {
+ public:
+ typedef std::basic_string<charT> string_type;
+ //! Convert to a date to standard string using format policies
+ static string_type date_to_string(date_type d)
+ {
+ typedef typename date_type::ymd_type ymd_type;
+ if (d.is_not_a_date()) {
+ return string_type(format_type::not_a_date());
+ }
+ if (d.is_neg_infinity()) {
+ return string_type(format_type::neg_infinity());
+ }
+ if (d.is_pos_infinity()) {
+ return string_type(format_type::pos_infinity());
+ }
+ ymd_type ymd = d.year_month_day();
+ return ymd_formatter<ymd_type, format_type, charT>::ymd_to_string(ymd);
+ }
+ };
+
+
+} } //namespace date_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/date_formatting_limited.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_formatting_limited.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,121 @@
+#ifndef DATE_TIME_DATE_FORMATTING_LIMITED_HPP___
+#define DATE_TIME_DATE_FORMATTING_LIMITED_HPP___
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/iso_format.hpp"
+#include "boost/date_time/compiler_config.hpp"
+#include <string>
+#include <sstream>
+#include <iomanip>
+
+
+namespace boost {
+namespace date_time {
+
+ //! Formats a month as as string into an ostream
+ template<class month_type, class format_type>
+ class month_formatter
+ {
+ public:
+ //! 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.
+ */
+ static std::ostream& format_month(const month_type& month,
+ std::ostream& os)
+ {
+ switch (format_type::month_format())
+ {
+ case month_as_short_string:
+ {
+ os << month.as_short_string();
+ break;
+ }
+ case month_as_long_string:
+ {
+ os << month.as_long_string();
+ break;
+ }
+ case month_as_integer:
+ {
+ os << std::setw(2) << std::setfill('0') << month.as_number();
+ break;
+ }
+
+ }
+ return os;
+ } // format_month
+ };
+
+
+ //! Convert ymd to a standard string formatting policies
+ template<class ymd_type, class format_type>
+ class ymd_formatter
+ {
+ public:
+ //! 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
+ */
+ static std::string ymd_to_string(ymd_type ymd)
+ {
+ typedef typename ymd_type::month_type month_type;
+ std::ostringstream ss;
+ ss << ymd.year;
+ if (format_type::has_date_sep_chars()) {
+ ss << format_type::month_sep_char();
+ }
+ //this name is a bit ugly, oh well....
+ month_formatter<month_type,format_type>::format_month(ymd.month, ss);
+ if (format_type::has_date_sep_chars()) {
+ ss << format_type::day_sep_char();
+ }
+ ss << std::setw(2) << std::setfill('0')
+ << ymd.day;
+ return ss.str();
+ }
+ };
+
+
+ //! Convert a date to string using format policies
+ template<class date_type, class format_type>
+ class date_formatter
+ {
+ public:
+ //! Convert to a date to standard string using format policies
+ static std::string date_to_string(date_type d)
+ {
+ typedef typename date_type::ymd_type ymd_type;
+ if (d.is_not_a_date()) {
+ return format_type::not_a_date();
+ }
+ if (d.is_neg_infinity()) {
+ return format_type::neg_infinity();
+ }
+ if (d.is_pos_infinity()) {
+ return format_type::pos_infinity();
+ }
+ ymd_type ymd = d.year_month_day();
+ return ymd_formatter<ymd_type, format_type>::ymd_to_string(ymd);
+ }
+ };
+
+
+} } //namespace date_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/date_formatting_locales.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_formatting_locales.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,233 @@
+#ifndef DATE_TIME_DATE_FORMATTING_LOCALES_HPP___
+#define DATE_TIME_DATE_FORMATTING_LOCALES_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/locale_config.hpp" // set BOOST_DATE_TIME_NO_LOCALE
+
+#ifndef BOOST_DATE_TIME_NO_LOCALE
+
+#include "boost/date_time/iso_format.hpp"
+#include "boost/date_time/date_names_put.hpp"
+#include "boost/date_time/parse_format_base.hpp"
+//#include <string>
+#include <sstream>
+#include <iomanip>
+
+
+namespace boost {
+namespace date_time {
+
+ //! Formats a month as as string into an ostream
+ template<class facet_type,
+ class charT = char>
+ class ostream_month_formatter
+ {
+ public:
+ typedef typename facet_type::month_type month_type;
+ typedef std::basic_ostream<charT> ostream_type;
+
+ //! Formats a month as as string into an output iterator
+ static void format_month(const month_type& month,
+ ostream_type& os,
+ const facet_type& f)
+ {
+
+ switch (f.month_format())
+ {
+ case month_as_short_string:
+ {
+ std::ostreambuf_iterator<charT> oitr(os);
+ f.put_month_short(oitr, month.as_enum());
+ break;
+ }
+ case month_as_long_string:
+ {
+ std::ostreambuf_iterator<charT> oitr(os);
+ f.put_month_long(oitr, month.as_enum());
+ break;
+ }
+ case month_as_integer:
+ {
+ charT fill_char = '0';
+ os << std::setw(2) << std::setfill(fill_char) << month.as_number();
+ break;
+ }
+
+ }
+ } // format_month
+
+ };
+
+
+ //! Formats a weekday
+ template<class weekday_type,
+ class facet_type,
+ class charT = char>
+ class ostream_weekday_formatter
+ {
+ public:
+ typedef typename facet_type::month_type month_type;
+ typedef std::basic_ostream<charT> ostream_type;
+
+ //! Formats a month as as string into an output iterator
+ static void format_weekday(const weekday_type& wd,
+ ostream_type& os,
+ const facet_type& f,
+ bool as_long_string)
+ {
+
+ std::ostreambuf_iterator<charT> oitr(os);
+ if (as_long_string) {
+ f.put_weekday_long(oitr, wd.as_enum());
+ }
+ else {
+ f.put_weekday_short(oitr, wd.as_enum());
+ }
+
+ } // format_weekday
+
+ };
+
+
+ //! Convert ymd to a standard string formatting policies
+ template<class ymd_type,
+ class facet_type,
+ class charT = char>
+ class ostream_ymd_formatter
+ {
+ public:
+ typedef typename ymd_type::month_type month_type;
+ typedef ostream_month_formatter<facet_type, charT> month_formatter_type;
+ typedef std::basic_ostream<charT> ostream_type;
+ typedef std::basic_string<charT> foo_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
+ */
+ // static string_type ymd_to_string(ymd_type ymd)
+// {
+// std::ostringstream ss;
+// facet_type dnp;
+// ymd_put(ymd, ss, dnp);
+// return ss.str();
+// }
+
+
+ // Put ymd to ostream -- part of ostream refactor
+ static void ymd_put(ymd_type ymd,
+ ostream_type& os,
+ const facet_type& f)
+ {
+ std::ostreambuf_iterator<charT> oitr(os);
+ charT fill_char = '0';
+ switch (f.date_order()) {
+ case ymd_order_iso: {
+ os << ymd.year;
+ if (f.has_date_sep_chars()) {
+ f.month_sep_char(oitr);
+ }
+ month_formatter_type::format_month(ymd.month, os, f);
+ if (f.has_date_sep_chars()) {
+ f.day_sep_char(oitr);
+ }
+ os << std::setw(2) << std::setfill(fill_char)
+ << ymd.day;
+ break;
+ }
+ case ymd_order_us: {
+ month_formatter_type::format_month(ymd.month, os, f);
+ if (f.has_date_sep_chars()) {
+ f.day_sep_char(oitr);
+ }
+ os << std::setw(2) << std::setfill(fill_char)
+ << ymd.day;
+ if (f.has_date_sep_chars()) {
+ f.month_sep_char(oitr);
+ }
+ os << ymd.year;
+ break;
+ }
+ case ymd_order_dmy: {
+ os << std::setw(2) << std::setfill(fill_char)
+ << ymd.day;
+ if (f.has_date_sep_chars()) {
+ f.day_sep_char(oitr);
+ }
+ month_formatter_type::format_month(ymd.month, os, f);
+ if (f.has_date_sep_chars()) {
+ f.month_sep_char(oitr);
+ }
+ os << ymd.year;
+ break;
+ }
+ }
+ }
+ };
+
+
+ //! Convert a date to string using format policies
+ template<class date_type,
+ class facet_type,
+ class charT = char>
+ class ostream_date_formatter
+ {
+ public:
+ typedef std::basic_ostream<charT> ostream_type;
+ typedef typename date_type::ymd_type ymd_type;
+
+ //! Put date into an ostream
+ static void date_put(const date_type& d,
+ ostream_type& os,
+ const facet_type& f)
+ {
+ special_values sv = d.as_special();
+ if (sv == not_special) {
+ ymd_type ymd = d.year_month_day();
+ ostream_ymd_formatter<ymd_type, facet_type, charT>::ymd_put(ymd, os, f);
+ }
+ else { // output a special value
+ std::ostreambuf_iterator<charT> coi(os);
+ f.put_special_value(coi, sv);
+ }
+ }
+
+
+ //! Put date into an ostream
+ static void date_put(const date_type& d,
+ ostream_type& os)
+ {
+ //retrieve the local from the ostream
+ std::locale locale = os.getloc();
+ if (std::has_facet<facet_type>(locale)) {
+ const facet_type& f = std::use_facet<facet_type>(locale);
+ date_put(d, os, f);
+ }
+ else {
+ //default to something sensible if no facet installed
+ facet_type default_facet;
+ date_put(d, os, default_facet);
+ }
+ } // date_to_ostream
+ }; //class date_formatter
+
+
+} } //namespace date_time
+
+#endif
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/date_generator_formatter.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_generator_formatter.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,263 @@
+#ifndef _DATE_TIME_DATE_GENERATOR_FORMATTER__HPP___
+#define _DATE_TIME_DATE_GENERATOR_FORMATTER__HPP___
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <iostream>
+#include <string>
+#include <vector>
+#include <algorithm>
+#include "boost/date_time/date_generators.hpp"
+
+namespace boost {
+namespace date_time {
+
+ //! 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.
+ */
+ template <class date_type, class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
+ class date_generator_formatter {
+ public:
+ typedef partial_date<date_type> partial_date_type;
+ typedef nth_kday_of_month<date_type> nth_kday_type;
+ typedef first_kday_of_month<date_type> first_kday_type;
+ typedef last_kday_of_month<date_type> last_kday_type;
+ typedef first_kday_after<date_type> kday_after_type;
+ typedef first_kday_before<date_type> kday_before_type;
+
+ typedef CharT char_type;
+ typedef std::basic_string<char_type> string_type;
+ typedef std::vector<string_type> collection_type;
+ static const char_type first_string[6];
+ static const char_type second_string[7];
+ static const char_type third_string[6];
+ static const char_type fourth_string[7];
+ static const char_type fifth_string[6];
+ static const char_type last_string[5];
+ static const char_type before_string[8];
+ static const char_type after_string[6];
+ static const char_type of_string[3];
+
+ enum phrase_elements {first=0, second, third, fourth, fifth, last,
+ before, after, of, number_of_phrase_elements};
+
+ //! Default format elements used
+ date_generator_formatter()
+ {
+ phrase_strings.push_back(string_type(first_string));
+ phrase_strings.push_back(string_type(second_string));
+ phrase_strings.push_back(string_type(third_string));
+ phrase_strings.push_back(string_type(fourth_string));
+ phrase_strings.push_back(string_type(fifth_string));
+ phrase_strings.push_back(string_type(last_string));
+ phrase_strings.push_back(string_type(before_string));
+ phrase_strings.push_back(string_type(after_string));
+ phrase_strings.push_back(string_type(of_string));
+ }
+
+ //! Constructor that allows for a custom set of phrase elements
+ date_generator_formatter(const string_type& first,
+ const string_type& second,
+ const string_type& third,
+ const string_type& fourth,
+ const string_type& fifth,
+ const string_type& last,
+ const string_type& before,
+ const string_type& after,
+ const string_type& of)
+ {
+ phrase_strings.push_back(string_type(first_string));
+ phrase_strings.push_back(string_type(second_string));
+ phrase_strings.push_back(string_type(third_string));
+ phrase_strings.push_back(string_type(fourth_string));
+ phrase_strings.push_back(string_type(fifth_string));
+ phrase_strings.push_back(string_type(last_string));
+ phrase_strings.push_back(string_type(before_string));
+ phrase_strings.push_back(string_type(after_string));
+ phrase_strings.push_back(string_type(of_string));
+ }
+
+ //! Replace 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.
+ */
+ void elements(const collection_type& new_strings,
+ phrase_elements beg_pos=first)
+ {
+ if(beg_pos < number_of_phrase_elements) {
+ typename collection_type::iterator itr = phrase_strings.begin();
+ itr += beg_pos;
+ std::copy(new_strings.begin(), new_strings.end(),
+ itr);
+ //phrase_strings.begin());
+ }
+ }
+
+ //!Put a partial_date => "dd Month"
+ template<class facet_type>
+ OutItrT put_partial_date(OutItrT next, std::ios_base& a_ios,
+ CharT a_fill, const partial_date_type& pd,
+ const facet_type& facet) const
+ {
+ facet.put(next, a_ios, a_fill, pd.day());
+ next = a_fill; //TODO change this ???
+ facet.put(next, a_ios, a_fill, pd.month());
+ return next;
+ }
+
+ //! Put an nth_day_of_the_week_in_month => "nth weekday of month"
+ template<class facet_type>
+ OutItrT put_nth_kday(OutItrT next, std::ios_base& a_ios,
+ CharT a_fill, const nth_kday_type& nkd,
+ const facet_type& facet) const
+ {
+ put_string(next, phrase_strings[nkd.nth_week() -1]);
+ next = a_fill; //TODO change this ???
+ facet.put(next, a_ios, a_fill, nkd.day_of_week());
+ next = a_fill; //TODO change this ???
+ put_string(next, string_type(of_string));
+ next = a_fill; //TODO change this ???
+ facet.put(next, a_ios, a_fill, nkd.month());
+ return next;
+ }
+
+ //! Put a first_day_of_the_week_in_month => "first weekday of month"
+ template<class facet_type>
+ OutItrT put_first_kday(OutItrT next, std::ios_base& a_ios,
+ CharT a_fill, const first_kday_type& fkd,
+ const facet_type& facet) const
+ {
+ put_string(next, phrase_strings[first]);
+ next = a_fill; //TODO change this ???
+ facet.put(next, a_ios, a_fill, fkd.day_of_week());
+ next = a_fill; //TODO change this ???
+ put_string(next, string_type(of_string));
+ next = a_fill; //TODO change this ???
+ facet.put(next, a_ios, a_fill, fkd.month());
+ return next;
+ }
+
+ //! Put a last_day_of_the_week_in_month => "last weekday of month"
+ template<class facet_type>
+ OutItrT put_last_kday(OutItrT next, std::ios_base& a_ios,
+ CharT a_fill, const last_kday_type& lkd,
+ const facet_type& facet) const
+ {
+ put_string(next, phrase_strings[last]);
+ next = a_fill; //TODO change this ???
+ facet.put(next, a_ios, a_fill, lkd.day_of_week());
+ next = a_fill; //TODO change this ???
+ put_string(next, string_type(of_string));
+ next = a_fill; //TODO change this ???
+ facet.put(next, a_ios, a_fill, lkd.month());
+ return next;
+ }
+
+ //! Put a first_day_of_the_week_before => "weekday before"
+ template<class facet_type>
+ OutItrT put_kday_before(OutItrT next, std::ios_base& a_ios,
+ CharT a_fill, const kday_before_type& fkb,
+ const facet_type& facet) const
+ {
+ facet.put(next, a_ios, a_fill, fkb.day_of_week());
+ next = a_fill; //TODO change this ???
+ put_string(next, phrase_strings[before]);
+ return next;
+ }
+
+ //! Put a first_day_of_the_week_after => "weekday after"
+ template<class facet_type>
+ OutItrT put_kday_after(OutItrT next, std::ios_base& a_ios,
+ CharT a_fill, const kday_after_type& fka,
+ const facet_type& facet) const
+ {
+ facet.put(next, a_ios, a_fill, fka.day_of_week());
+ next = a_fill; //TODO change this ???
+ put_string(next, phrase_strings[after]);
+ return next;
+ }
+
+
+ private:
+ collection_type phrase_strings;
+
+ //! helper function to put the various member string into stream
+ OutItrT put_string(OutItrT next, const string_type& str) const
+ {
+ typename string_type::const_iterator itr = str.begin();
+ while(itr != str.end()) {
+ *next = *itr;
+ ++itr;
+ ++next;
+ }
+ return next;
+ }
+ };
+
+ template<class date_type, class CharT, class OutItrT>
+ const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
+ date_generator_formatter<date_type, CharT, OutItrT>::first_string[6] =
+ {'f','i','r','s','t'};
+ template<class date_type, class CharT, class OutItrT>
+ const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
+ date_generator_formatter<date_type, CharT, OutItrT>::second_string[7] =
+ {'s','e','c','o','n','d'};
+ template<class date_type, class CharT, class OutItrT>
+ const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
+ date_generator_formatter<date_type, CharT, OutItrT>::third_string[6] =
+ {'t','h','i','r','d'};
+ template<class date_type, class CharT, class OutItrT>
+ const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
+ date_generator_formatter<date_type, CharT, OutItrT>::fourth_string[7] =
+ {'f','o','u','r','t','h'};
+ template<class date_type, class CharT, class OutItrT>
+ const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
+ date_generator_formatter<date_type, CharT, OutItrT>::fifth_string[6] =
+ {'f','i','f','t','h'};
+ template<class date_type, class CharT, class OutItrT>
+ const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
+ date_generator_formatter<date_type, CharT, OutItrT>::last_string[5] =
+ {'l','a','s','t'};
+ template<class date_type, class CharT, class OutItrT>
+ const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
+ date_generator_formatter<date_type, CharT, OutItrT>::before_string[8] =
+ {'b','e','f','o','r','e'};
+ template<class date_type, class CharT, class OutItrT>
+ const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
+ date_generator_formatter<date_type, CharT, OutItrT>::after_string[6] =
+ {'a','f','t','e','r'};
+ template<class date_type, class CharT, class OutItrT>
+ const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
+ date_generator_formatter<date_type, CharT, OutItrT>::of_string[3] =
+ {'o','f'};
+} } // namespaces
+
+#endif // _DATE_TIME_DATE_GENERATOR_FORMATTER__HPP___

Added: sandbox/SOC/2008/calendar/boost/date_time/date_generator_parser.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_generator_parser.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,329 @@
+
+#ifndef DATE_TIME_DATE_GENERATOR_PARSER_HPP__
+#define DATE_TIME_DATE_GENERATOR_PARSER_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/string_parse_tree.hpp"
+#include "boost/date_time/date_generators.hpp"
+#include "boost/date_time/format_date_parser.hpp"
+#include <string>
+#include <vector>
+
+namespace boost { namespace date_time {
+
+ //! 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.
+ *
+ */
+ template<class date_type, typename charT>
+ class date_generator_parser
+ {
+ public:
+ typedef std::basic_string<charT> string_type;
+ typedef std::istreambuf_iterator<charT> stream_itr_type;
+
+ typedef typename date_type::month_type month_type;
+ typedef typename date_type::day_of_week_type day_of_week_type;
+ typedef typename date_type::day_type day_type;
+
+ typedef string_parse_tree<charT> parse_tree_type;
+ typedef typename parse_tree_type::parse_match_result_type match_results;
+ typedef std::vector<std::basic_string<charT> > collection_type;
+
+ typedef partial_date<date_type> partial_date_type;
+ typedef nth_kday_of_month<date_type> nth_kday_type;
+ typedef first_kday_of_month<date_type> first_kday_type;
+ typedef last_kday_of_month<date_type> last_kday_type;
+ typedef first_kday_after<date_type> kday_after_type;
+ typedef first_kday_before<date_type> kday_before_type;
+
+ typedef charT char_type;
+ static const char_type first_string[6];
+ static const char_type second_string[7];
+ static const char_type third_string[6];
+ static const char_type fourth_string[7];
+ static const char_type fifth_string[6];
+ static const char_type last_string[5];
+ static const char_type before_string[8];
+ static const char_type after_string[6];
+ static const char_type of_string[3];
+
+ enum phrase_elements {first=0, second, third, fourth, fifth, last,
+ before, after, of, number_of_phrase_elements};
+
+ //! Creates a date_generator_parser with the default set of "element_strings"
+ date_generator_parser()
+ {
+ element_strings(string_type(first_string),
+ string_type(second_string),
+ string_type(third_string),
+ string_type(fourth_string),
+ string_type(fifth_string),
+ string_type(last_string),
+ string_type(before_string),
+ string_type(after_string),
+ string_type(of_string));
+ }
+
+ //! Creates a date_generator_parser using a user defined set of element strings
+ date_generator_parser(const string_type& first_str,
+ const string_type& second_str,
+ const string_type& third_str,
+ const string_type& fourth_str,
+ const string_type& fifth_str,
+ const string_type& last_str,
+ const string_type& before_str,
+ const string_type& after_str,
+ const string_type& of_str)
+ {
+ element_strings(first_str, second_str, third_str, fourth_str, fifth_str,
+ last_str, before_str, after_str, of_str);
+ }
+
+ //! Replace strings that determine nth week for generator
+ void element_strings(const string_type& first_str,
+ const string_type& second_str,
+ const string_type& third_str,
+ const string_type& fourth_str,
+ const string_type& fifth_str,
+ const string_type& last_str,
+ const string_type& before_str,
+ const string_type& after_str,
+ const string_type& of_str)
+ {
+ collection_type phrases;
+ phrases.push_back(first_str);
+ phrases.push_back(second_str);
+ phrases.push_back(third_str);
+ phrases.push_back(fourth_str);
+ phrases.push_back(fifth_str);
+ phrases.push_back(last_str);
+ phrases.push_back(before_str);
+ phrases.push_back(after_str);
+ phrases.push_back(of_str);
+ m_element_strings = parse_tree_type(phrases, this->first); // enum first
+ }
+
+ void element_strings(const collection_type& col)
+ {
+ m_element_strings = parse_tree_type(col, this->first); // enum first
+ }
+
+
+ //! returns partial_date parsed from stream
+ template<class facet_type>
+ partial_date_type
+ get_partial_date_type(stream_itr_type& sitr,
+ stream_itr_type& stream_end,
+ std::ios_base& a_ios,
+ const facet_type& facet) const
+ {
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
+ day_type d(1);
+ month_type m(1);
+ facet.get(sitr, stream_end, a_ios, d);
+ facet.get(sitr, stream_end, a_ios, m);
+
+ return partial_date_type(d,m);
+ }
+
+ //! returns nth_kday_of_week parsed from stream
+ template<class facet_type>
+ nth_kday_type
+ get_nth_kday_type(stream_itr_type& sitr,
+ stream_itr_type& stream_end,
+ std::ios_base& a_ios,
+ const facet_type& facet) const
+ {
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
+ typename nth_kday_type::week_num wn;
+ day_of_week_type wd(0); // no default constructor
+ month_type m(1); // no default constructor
+
+ match_results mr = m_element_strings.match(sitr, stream_end);
+ switch(mr.current_match) {
+ case first : { wn = nth_kday_type::first; break; }
+ case second : { wn = nth_kday_type::second; break; }
+ case third : { wn = nth_kday_type::third; break; }
+ case fourth : { wn = nth_kday_type::fourth; break; }
+ case fifth : { wn = nth_kday_type::fifth; break; }
+ default:
+ {
+ throw std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'");
+ break;
+ }
+ } // week num
+ facet.get(sitr, stream_end, a_ios, wd); // day_of_week
+ extract_element(sitr, stream_end, of); // "of" element
+ facet.get(sitr, stream_end, a_ios, m); // month
+
+ return nth_kday_type(wn, wd, m);
+ }
+
+ //! returns first_kday_of_week parsed from stream
+ template<class facet_type>
+ first_kday_type
+ get_first_kday_type(stream_itr_type& sitr,
+ stream_itr_type& stream_end,
+ std::ios_base& a_ios,
+ const facet_type& facet) const
+ {
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
+ day_of_week_type wd(0); // no default constructor
+ month_type m(1); // no default constructor
+
+ extract_element(sitr, stream_end, first); // "first" element
+ facet.get(sitr, stream_end, a_ios, wd); // day_of_week
+ extract_element(sitr, stream_end, of); // "of" element
+ facet.get(sitr, stream_end, a_ios, m); // month
+
+
+ return first_kday_type(wd, m);
+ }
+
+ //! returns last_kday_of_week parsed from stream
+ template<class facet_type>
+ last_kday_type
+ get_last_kday_type(stream_itr_type& sitr,
+ stream_itr_type& stream_end,
+ std::ios_base& a_ios,
+ const facet_type& facet) const
+ {
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
+ day_of_week_type wd(0); // no default constructor
+ month_type m(1); // no default constructor
+
+ extract_element(sitr, stream_end, last); // "last" element
+ facet.get(sitr, stream_end, a_ios, wd); // day_of_week
+ extract_element(sitr, stream_end, of); // "of" element
+ facet.get(sitr, stream_end, a_ios, m); // month
+
+
+ return last_kday_type(wd, m);
+ }
+
+ //! returns first_kday_of_week parsed from stream
+ template<class facet_type>
+ kday_before_type
+ get_kday_before_type(stream_itr_type& sitr,
+ stream_itr_type& stream_end,
+ std::ios_base& a_ios,
+ const facet_type& facet) const
+ {
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
+ day_of_week_type wd(0); // no default constructor
+
+ facet.get(sitr, stream_end, a_ios, wd); // day_of_week
+ extract_element(sitr, stream_end, before);// "before" element
+
+ return kday_before_type(wd);
+ }
+
+ //! returns first_kday_of_week parsed from stream
+ template<class facet_type>
+ kday_after_type
+ get_kday_after_type(stream_itr_type& sitr,
+ stream_itr_type& stream_end,
+ std::ios_base& a_ios,
+ const facet_type& facet) const
+ {
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
+ day_of_week_type wd(0); // no default constructor
+
+ facet.get(sitr, stream_end, a_ios, wd); // day_of_week
+ extract_element(sitr, stream_end, after); // "after" element
+
+ return kday_after_type(wd);
+ }
+
+ private:
+ parse_tree_type m_element_strings;
+
+ //! Extracts phrase element from input. Throws ios_base::failure on error.
+ void extract_element(stream_itr_type& sitr,
+ stream_itr_type& stream_end,
+ typename date_generator_parser::phrase_elements ele) const
+ {
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+ match_results mr = m_element_strings.match(sitr, stream_end);
+ if(mr.current_match != ele) {
+ throw std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'");
+ }
+ }
+
+ };
+
+ template<class date_type, class CharT>
+ const typename date_generator_parser<date_type, CharT>::char_type
+ date_generator_parser<date_type, CharT>::first_string[6] =
+ {'f','i','r','s','t'};
+ template<class date_type, class CharT>
+ const typename date_generator_parser<date_type, CharT>::char_type
+ date_generator_parser<date_type, CharT>::second_string[7] =
+ {'s','e','c','o','n','d'};
+ template<class date_type, class CharT>
+ const typename date_generator_parser<date_type, CharT>::char_type
+ date_generator_parser<date_type, CharT>::third_string[6] =
+ {'t','h','i','r','d'};
+ template<class date_type, class CharT>
+ const typename date_generator_parser<date_type, CharT>::char_type
+ date_generator_parser<date_type, CharT>::fourth_string[7] =
+ {'f','o','u','r','t','h'};
+ template<class date_type, class CharT>
+ const typename date_generator_parser<date_type, CharT>::char_type
+ date_generator_parser<date_type, CharT>::fifth_string[6] =
+ {'f','i','f','t','h'};
+ template<class date_type, class CharT>
+ const typename date_generator_parser<date_type, CharT>::char_type
+ date_generator_parser<date_type, CharT>::last_string[5] =
+ {'l','a','s','t'};
+ template<class date_type, class CharT>
+ const typename date_generator_parser<date_type, CharT>::char_type
+ date_generator_parser<date_type, CharT>::before_string[8] =
+ {'b','e','f','o','r','e'};
+ template<class date_type, class CharT>
+ const typename date_generator_parser<date_type, CharT>::char_type
+ date_generator_parser<date_type, CharT>::after_string[6] =
+ {'a','f','t','e','r'};
+ template<class date_type, class CharT>
+ const typename date_generator_parser<date_type, CharT>::char_type
+ date_generator_parser<date_type, CharT>::of_string[3] =
+ {'o','f'};
+
+} } //namespace
+
+#endif // DATE_TIME_DATE_GENERATOR_PARSER_HPP__
+

Added: sandbox/SOC/2008/calendar/boost/date_time/date_generators.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_generators.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,509 @@
+#ifndef DATE_TIME_DATE_GENERATORS_HPP__
+#define DATE_TIME_DATE_GENERATORS_HPP__
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+/*! @file date_generators.hpp
+ Definition and implementation of date algorithm templates
+*/
+#include <stdexcept>
+#include <sstream>
+#include "boost/date_time/date.hpp"
+#include "boost/date_time/compiler_config.hpp"
+
+namespace boost {
+namespace date_time {
+
+ //! 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.
+ @param date_type The type representing a date. This type must
+ export a calender_type which defines a year_type.
+ */
+ template<class date_type>
+ class year_based_generator
+ {
+ public:
+ typedef typename date_type::calendar_type calendar_type;
+ typedef typename calendar_type::year_type year_type;
+ year_based_generator() {};
+ virtual ~year_based_generator() {};
+ virtual date_type get_date(year_type y) const = 0;
+ //! Returns a string for use in a POSIX time_zone string
+ virtual std::string to_string() const =0;
+ };
+
+ //! Generates a date by applying the year to the given month and day.
+ /*!
+ Example usage:
+ @code
+ 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
+ @endcode
+ \ingroup date_alg
+ */
+ template<class date_type>
+ class partial_date : public year_based_generator<date_type>
+ {
+ public:
+ typedef typename date_type::calendar_type calendar_type;
+ typedef typename calendar_type::day_type day_type;
+ typedef typename calendar_type::month_type month_type;
+ typedef typename calendar_type::year_type year_type;
+ typedef typename date_type::duration_type duration_type;
+ typedef typename duration_type::duration_rep duration_rep;
+ partial_date(day_type d, month_type m) :
+ day_(d),
+ month_(m)
+ {}
+ //! Partial 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 */
+ partial_date(duration_rep days) :
+ day_(1), // default values
+ month_(1)
+ {
+ date_type d1(2000,1,1);
+ if(days > 1) {
+ if(days > 366) // prevents wrapping
+ {
+ days = 366;
+ }
+ days = days - 1;
+ duration_type dd(days);
+ d1 = d1 + dd;
+ }
+ day_ = d1.day();
+ month_ = d1.month();
+ }
+ //! Return 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:
+ * @code
+ * partial_date pd(29, Feb);
+ * pd.get_date(2003); // throws invalid_argument exception
+ * pg.get_date(2000); // returns 2000-2-29
+ * @endcode
+ */
+ date_type get_date(year_type y) const
+ {
+ if((day_ == 29) && (month_ == 2) && !(calendar_type::is_leap_year(y))) {
+ std::stringstream ss("");
+ ss << "No Feb 29th in given year of " << y << ".";
+ throw std::invalid_argument(ss.str());
+ //return date_type(1,1,1); // should never reach
+ } else {
+ return date_type(y, month_, day_);
+ }
+ }
+ date_type operator()(year_type y) const
+ {
+ return get_date(y);
+ //return date_type(y, month_, day_);
+ }
+ bool operator==(const partial_date& rhs) const
+ {
+ return (month_ == rhs.month_) && (day_ == rhs.day_);
+ }
+ bool operator<(const partial_date& rhs) const
+ {
+ if (month_ < rhs.month_) return true;
+ if (month_ > rhs.month_) return false;
+ //months are equal
+ return (day_ < rhs.day_);
+ }
+
+ // added for streaming purposes
+ month_type month() const
+ {
+ return month_;
+ }
+ day_type day() const
+ {
+ return day_;
+ }
+
+ //! Returns 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" */
+ virtual std::string to_string() const
+ {
+ std::stringstream ss;
+ date_type d(2004, month_, day_);
+ unsigned short c = d.day_of_year();
+ c--; // numbered 0-365 while day_of_year is 1 based...
+ ss << c;
+ return ss.str();
+ }
+ private:
+ day_type day_;
+ month_type month_;
+ };
+
+
+ //! 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.
+ * \ingroup date_alg
+ */
+ template<class date_type>
+ class nth_kday_of_month : public year_based_generator<date_type>
+ {
+ public:
+ typedef typename date_type::calendar_type calendar_type;
+ typedef typename calendar_type::day_of_week_type day_of_week_type;
+ typedef typename calendar_type::month_type month_type;
+ typedef typename calendar_type::year_type year_type;
+ typedef typename date_type::duration_type duration_type;
+ enum week_num {first=1, second, third, fourth, fifth};
+ nth_kday_of_month(week_num week_no,
+ day_of_week_type dow,
+ month_type m) :
+ month_(m),
+ wn_(week_no),
+ dow_(dow)
+ {}
+ //! Return a concrete date when provided with a year specific year.
+ date_type get_date(year_type y) const
+ {
+ date_type d(y, month_, 1); //first day of month
+ duration_type one_day(1);
+ duration_type one_week(7);
+ while (dow_ != d.day_of_week()) {
+ d = d + one_day;
+ }
+ int week = 1;
+ while (week < wn_) {
+ d = d + one_week;
+ week++;
+ }
+ // remove wrapping to next month behavior
+ if(d.month() != month_) {
+ d = d - one_week;
+ }
+ return d;
+ }
+ // added for streaming
+ month_type month() const
+ {
+ return month_;
+ }
+ week_num nth_week() const
+ {
+ return wn_;
+ }
+ day_of_week_type day_of_week() const
+ {
+ return dow_;
+ }
+ const char* nth_week_as_str() const
+ {
+ return nth_as_str(wn_);
+ }
+ //! Returns string suitable for use in POSIX time zone string
+ /*! Returns a string formatted as "M4.3.0" ==> 3rd Sunday in April. */
+ virtual std::string to_string() const
+ {
+ std::stringstream ss;
+ ss << 'M'
+ << static_cast<int>(month_) << '.'
+ << static_cast<int>(wn_) << '.'
+ << static_cast<int>(dow_);
+ return ss.str();
+ }
+ private:
+ month_type month_;
+ week_num wn_;
+ day_of_week_type dow_;
+ };
+
+ //! Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5.
+ BOOST_DATE_TIME_DECL const char* nth_as_str(int n);
+
+ //! Useful generator functor for finding holidays and daylight savings
+ /*! Similar to nth_kday_of_month, but requires less paramters
+ * \ingroup date_alg
+ */
+ template<class date_type>
+ class first_kday_of_month : public year_based_generator<date_type>
+ {
+ public:
+ typedef typename date_type::calendar_type calendar_type;
+ typedef typename calendar_type::day_of_week_type day_of_week_type;
+ typedef typename calendar_type::month_type month_type;
+ typedef typename calendar_type::year_type year_type;
+ typedef typename date_type::duration_type duration_type;
+ //!Specify the first 'Sunday' in 'April' spec
+ /*!@param dow The day of week, eg: Sunday, Monday, etc
+ * @param m The month of the year, eg: Jan, Feb, Mar, etc
+ */
+ first_kday_of_month(day_of_week_type dow, month_type m) :
+ month_(m),
+ dow_(dow)
+ {}
+ //! Return a concrete date when provided with a year specific year.
+ date_type get_date(year_type year) const
+ {
+ date_type d(year, month_,1);
+ duration_type one_day(1);
+ while (dow_ != d.day_of_week()) {
+ d = d + one_day;
+ }
+ return d;
+ }
+ // added for streaming
+ month_type month() const
+ {
+ return month_;
+ }
+ day_of_week_type day_of_week() const
+ {
+ return dow_;
+ }
+ //! Returns string suitable for use in POSIX time zone string
+ /*! Returns a string formatted as "M4.1.0" ==> 1st Sunday in April. */
+ virtual std::string to_string() const
+ {
+ std::stringstream ss;
+ ss << 'M'
+ << static_cast<int>(month_) << '.'
+ << 1 << '.'
+ << static_cast<int>(dow_);
+ return ss.str();
+ }
+ private:
+ month_type month_;
+ day_of_week_type dow_;
+ };
+
+
+
+ //! 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.
+ * @param date_type A date class that exports day_of_week, month_type, etc.
+ * \ingroup date_alg
+ */
+ template<class date_type>
+ class last_kday_of_month : public year_based_generator<date_type>
+ {
+ public:
+ typedef typename date_type::calendar_type calendar_type;
+ typedef typename calendar_type::day_of_week_type day_of_week_type;
+ typedef typename calendar_type::month_type month_type;
+ typedef typename calendar_type::year_type year_type;
+ typedef typename date_type::duration_type duration_type;
+ //!Specify the date spec like last 'Sunday' in 'April' spec
+ /*!@param dow The day of week, eg: Sunday, Monday, etc
+ * @param m The month of the year, eg: Jan, Feb, Mar, etc
+ */
+ last_kday_of_month(day_of_week_type dow, month_type m) :
+ month_(m),
+ dow_(dow)
+ {}
+ //! Return a concrete date when provided with a year specific year.
+ date_type get_date(year_type year) const
+ {
+ date_type d(year, month_, calendar_type::end_of_month_day(year,month_));
+ duration_type one_day(1);
+ while (dow_ != d.day_of_week()) {
+ d = d - one_day;
+ }
+ return d;
+ }
+ // added for streaming
+ month_type month() const
+ {
+ return month_;
+ }
+ day_of_week_type day_of_week() const
+ {
+ return dow_;
+ }
+ //! Returns string suitable for use in POSIX time zone string
+ /*! Returns a string formatted as "M4.5.0" ==> last Sunday in April. */
+ virtual std::string to_string() const
+ {
+ std::stringstream ss;
+ ss << 'M'
+ << static_cast<int>(month_) << '.'
+ << 5 << '.'
+ << static_cast<int>(dow_);
+ return ss.str();
+ }
+ private:
+ month_type month_;
+ day_of_week_type dow_;
+ };
+
+
+ //! Calculate something like "First Sunday after Jan 1,2002
+ /*! Date generator that takes a date and finds kday after
+ *@code
+ typedef boost::date_time::first_kday_after<date> firstkdayafter;
+ firstkdayafter fkaf(Monday);
+ fkaf.get_date(date(2002,Feb,1));
+ @endcode
+ * \ingroup date_alg
+ */
+ template<class date_type>
+ class first_kday_after
+ {
+ public:
+ typedef typename date_type::calendar_type calendar_type;
+ typedef typename calendar_type::day_of_week_type day_of_week_type;
+ typedef typename date_type::duration_type duration_type;
+ first_kday_after(day_of_week_type dow) :
+ dow_(dow)
+ {}
+ //! Return next kday given.
+ date_type get_date(date_type start_day) const
+ {
+ duration_type one_day(1);
+ date_type d = start_day + one_day;
+ while (dow_ != d.day_of_week()) {
+ d = d + one_day;
+ }
+ return d;
+ }
+ // added for streaming
+ day_of_week_type day_of_week() const
+ {
+ return dow_;
+ }
+ private:
+ day_of_week_type dow_;
+ };
+
+ //! Calculate something like "First Sunday before Jan 1,2002
+ /*! Date generator that takes a date and finds kday after
+ *@code
+ typedef boost::date_time::first_kday_before<date> firstkdaybefore;
+ firstkdaybefore fkbf(Monday);
+ fkbf.get_date(date(2002,Feb,1));
+ @endcode
+ * \ingroup date_alg
+ */
+ template<class date_type>
+ class first_kday_before
+ {
+ public:
+ typedef typename date_type::calendar_type calendar_type;
+ typedef typename calendar_type::day_of_week_type day_of_week_type;
+ typedef typename date_type::duration_type duration_type;
+ first_kday_before(day_of_week_type dow) :
+ dow_(dow)
+ {}
+ //! Return next kday given.
+ date_type get_date(date_type start_day) const
+ {
+ duration_type one_day(1);
+ date_type d = start_day - one_day;
+ while (dow_ != d.day_of_week()) {
+ d = d - one_day;
+ }
+ return d;
+ }
+ // added for streaming
+ day_of_week_type day_of_week() const
+ {
+ return dow_;
+ }
+ private:
+ day_of_week_type dow_;
+ };
+
+ //! 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 */
+ template<typename date_type, class weekday_type>
+ inline
+ typename date_type::duration_type days_until_weekday(const date_type& d, const weekday_type& wd)
+ {
+ typedef typename date_type::duration_type duration_type;
+ duration_type wks(0);
+ duration_type dd(wd.as_number() - d.day_of_week().as_number());
+ if(dd.is_negative()){
+ wks = duration_type(7);
+ }
+ return dd + wks;
+ }
+
+ //! 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. */
+ template<typename date_type, class weekday_type>
+ inline
+ typename date_type::duration_type days_before_weekday(const date_type& d, const weekday_type& wd)
+ {
+ typedef typename date_type::duration_type duration_type;
+ duration_type wks(0);
+ duration_type dd(wd.as_number() - d.day_of_week().as_number());
+ if(dd.days() > 0){
+ wks = duration_type(7);
+ }
+ // we want a number of days, not an offset. The value returned must
+ // be zero or larger.
+ return (-dd + wks);
+ }
+
+ //! 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. */
+ template<class date_type, class weekday_type>
+ inline
+ date_type next_weekday(const date_type& d, const weekday_type& wd)
+ {
+ return d + days_until_weekday(d, wd);
+ }
+
+ //! 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. */
+ template<class date_type, class weekday_type>
+ inline
+ date_type previous_weekday(const date_type& d, const weekday_type& wd)
+ {
+ return d - days_before_weekday(d, wd);
+ }
+
+} } //namespace date_time
+
+
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/date_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_iterator.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,101 @@
+#ifndef DATE_ITERATOR_HPP___
+#define DATE_ITERATOR_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <iterator>
+
+namespace boost {
+namespace date_time {
+ //! An iterator over dates with varying resolution (day, week, month, year, etc)
+ enum date_resolutions {day, week, months, year, decade, century, NumDateResolutions};
+
+ //! 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.
+ *
+ * <b>Template Parameters</b>
+ *
+ * <b>date_type</b>
+ *
+ * The date_type is a concrete date_type. The date_type must
+ * define a duration_type and a calendar_type.
+ */
+ template<class date_type>
+ class date_itr_base {
+ // works, but benefit unclear at the moment
+ // class date_itr_base : public std::iterator<std::input_iterator_tag,
+ // date_type, void, void, void>{
+ public:
+ typedef typename date_type::duration_type duration_type;
+ typedef date_type value_type;
+ typedef std::input_iterator_tag iterator_category;
+
+ date_itr_base(date_type d) : current_(d) {}
+ virtual ~date_itr_base() {};
+ date_itr_base& operator++()
+ {
+ current_ = current_ + get_offset(current_);
+ return *this;
+ }
+ date_itr_base& operator--()
+ {
+ current_ = current_ + get_neg_offset(current_);
+ return *this;
+ }
+ virtual duration_type get_offset(const date_type& current) const=0;
+ virtual duration_type get_neg_offset(const date_type& current) const=0;
+ date_type operator*() {return current_;};
+ date_type* operator->() {return &current_;};
+ bool operator< (const date_type& d) {return current_ < d;}
+ bool operator<= (const date_type& d) {return current_ <= d;}
+ bool operator> (const date_type& d) {return current_ > d;}
+ bool operator>= (const date_type& d) {return current_ >= d;}
+ bool operator== (const date_type& d) {return current_ == d;}
+ bool operator!= (const date_type& d) {return current_ != d;}
+ private:
+ date_type current_;
+ };
+
+ //! Overrides the base date iterator providing hook for functors
+ /*
+ * <b>offset_functor</b>
+ *
+ * The offset functor must define a get_offset function that takes the
+ * current point in time and calculates and offset.
+ *
+ */
+ template<class offset_functor, class date_type>
+ class date_itr : public date_itr_base<date_type> {
+ public:
+ typedef typename date_type::duration_type duration_type;
+ date_itr(date_type d, int factor=1) :
+ date_itr_base<date_type>(d),
+ of_(factor)
+ {}
+ private:
+ virtual duration_type get_offset(const date_type& current) const
+ {
+ return of_.get_offset(current);
+ }
+ virtual duration_type get_neg_offset(const date_type& current) const
+ {
+ return of_.get_neg_offset(current);
+ }
+ offset_functor of_;
+ };
+
+
+
+} } //namespace date_time
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/date_names_put.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_names_put.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,320 @@
+#ifndef DATE_TIME_DATE_NAMES_PUT_HPP___
+#define DATE_TIME_DATE_NAMES_PUT_HPP___
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/locale_config.hpp" // set BOOST_DATE_TIME_NO_LOCALE
+
+#ifndef BOOST_DATE_TIME_NO_LOCALE
+
+#include "boost/date_time/special_defs.hpp"
+#include "boost/date_time/date_defs.hpp"
+#include "boost/date_time/parse_format_base.hpp"
+#include "boost/lexical_cast.hpp"
+#include <locale>
+
+
+namespace boost {
+namespace date_time {
+
+ //! Output 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).
+ *
+ */
+ template<class Config,
+ class charT = char,
+ class OutputIterator = std::ostreambuf_iterator<charT> >
+ class date_names_put : public std::locale::facet
+ {
+ public:
+ date_names_put() {};
+ typedef OutputIterator iter_type;
+ typedef typename Config::month_type month_type;
+ typedef typename Config::month_enum month_enum;
+ typedef typename Config::weekday_enum weekday_enum;
+ typedef typename Config::special_value_enum special_value_enum;
+ //typedef typename Config::format_type format_type;
+ typedef std::basic_string<charT> string_type;
+ typedef charT char_type;
+ static const char_type default_special_value_names[3][17];
+ static const char_type separator[2];
+
+ static std::locale::id id;
+
+#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
+ std::locale::id& __get_id (void) const { return id; }
+#endif
+
+ void put_special_value(iter_type& oitr, special_value_enum sv) const
+ {
+ do_put_special_value(oitr, sv);
+ }
+ void put_month_short(iter_type& oitr, month_enum moy) const
+ {
+ do_put_month_short(oitr, moy);
+ }
+ void put_month_long(iter_type& oitr, month_enum moy) const
+ {
+ do_put_month_long(oitr, moy);
+ }
+ void put_weekday_short(iter_type& oitr, weekday_enum wd) const
+ {
+ do_put_weekday_short(oitr, wd);
+ }
+ void put_weekday_long(iter_type& oitr, weekday_enum wd) const
+ {
+ do_put_weekday_long(oitr, wd);
+ }
+ bool has_date_sep_chars() const
+ {
+ return do_has_date_sep_chars();
+ }
+ void year_sep_char(iter_type& oitr) const
+ {
+ do_year_sep_char(oitr);
+ }
+ //! char between year-month
+ void month_sep_char(iter_type& oitr) const
+ {
+ do_month_sep_char(oitr);
+ }
+ //! Char to separate month-day
+ void day_sep_char(iter_type& oitr) const
+ {
+ do_day_sep_char(oitr);
+ }
+ //! Determines the order to put the date elements
+ ymd_order_spec date_order() const
+ {
+ return do_date_order();
+ }
+ //! Determines if month is displayed as integer, short or long string
+ month_format_spec month_format() const
+ {
+ return do_month_format();
+ }
+
+ protected:
+ //! Default facet implementation uses month_type defaults
+ virtual void do_put_month_short(iter_type& oitr, month_enum moy) const
+ {
+ month_type gm(moy);
+ charT c = '\0';
+ put_string(oitr, gm.as_short_string(c));
+ }
+ //! Default facet implementation uses month_type defaults
+ virtual void do_put_month_long(iter_type& oitr,
+ month_enum moy) const
+ {
+ month_type gm(moy);
+ charT c = '\0';
+ put_string(oitr, gm.as_long_string(c));
+ }
+ //! Default facet implementation for special value types
+ virtual void do_put_special_value(iter_type& oitr, special_value_enum sv) const
+ {
+ if(sv <= 2) { // only output not_a_date_time, neg_infin, or pos_infin
+ string_type s(default_special_value_names[sv]);
+ put_string(oitr, s);
+ }
+ }
+ virtual void do_put_weekday_short(iter_type&, weekday_enum) const
+ {
+ }
+ virtual void do_put_weekday_long(iter_type&, weekday_enum) const
+ {
+ }
+ virtual bool do_has_date_sep_chars() const
+ {
+ return true;
+ }
+ virtual void do_year_sep_char(iter_type& oitr) const
+ {
+ string_type s(separator);
+ put_string(oitr, s);
+ }
+ //! char between year-month
+ virtual void do_month_sep_char(iter_type& oitr) const
+ {
+ string_type s(separator);
+ put_string(oitr, s);
+ }
+ //! Char to separate month-day
+ virtual void do_day_sep_char(iter_type& oitr) const
+ {
+ string_type s(separator); //put in '-'
+ put_string(oitr, s);
+ }
+ //! Default for date order
+ virtual ymd_order_spec do_date_order() const
+ {
+ return ymd_order_iso;
+ }
+ //! Default month format
+ virtual month_format_spec do_month_format() const
+ {
+ return month_as_short_string;
+ }
+ void put_string(iter_type& oi, const charT* const s) const
+ {
+ string_type s1(boost::lexical_cast<string_type>(s));
+ typename string_type::iterator si,end;
+ for (si=s1.begin(), end=s1.end(); si!=end; si++, oi++) {
+ *oi = *si;
+ }
+ }
+ void put_string(iter_type& oi, const string_type& s1) const
+ {
+ typename string_type::const_iterator si,end;
+ for (si=s1.begin(), end=s1.end(); si!=end; si++, oi++) {
+ *oi = *si;
+ }
+ }
+ };
+
+ template<class Config, class charT, class OutputIterator>
+ const typename date_names_put<Config, charT, OutputIterator>::char_type
+ date_names_put<Config, charT, OutputIterator>::default_special_value_names[3][17] = {
+ {'n','o','t','-','a','-','d','a','t','e','-','t','i','m','e'},
+ {'-','i','n','f','i','n','i','t','y'},
+ {'+','i','n','f','i','n','i','t','y'} };
+
+ template<class Config, class charT, class OutputIterator>
+ const typename date_names_put<Config, charT, OutputIterator>::char_type
+ date_names_put<Config, charT, OutputIterator>::separator[2] =
+ {'-', '\0'} ;
+
+
+ //! Generate storage location for a std::locale::id
+ template<class Config, class charT, class OutputIterator>
+ std::locale::id date_names_put<Config, charT, OutputIterator>::id;
+
+ //! A date name output facet that takes an array of char* to define strings
+ template<class Config,
+ class charT = char,
+ class OutputIterator = std::ostreambuf_iterator<charT> >
+ class all_date_names_put : public date_names_put<Config, charT, OutputIterator>
+ {
+ public:
+ all_date_names_put(const charT* const month_short_names[],
+ const charT* const month_long_names[],
+ const charT* const special_value_names[],
+ const charT* const weekday_short_names[],
+ const charT* const weekday_long_names[],
+ charT separator_char = '-',
+ ymd_order_spec order_spec = ymd_order_iso,
+ month_format_spec month_format = month_as_short_string) :
+ month_short_names_(month_short_names),
+ month_long_names_(month_long_names),
+ special_value_names_(special_value_names),
+ weekday_short_names_(weekday_short_names),
+ weekday_long_names_(weekday_long_names),
+ order_spec_(order_spec),
+ month_format_spec_(month_format)
+ {
+ separator_char_[0] = separator_char;
+ separator_char_[1] = '\0';
+
+ };
+ typedef OutputIterator iter_type;
+ typedef typename Config::month_enum month_enum;
+ typedef typename Config::weekday_enum weekday_enum;
+ typedef typename Config::special_value_enum special_value_enum;
+
+ const charT* const* get_short_month_names() const
+ {
+ return month_short_names_;
+ }
+ const charT* const* get_long_month_names() const
+ {
+ return month_long_names_;
+ }
+ const charT* const* get_special_value_names() const
+ {
+ return special_value_names_;
+ }
+ const charT* const* get_short_weekday_names()const
+ {
+ return weekday_short_names_;
+ }
+ const charT* const* get_long_weekday_names()const
+ {
+ return weekday_long_names_;
+ }
+
+ protected:
+ //! Generic facet that takes array of chars
+ virtual void do_put_month_short(iter_type& oitr, month_enum moy) const
+ {
+ this->put_string(oitr, month_short_names_[moy-1]);
+ }
+ //! Long month names
+ virtual void do_put_month_long(iter_type& oitr, month_enum moy) const
+ {
+ this->put_string(oitr, month_long_names_[moy-1]);
+ }
+ //! Special values names
+ virtual void do_put_special_value(iter_type& oitr, special_value_enum sv) const
+ {
+ this->put_string(oitr, special_value_names_[sv]);
+ }
+ virtual void do_put_weekday_short(iter_type& oitr, weekday_enum wd) const
+ {
+ this->put_string(oitr, weekday_short_names_[wd]);
+ }
+ virtual void do_put_weekday_long(iter_type& oitr, weekday_enum wd) const
+ {
+ this->put_string(oitr, weekday_long_names_[wd]);
+ }
+ //! char between year-month
+ virtual void do_month_sep_char(iter_type& oitr) const
+ {
+ this->put_string(oitr, separator_char_);
+ }
+ //! Char to separate month-day
+ virtual void do_day_sep_char(iter_type& oitr) const
+ {
+ this->put_string(oitr, separator_char_);
+ }
+ //! Set the date ordering
+ virtual ymd_order_spec do_date_order() const
+ {
+ return order_spec_;
+ }
+ //! Set the date ordering
+ virtual month_format_spec do_month_format() const
+ {
+ return month_format_spec_;
+ }
+
+ private:
+ const charT* const* month_short_names_;
+ const charT* const* month_long_names_;
+ const charT* const* special_value_names_;
+ const charT* const* weekday_short_names_;
+ const charT* const* weekday_long_names_;
+ charT separator_char_[2];
+ ymd_order_spec order_spec_;
+ month_format_spec month_format_spec_;
+ };
+
+} } //namespace boost::date_time
+
+#endif //BOOST_NO_STD_LOCALE
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/date_parsing.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/date_parsing.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,299 @@
+#ifndef _DATE_TIME_DATE_PARSING_HPP___
+#define _DATE_TIME_DATE_PARSING_HPP___
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/tokenizer.hpp"
+#include "boost/lexical_cast.hpp"
+#include "boost/date_time/compiler_config.hpp"
+#include "boost/date_time/parse_format_base.hpp"
+#include <string>
+#include <iterator>
+#include <algorithm>
+
+#if defined(BOOST_NO_STD_LOCALE)
+#include <cctype> // ::tolower(int)
+#else
+#include <locale> // std::tolower(char, locale)
+#endif
+
+namespace boost {
+namespace date_time {
+
+ //! A 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.
+ */
+ inline
+ std::string
+ convert_to_lower(const std::string& inp) {
+ std::string tmp;
+ unsigned i = 0;
+#if defined(BOOST_NO_STD_LOCALE)
+ while(i < inp.length()) {
+ tmp += static_cast<char>(std::tolower(inp.at(i++)));
+#else
+ static const std::locale loc(std::locale::classic());
+ while(i < inp.length()) {
+ // tolower and others were brought in to std for borland >= v564
+ // in compiler_config.hpp
+ std::string::value_type c(inp.at(i++));
+ tmp += std::tolower(c, loc);
+#endif
+
+ }
+ return tmp;
+ }
+
+ //! Helper function for parse_date.
+ /* Used by-value parameter because we change the string and may
+ * want to preserve the original argument */
+ template<class month_type>
+ unsigned short
+ month_str_to_ushort(std::string s) {
+ if((s.at(0) >= '0') && (s.at(0) <= '9')) {
+ return boost::lexical_cast<unsigned short>(s);
+ }
+ else {
+ s = convert_to_lower(s);
+ typename month_type::month_map_ptr_type ptr = month_type::get_month_map_ptr();
+ typename month_type::month_map_type::iterator iter = ptr->find(s);
+ if(iter != ptr->end()) { // required for STLport
+ return iter->second;
+ }
+ }
+ return 13; // intentionally out of range - name not found
+ }
+
+ //! Find index of a string in either of 2 arrays
+ /*! find_match searches both arrays for a match to 's'. Indexing of the
+ * arrays is from 0 to 'limit'. The index of the match is returned.
+ * Ex. "Jan" returns 0, "Dec" returns 11, "Tue" returns 2.
+ * 'limit' can be sent in with: greg_month::max(),
+ * greg_weekday::max() or date_time::NumSpecialValues */
+ template<class charT>
+ short find_match(const charT* const* short_names,
+ const charT* const* long_names,
+ short limit,
+ const std::basic_string<charT>& s) {
+ for(short i = 0; i <= limit; ++i){
+ if(short_names[i] == s || long_names[i] == s){
+ return i;
+ }
+ }
+ return static_cast<short>(limit + 1); // not-found, return a value out of range
+ }
+
+ //! Generic 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
+ */
+ template<class date_type>
+ date_type
+ parse_date(const std::string& s, int order_spec = ymd_order_iso) {
+ std::string spec_str("");
+ if(order_spec == ymd_order_iso) {
+ spec_str = "ymd";
+ }
+ else if(order_spec == ymd_order_dmy) {
+ spec_str = "dmy";
+ }
+ else { // (order_spec == ymd_order_us)
+ spec_str = "mdy";
+ }
+
+ typedef typename date_type::year_type year_type;
+ typedef typename date_type::month_type month_type;
+ unsigned pos = 0;
+ unsigned short year(0), month(0), day(0);
+ typedef typename std::basic_string<char>::traits_type traits_type;
+ typedef boost::char_separator<char, traits_type> char_separator_type;
+ typedef boost::tokenizer<char_separator_type,
+ std::basic_string<char>::const_iterator,
+ std::basic_string<char> > tokenizer;
+ typedef boost::tokenizer<char_separator_type,
+ std::basic_string<char>::const_iterator,
+ std::basic_string<char> >::iterator tokenizer_iterator;
+ // may need more delimiters, these work for the regression tests
+ const char sep_char[] = {',','-','.',' ','/','\0'};
+ char_separator_type sep(sep_char);
+ tokenizer tok(s,sep);
+ for(tokenizer_iterator beg=tok.begin();
+ beg!=tok.end() && pos < spec_str.size();
+ ++beg, ++pos) {
+ switch(spec_str.at(pos)) {
+ case 'y':
+ {
+ year = boost::lexical_cast<unsigned short>(*beg);
+ break;
+ }
+ case 'm':
+ {
+ month = month_str_to_ushort<month_type>(*beg);
+ break;
+ }
+ case 'd':
+ {
+ day = boost::lexical_cast<unsigned short>(*beg);
+ break;
+ }
+ } //switch
+ }
+ return date_type(year, month, day);
+ }
+
+ //! Generic function to parse undelimited date (eg: 20020201)
+ template<class date_type>
+ date_type
+ parse_undelimited_date(const std::string& s) {
+ int offsets[] = {4,2,2};
+ int pos = 0;
+ typedef typename date_type::year_type year_type;
+ //typename date_type::ymd_type ymd((year_type::min)(),1,1);
+ unsigned short y = 0, m = 0, d = 0;
+
+ /* The two bool arguments state that parsing will not wrap
+ * (only the first 8 characters will be parsed) and partial
+ * strings will not be parsed.
+ * Ex:
+ * "2005121" will parse 2005 & 12, but not the "1" */
+ boost::offset_separator osf(offsets, offsets+3, false, false);
+
+ typedef typename boost::tokenizer<boost::offset_separator,
+ std::basic_string<char>::const_iterator,
+ std::basic_string<char> > tokenizer_type;
+ tokenizer_type tok(s, osf);
+ for(typename tokenizer_type::iterator ti=tok.begin(); ti!=tok.end();++ti) {
+ unsigned short i = boost::lexical_cast<unsigned short>(*ti);
+ switch(pos) {
+ case 0: y = i; break;
+ case 1: m = i; break;
+ case 2: d = i; break;
+ }
+ pos++;
+ }
+ return date_type(y,m,d);
+ }
+
+ //! Helper 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 */
+ template<class date_type, class iterator_type>
+ inline
+ date_type
+ from_stream_type(iterator_type& beg,
+ iterator_type& end,
+ char)
+ {
+ std::stringstream ss("");
+ while(beg != end) {
+ ss << *beg++;
+ }
+ return parse_date<date_type>(ss.str());
+ }
+
+ //! Helper function for 'date gregorian::from_stream()'
+ /*! Returns the first string found in the stream referenced by the
+ * begining & end iterators */
+ template<class date_type, class iterator_type>
+ inline
+ date_type
+ from_stream_type(iterator_type& beg,
+ iterator_type& end,
+ std::string)
+ {
+ return parse_date<date_type>(*beg);
+ }
+
+ /* I believe the wchar stuff would be best elsewhere, perhaps in
+ * parse_date<>()? In the mean time this gets us started... */
+ //! Helper 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 */
+ template<class date_type, class iterator_type>
+ inline
+ date_type from_stream_type(iterator_type& beg,
+ iterator_type& end,
+ wchar_t)
+ {
+ std::stringstream ss("");
+ while(beg != end) {
+#if !defined(BOOST_DATE_TIME_NO_LOCALE)
+ ss << std::use_facet<std::ctype<wchar_t> >(std::locale()).narrow(*beg++, 'X'); // 'X' will cause exception to be thrown
+#else
+ ss << ss.narrow(*beg++, 'X');
+#endif
+ }
+ return parse_date<date_type>(ss.str());
+ }
+#ifndef BOOST_NO_STD_WSTRING
+ //! Helper function for 'date gregorian::from_stream()'
+ /*! Creates a string from the first wstring found in the stream
+ * referenced by the begining & end iterators */
+ template<class date_type, class iterator_type>
+ inline
+ date_type
+ from_stream_type(iterator_type& beg,
+ iterator_type& end,
+ std::wstring) {
+ std::wstring ws = *beg;
+ std::stringstream ss("");
+ std::wstring::iterator wsb = ws.begin(), wse = ws.end();
+ while(wsb != wse) {
+#if !defined(BOOST_DATE_TIME_NO_LOCALE)
+ ss << std::use_facet<std::ctype<wchar_t> >(std::locale()).narrow(*wsb++, 'X'); // 'X' will cause exception to be thrown
+#else
+ ss << ss.narrow(*wsb++, 'X'); // 'X' will cause exception to be thrown
+#endif
+ }
+ return parse_date<date_type>(ss.str());
+ }
+#endif // BOOST_NO_STD_WSTRING
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ // This function cannot be compiled with MSVC 6.0 due to internal compiler shorcomings
+#else
+ //! function called by wrapper functions: date_period_from_(w)string()
+ template<class date_type, class charT>
+ period<date_type, typename date_type::duration_type>
+ from_simple_string_type(const std::basic_string<charT>& s){
+ typedef typename std::basic_string<charT>::traits_type traits_type;
+ typedef typename boost::char_separator<charT, traits_type> char_separator;
+ typedef typename boost::tokenizer<char_separator,
+ typename std::basic_string<charT>::const_iterator,
+ std::basic_string<charT> > tokenizer;
+ const charT sep_list[4] = {'[','/',']','\0'};
+ char_separator sep(sep_list);
+ tokenizer tokens(s, sep);
+ typename tokenizer::iterator tok_it = tokens.begin();
+ std::basic_string<charT> date_string = *tok_it;
+ // get 2 string iterators and generate a date from them
+ typename std::basic_string<charT>::iterator date_string_start = date_string.begin(),
+ date_string_end = date_string.end();
+ typedef typename std::iterator_traits<typename std::basic_string<charT>::iterator>::value_type value_type;
+ date_type d1 = from_stream_type<date_type>(date_string_start, date_string_end, value_type());
+ date_string = *(++tok_it); // next token
+ date_string_start = date_string.begin(), date_string_end = date_string.end();
+ date_type d2 = from_stream_type<date_type>(date_string_start, date_string_end, value_type());
+ return period<date_type, typename date_type::duration_type>(d1, d2);
+ }
+#endif
+
+} } //namespace date_time
+
+
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/dst_rules.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/dst_rules.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,391 @@
+#ifndef DATE_TIME_DST_RULES_HPP__
+#define DATE_TIME_DST_RULES_HPP__
+
+/* 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, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+/*! @file dst_rules.hpp
+ Contains template class to provide static dst rule calculations
+*/
+
+#include "boost/date_time/date_generators.hpp"
+#include "boost/date_time/period.hpp"
+#include "boost/date_time/date_defs.hpp"
+#include <stdexcept>
+
+namespace boost {
+ namespace date_time {
+
+ enum time_is_dst_result {is_not_in_dst, is_in_dst,
+ ambiguous, invalid_time_label};
+
+
+ //! Dynamic class used to caluclate dst transition information
+ template<class date_type_,
+ class time_duration_type_>
+ class dst_calculator
+ {
+ public:
+ typedef time_duration_type_ time_duration_type;
+ typedef date_type_ date_type;
+
+ //! 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.
+ *@param time_of_day Time offset in the day for the local time
+ *@param dst_start_offset_minutes Local day offset for start of dst
+ *@param dst_length_minutes Number of minutes to adjust clock forward
+ *@retval status of time label w.r.t. dst
+ */
+ static time_is_dst_result
+ process_local_dst_start_day(const time_duration_type& time_of_day,
+ unsigned int dst_start_offset_minutes,
+ long dst_length_minutes)
+ {
+ //std::cout << "here" << std::endl;
+ if (time_of_day < time_duration_type(0,dst_start_offset_minutes,0)) {
+ return is_not_in_dst;
+ }
+ long offset = dst_start_offset_minutes + dst_length_minutes;
+ if (time_of_day >= time_duration_type(0,offset,0)) {
+ return is_in_dst;
+ }
+ return invalid_time_label;
+ }
+
+ //! Check 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.
+ *@param time_of_day Time offset in the day for the local time
+ *@param dst_end_offset_minutes Local time of day for end of dst
+ *@retval status of time label w.r.t. dst
+ */
+ static time_is_dst_result
+ process_local_dst_end_day(const time_duration_type& time_of_day,
+ unsigned int dst_end_offset_minutes,
+ long dst_length_minutes)
+ {
+ //in US this will be 60 so offset in day is 1,0,0
+ int offset = dst_end_offset_minutes-dst_length_minutes;
+ if (time_of_day < time_duration_type(0,offset,0)) {
+ return is_in_dst;
+ }
+ if (time_of_day >= time_duration_type(0,dst_end_offset_minutes,0)) {
+ return is_not_in_dst;
+ }
+ return ambiguous;
+ }
+
+ //! 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.
+ * @param current_day The day to check for dst
+ * @param time_of_day Time offset within the day to check
+ * @param dst_start_day Starting day of dst for the given locality
+ * @param dst_start_offset Time offset within day for dst boundary
+ * @param dst_end_day Ending day of dst for the given locality
+ * @param dst_end_offset Time offset within day given in dst for dst boundary
+ * @param dst_length lenght of dst adjusment
+ * @retval The time is either ambiguous, invalid, in dst, or not in dst
+ */
+ static time_is_dst_result
+ local_is_dst(const date_type& current_day,
+ const time_duration_type& time_of_day,
+ const date_type& dst_start_day,
+ const time_duration_type& dst_start_offset,
+ const date_type& dst_end_day,
+ const time_duration_type& dst_end_offset,
+ const time_duration_type& dst_length_minutes)
+ {
+ unsigned int start_minutes =
+ dst_start_offset.hours() * 60 + dst_start_offset.minutes();
+ unsigned int end_minutes =
+ dst_end_offset.hours() * 60 + dst_end_offset.minutes();
+ long length_minutes =
+ dst_length_minutes.hours() * 60 + dst_length_minutes.minutes();
+
+ return local_is_dst(current_day, time_of_day,
+ dst_start_day, start_minutes,
+ dst_end_day, end_minutes,
+ length_minutes);
+ }
+
+ //! 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.
+ * @param current_day The day to check for dst
+ * @param time_of_day Time offset within the day to check
+ * @param dst_start_day Starting day of dst for the given locality
+ * @param dst_start_offset_minutes Offset within day for dst
+ * boundary (eg 120 for US which is 02:00:00)
+ * @param dst_end_day Ending day of dst for the given locality
+ * @param dst_end_offset_minutes Offset within day given in dst for dst
+ * boundary (eg 120 for US which is 02:00:00)
+ * @param dst_length_minutes Length of dst adjusment (eg: 60 for US)
+ * @retval The time is either ambiguous, invalid, in dst, or not in dst
+ */
+ static time_is_dst_result
+ local_is_dst(const date_type& current_day,
+ const time_duration_type& time_of_day,
+ const date_type& dst_start_day,
+ unsigned int dst_start_offset_minutes,
+ const date_type& dst_end_day,
+ unsigned int dst_end_offset_minutes,
+ long dst_length_minutes)
+ {
+ //in northern hemisphere dst is in the middle of the year
+ if (dst_start_day < dst_end_day) {
+ if ((current_day > dst_start_day) && (current_day < dst_end_day)) {
+ return is_in_dst;
+ }
+ if ((current_day < dst_start_day) || (current_day > dst_end_day)) {
+ return is_not_in_dst;
+ }
+ }
+ else {//southern hemisphere dst is at begining /end of year
+ if ((current_day < dst_start_day) && (current_day > dst_end_day)) {
+ return is_not_in_dst;
+ }
+ if ((current_day > dst_start_day) || (current_day < dst_end_day)) {
+ return is_in_dst;
+ }
+ }
+
+ if (current_day == dst_start_day) {
+ return process_local_dst_start_day(time_of_day,
+ dst_start_offset_minutes,
+ dst_length_minutes);
+ }
+
+ if (current_day == dst_end_day) {
+ return process_local_dst_end_day(time_of_day,
+ dst_end_offset_minutes,
+ dst_length_minutes);
+ }
+ //you should never reach this statement
+ return invalid_time_label;
+ }
+
+ };
+
+
+ //! Compile-time configurable daylight savings time calculation engine
+ /* This template provides the ability to configure a daylight savings
+ * calculation at compile time covering all the cases. Unfortunately
+ * because of the number of dimensions related to daylight savings
+ * calculation the number of parameters is high. In addition, the
+ * start and end transition rules are complex types that specify
+ * an algorithm for calculation of the starting day and ending
+ * day of daylight savings time including the month and day
+ * specifications (eg: last sunday in October).
+ *
+ * @param date_type A type that represents dates, typically gregorian::date
+ * @param time_duration_type Used for the offset in the day calculations
+ * @param dst_traits A set of traits that define the rules of dst
+ * calculation. The dst_trait must include the following:
+ * start_rule_functor - Rule to calculate the starting date of a
+ * dst transition (eg: last_kday_of_month).
+ * start_day - static function that returns month of dst start for
+ * start_rule_functor
+ * start_month -static function that returns day or day of week for
+ * dst start of dst
+ * end_rule_functor - Rule to calculate the end of dst day.
+ * end_day - static fucntion that returns end day for end_rule_functor
+ * end_month - static function that returns end month for end_rule_functor
+ * dst_start_offset_minutes - number of minutes from start of day to transition to dst -- 120 (or 2:00 am) is typical for the U.S. and E.U.
+ * dst_start_offset_minutes - number of minutes from start of day to transition off of dst -- 180 (or 3:00 am) is typical for E.U.
+ * dst_length_minutes - number of minutes that dst shifts clock
+ */
+ template<class date_type,
+ class time_duration_type,
+ class dst_traits>
+ class dst_calc_engine
+ {
+ public:
+ typedef typename date_type::year_type year_type;
+ typedef typename date_type::calendar_type calendar_type;
+ typedef dst_calculator<date_type, time_duration_type> dstcalc;
+
+ //! 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.
+ * @retval The time is either ambiguous, invalid, in dst, or not in dst
+ */
+ static time_is_dst_result local_is_dst(const date_type& d,
+ const time_duration_type& td)
+ {
+
+ year_type y = d.year();
+ date_type dst_start = local_dst_start_day(y);
+ date_type dst_end = local_dst_end_day(y);
+ return dstcalc::local_is_dst(d,td,
+ dst_start,
+ dst_traits::dst_start_offset_minutes(),
+ dst_end,
+ dst_traits::dst_end_offset_minutes(),
+ dst_traits::dst_shift_length_minutes());
+
+ }
+
+ static bool is_dst_boundary_day(date_type d)
+ {
+ year_type y = d.year();
+ return ((d == local_dst_start_day(y)) ||
+ (d == local_dst_end_day(y)));
+ }
+
+ //! The time of day for the dst transition (eg: typically 01:00:00 or 02:00:00)
+ static time_duration_type dst_offset()
+ {
+ return time_duration_type(0,dst_traits::dst_shift_length_minutes(),0);
+ }
+
+ static date_type local_dst_start_day(year_type year)
+ {
+ return dst_traits::local_dst_start_day(year);
+ }
+
+ static date_type local_dst_end_day(year_type year)
+ {
+ return dst_traits::local_dst_end_day(year);
+ }
+
+
+ };
+
+ //! Depricated: Class to calculate dst boundaries for US time zones
+ /* Use dst_calc_engine instead.
+ * In 2007 US/Canada DST rules changed
+ * (http://en.wikipedia.org/wiki/Energy_Policy_Act_of_2005#Change_to_daylight_saving_time).
+ */
+ template<class date_type_,
+ class time_duration_type_,
+ unsigned int dst_start_offset_minutes=120, //from start of day
+ short dst_length_minutes=60> //1 hour == 60 min in US
+ class us_dst_rules
+ {
+ public:
+ typedef time_duration_type_ time_duration_type;
+ typedef date_type_ date_type;
+ typedef typename date_type::year_type year_type;
+ typedef typename date_type::calendar_type calendar_type;
+ typedef date_time::last_kday_of_month<date_type> lkday;
+ typedef date_time::first_kday_of_month<date_type> fkday;
+ typedef date_time::nth_kday_of_month<date_type> nkday;
+ typedef dst_calculator<date_type, time_duration_type> dstcalc;
+
+ //! 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.
+ * @retval The time is either ambiguous, invalid, in dst, or not in dst
+ */
+ static time_is_dst_result local_is_dst(const date_type& d,
+ const time_duration_type& td)
+ {
+
+ year_type y = d.year();
+ date_type dst_start = local_dst_start_day(y);
+ date_type dst_end = local_dst_end_day(y);
+ return dstcalc::local_is_dst(d,td,
+ dst_start,dst_start_offset_minutes,
+ dst_end, dst_start_offset_minutes,
+ dst_length_minutes);
+
+ }
+
+
+ static bool is_dst_boundary_day(date_type d)
+ {
+ year_type y = d.year();
+ return ((d == local_dst_start_day(y)) ||
+ (d == local_dst_end_day(y)));
+ }
+
+ static date_type local_dst_start_day(year_type year)
+ {
+ if (year >= year_type(2007)) {
+ //second sunday in march
+ nkday ssim(nkday::second, Sunday, gregorian::Mar);
+ return ssim.get_date(year);
+ } else {
+ //first sunday in april
+ fkday fsia(Sunday, gregorian::Apr);
+ return fsia.get_date(year);
+ }
+ }
+
+ static date_type local_dst_end_day(year_type year)
+ {
+ if (year >= year_type(2007)) {
+ //first sunday in november
+ fkday fsin(Sunday, gregorian::Nov);
+ return fsin.get_date(year);
+ } else {
+ //last sunday in october
+ lkday lsio(Sunday, gregorian::Oct);
+ return lsio.get_date(year);
+ }
+ }
+
+ static time_duration_type dst_offset()
+ {
+ return time_duration_type(0,dst_length_minutes,0);
+ }
+
+ private:
+
+
+ };
+
+ //! Used for local time adjustments in places that don't use dst
+ template<class date_type_, class time_duration_type_>
+ class null_dst_rules
+ {
+ public:
+ typedef time_duration_type_ time_duration_type;
+ typedef date_type_ date_type;
+
+
+ //! Calculates if the given local time is dst or not
+ /*! @retval Always is_not_in_dst since this is for zones without dst
+ */
+ static time_is_dst_result local_is_dst(const date_type&,
+ const time_duration_type&)
+ {
+ return is_not_in_dst;
+ }
+
+ //! Calculates if the given utc time is in dst
+ static time_is_dst_result utc_is_dst(const date_type&,
+ const time_duration_type&)
+ {
+ return is_not_in_dst;
+ }
+
+ static bool is_dst_boundary_day(date_type d)
+ {
+ return false;
+ }
+
+ static time_duration_type dst_offset()
+ {
+ return time_duration_type(0,0,0);
+ }
+
+ };
+
+
+ } } //namespace date_time
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/dst_transition_generators.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/dst_transition_generators.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,75 @@
+/* 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
+ */
+#ifndef DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__
+#define DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__
+
+
+
+namespace boost {
+namespace date_time {
+
+ //! Defines base interface for calculating start and end date of daylight savings
+ template<class date_type>
+ class dst_day_calc_rule
+ {
+ public:
+ typedef typename date_type::year_type year_type;
+ virtual ~dst_day_calc_rule() {};
+ virtual date_type start_day(year_type y) const=0;
+ virtual std::string start_rule_as_string() const=0;
+ virtual date_type end_day(year_type y) const=0;
+ virtual std::string end_rule_as_string() const=0;
+
+ };
+
+ //! Canonical form for a class that provides day rule calculation
+ /*! This class is used to generate specific sets of dst rules
+ *
+ *@param spec Provides a specifiction of the function object types used
+ * to generate start and end days of daylight savings as well
+ * as the date type.
+ */
+ template<class spec>
+ class day_calc_dst_rule : public dst_day_calc_rule<typename spec::date_type>
+ {
+ public:
+ typedef typename spec::date_type date_type;
+ typedef typename date_type::year_type year_type;
+ typedef typename spec::start_rule start_rule;
+ typedef typename spec::end_rule end_rule;
+ day_calc_dst_rule(start_rule dst_start,
+ end_rule dst_end) :
+ dst_start_(dst_start),
+ dst_end_(dst_end)
+ {}
+ virtual date_type start_day(year_type y) const
+ {
+ return dst_start_.get_date(y);
+ }
+ virtual std::string start_rule_as_string() const
+ {
+ return dst_start_.to_string();
+ }
+ virtual date_type end_day(year_type y) const
+ {
+ return dst_end_.get_date(y);
+ }
+ virtual std::string end_rule_as_string() const
+ {
+ return dst_end_.to_string();
+ }
+ private:
+ start_rule dst_start_;
+ end_rule dst_end_;
+ };
+
+
+} }//namespace
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/filetime_functions.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/filetime_functions.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,78 @@
+#ifndef DATE_TIME_FILETIME_FUNCTIONS_HPP__
+#define DATE_TIME_FILETIME_FUNCTIONS_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+/*! @file filetime_functions.hpp
+ * 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.
+ */
+
+#include <boost/date_time/compiler_config.hpp>
+#if defined(BOOST_HAS_FTIME) // skip this file if no FILETIME
+#include <windows.h>
+#include <boost/cstdint.hpp>
+#include <boost/date_time/time.hpp>
+
+
+namespace boost {
+namespace date_time {
+
+
+ //! 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 FILETIME's sub second value
+ * will be truncated. Nanosecond resolution has no truncation. */
+ template<class time_type>
+ inline
+ time_type time_from_ftime(const FILETIME& ft){
+ typedef typename time_type::date_type date_type;
+ typedef typename time_type::date_duration_type date_duration_type;
+ typedef typename time_type::time_duration_type time_duration_type;
+
+ /* OFFSET is difference between 1970-Jan-01 & 1601-Jan-01
+ * in 100-nanosecond intervals */
+ uint64_t c1 = 27111902UL;
+ uint64_t c2 = 3577643008UL; // issues warning without 'UL'
+ const uint64_t OFFSET = (c1 << 32) + c2;
+ const long sec_pr_day = 86400; // seconds per day
+
+ uint64_t filetime = ft.dwHighDateTime;
+ filetime <<= 32;
+ filetime += ft.dwLowDateTime;
+ filetime -= OFFSET; // filetime is now 100-nanos since 1970-Jan-01
+
+ uint64_t sec = filetime / 10000000;
+#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
+ uint64_t sub_sec = (filetime % 10000000) * 100; // nanoseconds
+#else
+ uint64_t sub_sec = (filetime % 10000000) / 10; // truncate to microseconds
+#endif
+
+ // split sec into usable chunks: days, hours, minutes, & seconds
+ long _d = sec / sec_pr_day;
+ long tmp = sec % sec_pr_day;
+ long _h = tmp / 3600; // sec_pr_hour
+ tmp %= 3600;
+ long _m = tmp / 60; // sec_pr_min
+ tmp %= 60;
+ long _s = tmp; // seconds
+
+ date_duration_type dd(_d);
+ date_type d = date_type(1970, Jan, 01) + dd;
+ return time_type(d, time_duration_type(_h, _m, _s, sub_sec));
+ }
+
+}} // boost::date_time
+
+#endif // BOOST_HAS_FTIME
+
+#endif // DATE_TIME_FILETIME_FUNCTIONS_HPP__

Added: sandbox/SOC/2008/calendar/boost/date_time/format_date_parser.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/format_date_parser.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,731 @@
+
+#ifndef DATE_TIME_FORMAT_DATE_PARSER_HPP__
+#define DATE_TIME_FORMAT_DATE_PARSER_HPP__
+
+/* Copyright (c) 2004-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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/lexical_cast.hpp"
+#include "boost/date_time/string_parse_tree.hpp"
+#include "boost/date_time/strings_from_facet.hpp"
+#include "boost/date_time/special_values_parser.hpp"
+#include <string>
+#include <vector>
+
+namespace boost { namespace date_time {
+
+//! 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. */
+template<typename int_type, typename charT>
+inline
+int_type
+fixed_string_to_int(std::istreambuf_iterator<charT>& itr,
+ std::istreambuf_iterator<charT>& stream_end,
+ parse_match_result<charT>& mr,
+ unsigned int length,
+ const charT& fill_char)
+{
+ //typedef std::basic_string<charT> string_type;
+ unsigned int j = 0;
+ //string_type s;
+ while (j < length && itr != stream_end &&
+ (std::isdigit(*itr) || *itr == fill_char)) {
+ if(*itr == fill_char) {
+ /* Since a fill_char can be anything, we convert it to a zero.
+ * lexical_cast will behave predictably when zero is used as fill. */
+ mr.cache += ('0');
+ }
+ else {
+ mr.cache += (*itr);
+ }
+ itr++;
+ j++;
+ }
+ int_type i = -1;
+ // mr.cache will hold leading zeros. size() tells us when input is too short.
+ if(mr.cache.size() < length) {
+ return i;
+ }
+ try {
+ i = boost::lexical_cast<int_type>(mr.cache);
+ }catch(bad_lexical_cast blc){
+ // we want to return -1 if the cast fails so nothing to do here
+ }
+ return i;
+}
+
+//! 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. */
+template<typename int_type, typename charT>
+inline
+int_type
+fixed_string_to_int(std::istreambuf_iterator<charT>& itr,
+ std::istreambuf_iterator<charT>& stream_end,
+ parse_match_result<charT>& mr,
+ unsigned int length)
+{
+ return fixed_string_to_int<int_type, charT>(itr, stream_end, mr, length, '0');
+}
+
+//! Helper 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 '-'. */
+template<typename int_type, typename charT>
+inline
+int_type
+var_string_to_int(std::istreambuf_iterator<charT>& itr,
+ std::istreambuf_iterator<charT>& /* stream_end */,
+ unsigned int max_length)
+{
+ typedef std::basic_string<charT> string_type;
+ unsigned int j = 0;
+ string_type s;
+ while ((j < max_length) && std::isdigit(*itr)) {
+ s += (*itr);
+ itr++;
+ j++;
+ }
+ int_type i = -1;
+ if(s.length() != 0) {
+ i = boost::lexical_cast<int_type>(s);
+ }
+ return i;
+}
+
+
+//! 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...
+
+ */
+template<class date_type, typename charT>
+class format_date_parser
+{
+ public:
+ typedef std::basic_string<charT> string_type;
+ typedef std::basic_ostringstream<charT> stringstream_type;
+ typedef std::istreambuf_iterator<charT> stream_itr_type;
+ typedef typename string_type::const_iterator const_itr;
+ typedef typename date_type::year_type year_type;
+ typedef typename date_type::month_type month_type;
+ typedef typename date_type::day_type day_type;
+ typedef typename date_type::duration_type duration_type;
+ typedef typename date_type::day_of_week_type day_of_week_type;
+ typedef typename date_type::day_of_year_type day_of_year_type;
+ typedef string_parse_tree<charT> parse_tree_type;
+ typedef typename parse_tree_type::parse_match_result_type match_results;
+ typedef std::vector<std::basic_string<charT> > input_collection_type;
+
+ // TODO sv_parser uses its default constructor - write the others
+
+ format_date_parser(const string_type& format_str,
+ const input_collection_type& month_short_names,
+ const input_collection_type& month_long_names,
+ const input_collection_type& weekday_short_names,
+ const input_collection_type& weekday_long_names) :
+ m_format(format_str),
+ m_month_short_names(month_short_names, 1),
+ m_month_long_names(month_long_names, 1),
+ m_weekday_short_names(weekday_short_names),
+ m_weekday_long_names(weekday_long_names)
+ {}
+
+ format_date_parser(const string_type& format_str,
+ const std::locale& locale) :
+ m_format(format_str),
+ m_month_short_names(gather_month_strings<charT>(locale), 1),
+ m_month_long_names(gather_month_strings<charT>(locale, false), 1),
+ m_weekday_short_names(gather_weekday_strings<charT>(locale)),
+ m_weekday_long_names(gather_weekday_strings<charT>(locale, false))
+ {}
+
+ format_date_parser(const format_date_parser<date_type,charT>& fdp)
+ {
+ this->m_format = fdp.m_format;
+ this->m_month_short_names = fdp.m_month_short_names;
+ this->m_month_long_names = fdp.m_month_long_names;
+ this->m_weekday_short_names = fdp.m_weekday_short_names;
+ this->m_weekday_long_names = fdp.m_weekday_long_names;
+ }
+
+ string_type format() const
+ {
+ return m_format;
+ }
+
+ void format(string_type format_str)
+ {
+ m_format = format_str;
+ }
+
+ void short_month_names(const input_collection_type& month_names)
+ {
+ m_month_short_names = parse_tree_type(month_names, 1);
+ }
+ void long_month_names(const input_collection_type& month_names)
+ {
+ m_month_long_names = parse_tree_type(month_names, 1);
+ }
+ void short_weekday_names(const input_collection_type& weekday_names)
+ {
+ m_weekday_short_names = parse_tree_type(weekday_names);
+ }
+ void long_weekday_names(const input_collection_type& weekday_names)
+ {
+ m_weekday_long_names = parse_tree_type(weekday_names);
+ }
+
+ date_type
+ parse_date(const string_type& value,
+ const string_type& format_str,
+ const special_values_parser<date_type,charT>& sv_parser) const
+ {
+ stringstream_type ss;
+ ss << value;
+ stream_itr_type sitr(ss);
+ stream_itr_type stream_end;
+ return parse_date(sitr, stream_end, format_str, sv_parser);
+ }
+
+ date_type
+ parse_date(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end,
+ const special_values_parser<date_type,charT>& sv_parser) const
+ {
+ return parse_date(sitr, stream_end, m_format, sv_parser);
+ }
+
+ /*! 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. */
+ date_type
+ parse_date(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end,
+ string_type format_str,
+ const special_values_parser<date_type,charT>& sv_parser) const
+ {
+ bool use_current_char = false;
+
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+ charT current_char = *sitr;
+
+ short year(0), month(0), day(0), day_of_year(0);// wkday(0);
+ /* Initialized the following to their minimum values. These intermediate
+ * objects are used so we get specific exceptions when part of the input
+ * is unparsable.
+ * Ex: "205-Jan-15" will throw a bad_year, "2005-Jsn-15"- bad_month, etc.*/
+ year_type t_year(1400);
+ month_type t_month(1);
+ day_type t_day(1);
+ day_of_week_type wkday(0);
+
+
+ const_itr itr(format_str.begin());
+ while (itr != format_str.end() && (sitr != stream_end)) {
+ if (*itr == '%') {
+ itr++;
+ if (*itr != '%') {
+ switch(*itr) {
+ case 'a':
+ {
+ //this value is just throw away. It could be used for
+ //error checking potentially, but it isn't helpful in
+ //actually constructing the date - we just need to get it
+ //out of the stream
+ match_results mr = m_weekday_short_names.match(sitr, stream_end);
+ if(mr.current_match == match_results::PARSE_ERROR) {
+ // check special_values
+ if(sv_parser.match(sitr, stream_end, mr)) {
+ return date_type(static_cast<special_values>(mr.current_match));
+ }
+ }
+ wkday = mr.current_match;
+ if (mr.has_remaining()) {
+ current_char = mr.last_char();
+ use_current_char = true;
+ }
+ break;
+ }
+ case 'A':
+ {
+ //this value is just throw away. It could be used for
+ //error checking potentially, but it isn't helpful in
+ //actually constructing the date - we just need to get it
+ //out of the stream
+ match_results mr = m_weekday_long_names.match(sitr, stream_end);
+ if(mr.current_match == match_results::PARSE_ERROR) {
+ // check special_values
+ if(sv_parser.match(sitr, stream_end, mr)) {
+ return date_type(static_cast<special_values>(mr.current_match));
+ }
+ }
+ wkday = mr.current_match;
+ if (mr.has_remaining()) {
+ current_char = mr.last_char();
+ use_current_char = true;
+ }
+ break;
+ }
+ case 'b':
+ {
+ match_results mr = m_month_short_names.match(sitr, stream_end);
+ if(mr.current_match == match_results::PARSE_ERROR) {
+ // check special_values
+ if(sv_parser.match(sitr, stream_end, mr)) {
+ return date_type(static_cast<special_values>(mr.current_match));
+ }
+ }
+ t_month = month_type(mr.current_match);
+ if (mr.has_remaining()) {
+ current_char = mr.last_char();
+ use_current_char = true;
+ }
+ break;
+ }
+ case 'B':
+ {
+ match_results mr = m_month_long_names.match(sitr, stream_end);
+ if(mr.current_match == match_results::PARSE_ERROR) {
+ // check special_values
+ if(sv_parser.match(sitr, stream_end, mr)) {
+ return date_type(static_cast<special_values>(mr.current_match));
+ }
+ }
+ t_month = month_type(mr.current_match);
+ if (mr.has_remaining()) {
+ current_char = mr.last_char();
+ use_current_char = true;
+ }
+ break;
+ }
+ case 'd':
+ {
+ match_results mr;
+ day = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2);
+ if(day == -1) {
+ if(sv_parser.match(sitr, stream_end, mr)) {
+ return date_type(static_cast<special_values>(mr.current_match));
+ }
+ }
+ t_day = day_type(day);
+ break;
+ }
+ case 'e':
+ {
+ match_results mr;
+ day = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2, ' ');
+ if(day == -1) {
+ if(sv_parser.match(sitr, stream_end, mr)) {
+ return date_type(static_cast<special_values>(mr.current_match));
+ }
+ }
+ t_day = day_type(day);
+ break;
+ }
+ case 'j':
+ {
+ match_results mr;
+ day_of_year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 3);
+ if(day_of_year == -1) {
+ if(sv_parser.match(sitr, stream_end, mr)) {
+ return date_type(static_cast<special_values>(mr.current_match));
+ }
+ }
+ // these next two lines are so we get an exception with bad input
+ day_of_year_type t_day_of_year(1);
+ t_day_of_year = day_of_year_type(day_of_year);
+ break;
+ }
+ case 'm':
+ {
+ match_results mr;
+ month = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2);
+ if(month == -1) {
+ if(sv_parser.match(sitr, stream_end, mr)) {
+ return date_type(static_cast<special_values>(mr.current_match));
+ }
+ }
+ t_month = month_type(month);
+ break;
+ }
+ case 'Y':
+ {
+ match_results mr;
+ year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 4);
+ if(year == -1) {
+ if(sv_parser.match(sitr, stream_end, mr)) {
+ return date_type(static_cast<special_values>(mr.current_match));
+ }
+ }
+ t_year = year_type(year);
+ break;
+ }
+ case 'y':
+ {
+ match_results mr;
+ year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2);
+ if(year == -1) {
+ if(sv_parser.match(sitr, stream_end, mr)) {
+ return date_type(static_cast<special_values>(mr.current_match));
+ }
+ }
+ year += 2000; //make 2 digit years in this century
+ t_year = year_type(year);
+ break;
+ }
+ default:
+ {} //ignore those we don't understand
+
+ }//switch
+
+ }
+ else { // itr == '%', second consecutive
+ sitr++;
+ }
+
+ itr++; //advance past format specifier
+ }
+ else { //skip past chars in format and in buffer
+ itr++;
+ if (use_current_char) {
+ use_current_char = false;
+ current_char = *sitr;
+ }
+ else {
+ sitr++;
+ }
+ }
+ }
+
+ if (day_of_year > 0) {
+ date_type d(static_cast<unsigned short>(year-1),12,31); //end of prior year
+ return d + duration_type(day_of_year);
+ }
+
+ return date_type(t_year, t_month, t_day); // exceptions were thrown earlier
+ // if input was no good
+ }
+
+ //! Throws bad_month if unable to parse
+ month_type
+ parse_month(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end,
+ string_type format_str) const
+ {
+ match_results mr;
+ return parse_month(sitr, stream_end, format_str, mr);
+ }
+
+ //! Throws bad_month if unable to parse
+ month_type
+ parse_month(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end,
+ string_type format_str,
+ match_results& mr) const
+ {
+ bool use_current_char = false;
+
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+ charT current_char = *sitr;
+
+ short month(0);
+
+ const_itr itr(format_str.begin());
+ while (itr != format_str.end() && (sitr != stream_end)) {
+ if (*itr == '%') {
+ itr++;
+ if (*itr != '%') {
+ switch(*itr) {
+ case 'b':
+ {
+ mr = m_month_short_names.match(sitr, stream_end);
+ month = mr.current_match;
+ if (mr.has_remaining()) {
+ current_char = mr.last_char();
+ use_current_char = true;
+ }
+ break;
+ }
+ case 'B':
+ {
+ mr = m_month_long_names.match(sitr, stream_end);
+ month = mr.current_match;
+ if (mr.has_remaining()) {
+ current_char = mr.last_char();
+ use_current_char = true;
+ }
+ break;
+ }
+ case 'm':
+ {
+ month = var_string_to_int<short, charT>(sitr, stream_end, 2);
+ // var_string_to_int returns -1 if parse failed. That will
+ // cause a bad_month exception to be thrown so we do nothing here
+ break;
+ }
+ default:
+ {} //ignore those we don't understand
+
+ }//switch
+
+ }
+ else { // itr == '%', second consecutive
+ sitr++;
+ }
+
+ itr++; //advance past format specifier
+ }
+ else { //skip past chars in format and in buffer
+ itr++;
+ if (use_current_char) {
+ use_current_char = false;
+ current_char = *sitr;
+ }
+ else {
+ sitr++;
+ }
+ }
+ }
+
+ return month_type(month); // throws bad_month exception when values are zero
+ }
+
+ //! Expects 1 or 2 digits 1-31. Throws bad_day_of_month if unable to parse
+ day_type
+ parse_var_day_of_month(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end) const
+ {
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
+ return day_type(var_string_to_int<short, charT>(sitr, stream_end, 2));
+ }
+ //! Expects 2 digits 01-31. Throws bad_day_of_month if unable to parse
+ day_type
+ parse_day_of_month(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end) const
+ {
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
+ //return day_type(var_string_to_int<short, charT>(sitr, stream_end, 2));
+ match_results mr;
+ return day_type(fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2));
+ }
+
+ day_of_week_type
+ parse_weekday(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end,
+ string_type format_str) const
+ {
+ match_results mr;
+ return parse_weekday(sitr, stream_end, format_str, mr);
+ }
+ day_of_week_type
+ parse_weekday(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end,
+ string_type format_str,
+ match_results& mr) const
+ {
+ bool use_current_char = false;
+
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+ charT current_char = *sitr;
+
+ short wkday(0);
+
+ const_itr itr(format_str.begin());
+ while (itr != format_str.end() && (sitr != stream_end)) {
+ if (*itr == '%') {
+ itr++;
+ if (*itr != '%') {
+ switch(*itr) {
+ case 'a':
+ {
+ //this value is just throw away. It could be used for
+ //error checking potentially, but it isn't helpful in
+ //actually constructing the date - we just need to get it
+ //out of the stream
+ mr = m_weekday_short_names.match(sitr, stream_end);
+ wkday = mr.current_match;
+ if (mr.has_remaining()) {
+ current_char = mr.last_char();
+ use_current_char = true;
+ }
+ break;
+ }
+ case 'A':
+ {
+ //this value is just throw away. It could be used for
+ //error checking potentially, but it isn't helpful in
+ //actually constructing the date - we just need to get it
+ //out of the stream
+ mr = m_weekday_long_names.match(sitr, stream_end);
+ wkday = mr.current_match;
+ if (mr.has_remaining()) {
+ current_char = mr.last_char();
+ use_current_char = true;
+ }
+ break;
+ }
+ case 'w':
+ {
+ // weekday as number 0-6, Sunday == 0
+ wkday = var_string_to_int<short, charT>(sitr, stream_end, 2);
+ break;
+ }
+ default:
+ {} //ignore those we don't understand
+
+ }//switch
+
+ }
+ else { // itr == '%', second consecutive
+ sitr++;
+ }
+
+ itr++; //advance past format specifier
+ }
+ else { //skip past chars in format and in buffer
+ itr++;
+ if (use_current_char) {
+ use_current_char = false;
+ current_char = *sitr;
+ }
+ else {
+ sitr++;
+ }
+ }
+ }
+
+ return day_of_week_type(wkday); // throws bad_day_of_month exception
+ // when values are zero
+ }
+
+ //! throws bad_year if unable to parse
+ year_type
+ parse_year(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end,
+ string_type format_str) const
+ {
+ match_results mr;
+ return parse_year(sitr, stream_end, format_str, mr);
+ }
+
+ //! throws bad_year if unable to parse
+ year_type
+ parse_year(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end,
+ string_type format_str,
+ match_results& mr) const
+ {
+ bool use_current_char = false;
+
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+ charT current_char = *sitr;
+
+ unsigned short year(0);
+
+ const_itr itr(format_str.begin());
+ while (itr != format_str.end() && (sitr != stream_end)) {
+ if (*itr == '%') {
+ itr++;
+ if (*itr != '%') {
+ //match_results mr;
+ switch(*itr) {
+ case 'Y':
+ {
+ // year from 4 digit string
+ year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 4);
+ break;
+ }
+ case 'y':
+ {
+ // year from 2 digit string (no century)
+ year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2);
+ year += 2000; //make 2 digit years in this century
+ break;
+ }
+ default:
+ {} //ignore those we don't understand
+
+ }//switch
+
+ }
+ else { // itr == '%', second consecutive
+ sitr++;
+ }
+
+ itr++; //advance past format specifier
+ }
+ else { //skip past chars in format and in buffer
+ itr++;
+ if (use_current_char) {
+ use_current_char = false;
+ current_char = *sitr;
+ }
+ else {
+ sitr++;
+ }
+ }
+ }
+
+ return year_type(year); // throws bad_year exception when values are zero
+ }
+
+
+ private:
+ string_type m_format;
+ parse_tree_type m_month_short_names;
+ parse_tree_type m_month_long_names;
+ parse_tree_type m_weekday_short_names;
+ parse_tree_type m_weekday_long_names;
+
+};
+
+} } //namespace
+
+#endif
+
+
+

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/conversion.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/conversion.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,73 @@
+#ifndef _GREGORIAN__CONVERSION_HPP___
+#define _GREGORIAN__CONVERSION_HPP___
+
+/* Copyright (c) 2004-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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <exception>
+#include "boost/date_time/gregorian/gregorian_types.hpp"
+#include "boost/date_time/c_time.hpp"
+#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
+# 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 // BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS
+#else
+# include <sstream>
+# include "boost/date_time/gregorian/gregorian_io.hpp"
+#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
+
+namespace boost {
+
+namespace gregorian {
+
+
+ //! Converts a date to a tm struct. Throws out_of_range exception if date is a special value
+ inline
+ std::tm to_tm(const date& d)
+ {
+ if(d.is_pos_infinity() || d.is_neg_infinity() || d.is_not_a_date()){
+#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
+ std::string s("tm unable to handle date value of " + to_simple_string(d));
+ throw std::out_of_range(s);
+#else
+ std::stringstream ss;
+ ss << "tm unable to handle date value of " << d;
+ throw std::out_of_range(ss.str());
+#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
+ }
+ std::tm datetm;
+ boost::gregorian::date::ymd_type ymd = d.year_month_day();
+ datetm.tm_year = ymd.year-1900;
+ datetm.tm_mon = ymd.month-1;
+ datetm.tm_mday = ymd.day;
+ datetm.tm_wday = d.day_of_week();
+ datetm.tm_yday = d.day_of_year()-1;
+ datetm.tm_hour = datetm.tm_min = datetm.tm_sec = 0;
+ datetm.tm_isdst = -1; // negative because not enough info to set tm_isdst
+ return datetm;
+ }
+
+ //! Converts a tm structure into a date dropping the any time values.
+ inline
+ date date_from_tm(const std::tm& datetm)
+ {
+ return date(static_cast<unsigned short>(datetm.tm_year+1900),
+ static_cast<unsigned short>(datetm.tm_mon+1),
+ static_cast<unsigned short>(datetm.tm_mday));
+ }
+
+
+} } //namespace boost::gregorian
+
+
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/formatters.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/formatters.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,162 @@
+#ifndef GREGORIAN_FORMATTERS_HPP___
+#define GREGORIAN_FORMATTERS_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/compiler_config.hpp"
+#include "boost/date_time/gregorian/gregorian_types.hpp"
+#if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS)
+#include "boost/date_time/date_formatting_limited.hpp"
+#else
+#include "boost/date_time/date_formatting.hpp"
+#endif
+#include "boost/date_time/iso_format.hpp"
+#include "boost/date_time/date_format_simple.hpp"
+
+/* NOTE: "to_*_string" code for older compilers, ones that define
+ * BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS, is located in
+ * formatters_limited.hpp
+ */
+
+namespace boost {
+namespace gregorian {
+
+ // wrapper function for to_simple_(w)string(date)
+ template<class charT>
+ inline
+ std::basic_string<charT> to_simple_string_type(const date& d) {
+ return date_time::date_formatter<date,date_time::simple_format<charT>,charT>::date_to_string(d);
+ }
+ //! To YYYY-mmm-DD string where mmm 3 char month name. Example: 2002-Jan-01
+ /*!\ingroup date_format
+ */
+ inline std::string to_simple_string(const date& d) {
+ return to_simple_string_type<char>(d);
+ }
+
+
+ // wrapper function for to_simple_(w)string(date_period)
+ template<class charT>
+ inline std::basic_string<charT> to_simple_string_type(const date_period& d) {
+ typedef std::basic_string<charT> string_type;
+ charT b = '[', m = '/', e=']';
+
+ string_type d1(date_time::date_formatter<date,date_time::simple_format<charT>,charT>::date_to_string(d.begin()));
+ string_type d2(date_time::date_formatter<date,date_time::simple_format<charT>,charT>::date_to_string(d.last()));
+ return string_type(b + d1 + m + d2 + e);
+ }
+ //! Convert date period to simple string. Example: [2002-Jan-01/2002-Jan-02]
+ /*!\ingroup date_format
+ */
+ inline std::string to_simple_string(const date_period& d) {
+ return to_simple_string_type<char>(d);
+ }
+
+ // wrapper function for to_iso_(w)string(date_period)
+ template<class charT>
+ inline std::basic_string<charT> to_iso_string_type(const date_period& d) {
+ charT sep = '/';
+ std::basic_string<charT> s(date_time::date_formatter<date,date_time::iso_format<charT>,charT>::date_to_string(d.begin()));
+ return s + sep + date_time::date_formatter<date,date_time::iso_format<charT>,charT>::date_to_string(d.last());
+ }
+ //! Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
+ /*!\ingroup date_format
+ */
+ inline std::string to_iso_string(const date_period& d) {
+ return to_iso_string_type<char>(d);
+ }
+
+
+ // wrapper function for to_iso_extended_(w)string(date)
+ template<class charT>
+ inline std::basic_string<charT> to_iso_extended_string_type(const date& d) {
+ return date_time::date_formatter<date,date_time::iso_extended_format<charT>,charT>::date_to_string(d);
+ }
+ //! Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31
+ /*!\ingroup date_format
+ */
+ inline std::string to_iso_extended_string(const date& d) {
+ return to_iso_extended_string_type<char>(d);
+ }
+
+ // wrapper function for to_iso_(w)string(date)
+ template<class charT>
+ inline std::basic_string<charT> to_iso_string_type(const date& d) {
+ return date_time::date_formatter<date,date_time::iso_format<charT>,charT>::date_to_string(d);
+ }
+ //! Convert to iso standard string YYYYMMDD. Example: 20021231
+ /*!\ingroup date_format
+ */
+ inline std::string to_iso_string(const date& d) {
+ return to_iso_string_type<char>(d);
+ }
+
+
+
+
+ // wrapper function for to_sql_(w)string(date)
+ template<class charT>
+ inline std::basic_string<charT> to_sql_string_type(const date& d)
+ {
+ date::ymd_type ymd = d.year_month_day();
+ std::basic_ostringstream<charT> ss;
+ ss << ymd.year << "-"
+ << std::setw(2) << std::setfill(ss.widen('0'))
+ << ymd.month.as_number() //solves problem with gcc 3.1 hanging
+ << "-"
+ << std::setw(2) << std::setfill(ss.widen('0'))
+ << ymd.day;
+ return ss.str();
+ }
+ inline std::string to_sql_string(const date& d) {
+ return to_sql_string_type<char>(d);
+ }
+
+
+#if !defined(BOOST_NO_STD_WSTRING)
+ //! Convert date period to simple string. Example: [2002-Jan-01/2002-Jan-02]
+ /*!\ingroup date_format
+ */
+ inline std::wstring to_simple_wstring(const date_period& d) {
+ return to_simple_string_type<wchar_t>(d);
+ }
+ //! To YYYY-mmm-DD string where mmm 3 char month name. Example: 2002-Jan-01
+ /*!\ingroup date_format
+ */
+ inline std::wstring to_simple_wstring(const date& d) {
+ return to_simple_string_type<wchar_t>(d);
+ }
+ //! Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
+ /*!\ingroup date_format
+ */
+ inline std::wstring to_iso_wstring(const date_period& d) {
+ return to_iso_string_type<wchar_t>(d);
+ }
+ //! Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31
+ /*!\ingroup date_format
+ */
+ inline std::wstring to_iso_extended_wstring(const date& d) {
+ return to_iso_extended_string_type<wchar_t>(d);
+ }
+ //! Convert to iso standard string YYYYMMDD. Example: 20021231
+ /*!\ingroup date_format
+ */
+ inline std::wstring to_iso_wstring(const date& d) {
+ return to_iso_string_type<wchar_t>(d);
+ }
+ inline std::wstring to_sql_wstring(const date& d) {
+ return to_sql_string_type<wchar_t>(d);
+ }
+#endif // BOOST_NO_STD_WSTRING
+
+} } //namespace gregorian
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/formatters_limited.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/formatters_limited.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,81 @@
+#ifndef GREGORIAN_FORMATTERS_LIMITED_HPP___
+#define GREGORIAN_FORMATTERS_LIMITED_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/gregorian_types.hpp"
+#include "boost/date_time/date_formatting_limited.hpp"
+#include "boost/date_time/iso_format.hpp"
+#include "boost/date_time/date_format_simple.hpp"
+#include "boost/date_time/compiler_config.hpp"
+
+namespace boost {
+namespace gregorian {
+
+ //! To YYYY-mmm-DD string where mmm 3 char month name. Example: 2002-Jan-01
+ /*!\ingroup date_format
+ */
+ inline std::string to_simple_string(const date& d) {
+ return date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d);
+ }
+
+ //! Convert date period to simple string. Example: [2002-Jan-01/2002-Jan-02]
+ /*!\ingroup date_format
+ */
+ inline std::string to_simple_string(const date_period& d) {
+ std::string s("[");
+ std::string d1(date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d.begin()));
+ std::string d2(date_time::date_formatter<date,date_time::simple_format<char> >::date_to_string(d.last()));
+ return std::string("[" + d1 + "/" + d2 + "]");
+ }
+
+ //! Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
+ /*!\ingroup date_format
+ */
+ inline std::string to_iso_string(const date_period& d) {
+ std::string s(date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d.begin()));
+ return s + "/" + date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d.last());
+ }
+
+
+ //! Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31
+ /*!\ingroup date_format
+ */
+ inline std::string to_iso_extended_string(const date& d) {
+ return date_time::date_formatter<date,date_time::iso_extended_format<char> >::date_to_string(d);
+ }
+
+ //! Convert to iso standard string YYYYMMDD. Example: 20021231
+ /*!\ingroup date_format
+ */
+ inline std::string to_iso_string(const date& d) {
+ return date_time::date_formatter<date,date_time::iso_format<char> >::date_to_string(d);
+ }
+
+
+
+ inline std::string to_sql_string(const date& d)
+ {
+ date::ymd_type ymd = d.year_month_day();
+ std::ostringstream ss;
+ ss << ymd.year << "-"
+ << std::setw(2) << std::setfill('0')
+ << ymd.month.as_number() //solves problem with gcc 3.1 hanging
+ << "-"
+ << std::setw(2) << std::setfill('0')
+ << ymd.day;
+ return ss.str();
+ }
+
+
+} } //namespace gregorian
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_calendar.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_calendar.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,47 @@
+#ifndef GREGORIAN_GREGORIAN_CALENDAR_HPP__
+#define GREGORIAN_GREGORIAN_CALENDAR_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/greg_weekday.hpp"
+#include "boost/date_time/gregorian/greg_day_of_year.hpp"
+#include "boost/date_time/gregorian_calendar.hpp"
+#include "boost/date_time/gregorian/greg_ymd.hpp"
+#include "boost/date_time/int_adapter.hpp"
+
+namespace boost {
+namespace gregorian {
+
+ //!An internal date representation that includes infinities, not a date
+ typedef date_time::int_adapter<unsigned long> fancy_date_rep;
+
+ //! Gregorian calendar for this implementation, hard work in the base
+ class gregorian_calendar :
+ public date_time::gregorian_calendar_base<greg_year_month_day, fancy_date_rep::int_type> {
+ public:
+ //! Type to hold a weekday (eg: Sunday, Monday,...)
+ typedef greg_weekday day_of_week_type;
+ //! Counter type from 1 to 366 for gregorian dates.
+ typedef greg_day_of_year_rep day_of_year_type;
+ //! Internal date representation that handles infinity, not a date
+ typedef fancy_date_rep date_rep_type;
+ //! Date rep implements the traits stuff as well
+ typedef fancy_date_rep date_traits_type;
+
+
+ private:
+ };
+
+} } //namespace gregorian
+
+
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_date.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_date.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,135 @@
+#ifndef GREG_DATE_HPP___
+#define GREG_DATE_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/date.hpp"
+#include "boost/date_time/special_defs.hpp"
+#include "boost/date_time/gregorian/greg_calendar.hpp"
+#include "boost/date_time/gregorian/greg_duration.hpp"
+
+namespace boost {
+namespace gregorian {
+
+ //bring special enum values into the namespace
+ using date_time::special_values;
+ using date_time::not_special;
+ using date_time::neg_infin;
+ using date_time::pos_infin;
+ using date_time::not_a_date_time;
+ using date_time::max_date_time;
+ using date_time::min_date_time;
+
+ //! A date type based on gregorian_calendar
+ /*! This class is the primary interface for programming with
+ greogorian dates. The is a lightweight type that can be
+ freely passed by value. All comparison operators are
+ supported.
+ \ingroup date_basics
+ */
+ class date : public date_time::date<date, gregorian_calendar, date_duration>
+ {
+ public:
+ typedef gregorian_calendar::year_type year_type;
+ typedef gregorian_calendar::month_type month_type;
+ typedef gregorian_calendar::day_type day_type;
+ typedef gregorian_calendar::day_of_year_type day_of_year_type;
+ typedef gregorian_calendar::ymd_type ymd_type;
+ typedef gregorian_calendar::date_rep_type date_rep_type;
+ typedef gregorian_calendar::date_int_type date_int_type;
+ typedef date_duration duration_type;
+#if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
+ //! Default constructor constructs with not_a_date_time
+ date():
+ date_time::date<date, gregorian_calendar, date_duration>(date_rep_type::from_special(not_a_date_time))
+ {}
+#endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR
+ //! Main constructor with year, month, day
+ date(year_type y, month_type m, day_type d)
+ : date_time::date<date, gregorian_calendar, date_duration>(y, m, d)
+ {
+ if (gregorian_calendar::end_of_month_day(y, m) < d) {
+ throw bad_day_of_month(std::string("Day of month is not valid for year"));
+ }
+ }
+ //! Constructor from a ymd_type structure
+ explicit date(const ymd_type& ymd)
+ : date_time::date<date, gregorian_calendar, date_duration>(ymd)
+ {}
+ //! Needed copy constructor
+ explicit date(const date_int_type& rhs):
+ date_time::date<date,gregorian_calendar, date_duration>(rhs)
+ {}
+ //! Needed copy constructor
+ explicit date(date_rep_type rhs):
+ date_time::date<date,gregorian_calendar, date_duration>(rhs)
+ {}
+ //! Constructor for infinities, not a date, max and min date
+ explicit date(special_values sv):
+ date_time::date<date, gregorian_calendar, date_duration>(date_rep_type::from_special(sv))
+ {
+ if (sv == min_date_time)
+ {
+ *this = date(1400, 1, 1);
+ }
+ if (sv == max_date_time)
+ {
+ *this = date(9999, 12, 31);
+ }
+
+ }
+ //!Return the Julian Day number for the date.
+ date_int_type julian_day() const
+ {
+ ymd_type ymd = year_month_day();
+ return gregorian_calendar::julian_day_number(ymd);
+ }
+ //!Return the day of year 1..365 or 1..366 (for leap year)
+ day_of_year_type day_of_year() const
+ {
+ date start_of_year(year(), 1, 1);
+ unsigned short doy = static_cast<unsigned short>((*this-start_of_year).days() + 1);
+ return day_of_year_type(doy);
+ }
+ //!Return the Modified Julian Day number for the date.
+ long modjulian_day() const
+ {
+ ymd_type ymd = year_month_day();
+ return gregorian_calendar::modjulian_day_number(ymd);
+ }
+ //!Return the iso 8601 week number 1..53
+ int week_number() const
+ {
+ ymd_type ymd = year_month_day();
+ return gregorian_calendar::week_number(ymd);
+ }
+ //! Return the day number from the calendar
+ date_int_type day_number() const
+ {
+ return days_;
+ }
+ //! Return the last day of the current month
+ date end_of_month() const
+ {
+ ymd_type ymd = year_month_day();
+ short eom_day = gregorian_calendar::end_of_month_day(ymd.year, ymd.month);
+ return date(ymd.year, ymd.month, eom_day);
+ }
+
+ private:
+
+ };
+
+
+
+} } //namespace gregorian
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_day.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_day.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,57 @@
+#ifndef GREG_DAY_HPP___
+#define GREG_DAY_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/constrained_value.hpp"
+#include <stdexcept>
+#include <string>
+
+namespace boost {
+namespace gregorian {
+
+ //! Exception type for gregorian day of month (1..31)
+ struct bad_day_of_month : public std::out_of_range
+ {
+ bad_day_of_month() :
+ std::out_of_range(std::string("Day of month value is out of range 1..31"))
+ {}
+ //! Allow other classes to throw with unique string for bad day like Feb 29
+ bad_day_of_month(const std::string& s) :
+ std::out_of_range(s)
+ {}
+ };
+ //! Policy class that declares error handling and day of month ranges
+ typedef CV::simple_exception_policy<unsigned short, 1, 31, bad_day_of_month> greg_day_policies;
+
+ //! Generated represetation for gregorian day of month
+ typedef CV::constrained_value<greg_day_policies> greg_day_rep;
+
+ //! Represent a day of the month (range 1 - 31)
+ /*! This small class allows for simple conversion an integer value into
+ a day of the month for a standard gregorian calendar. The type
+ is automatically range checked so values outside of the range 1-31
+ will cause a bad_day_of_month exception
+ */
+ class greg_day : public greg_day_rep {
+ public:
+ greg_day(unsigned short day_of_month) : greg_day_rep(day_of_month) {}
+ unsigned short as_number() const {return value_;}
+ operator unsigned short() const {return value_;}
+ private:
+
+ };
+
+
+
+} } //namespace gregorian
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_day_of_year.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_day_of_year.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,38 @@
+#ifndef GREG_DAY_OF_YEAR_HPP___
+#define GREG_DAY_OF_YEAR_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/constrained_value.hpp"
+#include <stdexcept>
+#include <string>
+
+namespace boost {
+namespace gregorian {
+
+ //! Exception type for day of year (1..366)
+ struct bad_day_of_year : public std::out_of_range
+ {
+ bad_day_of_year() :
+ std::out_of_range(std::string("Day of year value is out of range 1..366"))
+ {}
+ };
+
+ //! A day of the year range (1..366)
+ typedef CV::simple_exception_policy<unsigned short,1,366,bad_day_of_year> greg_day_of_year_policies;
+
+ //! Define a range representation type for the day of the year 1..366
+ typedef CV::constrained_value<greg_day_of_year_policies> greg_day_of_year_rep;
+
+
+} } //namespace gregorian
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,38 @@
+#ifndef GREG_DURATION_HPP___
+#define GREG_DURATION_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/date_duration.hpp"
+#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
+#include "boost/date_time/date_duration_types.hpp"
+#endif
+#include "boost/date_time/int_adapter.hpp"
+
+
+namespace boost {
+namespace gregorian {
+
+
+ //!An internal date representation that includes infinities, not a date
+ typedef boost::date_time::duration_traits_adapted date_duration_rep;
+
+ //! Durations in days for gregorian system
+ /*! \ingroup date_basics
+ */
+ typedef date_time::date_duration<date_duration_rep> date_duration;
+
+ //! Shorthand for date_duration
+ typedef date_duration days;
+
+} } //namespace gregorian
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration_types.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_duration_types.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,34 @@
+#ifndef GREG_DURATION_TYPES_HPP___
+#define GREG_DURATION_TYPES_HPP___
+
+/* Copyright (c) 2004 CrystalClear Software, Inc.
+ * Subject to 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/gregorian/greg_date.hpp"
+#include "boost/date_time/int_adapter.hpp"
+#include "boost/date_time/adjust_functors.hpp"
+#include "boost/date_time/date_duration.hpp"
+#include "boost/date_time/date_duration_types.hpp"
+
+namespace boost {
+namespace gregorian {
+
+ //! config struct for additional duration types (ie months_duration<> & years_duration<>)
+ struct greg_durations_config {
+ typedef date date_type;
+ typedef date_time::int_adapter<int> int_rep;
+ typedef date_time::month_functor<date_type> month_adjustor_type;
+ };
+
+ typedef date_time::months_duration<greg_durations_config> months;
+ typedef date_time::years_duration<greg_durations_config> years;
+ typedef date_time::weeks_duration<date_time::duration_traits_adapted> weeks;
+
+}} // namespace boost::gregorian
+
+#endif // GREG_DURATION_TYPES_HPP___

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_facet.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_facet.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,351 @@
+#ifndef GREGORIAN_FACET_HPP___
+#define GREGORIAN_FACET_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/gregorian_types.hpp"
+#include "boost/date_time/date_formatting_locales.hpp" // sets BOOST_DATE_TIME_NO_LOCALE
+#include "boost/date_time/gregorian/parsers.hpp"
+#include <string>
+#include <exception>
+
+//This file is basically commented out if locales are not supported
+#ifndef BOOST_DATE_TIME_NO_LOCALE
+
+
+namespace boost {
+namespace gregorian {
+
+ //! Configuration of the output facet template
+ struct greg_facet_config
+ {
+ typedef boost::gregorian::greg_month month_type;
+ typedef boost::date_time::special_values special_value_enum;
+ typedef boost::gregorian::months_of_year month_enum;
+ typedef boost::date_time::weekdays weekday_enum;
+ };
+
+#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
+ //! Create the base facet type for gregorian::date
+ typedef boost::date_time::date_names_put<greg_facet_config> greg_base_facet;
+
+ //! ostream operator for gregorian::date
+ /*! Uses the date facet to determine various output parameters including:
+ * - string values for the month (eg: Jan, Feb, Mar) (default: English)
+ * - string values for special values (eg: not-a-date-time) (default: English)
+ * - selection of long, short strings, or numerical month representation (default: short string)
+ * - month day year order (default yyyy-mmm-dd)
+ */
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os, const date& d)
+ {
+ typedef boost::date_time::date_names_put<greg_facet_config, charT> facet_def;
+ typedef boost::date_time::ostream_date_formatter<date, facet_def, charT> greg_ostream_formatter;
+ greg_ostream_formatter::date_put(d, os);
+ return os;
+ }
+
+ //! operator<< for gregorian::greg_month typically streaming: Jan, Feb, Mar...
+ /*! Uses the date facet to determine output string as well as selection of long or short strings.
+ * Default if no facet is installed is to output a 2 wide numeric value for the month
+ * eg: 01 == Jan, 02 == Feb, ... 12 == Dec.
+ */
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os, const greg_month& m)
+ {
+ typedef boost::date_time::date_names_put<greg_facet_config, charT> facet_def;
+ typedef boost::date_time::ostream_month_formatter<facet_def, charT> greg_month_formatter;
+ std::locale locale = os.getloc();
+ if (std::has_facet<facet_def>(locale)) {
+ const facet_def& f = std::use_facet<facet_def>(locale);
+ greg_month_formatter::format_month(m, os, f);
+
+ }
+ else { //default to numeric
+ charT fill_char = '0';
+ os << std::setw(2) << std::setfill(fill_char) << m.as_number();
+ }
+
+ return os;
+ }
+
+ //! operator<< for gregorian::greg_weekday typically streaming: Sun, Mon, Tue, ...
+ /*! Uses the date facet to determine output string as well as selection of long or short string.
+ * Default if no facet is installed is to output a 3 char english string for the
+ * day of the week.
+ */
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os, const greg_weekday& wd)
+ {
+ typedef boost::date_time::date_names_put<greg_facet_config, charT> facet_def;
+ typedef boost::date_time::ostream_weekday_formatter<greg_weekday, facet_def, charT> greg_weekday_formatter;
+ std::locale locale = os.getloc();
+ if (std::has_facet<facet_def>(locale)) {
+ const facet_def& f = std::use_facet<facet_def>(locale);
+ greg_weekday_formatter::format_weekday(wd.as_enum(), os, f, true);
+ }
+ else { //default to short English string eg: Sun, Mon, Tue, Wed...
+ os << wd.as_short_string();
+ }
+
+ return os;
+ }
+
+ //! operator<< for gregorian::date_period typical output: [2002-Jan-01/2002-Jan-31]
+ /*! Uses the date facet to determine output string as well as selection of long
+ * or short string fr dates.
+ * Default if no facet is installed is to output a 3 char english string for the
+ * day of the week.
+ */
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os, const date_period& dp)
+ {
+ os << '['; //TODO: facet or manipulator for periods?
+ os << dp.begin();
+ os << '/'; //TODO: facet or manipulator for periods?
+ os << dp.last();
+ os << ']';
+ return os;
+ }
+
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os, const date_duration& dd)
+ {
+ //os << dd.days();
+ os << dd.get_rep();
+ return os;
+ }
+
+ //! operator<< for gregorian::partial_date. Output: "Jan 1"
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os, const partial_date& pd)
+ {
+ os << std::setw(2) << std::setfill('0') << pd.day() << ' '
+ << pd.month().as_short_string() ;
+ return os;
+ }
+
+ //! operator<< for gregorian::nth_kday_of_month. Output: "first Mon of Jun"
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os,
+ const nth_kday_of_month& nkd)
+ {
+ os << nkd.nth_week_as_str() << ' '
+ << nkd.day_of_week() << " of "
+ << nkd.month().as_short_string() ;
+ return os;
+ }
+
+ //! operator<< for gregorian::first_kday_of_month. Output: "first Mon of Jun"
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os,
+ const first_kday_of_month& fkd)
+ {
+ os << "first " << fkd.day_of_week() << " of "
+ << fkd.month().as_short_string() ;
+ return os;
+ }
+
+ //! operator<< for gregorian::last_kday_of_month. Output: "last Mon of Jun"
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os,
+ const last_kday_of_month& lkd)
+ {
+ os << "last " << lkd.day_of_week() << " of "
+ << lkd.month().as_short_string() ;
+ return os;
+ }
+
+ //! operator<< for gregorian::first_kday_after. Output: "first Mon after"
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os,
+ const first_kday_after& fka)
+ {
+ os << fka.day_of_week() << " after";
+ return os;
+ }
+
+ //! operator<< for gregorian::first_kday_before. Output: "first Mon before"
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os,
+ const first_kday_before& fkb)
+ {
+ os << fkb.day_of_week() << " before";
+ return os;
+ }
+#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
+ /**************** Input Streaming ******************/
+
+#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
+ //! operator>> for gregorian::date
+ template<class charT>
+ inline
+ std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is, date& d)
+ {
+ std::istream_iterator<std::basic_string<charT>, charT> beg(is), eos;
+
+ typedef boost::date_time::all_date_names_put<greg_facet_config, charT> facet_def;
+ d = from_stream(beg, eos);
+ return is;
+ }
+#endif // BOOST_NO_STD_ITERATOR_TRAITS
+
+ //! operator>> for gregorian::date_duration
+ template<class charT>
+ inline
+ std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is,
+ date_duration& dd)
+ {
+ long v;
+ is >> v;
+ dd = date_duration(v);
+ return is;
+ }
+
+ //! operator>> for gregorian::date_period
+ template<class charT>
+ inline
+ std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is,
+ date_period& dp)
+ {
+ std::basic_string<charT> s;
+ is >> s;
+ dp = date_time::from_simple_string_type<date>(s);
+ return is;
+ }
+
+ //! generates a locale with the set of gregorian name-strings of type char*
+ BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, char type);
+
+ //! Returns a pointer to a facet with a default set of names (English)
+ /* Necessary in the event an exception is thrown from op>> for
+ * weekday or month. See comments in those functions for more info */
+ BOOST_DATE_TIME_DECL boost::date_time::all_date_names_put<greg_facet_config, char>* create_facet_def(char type);
+
+#ifndef BOOST_NO_STD_WSTRING
+ //! generates a locale with the set of gregorian name-strings of type wchar_t*
+ BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, wchar_t type);
+ //! Returns a pointer to a facet with a default set of names (English)
+ /* Necessary in the event an exception is thrown from op>> for
+ * weekday or month. See comments in those functions for more info */
+ BOOST_DATE_TIME_DECL boost::date_time::all_date_names_put<greg_facet_config, wchar_t>* create_facet_def(wchar_t type);
+#endif // BOOST_NO_STD_WSTRING
+
+ //! operator>> for gregorian::greg_month - throws exception if invalid month given
+ template<class charT>
+ inline
+ std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is,greg_month& m)
+ {
+ typedef boost::date_time::all_date_names_put<greg_facet_config, charT> facet_def;
+
+ std::basic_string<charT> s;
+ is >> s;
+
+ if(!std::has_facet<facet_def>(is.getloc())) {
+ std::locale loc = is.getloc();
+ charT a = '\0';
+ is.imbue(generate_locale(loc, a));
+ }
+
+ short num = 0;
+
+ try{
+ const facet_def& f = std::use_facet<facet_def>(is.getloc());
+ num = date_time::find_match(f.get_short_month_names(),
+ f.get_long_month_names(),
+ (greg_month::max)(), s);
+ }
+ /* bad_cast will be thrown if the desired facet is not accessible
+ * so we can generate the facet. This has the drawback of using english
+ * names as a default. */
+ catch(std::bad_cast bc){
+ std::cout << "Month exception caught" << std::endl;
+ charT a = '\0';
+ const facet_def* f = create_facet_def(a);
+ num = date_time::find_match(f->get_short_month_names(),
+ f->get_long_month_names(),
+ (greg_month::max)(), s);
+ delete(f);
+ }
+
+ num += 1; // months numbered 1-12
+ m = greg_month(num);
+
+ return is;
+ }
+
+ //! operator>> for gregorian::greg_weekday - throws exception if invalid weekday given
+ template<class charT>
+ inline
+ std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is,greg_weekday& wd)
+ {
+ typedef boost::date_time::all_date_names_put<greg_facet_config, charT> facet_def;
+
+ std::basic_string<charT> s;
+ is >> s;
+
+ if(!std::has_facet<facet_def>(is.getloc())) {
+ std::locale loc = is.getloc();
+ charT a = '\0';
+ is.imbue(generate_locale(loc, a));
+ }
+
+ short num = 0;
+ try{
+ const facet_def& f = std::use_facet<facet_def>(is.getloc());
+ num = date_time::find_match(f.get_short_weekday_names(),
+ f.get_long_weekday_names(),
+ (greg_weekday::max)(), s);
+ }
+ /* bad_cast will be thrown if the desired facet is not accessible
+ * so we can generate the facet. This has the drawback of using english
+ * names as a default. */
+ catch(std::bad_cast bc){
+ //std::cout << "Weekday exception caught" << std::endl;
+ charT a = '\0';
+ const facet_def* f = create_facet_def(a);
+ num = date_time::find_match(f->get_short_weekday_names(),
+ f->get_long_weekday_names(),
+ (greg_weekday::max)(), s);
+ delete(f);
+ }
+
+ wd = greg_weekday(num); // weekdays numbered 0-6
+ return is;
+ }
+
+} } //namespace gregorian
+
+#endif
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_month.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_month.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,105 @@
+#ifndef GREG_MONTH_HPP___
+#define GREG_MONTH_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/constrained_value.hpp"
+#include "boost/date_time/date_defs.hpp"
+#include "boost/shared_ptr.hpp"
+#include "boost/date_time/compiler_config.hpp"
+#include <stdexcept>
+#include <string>
+#include <map>
+#include <algorithm>
+#include <cctype>
+
+namespace boost {
+namespace gregorian {
+
+ typedef date_time::months_of_year months_of_year;
+
+ //bring enum values into the namespace
+ using date_time::Jan;
+ using date_time::Feb;
+ using date_time::Mar;
+ using date_time::Apr;
+ using date_time::May;
+ using date_time::Jun;
+ using date_time::Jul;
+ using date_time::Aug;
+ using date_time::Sep;
+ using date_time::Oct;
+ using date_time::Nov;
+ using date_time::Dec;
+ using date_time::NotAMonth;
+ using date_time::NumMonths;
+
+ //! Exception thrown if a greg_month is constructed with a value out of range
+ struct bad_month : public std::out_of_range
+ {
+ bad_month() : std::out_of_range(std::string("Month number is out of range 1..12")) {}
+ };
+ //! Build a policy class for the greg_month_rep
+ typedef CV::simple_exception_policy<unsigned short, 1, 12, bad_month> greg_month_policies;
+ //! A constrained range that implements the gregorian_month rules
+ typedef CV::constrained_value<greg_month_policies> greg_month_rep;
+
+
+ //! Wrapper class to represent months in gregorian based calendar
+ class BOOST_DATE_TIME_DECL greg_month : public greg_month_rep {
+ public:
+ typedef date_time::months_of_year month_enum;
+ typedef std::map<std::string, unsigned short> month_map_type;
+ typedef boost::shared_ptr<month_map_type> month_map_ptr_type;
+ //! Construct a month from the months_of_year enumeration
+ greg_month(month_enum theMonth) :
+ greg_month_rep(static_cast<greg_month_rep::value_type>(theMonth)) {}
+ //! Construct from a short value
+ greg_month(unsigned short theMonth) : greg_month_rep(theMonth) {}
+ //! Convert the value back to a short
+ operator unsigned short() const {return value_;}
+ //! Returns month as number from 1 to 12
+ unsigned short as_number() const {return value_;}
+ month_enum as_enum() const {return static_cast<month_enum>(value_);}
+ const char* as_short_string() const;
+ const char* as_long_string() const;
+#ifndef BOOST_NO_STD_WSTRING
+ const wchar_t* as_short_wstring() const;
+ const wchar_t* as_long_wstring() const;
+#endif // BOOST_NO_STD_WSTRING
+ //! Shared pointer to a map of Month strings (Names & Abbrev) & numbers
+ static month_map_ptr_type get_month_map_ptr();
+
+ /* parameterized as_*_string functions are intended to be called
+ * from a template function: "... as_short_string(charT c='\0');" */
+ const char* as_short_string(char) const
+ {
+ return as_short_string();
+ }
+ const char* as_long_string(char) const
+ {
+ return as_long_string();
+ }
+#ifndef BOOST_NO_STD_WSTRING
+ const wchar_t* as_short_string(wchar_t) const
+ {
+ return as_short_wstring();
+ }
+ const wchar_t* as_long_string(wchar_t) const
+ {
+ return as_long_wstring();
+ }
+#endif // BOOST_NO_STD_WSTRING
+ };
+
+} } //namespace gregorian
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_serialize.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_serialize.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,489 @@
+#ifndef GREGORIAN_SERIALIZE_HPP___
+#define GREGORIAN_SERIALIZE_HPP___
+
+/* Copyright (c) 2004-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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/gregorian_types.hpp"
+#include "boost/date_time/gregorian/parsers.hpp"
+#include "boost/serialization/split_free.hpp"
+
+
+// macros to split serialize functions into save & load functions
+// An expanded version is below for gregorian::date
+// NOTE: these macros define template functions in the boost::serialization namespace.
+// They must be expanded *outside* of any namespace
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_duration)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_duration::duration_rep)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_period)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_month)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_day)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_weekday)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::partial_date)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::nth_kday_of_month)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_of_month)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::last_kday_of_month)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_before)
+BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_after)
+
+namespace boost {
+namespace serialization {
+
+/*! Method that does serialization for gregorian::date -- splits to load/save
+ */
+template<class Archive>
+inline void serialize(Archive & ar,
+ ::boost::gregorian::date & d,
+ const unsigned int file_version)
+{
+ split_free(ar, d, file_version);
+}
+
+//! Function to save gregorian::date objects using serialization lib
+/*! Dates are serialized into a string for transport and storage.
+ * While it would be more efficient to store the internal
+ * integer used to manipulate the dates, it is an unstable solution.
+ */
+template<class Archive>
+void save(Archive & ar,
+ const ::boost::gregorian::date & d,
+ unsigned int /* version */)
+{
+ std::string ds = to_iso_string(d);
+ ar & make_nvp("date", ds);
+}
+
+//! Function to load gregorian::date objects using serialization lib
+/*! Dates are serialized into a string for transport and storage.
+ * While it would be more efficient to store the internal
+ * integer used to manipulate the dates, it is an unstable solution.
+ */
+template<class Archive>
+void load(Archive & ar,
+ ::boost::gregorian::date & d,
+ unsigned int /*version*/)
+{
+ std::string ds;
+ ar & make_nvp("date", ds);
+ try{
+ d = ::boost::gregorian::from_undelimited_string(ds);
+ }catch(bad_lexical_cast be) {
+ gregorian::special_values sv = gregorian::special_value_from_string(ds);
+ if(sv == gregorian::not_special) {
+ throw(be); // no match found, rethrow original exception
+ }
+ else {
+ d = gregorian::date(sv);
+ }
+ }
+}
+
+
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar,
+ ::boost::gregorian::date* dp,
+ const unsigned int /*file_version*/)
+{
+ // retrieve data from archive required to construct new
+ // invoke inplace constructor to initialize instance of date
+ ::new(dp) ::boost::gregorian::date(::boost::gregorian::not_a_date_time);
+}
+
+/**** date_duration ****/
+
+//! Function to save gregorian::date_duration objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::date_duration & dd,
+ unsigned int /*version*/)
+{
+ typename gregorian::date_duration::duration_rep dr = dd.get_rep();
+ ar & make_nvp("date_duration", dr);
+}
+//! Function to load gregorian::date_duration objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::date_duration & dd, unsigned int /*version*/)
+{
+ typename gregorian::date_duration::duration_rep dr(0);
+ ar & make_nvp("date_duration", dr);
+ dd = gregorian::date_duration(dr);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar, gregorian::date_duration* dd,
+ const unsigned int /*file_version*/)
+{
+ ::new(dd) gregorian::date_duration(gregorian::not_a_date_time);
+}
+
+/**** date_duration::duration_rep (most likely int_adapter) ****/
+
+//! helper unction to save date_duration objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::date_duration::duration_rep & dr,
+ unsigned int /*version*/)
+{
+ typename gregorian::date_duration::duration_rep::int_type it = dr.as_number();
+ ar & make_nvp("date_duration_duration_rep", it);
+}
+//! helper function to load date_duration objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::date_duration::duration_rep & dr, unsigned int /*version*/)
+{
+ typename gregorian::date_duration::duration_rep::int_type it(0);
+ ar & make_nvp("date_duration_duration_rep", it);
+ dr = gregorian::date_duration::duration_rep::int_type(it);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar, gregorian::date_duration::duration_rep* dr,
+ const unsigned int /*file_version*/)
+{
+ ::new(dr) gregorian::date_duration::duration_rep(0);
+}
+
+/**** date_period ****/
+
+//! Function to save gregorian::date_period objects using serialization lib
+/*! date_period objects are broken down into 2 parts for serialization:
+ * the begining date object and the end date object
+ */
+template<class Archive>
+void save(Archive & ar, const gregorian::date_period& dp,
+ unsigned int /*version*/)
+{
+ gregorian::date d1 = dp.begin();
+ gregorian::date d2 = dp.end();
+ ar & make_nvp("date_period_begin_date", d1);
+ ar & make_nvp("date_period_end_date", d2);
+}
+//! Function to load gregorian::date_period objects using serialization lib
+/*! date_period objects are broken down into 2 parts for serialization:
+ * the begining date object and the end date object
+ */
+template<class Archive>
+void load(Archive & ar, gregorian::date_period& dp, unsigned int /*version*/)
+{
+ gregorian::date d1(gregorian::not_a_date_time);
+ gregorian::date d2(gregorian::not_a_date_time);
+ ar & make_nvp("date_period_begin_date", d1);
+ ar & make_nvp("date_period_end_date", d2);
+ dp = gregorian::date_period(d1,d2);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar, gregorian::date_period* dp,
+ const unsigned int /*file_version*/)
+{
+ gregorian::date d(gregorian::not_a_date_time);
+ gregorian::date_duration dd(1);
+ ::new(dp) gregorian::date_period(d,dd);
+}
+
+/**** greg_month ****/
+
+//! Function to save gregorian::greg_month objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::greg_month& gm,
+ unsigned int /*version*/)
+{
+ unsigned short us = gm.as_number();
+ ar & make_nvp("greg_month", us);
+}
+//! Function to load gregorian::greg_month objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::greg_month& gm, unsigned int /*version*/)
+{
+ unsigned short us;
+ ar & make_nvp("greg_month", us);
+ gm = gregorian::greg_month(us);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar, gregorian::greg_month* gm,
+ const unsigned int /*file_version*/)
+{
+ ::new(gm) gregorian::greg_month(1);
+}
+
+/**** greg_day ****/
+
+//! Function to save gregorian::greg_day objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::greg_day& gd,
+ unsigned int /*version*/)
+{
+ unsigned short us = gd.as_number();
+ ar & make_nvp("greg_day", us);
+}
+//! Function to load gregorian::greg_day objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::greg_day& gd, unsigned int /*version*/)
+{
+ unsigned short us;
+ ar & make_nvp("greg_day", us);
+ gd = gregorian::greg_day(us);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar, gregorian::greg_day* gd,
+ const unsigned int /*file_version*/)
+{
+ ::new(gd) gregorian::greg_day(1);
+}
+
+/**** greg_weekday ****/
+
+//! Function to save gregorian::greg_weekday objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::greg_weekday& gd,
+ unsigned int /*version*/)
+{
+ unsigned short us = gd.as_number();
+ ar & make_nvp("greg_weekday", us);
+}
+//! Function to load gregorian::greg_weekday objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::greg_weekday& gd, unsigned int /*version*/)
+{
+ unsigned short us;
+ ar & make_nvp("greg_weekday", us);
+ gd = gregorian::greg_weekday(us);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar, gregorian::greg_weekday* gd,
+ const unsigned int /*file_version*/)
+{
+ ::new(gd) gregorian::greg_weekday(1);
+}
+
+/**** date_generators ****/
+
+/**** partial_date ****/
+
+//! Function to save gregorian::partial_date objects using serialization lib
+/*! partial_date objects are broken down into 2 parts for serialization:
+ * the day (typically greg_day) and month (typically greg_month) objects
+ */
+template<class Archive>
+void save(Archive & ar, const gregorian::partial_date& pd,
+ unsigned int /*version*/)
+{
+ gregorian::greg_day gd(pd.day());
+ gregorian::greg_month gm(pd.month().as_number());
+ ar & make_nvp("partial_date_day", gd);
+ ar & make_nvp("partial_date_month", gm);
+}
+//! Function to load gregorian::partial_date objects using serialization lib
+/*! partial_date objects are broken down into 2 parts for serialization:
+ * the day (greg_day) and month (greg_month) objects
+ */
+template<class Archive>
+void load(Archive & ar, gregorian::partial_date& pd, unsigned int /*version*/)
+{
+ gregorian::greg_day gd(1);
+ gregorian::greg_month gm(1);
+ ar & make_nvp("partial_date_day", gd);
+ ar & make_nvp("partial_date_month", gm);
+ pd = gregorian::partial_date(gd,gm);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar, gregorian::partial_date* pd,
+ const unsigned int /*file_version*/)
+{
+ gregorian::greg_month gm(1);
+ gregorian::greg_day gd(1);
+ ::new(pd) gregorian::partial_date(gd,gm);
+}
+
+/**** nth_kday_of_month ****/
+
+//! Function to save nth_day_of_the_week_in_month objects using serialization lib
+/*! nth_day_of_the_week_in_month objects are broken down into 3 parts for
+ * serialization: the week number, the day of the week, and the month
+ */
+template<class Archive>
+void save(Archive & ar, const gregorian::nth_kday_of_month& nkd,
+ unsigned int /*version*/)
+{
+ typename gregorian::nth_kday_of_month::week_num wn(nkd.nth_week());
+ typename gregorian::nth_kday_of_month::day_of_week_type d(nkd.day_of_week().as_number());
+ typename gregorian::nth_kday_of_month::month_type m(nkd.month().as_number());
+ ar & make_nvp("nth_kday_of_month_week_num", wn);
+ ar & make_nvp("nth_kday_of_month_day_of_week", d);
+ ar & make_nvp("nth_kday_of_month_month", m);
+}
+//! Function to load nth_day_of_the_week_in_month objects using serialization lib
+/*! nth_day_of_the_week_in_month objects are broken down into 3 parts for
+ * serialization: the week number, the day of the week, and the month
+ */
+template<class Archive>
+void load(Archive & ar, gregorian::nth_kday_of_month& nkd, unsigned int /*version*/)
+{
+ typename gregorian::nth_kday_of_month::week_num wn(gregorian::nth_kday_of_month::first);
+ typename gregorian::nth_kday_of_month::day_of_week_type d(gregorian::Monday);
+ typename gregorian::nth_kday_of_month::month_type m(gregorian::Jan);
+ ar & make_nvp("nth_kday_of_month_week_num", wn);
+ ar & make_nvp("nth_kday_of_month_day_of_week", d);
+ ar & make_nvp("nth_kday_of_month_month", m);
+
+ nkd = gregorian::nth_kday_of_month(wn,d,m);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar,
+ gregorian::nth_kday_of_month* nkd,
+ const unsigned int /*file_version*/)
+{
+ // values used are not significant
+ ::new(nkd) gregorian::nth_kday_of_month(gregorian::nth_kday_of_month::first,
+ gregorian::Monday,gregorian::Jan);
+}
+
+/**** first_kday_of_month ****/
+
+//! Function to save first_day_of_the_week_in_month objects using serialization lib
+/*! first_day_of_the_week_in_month objects are broken down into 2 parts for
+ * serialization: the day of the week, and the month
+ */
+template<class Archive>
+void save(Archive & ar, const gregorian::first_kday_of_month& fkd,
+ unsigned int /*version*/)
+{
+ typename gregorian::first_kday_of_month::day_of_week_type d(fkd.day_of_week().as_number());
+ typename gregorian::first_kday_of_month::month_type m(fkd.month().as_number());
+ ar & make_nvp("first_kday_of_month_day_of_week", d);
+ ar & make_nvp("first_kday_of_month_month", m);
+}
+//! Function to load first_day_of_the_week_in_month objects using serialization lib
+/*! first_day_of_the_week_in_month objects are broken down into 2 parts for
+ * serialization: the day of the week, and the month
+ */
+template<class Archive>
+void load(Archive & ar, gregorian::first_kday_of_month& fkd, unsigned int /*version*/)
+{
+ typename gregorian::first_kday_of_month::day_of_week_type d(gregorian::Monday);
+ typename gregorian::first_kday_of_month::month_type m(gregorian::Jan);
+ ar & make_nvp("first_kday_of_month_day_of_week", d);
+ ar & make_nvp("first_kday_of_month_month", m);
+
+ fkd = gregorian::first_kday_of_month(d,m);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar,
+ gregorian::first_kday_of_month* fkd,
+ const unsigned int /*file_version*/)
+{
+ // values used are not significant
+ ::new(fkd) gregorian::first_kday_of_month(gregorian::Monday,gregorian::Jan);
+}
+
+/**** last_kday_of_month ****/
+
+//! Function to save last_day_of_the_week_in_month objects using serialization lib
+/*! last_day_of_the_week_in_month objects are broken down into 2 parts for
+ * serialization: the day of the week, and the month
+ */
+template<class Archive>
+void save(Archive & ar, const gregorian::last_kday_of_month& lkd,
+ unsigned int /*version*/)
+{
+ typename gregorian::last_kday_of_month::day_of_week_type d(lkd.day_of_week().as_number());
+ typename gregorian::last_kday_of_month::month_type m(lkd.month().as_number());
+ ar & make_nvp("last_kday_of_month_day_of_week", d);
+ ar & make_nvp("last_kday_of_month_month", m);
+}
+//! Function to load last_day_of_the_week_in_month objects using serialization lib
+/*! last_day_of_the_week_in_month objects are broken down into 2 parts for
+ * serialization: the day of the week, and the month
+ */
+template<class Archive>
+void load(Archive & ar, gregorian::last_kday_of_month& lkd, unsigned int /*version*/)
+{
+ typename gregorian::last_kday_of_month::day_of_week_type d(gregorian::Monday);
+ typename gregorian::last_kday_of_month::month_type m(gregorian::Jan);
+ ar & make_nvp("last_kday_of_month_day_of_week", d);
+ ar & make_nvp("last_kday_of_month_month", m);
+
+ lkd = gregorian::last_kday_of_month(d,m);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar,
+ gregorian::last_kday_of_month* lkd,
+ const unsigned int /*file_version*/)
+{
+ // values used are not significant
+ ::new(lkd) gregorian::last_kday_of_month(gregorian::Monday,gregorian::Jan);
+}
+
+/**** first_kday_before ****/
+
+//! Function to save first_day_of_the_week_before objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::first_kday_before& fkdb,
+ unsigned int /*version*/)
+{
+ typename gregorian::first_kday_before::day_of_week_type d(fkdb.day_of_week().as_number());
+ ar & make_nvp("first_kday_before_day_of_week", d);
+}
+//! Function to load first_day_of_the_week_before objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::first_kday_before& fkdb, unsigned int /*version*/)
+{
+ typename gregorian::first_kday_before::day_of_week_type d(gregorian::Monday);
+ ar & make_nvp("first_kday_before_day_of_week", d);
+
+ fkdb = gregorian::first_kday_before(d);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar,
+ gregorian::first_kday_before* fkdb,
+ const unsigned int /*file_version*/)
+{
+ // values used are not significant
+ ::new(fkdb) gregorian::first_kday_before(gregorian::Monday);
+}
+
+/**** first_kday_after ****/
+
+//! Function to save first_day_of_the_week_after objects using serialization lib
+template<class Archive>
+void save(Archive & ar, const gregorian::first_kday_after& fkda,
+ unsigned int /*version*/)
+{
+ typename gregorian::first_kday_after::day_of_week_type d(fkda.day_of_week().as_number());
+ ar & make_nvp("first_kday_after_day_of_week", d);
+}
+//! Function to load first_day_of_the_week_after objects using serialization lib
+template<class Archive>
+void load(Archive & ar, gregorian::first_kday_after& fkda, unsigned int /*version*/)
+{
+ typename gregorian::first_kday_after::day_of_week_type d(gregorian::Monday);
+ ar & make_nvp("first_kday_after_day_of_week", d);
+
+ fkda = gregorian::first_kday_after(d);
+}
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar,
+ gregorian::first_kday_after* fkda,
+ const unsigned int /*file_version*/)
+{
+ // values used are not significant
+ ::new(fkda) gregorian::first_kday_after(gregorian::Monday);
+}
+
+} // namespace serialization
+} // namespace boost
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_weekday.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_weekday.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,66 @@
+#ifndef GREG_WEEKDAY_HPP___
+#define GREG_WEEKDAY_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/constrained_value.hpp"
+#include "boost/date_time/date_defs.hpp"
+#include "boost/date_time/compiler_config.hpp"
+#include <stdexcept>
+#include <string>
+
+namespace boost {
+namespace gregorian {
+
+ //bring enum values into the namespace
+ using date_time::Sunday;
+ using date_time::Monday;
+ using date_time::Tuesday;
+ using date_time::Wednesday;
+ using date_time::Thursday;
+ using date_time::Friday;
+ using date_time::Saturday;
+
+
+ //! Exception that flags that a weekday number is incorrect
+ struct bad_weekday : public std::out_of_range
+ {
+ bad_weekday() : std::out_of_range(std::string("Weekday os out of range 0..6")) {}
+ };
+ typedef CV::simple_exception_policy<unsigned short, 0, 6, bad_weekday> greg_weekday_policies;
+ typedef CV::constrained_value<greg_weekday_policies> greg_weekday_rep;
+
+
+ //! Represent a day within a week (range 0==Sun to 6==Sat)
+ class BOOST_DATE_TIME_DECL greg_weekday : public greg_weekday_rep {
+ public:
+ typedef boost::date_time::weekdays weekday_enum;
+ greg_weekday(unsigned short day_of_week_num) :
+ greg_weekday_rep(day_of_week_num)
+ {}
+
+ unsigned short as_number() const {return value_;}
+ const char* as_short_string() const;
+ const char* as_long_string() const;
+#ifndef BOOST_NO_STD_WSTRING
+ const wchar_t* as_short_wstring() const;
+ const wchar_t* as_long_wstring() const;
+#endif // BOOST_NO_STD_WSTRING
+ weekday_enum as_enum() const {return static_cast<weekday_enum>(value_);}
+
+
+ };
+
+
+
+} } //namespace gregorian
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_year.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_year.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,53 @@
+#ifndef GREG_YEAR_HPP___
+#define GREG_YEAR_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/constrained_value.hpp"
+#include <stdexcept>
+#include <string>
+
+namespace boost {
+namespace gregorian {
+
+ //! Exception type for gregorian year
+ struct bad_year : public std::out_of_range
+ {
+ bad_year() :
+ std::out_of_range(std::string("Year is out of valid range: 1400..10000"))
+ {}
+ };
+ //! Policy class that declares error handling gregorian year type
+ typedef CV::simple_exception_policy<unsigned short, 1400, 10000, bad_year> greg_year_policies;
+
+ //! Generated representation for gregorian year
+ typedef CV::constrained_value<greg_year_policies> greg_year_rep;
+
+ //! Represent a day of the month (range 1900 - 10000)
+ /*! This small class allows for simple conversion an integer value into
+ a year for the gregorian calendar. This currently only allows a
+ range of 1900 to 10000. Both ends of the range are a bit arbitrary
+ at the moment, but they are the limits of current testing of the
+ library. As such they may be increased in the future.
+ */
+ class greg_year : public greg_year_rep {
+ public:
+ greg_year(unsigned short year) : greg_year_rep(year) {}
+ operator unsigned short() const {return value_;}
+ private:
+
+ };
+
+
+
+} } //namespace gregorian
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_ymd.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/greg_ymd.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,33 @@
+#ifndef DATE_TIME_GREG_YMD_HPP__
+#define DATE_TIME_GREG_YMD_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/year_month_day.hpp"
+#include "boost/date_time/special_defs.hpp"
+#include "boost/date_time/gregorian/greg_day.hpp"
+#include "boost/date_time/gregorian/greg_year.hpp"
+#include "boost/date_time/gregorian/greg_month.hpp"
+
+namespace boost {
+namespace gregorian {
+
+ typedef date_time::year_month_day_base<greg_year,
+ greg_month,
+ greg_day> greg_year_month_day;
+
+
+
+} } //namespace gregorian
+
+
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,38 @@
+#ifndef GREGORIAN_HPP__
+#define GREGORIAN_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+/*! @file gregorian.hpp
+ Single file header that provides overall include for all elements of
+ the gregorian date-time system. This includes the various types
+ defined, but also other functions for formatting and parsing.
+*/
+
+
+#include "boost/date_time/compiler_config.hpp"
+#include "boost/date_time/gregorian/gregorian_types.hpp"
+#include "boost/date_time/gregorian/conversion.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
+
+#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
+#include "boost/date_time/gregorian/greg_facet.hpp"
+#else
+#include "boost/date_time/gregorian/gregorian_io.hpp"
+#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
+
+#include "boost/date_time/gregorian/parsers.hpp"
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian_io.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian_io.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,777 @@
+#ifndef DATE_TIME_GREGORIAN_IO_HPP__
+#define DATE_TIME_GREGORIAN_IO_HPP__
+
+/* Copyright (c) 2004-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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/date_facet.hpp"
+#include "boost/io/ios_state.hpp"
+#include <iostream>
+#include <locale>
+
+namespace boost {
+namespace gregorian {
+
+
+ typedef boost::date_time::period_formatter<wchar_t> wperiod_formatter;
+ typedef boost::date_time::period_formatter<char> period_formatter;
+
+ typedef boost::date_time::date_facet<date,wchar_t> wdate_facet;
+ typedef boost::date_time::date_facet<date,char> date_facet;
+
+ typedef boost::date_time::period_parser<date,char> period_parser;
+ typedef boost::date_time::period_parser<date,wchar_t> wperiod_parser;
+
+ typedef boost::date_time::special_values_formatter<char> special_values_formatter;
+ typedef boost::date_time::special_values_formatter<wchar_t> wspecial_values_formatter;
+
+ typedef boost::date_time::special_values_parser<date,char> special_values_parser;
+ typedef boost::date_time::special_values_parser<date,wchar_t> wspecial_values_parser;
+
+ typedef boost::date_time::date_input_facet<date,char> date_input_facet;
+ typedef boost::date_time::date_input_facet<date,wchar_t> wdate_input_facet;
+
+ template <class CharT, class TraitsT>
+ inline std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date& d) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
+ std::ostreambuf_iterator<CharT> output_itr(os);
+ if (std::has_facet<custom_date_facet>(os.getloc()))
+ std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), d);
+ else {
+ //instantiate a custom facet for dealing with dates since the user
+ //has not put one in the stream so far. This is for efficiency
+ //since we would always need to reconstruct for every date
+ //if the locale did not already exist. Of course this will be overridden
+ //if the user imbues at some later point. With the default settings
+ //for the facet the resulting format will be the same as the
+ //std::time_facet settings.
+ custom_date_facet* f = new custom_date_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(output_itr, os, os.fill(), d);
+ }
+ return os;
+ }
+
+ //! input operator for date
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, date& d)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, d);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, d);
+ }
+ }
+ catch(...) {
+ // mask tells us what exceptions are turned on
+ std::ios_base::iostate exception_mask = is.exceptions();
+ // if the user wants exceptions on failbit, we'll rethrow our
+ // date_time exception & set the failbit
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {} // ignore this one
+ throw; // rethrow original exception
+ }
+ else {
+ // if the user want's to fail quietly, we simply set the failbit
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+ template <class CharT, class TraitsT>
+ inline std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date_duration& dd) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
+ std::ostreambuf_iterator<CharT> output_itr(os);
+ if (std::has_facet<custom_date_facet>(os.getloc()))
+ std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), dd);
+ else {
+ custom_date_facet* f = new custom_date_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(output_itr, os, os.fill(), dd);
+
+ }
+ return os;
+ }
+
+ //! input operator for date_duration
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, date_duration& dd)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, dd);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, dd);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+ template <class CharT, class TraitsT>
+ inline std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date_period& dp) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
+ std::ostreambuf_iterator<CharT> output_itr(os);
+ if (std::has_facet<custom_date_facet>(os.getloc()))
+ std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), dp);
+ else {
+ //instantiate a custom facet for dealing with date periods since the user
+ //has not put one in the stream so far. This is for efficiency
+ //since we would always need to reconstruct for every time period
+ //if the local did not already exist. Of course this will be overridden
+ //if the user imbues at some later point. With the default settings
+ //for the facet the resulting format will be the same as the
+ //std::time_facet settings.
+ custom_date_facet* f = new custom_date_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(output_itr, os, os.fill(), dp);
+
+ }
+ return os;
+ }
+
+ //! input operator for date_period
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, date_period& dp)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, dp);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, dp);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+ /********** small gregorian types **********/
+
+ template <class CharT, class TraitsT>
+ inline std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::greg_month& gm) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
+ std::ostreambuf_iterator<CharT> output_itr(os);
+ if (std::has_facet<custom_date_facet>(os.getloc()))
+ std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), gm);
+ else {
+ custom_date_facet* f = new custom_date_facet();//-> 10/1074199752/32 because year & day not initialized in put(...)
+ //custom_date_facet* f = new custom_date_facet("%B");
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(output_itr, os, os.fill(), gm);
+ }
+ return os;
+ }
+
+ //! input operator for greg_month
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, greg_month& m)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, m);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, m);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+
+ template <class CharT, class TraitsT>
+ inline std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::greg_weekday& gw) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
+ std::ostreambuf_iterator<CharT> output_itr(os);
+ if (std::has_facet<custom_date_facet>(os.getloc()))
+ std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), gw);
+ else {
+ custom_date_facet* f = new custom_date_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(output_itr, os, os.fill(), gw);
+ }
+ return os;
+ }
+
+ //! input operator for greg_weekday
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, greg_weekday& wd)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, wd);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, wd);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+ //NOTE: output operator for greg_day was not necessary
+
+ //! input operator for greg_day
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, greg_day& gd)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, gd);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, gd);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+ //NOTE: output operator for greg_year was not necessary
+
+ //! input operator for greg_year
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, greg_year& gy)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, gy);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, gy);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+ /********** date generator types **********/
+
+ template <class CharT, class TraitsT>
+ inline std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::partial_date& pd) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
+ std::ostreambuf_iterator<CharT> output_itr(os);
+ if (std::has_facet<custom_date_facet>(os.getloc()))
+ std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), pd);
+ else {
+ custom_date_facet* f = new custom_date_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(output_itr, os, os.fill(), pd);
+ }
+ return os;
+ }
+
+ //! input operator for partial_date
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, partial_date& pd)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, pd);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, pd);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+ template <class CharT, class TraitsT>
+ inline std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::nth_day_of_the_week_in_month& nkd) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
+ std::ostreambuf_iterator<CharT> output_itr(os);
+ if (std::has_facet<custom_date_facet>(os.getloc()))
+ std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), nkd);
+ else {
+ custom_date_facet* f = new custom_date_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(output_itr, os, os.fill(), nkd);
+ }
+ return os;
+ }
+
+ //! input operator for nth_day_of_the_week_in_month
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is,
+ nth_day_of_the_week_in_month& nday)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, nday);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, nday);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+
+ template <class CharT, class TraitsT>
+ inline std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_in_month& fkd) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
+ std::ostreambuf_iterator<CharT> output_itr(os);
+ if (std::has_facet<custom_date_facet>(os.getloc()))
+ std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fkd);
+ else {
+ custom_date_facet* f = new custom_date_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(output_itr, os, os.fill(), fkd);
+ }
+ return os;
+ }
+
+ //! input operator for first_day_of_the_week_in_month
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is,
+ first_day_of_the_week_in_month& fkd)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fkd);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, fkd);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+
+ template <class CharT, class TraitsT>
+ inline std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::last_day_of_the_week_in_month& lkd) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
+ std::ostreambuf_iterator<CharT> output_itr(os);
+ if (std::has_facet<custom_date_facet>(os.getloc()))
+ std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), lkd);
+ else {
+ custom_date_facet* f = new custom_date_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(output_itr, os, os.fill(), lkd);
+ }
+ return os;
+ }
+
+ //! input operator for last_day_of_the_week_in_month
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is,
+ last_day_of_the_week_in_month& lkd)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, lkd);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, lkd);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+
+ template <class CharT, class TraitsT>
+ inline std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_after& fda) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
+ std::ostreambuf_iterator<CharT> output_itr(os);
+ if (std::has_facet<custom_date_facet>(os.getloc())) {
+ std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fda);
+ }
+ else {
+ custom_date_facet* f = new custom_date_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(output_itr, os, os.fill(), fda);
+ }
+ return os;
+ }
+
+ //! input operator for first_day_of_the_week_after
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is,
+ first_day_of_the_week_after& fka)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fka);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, fka);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+
+ template <class CharT, class TraitsT>
+ inline std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_before& fdb) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
+ std::ostreambuf_iterator<CharT> output_itr(os);
+ if (std::has_facet<custom_date_facet>(os.getloc())) {
+ std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fdb);
+ }
+ else {
+ custom_date_facet* f = new custom_date_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(output_itr, os, os.fill(), fdb);
+ }
+ return os;
+ }
+
+ //! input operator for first_day_of_the_week_before
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is,
+ first_day_of_the_week_before& fkb)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::date_input_facet<date, CharT> date_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<date_input_facet>(is.getloc())) {
+ std::use_facet<date_input_facet>(is.getloc()).get(sit, str_end, is, fkb);
+ }
+ else {
+ date_input_facet* f = new date_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, fkb);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+
+} } // namespaces
+
+#endif // DATE_TIME_GREGORIAN_IO_HPP__

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian_types.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/gregorian_types.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,109 @@
+#ifndef _GREGORIAN_TYPES_HPP__
+#define _GREGORIAN_TYPES_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+/*! @file gregorian_types.hpp
+ Single file header that defines most of the types for the gregorian
+ date-time system.
+*/
+
+#include "boost/date_time/date.hpp"
+#include "boost/date_time/period.hpp"
+#include "boost/date_time/gregorian/greg_calendar.hpp"
+#include "boost/date_time/gregorian/greg_duration.hpp"
+#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
+#include "boost/date_time/gregorian/greg_duration_types.hpp"
+#endif
+#include "boost/date_time/gregorian/greg_date.hpp"
+#include "boost/date_time/date_generators.hpp"
+#include "boost/date_time/date_clock_device.hpp"
+#include "boost/date_time/date_iterator.hpp"
+#include "boost/date_time/adjust_functors.hpp"
+
+namespace boost {
+
+//! Gregorian date system based on date_time components
+/*! This date system defines a full complement of types including
+ * a date, date_duration, date_period, day_clock, and a
+ * day_iterator.
+ */
+namespace gregorian {
+ //! Date periods for the gregorian system
+ /*!\ingroup date_basics
+ */
+ typedef date_time::period<date, date_duration> date_period;
+
+ //! A unifying date_generator base type
+ /*! A unifying 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
+ */
+ typedef date_time::year_based_generator<date> year_based_generator;
+
+ //! A date generation object type
+ typedef date_time::partial_date<date> partial_date;
+
+ typedef date_time::nth_kday_of_month<date> nth_kday_of_month;
+ typedef nth_kday_of_month nth_day_of_the_week_in_month;
+
+ typedef date_time::first_kday_of_month<date> first_kday_of_month;
+ typedef first_kday_of_month first_day_of_the_week_in_month;
+
+ typedef date_time::last_kday_of_month<date> last_kday_of_month;
+ typedef last_kday_of_month last_day_of_the_week_in_month;
+
+ typedef date_time::first_kday_after<date> first_kday_after;
+ typedef first_kday_after first_day_of_the_week_after;
+
+ typedef date_time::first_kday_before<date> first_kday_before;
+ typedef first_kday_before first_day_of_the_week_before;
+
+ //! A clock to get the current day from the local computer
+ /*!\ingroup date_basics
+ */
+ typedef date_time::day_clock<date> day_clock;
+
+ //! Base date_iterator type for gregorian types.
+ /*!\ingroup date_basics
+ */
+ typedef date_time::date_itr_base<date> date_iterator;
+
+ //! A day level iterator
+ /*!\ingroup date_basics
+ */
+ typedef date_time::date_itr<date_time::day_functor<date>,
+ date> day_iterator;
+ //! A week level iterator
+ /*!\ingroup date_basics
+ */
+ typedef date_time::date_itr<date_time::week_functor<date>,
+ date> week_iterator;
+ //! A month level iterator
+ /*!\ingroup date_basics
+ */
+ typedef date_time::date_itr<date_time::month_functor<date>,
+ date> month_iterator;
+ //! A year level iterator
+ /*!\ingroup date_basics
+ */
+ typedef date_time::date_itr<date_time::year_functor<date>,
+ date> year_iterator;
+
+ // bring in these date_generator functions from date_time namespace
+ using date_time::days_until_weekday;
+ using date_time::days_before_weekday;
+ using date_time::next_weekday;
+ using date_time::previous_weekday;
+
+} } //namespace gregorian
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian/parsers.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian/parsers.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,91 @@
+#ifndef GREGORIAN_PARSERS_HPP___
+#define GREGORIAN_PARSERS_HPP___
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/gregorian_types.hpp"
+#include "boost/date_time/date_parsing.hpp"
+#include "boost/date_time/compiler_config.hpp"
+#include "boost/date_time/parse_format_base.hpp"
+#include <string>
+#include <sstream>
+
+namespace boost {
+namespace gregorian {
+
+ //! Return special_value from string argument
+ /*! Return special_value from string argument. If argument is
+ * not one of the special value names (defined in src/gregorian/names.hpp),
+ * return 'not_special' */
+ BOOST_DATE_TIME_DECL special_values special_value_from_string(const std::string& s);
+
+ //! Deprecated: Use from_simple_string
+ inline date from_string(std::string s) {
+ return date_time::parse_date<date>(s);
+ }
+
+ //! From delimited date string where with order year-month-day eg: 2002-1-25 or 2003-Jan-25 (full month name is also accepted)
+ inline date from_simple_string(std::string s) {
+ return date_time::parse_date<date>(s, date_time::ymd_order_iso);
+ }
+
+ //! From delimited date string where with order year-month-day eg: 1-25-2003 or Jan-25-2003 (full month name is also accepted)
+ inline date from_us_string(std::string s) {
+ return date_time::parse_date<date>(s, date_time::ymd_order_us);
+ }
+
+ //! From delimited date string where with order day-month-year eg: 25-1-2002 or 25-Jan-2003 (full month name is also accepted)
+ inline date from_uk_string(std::string s) {
+ return date_time::parse_date<date>(s, date_time::ymd_order_dmy);
+ }
+
+ //! From iso type date string where with order year-month-day eg: 20020125
+ inline date from_undelimited_string(std::string s) {
+ return date_time::parse_undelimited_date<date>(s);
+ }
+
+ //! From iso type date string where with order year-month-day eg: 20020125
+ inline date date_from_iso_string(const std::string& s) {
+ return date_time::parse_undelimited_date<date>(s);
+ }
+
+#if !(defined(BOOST_NO_STD_ITERATOR_TRAITS))
+ //! Stream should hold a date in the form of: 2002-1-25. Month number, abbrev, or name are accepted
+ /* Arguments passed in by-value for convertability of char[]
+ * to iterator_type. Calls to from_stream_type are by-reference
+ * since conversion is already done */
+ template<class iterator_type>
+ inline date from_stream(iterator_type beg, iterator_type end) {
+ if(beg == end)
+ {
+ return date(not_a_date_time);
+ }
+ typedef typename std::iterator_traits<iterator_type>::value_type value_type;
+ return date_time::from_stream_type<date>(beg, end, value_type());
+ }
+#endif //BOOST_NO_STD_ITERATOR_TRAITS
+
+#if (defined(_MSC_VER) && (_MSC_VER < 1300))
+ // This function cannot be compiled with MSVC 6.0 due to internal compiler shorcomings
+#else
+ //! Function to parse a date_period from a string (eg: [2003-Oct-31/2003-Dec-25])
+ inline date_period date_period_from_string(const std::string& s){
+ return date_time::from_simple_string_type<date,char>(s);
+ }
+# if !defined(BOOST_NO_STD_WSTRING)
+ //! Function to parse a date_period from a wstring (eg: [2003-Oct-31/2003-Dec-25])
+ inline date_period date_period_from_wstring(const std::wstring& s){
+ return date_time::from_simple_string_type<date,wchar_t>(s);
+ }
+# endif // BOOST_NO_STD_WSTRING
+#endif
+
+} } //namespace gregorian
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian_calendar.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian_calendar.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,70 @@
+#ifndef DATE_TIME_GREGORIAN_CALENDAR_HPP__
+#define DATE_TIME_GREGORIAN_CALENDAR_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+namespace boost {
+namespace date_time {
+
+
+ //! 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.
+ @param ymd_type_ Struct type representing the year, month, day. The ymd_type must
+ define a of types for the year, month, and day. These types need to be
+ arithmetic types.
+ @param date_int_type_ Underlying type for the date count. Must be an arithmetic type.
+ */
+ template<typename ymd_type_, typename date_int_type_>
+ class gregorian_calendar_base {
+ public:
+ //! define a type a date split into components
+ typedef ymd_type_ ymd_type;
+ //! define a type for representing months
+ typedef typename ymd_type::month_type month_type;
+ //! define a type for representing days
+ typedef typename ymd_type::day_type day_type;
+ //! Type to hold a stand alone year value (eg: 2002)
+ typedef typename ymd_type::year_type year_type;
+ //! Define the integer type to use for internal calculations
+ typedef date_int_type_ date_int_type;
+
+
+ static unsigned short day_of_week(const ymd_type& ymd);
+ static int week_number(const ymd_type&ymd);
+ //static unsigned short day_of_year(date_int_type);
+ static date_int_type day_number(const ymd_type& ymd);
+ static date_int_type julian_day_number(const ymd_type& ymd);
+ static long modjulian_day_number(const ymd_type& ymd);
+ static ymd_type from_day_number(date_int_type);
+ static ymd_type from_julian_day_number(date_int_type);
+ static ymd_type from_modjulian_day_number(long);
+ static bool is_leap_year(year_type);
+ static unsigned short end_of_month_day(year_type y, month_type m);
+ static ymd_type epoch();
+ static unsigned short days_in_week();
+
+ };
+
+
+
+} } //namespace
+
+#ifndef NO_BOOST_DATE_TIME_INLINE
+#include "boost/date_time/gregorian_calendar.ipp"
+#endif
+
+
+
+#endif
+
+

Added: sandbox/SOC/2008/calendar/boost/date_time/gregorian_calendar.ipp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/gregorian_calendar.ipp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,219 @@
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#ifndef NO_BOOST_DATE_TIME_INLINE
+ #undef BOOST_DATE_TIME_INLINE
+ #define BOOST_DATE_TIME_INLINE inline
+#endif
+
+namespace boost {
+namespace date_time {
+ //! Return the day of the week (0==Sunday, 1==Monday, etc)
+ /*! Converts a the year-month-day into a day of the week number
+ */
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ unsigned short
+ gregorian_calendar_base<ymd_type_,date_int_type_>::day_of_week(const ymd_type& ymd) {
+ unsigned short a = static_cast<unsigned short>((14-ymd.month)/12);
+ unsigned short y = static_cast<unsigned short>(ymd.year - a);
+ unsigned short m = static_cast<unsigned short>(ymd.month + 12*a - 2);
+ unsigned short d = static_cast<unsigned short>((ymd.day + y + (y/4) - (y/100) + (y/400) + (31*m)/12) % 7);
+ //std::cout << year << "-" << month << "-" << day << " is day: " << d << "\n";
+ return d;
+ }
+
+ //!Return the iso week number for the date
+ /*!Implements the rules associated with the iso 8601 week number.
+ Basically the rule is that Week 1 of the year is the week that contains
+ January 4th or the week that contains the first Thursday in January.
+ Reference for this algorithm is the Calendar FAQ by Claus Tondering, April 2000.
+ */
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ int
+ gregorian_calendar_base<ymd_type_,date_int_type_>::week_number(const ymd_type& ymd) {
+ unsigned long julianbegin = julian_day_number(ymd_type(ymd.year,1,1));
+ unsigned long juliantoday = julian_day_number(ymd);
+ unsigned long day = (julianbegin + 3) % 7;
+ unsigned long week = (juliantoday + day - julianbegin + 4)/7;
+
+ if ((week >= 1) && (week <= 52)) {
+ return week;
+ }
+
+ if ((week == 53)) {
+ if((day==6) ||(day == 5 && is_leap_year(ymd.year))) {
+ return week; //under these circumstances week == 53.
+ } else {
+ return 1; //monday - wednesday is in week 1 of next year
+ }
+ }
+ //if the week is not in current year recalculate using the previous year as the beginning year
+ else if (week == 0) {
+ julianbegin = julian_day_number(ymd_type(static_cast<unsigned short>(ymd.year-1),1,1));
+ juliantoday = julian_day_number(ymd);
+ day = (julianbegin + 3) % 7;
+ week = (juliantoday + day - julianbegin + 4)/7;
+ return week;
+ }
+
+ return week; //not reachable -- well except if day == 5 and is_leap_year != true
+
+ }
+
+ //! Convert a ymd_type into a day number
+ /*! The day number is an absolute number of days since the start of count
+ */
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ date_int_type_
+ gregorian_calendar_base<ymd_type_,date_int_type_>::day_number(const ymd_type& ymd)
+ {
+ unsigned short a = static_cast<unsigned short>((14-ymd.month)/12);
+ unsigned short y = static_cast<unsigned short>(ymd.year + 4800 - a);
+ unsigned short m = static_cast<unsigned short>(ymd.month + 12*a - 3);
+ unsigned long d = ymd.day + ((153*m + 2)/5) + 365*y + (y/4) - (y/100) + (y/400) - 32045;
+ return d;
+ }
+
+ //! Convert a year-month-day into the julian day number
+ /*! Since this implementation uses julian day internally, this is the same as the day_number.
+ */
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ date_int_type_
+ gregorian_calendar_base<ymd_type_,date_int_type_>::julian_day_number(const ymd_type& ymd)
+ {
+ return day_number(ymd);
+ }
+
+ //! Convert year-month-day into a modified julian day number
+ /*! The day number is an absolute number of days.
+ * MJD 0 thus started on 17 Nov 1858(Gregorian) at 00:00:00 UTC
+ */
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ long
+ gregorian_calendar_base<ymd_type_,date_int_type_>::modjulian_day_number(const ymd_type& ymd)
+ {
+ return julian_day_number(ymd)-2400001; //prerounded
+ }
+
+ //! Change a day number into a year-month-day
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ ymd_type_
+ gregorian_calendar_base<ymd_type_,date_int_type_>::from_day_number(date_int_type dayNumber)
+ {
+ date_int_type a = dayNumber + 32044;
+ date_int_type b = (4*a + 3)/146097;
+ date_int_type c = a-((146097*b)/4);
+ date_int_type d = (4*c + 3)/1461;
+ date_int_type e = c - (1461*d)/4;
+ date_int_type m = (5*e + 2)/153;
+ unsigned short day = static_cast<unsigned short>(e - ((153*m + 2)/5) + 1);
+ unsigned short month = static_cast<unsigned short>(m + 3 - 12 * (m/10));
+ year_type year = static_cast<unsigned short>(100*b + d - 4800 + (m/10));
+ //std::cout << year << "-" << month << "-" << day << "\n";
+
+ return ymd_type(static_cast<unsigned short>(year),month,day);
+ }
+
+ //! Change a day number into a year-month-day
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ ymd_type_
+ gregorian_calendar_base<ymd_type_,date_int_type_>::from_julian_day_number(date_int_type dayNumber)
+ {
+ date_int_type a = dayNumber + 32044;
+ date_int_type b = (4*a+3)/146097;
+ date_int_type c = a - ((146097*b)/4);
+ date_int_type d = (4*c + 3)/1461;
+ date_int_type e = c - ((1461*d)/4);
+ date_int_type m = (5*e + 2)/153;
+ unsigned short day = static_cast<unsigned short>(e - ((153*m + 2)/5) + 1);
+ unsigned short month = static_cast<unsigned short>(m + 3 - 12 * (m/10));
+ year_type year = static_cast<year_type>(100*b + d - 4800 + (m/10));
+ //std::cout << year << "-" << month << "-" << day << "\n";
+
+ return ymd_type(year,month,day);
+ }
+
+ //! Change a modified julian day number into a year-month-day
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ ymd_type_
+ gregorian_calendar_base<ymd_type_,date_int_type_>::from_modjulian_day_number(long dayNumber) {
+ date_int_type jd = dayNumber + 2400001; //is 2400000.5 prerounded
+ return from_julian_day_number(jd);
+ }
+
+ //! Determine if the provided year is a leap year
+ /*!
+ *@return true if year is a leap year, false otherwise
+ */
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ bool
+ gregorian_calendar_base<ymd_type_,date_int_type_>::is_leap_year(year_type year)
+ {
+ //divisible by 4, not if divisible by 100, but true if divisible by 400
+ return (!(year % 4)) && ((year % 100) || (!(year % 400)));
+ }
+
+ //! Calculate the last day of the month
+ /*! Find the day which is the end of the month given year and month
+ * No error checking is performed.
+ */
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ unsigned short
+ gregorian_calendar_base<ymd_type_,date_int_type_>::end_of_month_day(year_type year,
+ month_type month)
+ {
+ switch (month) {
+ case 2:
+ if (is_leap_year(year)) {
+ return 29;
+ } else {
+ return 28;
+ };
+ case 4:
+ case 6:
+ case 9:
+ case 11:
+ return 30;
+ default:
+ return 31;
+ };
+
+ }
+
+ //! Provide the ymd_type specification for the calandar start
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ ymd_type_
+ gregorian_calendar_base<ymd_type_,date_int_type_>::epoch()
+ {
+ return ymd_type(1400,1,1);
+ }
+
+ //! Defines length of a week for week calculations
+ template<typename ymd_type_, typename date_int_type_>
+ BOOST_DATE_TIME_INLINE
+ unsigned short
+ gregorian_calendar_base<ymd_type_,date_int_type_>::days_in_week()
+ {
+ return 7;
+ }
+
+
+} } //namespace gregorian
+
+

Added: sandbox/SOC/2008/calendar/boost/date_time/int_adapter.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/int_adapter.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,507 @@
+#ifndef _DATE_TIME_INT_ADAPTER_HPP__
+#define _DATE_TIME_INT_ADAPTER_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/config.hpp"
+#include "boost/limits.hpp" //work around compilers without limits
+#include "boost/date_time/special_defs.hpp"
+#include "boost/date_time/locale_config.hpp"
+#include <iostream>
+
+namespace boost {
+namespace date_time {
+
+
+//! 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:
+ *@code
+ * +infinity - infinity == Not A Number (NAN)
+ * infinity * non-zero == infinity
+ * infinity * zero == NAN
+ * +infinity * -integer == -infinity
+ * infinity / infinity == NAN
+ * infinity * infinity == infinity
+ *@endcode
+ */
+template<typename int_type_>
+class int_adapter {
+public:
+ typedef int_type_ int_type;
+ int_adapter(int_type v) :
+ value_(v)
+ {}
+ static bool has_infinity()
+ {
+ return true;
+ }
+ static const int_adapter pos_infinity()
+ {
+ return (::std::numeric_limits<int_type>::max)();
+ }
+ static const int_adapter neg_infinity()
+ {
+ return (::std::numeric_limits<int_type>::min)();
+ }
+ static const int_adapter not_a_number()
+ {
+ return (::std::numeric_limits<int_type>::max)()-1;
+ }
+ static int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION ()
+ {
+ return (::std::numeric_limits<int_type>::max)()-2;
+ }
+ static int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION ()
+ {
+ return (::std::numeric_limits<int_type>::min)()+1;
+ }
+ static int_adapter from_special(special_values sv)
+ {
+ switch (sv) {
+ case not_a_date_time: return not_a_number();
+ case neg_infin: return neg_infinity();
+ case pos_infin: return pos_infinity();
+ case max_date_time: return (max)();
+ case min_date_time: return (min)();
+ default: return not_a_number();
+ }
+ }
+ static bool is_inf(int_type v)
+ {
+ return (v == neg_infinity().as_number() ||
+ v == pos_infinity().as_number());
+ }
+ static bool is_neg_inf(int_type v)
+ {
+ return (v == neg_infinity().as_number());
+ }
+ static bool is_pos_inf(int_type v)
+ {
+ return (v == pos_infinity().as_number());
+ }
+ static bool is_not_a_number(int_type v)
+ {
+ return (v == not_a_number().as_number());
+ }
+ //! Returns either special value type or is_not_special
+ static special_values to_special(int_type v)
+ {
+ if (is_not_a_number(v)) return not_a_date_time;
+ if (is_neg_inf(v)) return neg_infin;
+ if (is_pos_inf(v)) return pos_infin;
+ return not_special;
+ }
+
+ //-3 leaves room for representations of infinity and not a date
+ static int_type maxcount()
+ {
+ return (::std::numeric_limits<int_type>::max)()-3;
+ }
+ bool is_infinity() const
+ {
+ return (value_ == neg_infinity().as_number() ||
+ value_ == pos_infinity().as_number());
+ }
+ bool is_pos_infinity()const
+ {
+ return(value_ == pos_infinity().as_number());
+ }
+ bool is_neg_infinity()const
+ {
+ return(value_ == neg_infinity().as_number());
+ }
+ bool is_nan() const
+ {
+ return (value_ == not_a_number().as_number());
+ }
+ bool is_special() const
+ {
+ return(is_infinity() || is_nan());
+ }
+ bool operator==(const int_adapter& rhs) const
+ {
+ return (compare(rhs) == 0);
+ }
+ bool operator==(const int& rhs) const
+ {
+ // quiets compiler warnings
+ bool is_signed = std::numeric_limits<int_type>::is_signed;
+ if(!is_signed)
+ {
+ if(is_neg_inf(value_) && rhs == 0)
+ {
+ return false;
+ }
+ }
+ return (compare(rhs) == 0);
+ }
+ bool operator!=(const int_adapter& rhs) const
+ {
+ return (compare(rhs) != 0);
+ }
+ bool operator!=(const int& rhs) const
+ {
+ // quiets compiler warnings
+ bool is_signed = std::numeric_limits<int_type>::is_signed;
+ if(!is_signed)
+ {
+ if(is_neg_inf(value_) && rhs == 0)
+ {
+ return true;
+ }
+ }
+ return (compare(rhs) != 0);
+ }
+ bool operator<(const int_adapter& rhs) const
+ {
+ return (compare(rhs) == -1);
+ }
+ bool operator<(const int& rhs) const
+ {
+ // quiets compiler warnings
+ bool is_signed = std::numeric_limits<int_type>::is_signed;
+ if(!is_signed)
+ {
+ if(is_neg_inf(value_) && rhs == 0)
+ {
+ return true;
+ }
+ }
+ return (compare(rhs) == -1);
+ }
+ bool operator>(const int_adapter& rhs) const
+ {
+ return (compare(rhs) == 1);
+ }
+ int_type as_number() const
+ {
+ return value_;
+ }
+ //! Returns either special value type or is_not_special
+ special_values as_special() const
+ {
+ return int_adapter::to_special(value_);
+ }
+ //creates nasty ambiguities
+// operator int_type() const
+// {
+// return value_;
+// }
+
+ /*! Operator allows for adding dissimilar int_adapter types.
+ * The return type will match that of the the calling object's type */
+ template<class rhs_type>
+ inline
+ int_adapter operator+(const int_adapter<rhs_type>& rhs) const
+ {
+ if(is_special() || rhs.is_special())
+ {
+ if (is_nan() || rhs.is_nan())
+ {
+ return int_adapter::not_a_number();
+ }
+ if((is_pos_inf(value_) && rhs.is_neg_inf(rhs.as_number())) ||
+ (is_neg_inf(value_) && rhs.is_pos_inf(rhs.as_number())) )
+ {
+ return int_adapter::not_a_number();
+ }
+ if (is_infinity())
+ {
+ return *this;
+ }
+ if (rhs.is_pos_inf(rhs.as_number()))
+ {
+ return int_adapter::pos_infinity();
+ }
+ if (rhs.is_neg_inf(rhs.as_number()))
+ {
+ return int_adapter::neg_infinity();
+ }
+ }
+ return int_adapter<int_type>(value_ + rhs.as_number());
+ }
+
+ int_adapter operator+(const int_type rhs) const
+ {
+ if(is_special())
+ {
+ if (is_nan())
+ {
+ return int_adapter<int_type>(not_a_number());
+ }
+ if (is_infinity())
+ {
+ return *this;
+ }
+ }
+ return int_adapter<int_type>(value_ + rhs);
+ }
+
+ /*! Operator allows for subtracting dissimilar int_adapter types.
+ * The return type will match that of the the calling object's type */
+ template<class rhs_type>
+ inline
+ int_adapter operator-(const int_adapter<rhs_type>& rhs)const
+ {
+ if(is_special() || rhs.is_special())
+ {
+ if (is_nan() || rhs.is_nan())
+ {
+ return int_adapter::not_a_number();
+ }
+ if((is_pos_inf(value_) && rhs.is_pos_inf(rhs.as_number())) ||
+ (is_neg_inf(value_) && rhs.is_neg_inf(rhs.as_number())) )
+ {
+ return int_adapter::not_a_number();
+ }
+ if (is_infinity())
+ {
+ return *this;
+ }
+ if (rhs.is_pos_inf(rhs.as_number()))
+ {
+ return int_adapter::neg_infinity();
+ }
+ if (rhs.is_neg_inf(rhs.as_number()))
+ {
+ return int_adapter::pos_infinity();
+ }
+ }
+ return int_adapter<int_type>(value_ - rhs.as_number());
+ }
+ int_adapter operator-(const int_type rhs) const
+ {
+ if(is_special())
+ {
+ if (is_nan())
+ {
+ return int_adapter<int_type>(not_a_number());
+ }
+ if (is_infinity())
+ {
+ return *this;
+ }
+ }
+ return int_adapter<int_type>(value_ - rhs);
+ }
+
+ // should templatize this to be consistant with op +-
+ int_adapter operator*(const int_adapter& rhs)const
+ {
+ if(this->is_special() || rhs.is_special())
+ {
+ return mult_div_specials(rhs);
+ }
+ return int_adapter<int_type>(value_ * rhs.value_);
+ }
+ /*! Provided for cases when automatic conversion from
+ * 'int' to 'int_adapter' causes incorrect results. */
+ int_adapter operator*(const int rhs) const
+ {
+ if(is_special())
+ {
+ return mult_div_specials(rhs);
+ }
+ return int_adapter<int_type>(value_ * rhs);
+ }
+
+ // should templatize this to be consistant with op +-
+ int_adapter operator/(const int_adapter& rhs)const
+ {
+ if(this->is_special() || rhs.is_special())
+ {
+ if(is_infinity() && rhs.is_infinity())
+ {
+ return int_adapter<int_type>(not_a_number());
+ }
+ if(rhs != 0)
+ {
+ return mult_div_specials(rhs);
+ }
+ else { // let divide by zero blow itself up
+ return int_adapter<int_type>(value_ / rhs.value_);
+ }
+ }
+ return int_adapter<int_type>(value_ / rhs.value_);
+ }
+ /*! Provided for cases when automatic conversion from
+ * 'int' to 'int_adapter' causes incorrect results. */
+ int_adapter operator/(const int rhs) const
+ {
+ if(is_special() && rhs != 0)
+ {
+ return mult_div_specials(rhs);
+ }
+ return int_adapter<int_type>(value_ / rhs);
+ }
+
+ // should templatize this to be consistant with op +-
+ int_adapter operator%(const int_adapter& rhs)const
+ {
+ if(this->is_special() || rhs.is_special())
+ {
+ if(is_infinity() && rhs.is_infinity())
+ {
+ return int_adapter<int_type>(not_a_number());
+ }
+ if(rhs != 0)
+ {
+ return mult_div_specials(rhs);
+ }
+ else { // let divide by zero blow itself up
+ return int_adapter<int_type>(value_ % rhs.value_);
+ }
+ }
+ return int_adapter<int_type>(value_ % rhs.value_);
+ }
+ /*! Provided for cases when automatic conversion from
+ * 'int' to 'int_adapter' causes incorrect results. */
+ int_adapter operator%(const int rhs) const
+ {
+ if(is_special() && rhs != 0)
+ {
+ return mult_div_specials(rhs);
+ }
+ return int_adapter<int_type>(value_ % rhs);
+ }
+private:
+ int_type value_;
+
+ //! returns -1, 0, 1, or 2 if 'this' is <, ==, >, or 'nan comparison' rhs
+ int compare(const int_adapter& rhs)const
+ {
+ if(this->is_special() || rhs.is_special())
+ {
+ if(this->is_nan() || rhs.is_nan()) {
+ if(this->is_nan() && rhs.is_nan()) {
+ return 0; // equal
+ }
+ else {
+ return 2; // nan
+ }
+ }
+ if((is_neg_inf(value_) && !is_neg_inf(rhs.value_)) ||
+ (is_pos_inf(rhs.value_) && !is_pos_inf(value_)) )
+ {
+ return -1; // less than
+ }
+ if((is_pos_inf(value_) && !is_pos_inf(rhs.value_)) ||
+ (is_neg_inf(rhs.value_) && !is_neg_inf(value_)) ) {
+ return 1; // greater than
+ }
+ }
+ if(value_ < rhs.value_) return -1;
+ if(value_ > rhs.value_) return 1;
+ // implied-> if(value_ == rhs.value_)
+ return 0;
+ }
+ /* When multiplying and dividing with at least 1 special value
+ * very simmilar rules apply. In those cases where the rules
+ * are different, they are handled in the respective operator
+ * function. */
+ //! Assumes at least 'this' or 'rhs' is a special value
+ int_adapter mult_div_specials(const int_adapter& rhs)const
+ {
+ int min_value;
+ // quiets compiler warnings
+ bool is_signed = std::numeric_limits<int_type>::is_signed;
+ if(is_signed) {
+ min_value = 0;
+ }
+ else {
+ min_value = 1;// there is no zero with unsigned
+ }
+ if(this->is_nan() || rhs.is_nan()) {
+ return int_adapter<int_type>(not_a_number());
+ }
+ if((*this > 0 && rhs > 0) || (*this < min_value && rhs < min_value)) {
+ return int_adapter<int_type>(pos_infinity());
+ }
+ if((*this > 0 && rhs < min_value) || (*this < min_value && rhs > 0)) {
+ return int_adapter<int_type>(neg_infinity());
+ }
+ //implied -> if(this->value_ == 0 || rhs.value_ == 0)
+ return int_adapter<int_type>(not_a_number());
+ }
+ /* Overloaded function necessary because of special
+ * situation where int_adapter is instantiated with
+ * 'unsigned' and func is called with negative int.
+ * It would produce incorrect results since 'unsigned'
+ * wraps around when initialized with a negative value */
+ //! Assumes 'this' is a special value
+ int_adapter mult_div_specials(const int& rhs) const
+ {
+ int min_value;
+ // quiets compiler warnings
+ bool is_signed = std::numeric_limits<int_type>::is_signed;
+ if(is_signed) {
+ min_value = 0;
+ }
+ else {
+ min_value = 1;// there is no zero with unsigned
+ }
+ if(this->is_nan()) {
+ return int_adapter<int_type>(not_a_number());
+ }
+ if((*this > 0 && rhs > 0) || (*this < min_value && rhs < 0)) {
+ return int_adapter<int_type>(pos_infinity());
+ }
+ if((*this > 0 && rhs < 0) || (*this < min_value && rhs > 0)) {
+ return int_adapter<int_type>(neg_infinity());
+ }
+ //implied -> if(this->value_ == 0 || rhs.value_ == 0)
+ return int_adapter<int_type>(not_a_number());
+ }
+
+};
+
+#ifndef BOOST_DATE_TIME_NO_LOCALE
+ /*! Expected output is either a numeric representation
+ * or a special values representation.<BR>
+ * Ex. "12", "+infinity", "not-a-number", etc. */
+ //template<class charT = char, class traits = std::traits<charT>, typename int_type>
+ template<class charT, class traits, typename int_type>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os, const int_adapter<int_type>& ia)
+ {
+ if(ia.is_special()) {
+ // switch copied from date_names_put.hpp
+ switch(ia.as_special())
+ {
+ case not_a_date_time:
+ os << "not-a-number";
+ break;
+ case pos_infin:
+ os << "+infinity";
+ break;
+ case neg_infin:
+ os << "-infinity";
+ break;
+ default:
+ os << "";
+ }
+ }
+ else {
+ os << ia.as_number();
+ }
+ return os;
+ }
+#endif
+
+
+} } //namespace date_time
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/iso_format.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/iso_format.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,303 @@
+#ifndef ISO_FORMAT_HPP___
+#define ISO_FORMAT_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/parse_format_base.hpp"
+
+namespace boost {
+namespace date_time {
+
+//! Class to provide common iso formatting spec
+template<class charT>
+class iso_format_base {
+public:
+ //! Describe month format -- its an integer in iso format
+ static month_format_spec month_format()
+ {
+ return month_as_integer;
+ }
+
+ //! String used printed is date is invalid
+ static const charT* not_a_date()
+ {
+ return "not-a-date-time";
+ }
+ //! String used to for positive infinity value
+ static const charT* pos_infinity()
+ {
+ return "+infinity";
+ }
+ //! String used to for positive infinity value
+ static const charT* neg_infinity()
+ {
+ return "-infinity";
+ }
+
+ //! ISO char for a year -- used in durations
+ static charT year_sep_char()
+ {
+ return 'Y';
+ }
+ //! ISO char for a month
+ static charT month_sep_char()
+ {
+ return '-';
+ }
+ //! ISO char for a day
+ static charT day_sep_char()
+ {
+ return '-';
+ }
+ //! char for minute
+ static charT hour_sep_char()
+ {
+ return ':';
+ }
+ //! char for minute
+ static charT minute_sep_char()
+ {
+ return ':';
+ }
+ //! char for second
+ static charT second_sep_char()
+ {
+ return ':';
+ }
+ //! ISO char for a period
+ static charT period_start_char()
+ {
+ return 'P';
+ }
+ //! Used in time in mixed strings to set start of time
+ static charT time_start_char()
+ {
+ return 'T';
+ }
+
+ //! Used in mixed strings to identify start of a week number
+ static charT week_start_char()
+ {
+ return 'W';
+ }
+
+ //! Separators for periods
+ static charT period_sep_char()
+ {
+ return '/';
+ }
+ //! Separator for hh:mm:ss
+ static charT time_sep_char()
+ {
+ return ':';
+ }
+ //! Preferred Separator for hh:mm:ss,decimal_fraction
+ static charT fractional_time_sep_char()
+ {
+ return ',';
+ }
+
+ static bool is_component_sep(charT sep)
+ {
+ switch(sep) {
+ case 'H':
+ case 'M':
+ case 'S':
+ case 'W':
+ case 'T':
+ case 'Y':
+ case 'D':return true;
+ default:
+ return false;
+ }
+ }
+
+ static bool is_fractional_time_sep(charT sep)
+ {
+ switch(sep) {
+ case ',':
+ case '.': return true;
+ default: return false;
+ }
+ }
+ static bool is_timezone_sep(charT sep)
+ {
+ switch(sep) {
+ case '+':
+ case '-': return true;
+ default: return false;
+ }
+ }
+ static charT element_sep_char()
+ {
+ return '-';
+ }
+
+};
+
+#ifndef BOOST_NO_STD_WSTRING
+
+//! Class to provide common iso formatting spec
+template<>
+class iso_format_base<wchar_t> {
+public:
+ //! Describe month format -- its an integer in iso format
+ static month_format_spec month_format()
+ {
+ return month_as_integer;
+ }
+
+ //! String used printed is date is invalid
+ static const wchar_t* not_a_date()
+ {
+ return L"not-a-date-time";
+ }
+ //! String used to for positive infinity value
+ static const wchar_t* pos_infinity()
+ {
+ return L"+infinity";
+ }
+ //! String used to for positive infinity value
+ static const wchar_t* neg_infinity()
+ {
+ return L"-infinity";
+ }
+
+ //! ISO char for a year -- used in durations
+ static wchar_t year_sep_char()
+ {
+ return 'Y';
+ }
+ //! ISO char for a month
+ static wchar_t month_sep_char()
+ {
+ return '-';
+ }
+ //! ISO char for a day
+ static wchar_t day_sep_char()
+ {
+ return '-';
+ }
+ //! char for minute
+ static wchar_t hour_sep_char()
+ {
+ return ':';
+ }
+ //! char for minute
+ static wchar_t minute_sep_char()
+ {
+ return ':';
+ }
+ //! char for second
+ static wchar_t second_sep_char()
+ {
+ return ':';
+ }
+ //! ISO char for a period
+ static wchar_t period_start_char()
+ {
+ return 'P';
+ }
+ //! Used in time in mixed strings to set start of time
+ static wchar_t time_start_char()
+ {
+ return 'T';
+ }
+
+ //! Used in mixed strings to identify start of a week number
+ static wchar_t week_start_char()
+ {
+ return 'W';
+ }
+
+ //! Separators for periods
+ static wchar_t period_sep_char()
+ {
+ return '/';
+ }
+ //! Separator for hh:mm:ss
+ static wchar_t time_sep_char()
+ {
+ return ':';
+ }
+ //! Preferred Separator for hh:mm:ss,decimal_fraction
+ static wchar_t fractional_time_sep_char()
+ {
+ return ',';
+ }
+
+ static bool is_component_sep(wchar_t sep)
+ {
+ switch(sep) {
+ case 'H':
+ case 'M':
+ case 'S':
+ case 'W':
+ case 'T':
+ case 'Y':
+ case 'D':return true;
+ default:
+ return false;
+ }
+ }
+
+ static bool is_fractional_time_sep(wchar_t sep)
+ {
+ switch(sep) {
+ case ',':
+ case '.': return true;
+ default: return false;
+ }
+ }
+ static bool is_timezone_sep(wchar_t sep)
+ {
+ switch(sep) {
+ case '+':
+ case '-': return true;
+ default: return false;
+ }
+ }
+ static wchar_t element_sep_char()
+ {
+ return '-';
+ }
+
+};
+
+#endif // BOOST_NO_STD_WSTRING
+
+//! Format description for iso normal YYYYMMDD
+template<class charT>
+class iso_format : public iso_format_base<charT> {
+public:
+ //! The ios standard format doesn't use char separators
+ static bool has_date_sep_chars()
+ {
+ return false;
+ }
+};
+
+//! Extended format uses seperators YYYY-MM-DD
+template<class charT>
+class iso_extended_format : public iso_format_base<charT> {
+public:
+ //! Extended format needs char separators
+ static bool has_date_sep_chars()
+ {
+ return true;
+ }
+
+};
+
+} } //namespace date_time
+
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/local_time/conversion.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/conversion.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,35 @@
+#ifndef DATE_TIME_LOCAL_TIME_CONVERSION_HPP__
+#define DATE_TIME_LOCAL_TIME_CONVERSION_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/posix_time/conversion.hpp"
+#include "boost/date_time/c_time.hpp"
+#include "boost/date_time/local_time/local_date_time.hpp"
+
+namespace boost {
+namespace local_time {
+
+//! Function that creates a tm struct from a local_date_time
+inline
+tm to_tm(const local_date_time& lt) {
+ tm lt_tm;
+ lt_tm = posix_time::to_tm(lt.local_time());
+ if(lt.is_dst()){
+ lt_tm.tm_isdst = 1;
+ }
+ else{
+ lt_tm.tm_isdst = 0;
+ }
+ return lt_tm;
+}
+
+
+}} // namespaces
+#endif // DATE_TIME_LOCAL_TIME_CONVERSION_HPP__

Added: sandbox/SOC/2008/calendar/boost/date_time/local_time/custom_time_zone.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/custom_time_zone.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,169 @@
+#ifndef LOCAL_TIME_CUSTOM_TIME_ZONE_HPP__
+#define LOCAL_TIME_CUSTOM_TIME_ZONE_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/time_zone_base.hpp"
+#include "boost/date_time/time_zone_names.hpp"
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/local_time/dst_transition_day_rules.hpp"
+#include "boost/date_time/string_convert.hpp"
+//#include "boost/date_time/special_defs.hpp"
+#include "boost/shared_ptr.hpp"
+
+namespace boost {
+namespace local_time {
+
+ //typedef boost::date_time::time_zone_names time_zone_names;
+ typedef boost::date_time::dst_adjustment_offsets<boost::posix_time::time_duration> dst_adjustment_offsets;
+ //typedef boost::date_time::time_zone_base<boost::posix_time::ptime> time_zone;
+ typedef boost::shared_ptr<dst_calc_rule> dst_calc_rule_ptr;
+
+ //! A real time zone
+ template<class CharT>
+ class custom_time_zone_base : public date_time::time_zone_base<posix_time::ptime,CharT> {
+ public:
+ typedef boost::posix_time::time_duration time_duration_type;
+ typedef date_time::time_zone_base<posix_time::ptime,CharT> base_type;
+ typedef typename base_type::string_type string_type;
+ typedef typename base_type::stringstream_type stringstream_type;
+ typedef date_time::time_zone_names_base<CharT> time_zone_names;
+ typedef CharT char_type;
+
+ custom_time_zone_base(const time_zone_names& zone_names,
+ const time_duration_type& utc_offset,
+ const dst_adjustment_offsets& dst_shift,
+ boost::shared_ptr<dst_calc_rule> calc_rule) :
+ zone_names_(zone_names),
+ base_utc_offset_(utc_offset),
+ dst_offsets_(dst_shift),
+ dst_calc_rules_(calc_rule)
+ {};
+ virtual ~custom_time_zone_base() {};
+ virtual string_type dst_zone_abbrev() const
+ {
+ return zone_names_.dst_zone_abbrev();
+ }
+ virtual string_type std_zone_abbrev() const
+ {
+ return zone_names_.std_zone_abbrev();
+ }
+ virtual string_type dst_zone_name() const
+ {
+ return zone_names_.dst_zone_name();
+ }
+ virtual string_type std_zone_name() const
+ {
+ return zone_names_.std_zone_name();
+ }
+ //! True if zone uses daylight savings adjustments
+ virtual bool has_dst() const
+ {
+ return (dst_calc_rules_); //if calc_rule is set the tz has dst
+ }
+ //! Local time that DST starts -- NADT if has_dst is false
+ virtual posix_time::ptime dst_local_start_time(gregorian::greg_year y) const
+ {
+ gregorian::date d(gregorian::not_a_date_time);
+ if (dst_calc_rules_) {
+ d = dst_calc_rules_->start_day(y);
+ }
+ return posix_time::ptime(d, dst_offsets_.dst_start_offset_);
+ }
+ //! Local time that DST ends -- NADT if has_dst is false
+ virtual posix_time::ptime dst_local_end_time(gregorian::greg_year y) const
+ {
+ gregorian::date d(gregorian::not_a_date_time);
+ if (dst_calc_rules_) {
+ d = dst_calc_rules_->end_day(y);
+ }
+ return posix_time::ptime(d, dst_offsets_.dst_end_offset_);
+ }
+ //! Base offset from UTC for zone (eg: -07:30:00)
+ virtual time_duration_type base_utc_offset() const
+ {
+ return base_utc_offset_;
+ }
+ //! Adjustment forward or back made while DST is in effect
+ virtual time_duration_type dst_offset() const
+ {
+ return dst_offsets_.dst_adjust_;
+ }
+ //! Returns a POSIX time_zone string for this object
+ virtual string_type to_posix_string() const
+ {
+ // std offset dst [offset],start[/time],end[/time] - w/o spaces
+ stringstream_type ss;
+ ss.fill('0');
+ boost::shared_ptr<dst_calc_rule> no_rules;
+ // std
+ ss << std_zone_abbrev();
+ // offset
+ if(base_utc_offset().is_negative()) {
+ // inverting the sign guarantees we get two digits
+ ss << '-' << std::setw(2) << base_utc_offset().invert_sign().hours();
+ }
+ else {
+ ss << '+' << std::setw(2) << base_utc_offset().hours();
+ }
+ if(base_utc_offset().minutes() != 0 || base_utc_offset().seconds() != 0) {
+ ss << ':' << std::setw(2) << base_utc_offset().minutes();
+ if(base_utc_offset().seconds() != 0) {
+ ss << ':' << std::setw(2) << base_utc_offset().seconds();
+ }
+ }
+ if(dst_calc_rules_ != no_rules) {
+ // dst
+ ss << dst_zone_abbrev();
+ // dst offset
+ if(dst_offset().is_negative()) {
+ // inverting the sign guarantees we get two digits
+ ss << '-' << std::setw(2) << dst_offset().invert_sign().hours();
+ }
+ else {
+ ss << '+' << std::setw(2) << dst_offset().hours();
+ }
+ if(dst_offset().minutes() != 0 || dst_offset().seconds() != 0) {
+ ss << ':' << std::setw(2) << dst_offset().minutes();
+ if(dst_offset().seconds() != 0) {
+ ss << ':' << std::setw(2) << dst_offset().seconds();
+ }
+ }
+ // start/time
+ ss << ',' << date_time::convert_string_type<char, char_type>(dst_calc_rules_->start_rule_as_string()) << '/'
+ << std::setw(2) << dst_offsets_.dst_start_offset_.hours() << ':'
+ << std::setw(2) << dst_offsets_.dst_start_offset_.minutes();
+ if(dst_offsets_.dst_start_offset_.seconds() != 0) {
+ ss << ':' << std::setw(2) << dst_offsets_.dst_start_offset_.seconds();
+ }
+ // end/time
+ ss << ',' << date_time::convert_string_type<char, char_type>(dst_calc_rules_->end_rule_as_string()) << '/'
+ << std::setw(2) << dst_offsets_.dst_end_offset_.hours() << ':'
+ << std::setw(2) << dst_offsets_.dst_end_offset_.minutes();
+ if(dst_offsets_.dst_end_offset_.seconds() != 0) {
+ ss << ':' << std::setw(2) << dst_offsets_.dst_end_offset_.seconds();
+ }
+ }
+
+ return ss.str();
+ }
+ private:
+ time_zone_names zone_names_;
+ bool has_dst_;
+ time_duration_type base_utc_offset_;
+ dst_adjustment_offsets dst_offsets_;
+ boost::shared_ptr<dst_calc_rule> dst_calc_rules_;
+ };
+
+ typedef custom_time_zone_base<char> custom_time_zone;
+
+} }//namespace
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/local_time/date_duration_operators.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/date_duration_operators.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,115 @@
+#ifndef LOCAL_TIME_DATE_DURATION_OPERATORS_HPP___
+#define LOCAL_TIME_DATE_DURATION_OPERATORS_HPP___
+
+/* Copyright (c) 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/greg_duration_types.hpp"
+#include "boost/date_time/local_time/local_date_time.hpp"
+
+namespace boost {
+namespace local_time {
+
+ /*!@file date_duration_operators.hpp Operators for local_date_time and
+ * optional gregorian types. Operators use snap-to-end-of-month behavior.
+ * Further details on this behavior can be found in reference for
+ * date_time/date_duration_types.hpp and documentation for
+ * month and year iterators.
+ */
+
+
+ /*! Adds a months object and a local_date_time. Result will be same
+ * day-of-month as local_date_time unless original day was the last day of month.
+ * see date_time::months_duration for more details */
+ inline
+ local_date_time
+ operator+(const local_date_time& t, const boost::gregorian::months& m)
+ {
+ return t + m.get_offset(t.utc_time().date());
+ }
+
+ /*! Adds a months object to a local_date_time. Result will be same
+ * day-of-month as local_date_time unless original day was the last day of month.
+ * see date_time::months_duration for more details */
+ inline
+ local_date_time
+ operator+=(local_date_time& t, const boost::gregorian::months& m)
+ {
+ return t += m.get_offset(t.utc_time().date());
+ }
+
+ /*! Subtracts a months object and a local_date_time. Result will be same
+ * day-of-month as local_date_time unless original day was the last day of month.
+ * see date_time::months_duration for more details */
+ inline
+ local_date_time
+ operator-(const local_date_time& t, const boost::gregorian::months& m)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return t + m.get_neg_offset(t.utc_time().date());
+ }
+
+ /*! Subtracts a months object from a local_date_time. Result will be same
+ * day-of-month as local_date_time unless original day was the last day of month.
+ * see date_time::months_duration for more details */
+ inline
+ local_date_time
+ operator-=(local_date_time& t, const boost::gregorian::months& m)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return t += m.get_neg_offset(t.utc_time().date());
+ }
+
+ // local_date_time & years
+
+ /*! Adds a years object and a local_date_time. Result will be same
+ * month and day-of-month as local_date_time unless original day was the
+ * last day of month. see date_time::years_duration for more details */
+ inline
+ local_date_time
+ operator+(const local_date_time& t, const boost::gregorian::years& y)
+ {
+ return t + y.get_offset(t.utc_time().date());
+ }
+
+ /*! Adds a years object to a local_date_time. Result will be same
+ * month and day-of-month as local_date_time unless original day was the
+ * last day of month. see date_time::years_duration for more details */
+ inline
+ local_date_time
+ operator+=(local_date_time& t, const boost::gregorian::years& y)
+ {
+ return t += y.get_offset(t.utc_time().date());
+ }
+
+ /*! Subtracts a years object and a local_date_time. Result will be same
+ * month and day-of-month as local_date_time unless original day was the
+ * last day of month. see date_time::years_duration for more details */
+ inline
+ local_date_time
+ operator-(const local_date_time& t, const boost::gregorian::years& y)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return t + y.get_neg_offset(t.utc_time().date());
+ }
+
+ /*! Subtracts a years object from a local_date_time. Result will be same
+ * month and day-of-month as local_date_time unless original day was the
+ * last day of month. see date_time::years_duration for more details */
+ inline
+ local_date_time
+ operator-=(local_date_time& t, const boost::gregorian::years& y)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return t += y.get_neg_offset(t.utc_time().date());
+ }
+
+
+}} // namespaces
+
+#endif // LOCAL_TIME_DATE_DURATION_OPERATORS_HPP___

Added: sandbox/SOC/2008/calendar/boost/date_time/local_time/dst_transition_day_rules.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/dst_transition_day_rules.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,77 @@
+#ifndef LOCAL_TIME_DST_TRANSITION_DAY_RULES_HPP__
+#define LOCAL_TIME_DST_TRANSITION_DAY_RULES_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/gregorian/gregorian_types.hpp"
+#include "boost/date_time/dst_transition_generators.hpp"
+
+namespace boost {
+namespace local_time {
+
+ //! Provides rule of the form starting Apr 30 ending Oct 21
+ typedef date_time::dst_day_calc_rule<gregorian::date> dst_calc_rule;
+
+ struct partial_date_rule_spec
+ {
+ typedef gregorian::date date_type;
+ typedef gregorian::partial_date start_rule;
+ typedef gregorian::partial_date end_rule;
+ };
+
+ //! Provides rule of the form first Sunday in April, last Saturday in Oct
+ typedef date_time::day_calc_dst_rule<partial_date_rule_spec> partial_date_dst_rule;
+
+ struct first_last_rule_spec
+ {
+ typedef gregorian::date date_type;
+ typedef gregorian::first_kday_of_month start_rule;
+ typedef gregorian::last_kday_of_month end_rule;
+ };
+
+ //! Provides rule of the form first Sunday in April, last Saturday in Oct
+ typedef date_time::day_calc_dst_rule<first_last_rule_spec> first_last_dst_rule;
+
+ struct last_last_rule_spec
+ {
+ typedef gregorian::date date_type;
+ typedef gregorian::last_kday_of_month start_rule;
+ typedef gregorian::last_kday_of_month end_rule;
+ };
+
+ //! Provides rule of the form last Sunday in April, last Saturday in Oct
+ typedef date_time::day_calc_dst_rule<last_last_rule_spec> last_last_dst_rule;
+
+ struct nth_last_rule_spec
+ {
+ typedef gregorian::date date_type;
+ typedef gregorian::nth_kday_of_month start_rule;
+ typedef gregorian::last_kday_of_month end_rule;
+ };
+
+ //! Provides rule in form of [1st|2nd|3rd|4th] Sunday in April, last Sunday in Oct
+ typedef date_time::day_calc_dst_rule<nth_last_rule_spec> nth_last_dst_rule;
+
+ struct nth_kday_rule_spec
+ {
+ typedef gregorian::date date_type;
+ typedef gregorian::nth_kday_of_month start_rule;
+ typedef gregorian::nth_kday_of_month end_rule;
+ };
+
+ //! Provides rule in form of [1st|2nd|3rd|4th] Sunday in April/October
+ typedef date_time::day_calc_dst_rule<nth_kday_rule_spec> nth_kday_dst_rule;
+ //! Provides rule in form of [1st|2nd|3rd|4th] Sunday in April/October
+ typedef date_time::day_calc_dst_rule<nth_kday_rule_spec> nth_day_of_the_week_in_month_dst_rule;
+
+
+} }//namespace
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/local_time/local_date_time.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/local_date_time.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,525 @@
+#ifndef LOCAL_TIME_LOCAL_DATE_TIME_HPP__
+#define LOCAL_TIME_LOCAL_DATE_TIME_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/time.hpp"
+#include "boost/date_time/posix_time/posix_time.hpp" //todo remove?
+#include "boost/shared_ptr.hpp"
+#include "boost/date_time/dst_rules.hpp"
+#include "boost/date_time/time_zone_base.hpp"
+#include "boost/date_time/special_defs.hpp"
+#include <string>
+#include <sstream>
+
+namespace boost {
+namespace local_time {
+
+ //! simple exception for reporting when STD or DST cannot be determined
+ struct ambiguous_result : public std::logic_error
+ {
+ ambiguous_result (std::string _msg="") :
+ std::logic_error(std::string("Daylight Savings Results are ambiguous: " + _msg)) {}
+ };
+ //! simple exception for when time label given cannot exist
+ struct time_label_invalid : public std::logic_error
+ {
+ time_label_invalid (std::string _msg="") :
+ std::logic_error(std::string("Time label given is invalid: " + _msg)) {}
+ };
+ struct dst_not_valid: public std::logic_error
+ {
+ dst_not_valid(std::string _msg="") :
+ std::logic_error(std::string("is_dst flag does not match resulting dst for time label given: " + _msg)) {}
+ };
+
+ //TODO: I think these should be in local_date_time_base and not
+ // necessarily brought into the namespace
+ using date_time::time_is_dst_result;
+ using date_time::is_in_dst;
+ using date_time::is_not_in_dst;
+ using date_time::ambiguous;
+ using date_time::invalid_time_label;
+
+ //! Representation of "wall-clock" time in a particular time zone
+ /*! Representation of "wall-clock" time in a particular time zone
+ * Local_date_time_base holds a time value (date and time offset from 00:00)
+ * along with a time zone. The time value is stored as UTC and conversions
+ * to wall clock time are made as needed. This approach allows for
+ * operations between wall-clock times in different time zones, and
+ * daylight savings time considerations, to be made. Time zones are
+ * required to be in the form of a boost::shared_ptr<time_zone_base>.
+ */
+ template<class utc_time_=posix_time::ptime,
+ class tz_type=date_time::time_zone_base<utc_time_,char> >
+ class local_date_time_base : public date_time::base_time<utc_time_,
+ boost::posix_time::posix_time_system> {
+ public:
+ typedef utc_time_ utc_time_type;
+ typedef typename utc_time_type::time_duration_type time_duration_type;
+ typedef typename utc_time_type::date_type date_type;
+ typedef typename date_type::duration_type date_duration_type;
+ typedef typename utc_time_type::time_system_type time_system_type;
+ /*! This constructor interprets the passed time as a UTC time.
+ * So, for example, if the passed timezone is UTC-5 then the
+ * time will be adjusted back 5 hours. The time zone allows for
+ * automatic calculation of whether the particular time is adjusted for
+ * daylight savings, etc.
+ * If the time zone shared pointer is null then time stays unadjusted.
+ *@param t A UTC time
+ *@param tz Timezone for to adjust the UTC time to.
+ */
+ local_date_time_base(utc_time_type t,
+ boost::shared_ptr<tz_type> tz) :
+ date_time::base_time<utc_time_type, time_system_type>(t),
+ zone_(tz)
+ {
+ // param was already utc so nothing more to do
+ }
+
+ /*! This constructs a local time -- the passed time information
+ * understood to be in the passed tz. The DST flag must be passed
+ * to indicate whether the time is in daylight savings or not.
+ * @throws -- time_label_invalid if the time passed does not exist in
+ * the given locale. The non-existent case occurs typically
+ * during the shift-back from daylight savings time. When
+ * the clock is shifted forward a range of times
+ * (2 am to 3 am in the US) is skipped and hence is invalid.
+ * @throws -- dst_not_valid if the DST flag is passed for a period
+ * where DST is not active.
+ */
+ local_date_time_base(date_type d,
+ time_duration_type td,
+ boost::shared_ptr<tz_type> tz,
+ bool dst_flag) : //necessary for constr_adj()
+ date_time::base_time<utc_time_type,time_system_type>(construction_adjustment(utc_time_type(d, td), tz, dst_flag)),
+ zone_(tz)
+ {
+ if(tz != boost::shared_ptr<tz_type>() && tz->has_dst()){
+
+ // d & td are already local so we use them
+ time_is_dst_result result = check_dst(d, td, tz);
+ bool in_dst = (result == is_in_dst); // less processing than is_dst()
+
+ // ambig occurs at end, invalid at start
+ if(result == invalid_time_label){
+ // Ex: 2:15am local on trans-in day in nyc, dst_flag irrelevant
+ std::stringstream ss;
+ ss << "time given: " << d << ' ' << td;
+ throw time_label_invalid(ss.str());
+ }
+ else if(result != ambiguous && in_dst != dst_flag){
+ // is dst_flag accurate?
+ // Ex: false flag in NYC in June
+ std::stringstream ss;
+ ss << "flag given: " << (dst_flag ? "dst=true" : "dst=false")
+ << ", dst calculated: " << (in_dst ? "dst=true" : "dst=false");
+ throw dst_not_valid(ss.str());
+ }
+
+ // everything checks out and conversion to utc already done
+ }
+ }
+
+ //TODO maybe not the right set...Ignore the last 2 for now...
+ enum DST_CALC_OPTIONS { EXCEPTION_ON_ERROR, NOT_DATE_TIME_ON_ERROR };
+ //ASSUME_DST_ON_ERROR, ASSUME_NOT_DST_ON_ERROR };
+
+ /*! This constructs a local time -- the passed time information
+ * understood to be in the passed tz. The DST flag is calculated
+ * according to the specified rule.
+ */
+ local_date_time_base(date_type d,
+ time_duration_type td,
+ boost::shared_ptr<tz_type> tz,
+ DST_CALC_OPTIONS calc_option) :
+ // dummy value - time_ is set in constructor code
+ date_time::base_time<utc_time_type,time_system_type>(utc_time_type(d,td)),
+ zone_(tz)
+ {
+ time_is_dst_result result = check_dst(d, td, tz);
+ if(result == ambiguous) {
+ if(calc_option == EXCEPTION_ON_ERROR){
+ std::stringstream ss;
+ ss << "time given: " << d << ' ' << td;
+ throw ambiguous_result(ss.str());
+ }
+ else{ // NADT on error
+ this->time_ = posix_time::posix_time_system::get_time_rep(date_type(date_time::not_a_date_time), time_duration_type(date_time::not_a_date_time));
+ }
+ }
+ else if(result == invalid_time_label){
+ if(calc_option == EXCEPTION_ON_ERROR){
+ std::stringstream ss;
+ ss << "time given: " << d << ' ' << td;
+ throw time_label_invalid(ss.str());
+ }
+ else{ // NADT on error
+ this->time_ = posix_time::posix_time_system::get_time_rep(date_type(date_time::not_a_date_time), time_duration_type(date_time::not_a_date_time));
+ }
+ }
+ else if(result == is_in_dst){
+ utc_time_type t =
+ construction_adjustment(utc_time_type(d, td), tz, true);
+ this->time_ = posix_time::posix_time_system::get_time_rep(t.date(),
+ t.time_of_day());
+ }
+ else{
+ utc_time_type t =
+ construction_adjustment(utc_time_type(d, td), tz, false);
+ this->time_ = posix_time::posix_time_system::get_time_rep(t.date(),
+ t.time_of_day());
+ }
+ }
+
+
+ //! Determines if given time label is in daylight savings for given zone
+ /*! Determines if given time label is in daylight savings for given zone.
+ * Takes a date and time_duration representing a local time, along
+ * with time zone, and returns a time_is_dst_result object as result.
+ */
+ static time_is_dst_result check_dst(date_type d,
+ time_duration_type td,
+ boost::shared_ptr<tz_type> tz)
+ {
+ if(tz != boost::shared_ptr<tz_type>() && tz->has_dst()) {
+ typedef typename date_time::dst_calculator<date_type, time_duration_type> dst_calculator;
+ return dst_calculator::local_is_dst(
+ d, td,
+ tz->dst_local_start_time(d.year()).date(),
+ tz->dst_local_start_time(d.year()).time_of_day(),
+ tz->dst_local_end_time(d.year()).date(),
+ tz->dst_local_end_time(d.year()).time_of_day(),
+ tz->dst_offset()
+ );
+ }
+ else{
+ return is_not_in_dst;
+ }
+ }
+
+ //! Simple destructor, releases time zone if last referrer
+ ~local_date_time_base() {};
+
+ //! Copy constructor
+ local_date_time_base(const local_date_time_base& rhs) :
+ date_time::base_time<utc_time_type, time_system_type>(rhs),
+ zone_(rhs.zone_)
+ {}
+
+ //! Special values constructor
+ explicit local_date_time_base(const boost::date_time::special_values sv,
+ boost::shared_ptr<tz_type> tz = boost::shared_ptr<tz_type>()) :
+ date_time::base_time<utc_time_type, time_system_type>(utc_time_type(sv)),
+ zone_(tz)
+ {}
+
+ //! returns time zone associated with calling instance
+ boost::shared_ptr<tz_type> zone() const
+ {
+ return zone_;
+ }
+ //! returns false is time_zone is NULL and if time value is a special_value
+ bool is_dst() const
+ {
+ if(zone_ != boost::shared_ptr<tz_type>() && zone_->has_dst() && !this->is_special()) {
+ // check_dst takes a local time, *this is utc
+ utc_time_type lt(this->time_);
+ lt += zone_->base_utc_offset();
+ // dst_offset only needs to be considered with ambiguous time labels
+ // make that adjustment there
+
+ switch(check_dst(lt.date(), lt.time_of_day(), zone_)){
+ case is_not_in_dst:
+ return false;
+ case is_in_dst:
+ return true;
+ case ambiguous:
+ if(lt + zone_->dst_offset() < zone_->dst_local_end_time(lt.date().year())) {
+ return true;
+ }
+ break;
+ case invalid_time_label:
+ if(lt >= zone_->dst_local_start_time(lt.date().year())) {
+ return true;
+ }
+ break;
+ }
+ }
+ return false;
+ }
+ //! Returns object's time value as a utc representation
+ utc_time_type utc_time() const
+ {
+ return utc_time_type(this->time_);
+ }
+ //! Returns object's time value as a local representation
+ utc_time_type local_time() const
+ {
+ if(zone_ != boost::shared_ptr<tz_type>()){
+ utc_time_type lt = this->utc_time() + zone_->base_utc_offset();
+ if (is_dst()) {
+ lt += zone_->dst_offset();
+ }
+ return lt;
+ }
+ return utc_time_type(this->time_);
+ }
+ //! Returns string in the form "2003-Aug-20 05:00:00 EDT"
+ /*! Returns string in the form "2003-Aug-20 05:00:00 EDT". If
+ * time_zone is NULL the time zone abbreviation will be "UTC". The time
+ * zone abbrev will not be included if calling object is a special_value*/
+ std::string to_string() const
+ {
+ //TODO is this a temporary function ???
+ std::stringstream ss;
+ if(this->is_special()){
+ ss << utc_time();
+ return ss.str();
+ }
+ if(zone_ == boost::shared_ptr<tz_type>()) {
+ ss << utc_time() << " UTC";
+ return ss.str();
+ }
+ bool is_dst_ = is_dst();
+ utc_time_type lt = this->utc_time() + zone_->base_utc_offset();
+ if (is_dst_) {
+ lt += zone_->dst_offset();
+ }
+ ss << local_time() << " ";
+ if (is_dst()) {
+ ss << zone_->dst_zone_abbrev();
+ }
+ else {
+ ss << zone_->std_zone_abbrev();
+ }
+ return ss.str();
+ }
+ /*! returns a local_date_time_base in the given time zone with the
+ * optional time_duration added. */
+ local_date_time_base local_time_in(boost::shared_ptr<tz_type> new_tz,
+ time_duration_type td=time_duration_type(0,0,0)) const
+ {
+ return local_date_time_base(utc_time_type(this->time_) + td, new_tz);
+ }
+
+ //! Returns name of associated time zone or "Coordinated Universal Time".
+ /*! Optional bool parameter will return time zone as an offset
+ * (ie "+07:00" extended iso format). Empty string is returned for
+ * classes that do not use a time_zone */
+ std::string zone_name(bool as_offset=false) const
+ {
+ if(zone_ == boost::shared_ptr<tz_type>()) {
+ if(as_offset) {
+ return std::string("Z");
+ }
+ else {
+ return std::string("Coordinated Universal Time");
+ }
+ }
+ if (is_dst()) {
+ if(as_offset) {
+ time_duration_type td = zone_->base_utc_offset();
+ td += zone_->dst_offset();
+ return zone_as_offset(td, ":");
+ }
+ else {
+ return zone_->dst_zone_name();
+ }
+ }
+ else {
+ if(as_offset) {
+ time_duration_type td = zone_->base_utc_offset();
+ return zone_as_offset(td, ":");
+ }
+ else {
+ return zone_->std_zone_name();
+ }
+ }
+ }
+ //! Returns abbreviation of associated time zone or "UTC".
+ /*! Optional bool parameter will return time zone as an offset
+ * (ie "+0700" iso format). Empty string is returned for classes
+ * that do not use a time_zone */
+ std::string zone_abbrev(bool as_offset=false) const
+ {
+ if(zone_ == boost::shared_ptr<tz_type>()) {
+ if(as_offset) {
+ return std::string("Z");
+ }
+ else {
+ return std::string("UTC");
+ }
+ }
+ if (is_dst()) {
+ if(as_offset) {
+ time_duration_type td = zone_->base_utc_offset();
+ td += zone_->dst_offset();
+ return zone_as_offset(td, "");
+ }
+ else {
+ return zone_->dst_zone_abbrev();
+ }
+ }
+ else {
+ if(as_offset) {
+ time_duration_type td = zone_->base_utc_offset();
+ return zone_as_offset(td, "");
+ }
+ else {
+ return zone_->std_zone_abbrev();
+ }
+ }
+ }
+
+ //! returns a posix_time_zone string for the associated time_zone. If no time_zone, "UTC+00" is returned.
+ std::string zone_as_posix_string() const
+ {
+ if(zone_ == shared_ptr<tz_type>()) {
+ return std::string("UTC+00");
+ }
+ return zone_->to_posix_string();
+ }
+
+ //! Equality comparison operator
+ /*bool operator==(const date_time::base_time<boost::posix_time::ptime,boost::posix_time::posix_time_system>& rhs) const
+ { // fails due to rhs.time_ being protected
+ return date_time::base_time<boost::posix_time::ptime,boost::posix_time::posix_time_system>::operator==(rhs);
+ //return this->time_ == rhs.time_;
+ }*/
+ //! Equality comparison operator
+ bool operator==(const local_date_time_base& rhs) const
+ {
+ return time_system_type::is_equal(this->time_, rhs.time_);
+ }
+ //! Non-Equality comparison operator
+ bool operator!=(const local_date_time_base& rhs) const
+ {
+ return !(*this == rhs);
+ }
+ //! Less than comparison operator
+ bool operator<(const local_date_time_base& rhs) const
+ {
+ return time_system_type::is_less(this->time_, rhs.time_);
+ }
+ //! Less than or equal to comparison operator
+ bool operator<=(const local_date_time_base& rhs) const
+ {
+ return (*this < rhs || *this == rhs);
+ }
+ //! Greater than comparison operator
+ bool operator>(const local_date_time_base& rhs) const
+ {
+ return !(*this <= rhs);
+ }
+ //! Greater than or equal to comparison operator
+ bool operator>=(const local_date_time_base& rhs) const
+ {
+ return (*this > rhs || *this == rhs);
+ }
+
+ //! Local_date_time + date_duration
+ local_date_time_base operator+(const date_duration_type& dd) const
+ {
+ return local_date_time_base(time_system_type::add_days(this->time_,dd), zone_);
+ }
+ //! Local_date_time += date_duration
+ local_date_time_base operator+=(const date_duration_type& dd)
+ {
+ this->time_ = time_system_type::add_days(this->time_,dd);
+ return *this;
+ }
+ //! Local_date_time - date_duration
+ local_date_time_base operator-(const date_duration_type& dd) const
+ {
+ return local_date_time_base(time_system_type::subtract_days(this->time_,dd), zone_);
+ }
+ //! Local_date_time -= date_duration
+ local_date_time_base operator-=(const date_duration_type& dd)
+ {
+ this->time_ = time_system_type::subtract_days(this->time_,dd);
+ return *this;
+ }
+ //! Local_date_time + time_duration
+ local_date_time_base operator+(const time_duration_type& td) const
+ {
+ return local_date_time_base(time_system_type::add_time_duration(this->time_,td), zone_);
+ }
+ //! Local_date_time += time_duration
+ local_date_time_base operator+=(const time_duration_type& td)
+ {
+ this->time_ = time_system_type::add_time_duration(this->time_,td);
+ return *this;
+ }
+ //! Local_date_time - time_duration
+ local_date_time_base operator-(const time_duration_type& td) const
+ {
+ return local_date_time_base(time_system_type::subtract_time_duration(this->time_,td), zone_);
+ }
+ //! Local_date_time -= time_duration
+ local_date_time_base operator-=(const time_duration_type& td)
+ {
+ this->time_ = time_system_type::subtract_time_duration(this->time_,td);
+ return *this;
+ }
+ //! local_date_time -= local_date_time --> time_duration_type
+ time_duration_type operator-(const local_date_time_base& rhs) const
+ {
+ return utc_time_type(this->time_) - utc_time_type(rhs.time_);
+ }
+ private:
+ boost::shared_ptr<tz_type> zone_;
+ //bool is_dst_;
+
+ /*! Adjust the passed in time to UTC?
+ */
+ utc_time_type construction_adjustment(utc_time_type t,
+ boost::shared_ptr<tz_type> z,
+ bool dst_flag)
+ {
+ if(z != boost::shared_ptr<tz_type>()) {
+ if(dst_flag && z->has_dst()) {
+ t -= z->dst_offset();
+ } // else no adjust
+ t -= z->base_utc_offset();
+ }
+ return t;
+ }
+
+ /*! Simple formatting code -- todo remove this?
+ */
+ std::string zone_as_offset(const time_duration_type& td,
+ const std::string& separator) const
+ {
+ std::stringstream ss;
+ if(td.is_negative()) {
+ // a negative duration is represented as "-[h]h:mm"
+ // we require two digits for the hour. A positive duration
+ // with the %H flag will always give two digits
+ ss << "-";
+ }
+ else {
+ ss << "+";
+ }
+ ss << std::setw(2) << std::setfill('0')
+ << date_time::absolute_value(td.hours())
+ << separator
+ << std::setw(2) << std::setfill('0')
+ << date_time::absolute_value(td.minutes());
+ return ss.str();
+ }
+ };
+
+ //!Use the default parameters to define local_date_time
+ typedef local_date_time_base<> local_date_time;
+
+} }
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,24 @@
+#ifndef LOCAL_TIME_LOCAL_TIME_HPP__
+#define LOCAL_TIME_LOCAL_TIME_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/local_time/local_date_time.hpp"
+#include "boost/date_time/local_time/local_time_types.hpp"
+#if !defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
+#include "boost/date_time/local_time/local_time_io.hpp"
+#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
+#include "boost/date_time/local_time/posix_time_zone.hpp"
+#include "boost/date_time/local_time/custom_time_zone.hpp"
+#include "boost/date_time/local_time/tz_database.hpp"
+#include "boost/date_time/local_time/conversion.hpp"
+#include "boost/date_time/time_zone_base.hpp"
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time_io.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time_io.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,118 @@
+#ifndef BOOST_DATE_TIME_LOCAL_TIME_IO_HPP__
+#define BOOST_DATE_TIME_LOCAL_TIME_IO_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <iostream>
+#include "boost/date_time/local_time/local_date_time.hpp"
+#include "boost/date_time/local_time/posix_time_zone.hpp"
+#include "boost/date_time/time_facet.hpp"
+#include "boost/date_time/string_convert.hpp"
+#include "boost/io/ios_state.hpp"
+
+namespace boost {
+namespace local_time {
+
+ typedef boost::date_time::time_facet<local_date_time, wchar_t> wlocal_time_facet;
+ typedef boost::date_time::time_facet<local_date_time, char> local_time_facet;
+
+ typedef boost::date_time::time_input_facet<local_date_time::utc_time_type,wchar_t> wlocal_time_input_facet;
+ typedef boost::date_time::time_input_facet<local_date_time::utc_time_type,char> local_time_input_facet;
+
+ //! operator<< for local_date_time - see local_time docs for formatting details
+ template<class CharT, class TraitsT>
+ inline
+ std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os, const local_date_time& ldt)
+ {
+ boost::io::ios_flags_saver iflags(os);
+ typedef local_date_time time_type;//::utc_time_type typename
+ typedef date_time::time_facet<time_type, CharT> custom_time_facet;
+ typedef std::time_put<CharT> std_time_facet;
+ std::ostreambuf_iterator<CharT> oitr(os);
+
+ if(std::has_facet<custom_time_facet>(os.getloc())) {
+ std::use_facet<custom_time_facet>(os.getloc()).put(oitr,
+ os,
+ os.fill(),
+ ldt);
+ }
+ else {
+ custom_time_facet* f = new custom_time_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(oitr, os, os.fill(), ldt);
+ }
+
+ return os;
+ }
+
+
+ //! input operator for local_date_time
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, local_date_time& ldt)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename local_date_time::utc_time_type utc_time_type;
+ typedef typename date_time::time_input_facet<utc_time_type, CharT> time_input_facet;
+
+ // intermediate objects
+ std::basic_string<CharT> tz_str;
+ utc_time_type pt(not_a_date_time);
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<time_input_facet>(is.getloc())) {
+ std::use_facet<time_input_facet>(is.getloc()).get_local_time(sit, str_end, is, pt, tz_str);
+ }
+ else {
+ time_input_facet* f = new time_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get_local_time(sit, str_end, is, pt, tz_str);
+ }
+ if(tz_str.empty()) {
+ time_zone_ptr null_ptr;
+ // a null time_zone_ptr creates a local_date_time that is UTC
+ ldt = local_date_time(pt, null_ptr);
+ }
+ else {
+ time_zone_ptr tz_ptr(new posix_time_zone(date_time::convert_string_type<CharT,char>(tz_str)));
+ // the "date & time" constructor expects the time label to *not* be utc.
+ // a posix_tz_string also expects the time label to *not* be utc.
+ ldt = local_date_time(pt.date(), pt.time_of_day(), tz_ptr, local_date_time::EXCEPTION_ON_ERROR);
+ }
+ }
+ catch(...) {
+ // mask tells us what exceptions are turned on
+ std::ios_base::iostate exception_mask = is.exceptions();
+ // if the user wants exceptions on failbit, we'll rethrow our
+ // date_time exception & set the failbit
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {} // ignore this one
+ throw; // rethrow original exception
+ }
+ else {
+ // if the user want's to fail quietly, we simply set the failbit
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+
+} } // namespaces
+
+#endif // BOOST_DATE_TIME_LOCAL_TIME_IO_HPP__

Added: sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time_types.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/local_time_types.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,52 @@
+#ifndef LOCAL_TIME_LOCAL_TIME_TYPES_HPP__
+#define LOCAL_TIME_LOCAL_TIME_TYPES_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/local_time/local_date_time.hpp"
+#include "boost/date_time/period.hpp"
+#include "boost/date_time/time_iterator.hpp"
+#include "boost/date_time/compiler_config.hpp"
+#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
+#include "boost/date_time/local_time/date_duration_operators.hpp"
+#endif //BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES
+#include "boost/date_time/local_time/custom_time_zone.hpp"
+
+namespace boost {
+namespace local_time {
+
+ typedef boost::date_time::period<local_date_time,
+ boost::posix_time::time_duration> local_time_period;
+
+ typedef date_time::time_itr<local_date_time> local_time_iterator;
+
+ typedef date_time::second_clock<local_date_time> local_sec_clock;
+ typedef date_time::microsec_clock<local_date_time> local_microsec_clock;
+
+ typedef date_time::time_zone_base<posix_time::ptime, char> time_zone;
+ typedef date_time::time_zone_base<posix_time::ptime, wchar_t> wtime_zone;
+
+ //! Shared Pointer for custom_time_zone and posix_time_zone objects
+ typedef boost::shared_ptr<time_zone> time_zone_ptr;
+ typedef boost::shared_ptr<wtime_zone> wtime_zone_ptr;
+
+ typedef date_time::time_zone_names_base<char> time_zone_names;
+ typedef date_time::time_zone_names_base<wchar_t> wtime_zone_names;
+
+ //bring special enum values into the namespace
+ using date_time::special_values;
+ using date_time::not_special;
+ using date_time::neg_infin;
+ using date_time::pos_infin;
+ using date_time::not_a_date_time;
+ using date_time::max_date_time;
+ using date_time::min_date_time;
+
+}} // namespaces
+
+#endif // LOCAL_TIME_LOCAL_TIME_TYPES_HPP__

Added: sandbox/SOC/2008/calendar/boost/date_time/local_time/posix_time_zone.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/posix_time_zone.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,443 @@
+#ifndef _DATE_TIME_POSIX_TIME_ZONE__
+#define _DATE_TIME_POSIX_TIME_ZONE__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <string>
+#include <sstream>
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include "boost/date_time/time_zone_names.hpp"
+#include "boost/date_time/time_zone_base.hpp"
+#include "boost/date_time/local_time/dst_transition_day_rules.hpp"
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/string_convert.hpp"
+#include "boost/date_time/time_parsing.hpp"
+#include "boost/tokenizer.hpp"
+#include <stdexcept>
+
+namespace boost{
+namespace local_time{
+
+ //! simple exception for UTC and Daylight savings start/end offsets
+ struct bad_offset : public std::out_of_range
+ {
+ bad_offset(std::string _msg="") : std::out_of_range(std::string("Offset out of range: " + _msg)) {}
+ };
+ //! simple exception for UTC daylight savings adjustment
+ struct bad_adjustment : public std::out_of_range
+ {
+ bad_adjustment(std::string _msg="") : std::out_of_range(std::string("Adjustment out of range: " + _msg)) {}
+ };
+
+ typedef boost::date_time::dst_adjustment_offsets<boost::posix_time::time_duration> dst_adjustment_offsets;
+
+ //! A time zone class constructed from a POSIX time zone string
+ /*! A POSIX time zone string takes the form of:<br>
+ * "std offset dst [offset],start[/time],end[/time]" (w/no spaces)
+ * 'std' specifies the abbrev of the time zone.<br>
+ * 'offset' is the offset from UTC.<br>
+ * 'dst' specifies the abbrev of the time zone during daylight savings time.<br>
+ * The second offset is how many hours changed during DST. Default=1<br>
+ * 'start' and'end' are the dates when DST goes into (and out of) effect.<br>
+ * 'offset' takes the form of: [+|-]hh[:mm[:ss]] {h=0-23, m/s=0-59}<br>
+ * 'time' and 'offset' take the same form. Time defaults=02:00:00<br>
+ * 'start' and 'end' can be one of three forms:<br>
+ * Mm.w.d {month=1-12, week=1-5 (5 is always last), day=0-6}<br>
+ * Jn {n=1-365 Feb29 is never counted}<br>
+ * n {n=0-365 Feb29 is counted in leap years}<br>
+ * Example "PST-5PDT01:00:00,M4.1.0/02:00:00,M10.1.0/02:00:00"
+ * <br>
+ * Exceptions will be thrown under these conditions:<br>
+ * An invalid date spec (see date class)<br>
+ * A boost::local_time::bad_offset exception will be thrown for:<br>
+ * A DST start or end offset that is negative or more than 24 hours<br>
+ * A UTC zone that is greater than +12 or less than -12 hours<br>
+ * A boost::local_time::bad_adjustment exception will be thrown for:<br>
+ * A DST adjustment that is 24 hours or more (positive or negative)<br>
+ */
+ template<class CharT>
+ class posix_time_zone_base : public date_time::time_zone_base<posix_time::ptime,CharT> {
+ public:
+ typedef boost::posix_time::time_duration time_duration_type;
+ typedef date_time::time_zone_names_base<CharT> time_zone_names;
+ typedef date_time::time_zone_base<posix_time::ptime,CharT> base_type;
+ typedef typename base_type::string_type string_type;
+ typedef CharT char_type;
+ typedef typename base_type::stringstream_type stringstream_type;
+ typedef boost::char_separator<char_type, std::char_traits<char_type> > char_separator_type;
+ typedef boost::tokenizer<char_separator_type,
+ typename string_type::const_iterator,
+ string_type> tokenizer_type;
+ typedef typename boost::tokenizer<char_separator_type,
+ typename string_type::const_iterator,
+ string_type>::iterator tokenizer_iterator_type;
+
+ //! Construct from a POSIX time zone string
+ posix_time_zone_base(const string_type& s) :
+ //zone_names_("std_name","std_abbrev","no-dst","no-dst"),
+ zone_names_(),
+ has_dst_(false),
+ base_utc_offset_(posix_time::hours(0)),
+ dst_offsets_(posix_time::hours(0),posix_time::hours(0),posix_time::hours(0)),
+ dst_calc_rules_()
+ {
+ const char_type sep_chars[2] = {','};
+ char_separator_type sep(sep_chars);
+ tokenizer_type tokens(s, sep);
+ tokenizer_iterator_type it = tokens.begin();
+ calc_zone(*it++);
+ if(has_dst_){
+ string_type tmp_str = *it++;
+ calc_rules(tmp_str, *it);
+ }
+ }
+ virtual ~posix_time_zone_base() {};
+ //!String for the zone when not in daylight savings (eg: EST)
+ virtual string_type std_zone_abbrev()const
+ {
+ return zone_names_.std_zone_abbrev();
+ }
+ //!String for the timezone when in daylight savings (eg: EDT)
+ /*! For those time zones that have no DST, an empty string is used */
+ virtual string_type dst_zone_abbrev() const
+ {
+ return zone_names_.dst_zone_abbrev();
+ }
+ //!String for the zone when not in daylight savings (eg: Eastern Standard Time)
+ /*! The full STD name is not extracted from the posix time zone string.
+ * Therefore, the STD abbreviation is used in it's place */
+ virtual string_type std_zone_name()const
+ {
+ return zone_names_.std_zone_name();
+ }
+ //!String for the timezone when in daylight savings (eg: Eastern Daylight Time)
+ /*! The full DST name is not extracted from the posix time zone string.
+ * Therefore, the STD abbreviation is used in it's place. For time zones
+ * that have no DST, an empty string is used */
+ virtual string_type dst_zone_name()const
+ {
+ return zone_names_.dst_zone_name();
+ }
+ //! True if zone uses daylight savings adjustments otherwise false
+ virtual bool has_dst()const
+ {
+ return has_dst_;
+ }
+ //! Local time that DST starts -- NADT if has_dst is false
+ virtual posix_time::ptime dst_local_start_time(gregorian::greg_year y)const
+ {
+ gregorian::date d(gregorian::not_a_date_time);
+ if(has_dst_)
+ {
+ d = dst_calc_rules_->start_day(y);
+ }
+ return posix_time::ptime(d, dst_offsets_.dst_start_offset_);
+ }
+ //! Local time that DST ends -- NADT if has_dst is false
+ virtual posix_time::ptime dst_local_end_time(gregorian::greg_year y)const
+ {
+ gregorian::date d(gregorian::not_a_date_time);
+ if(has_dst_)
+ {
+ d = dst_calc_rules_->end_day(y);
+ }
+ return posix_time::ptime(d, dst_offsets_.dst_end_offset_);
+ }
+ //! Base offset from UTC for zone (eg: -07:30:00)
+ virtual time_duration_type base_utc_offset()const
+ {
+ return base_utc_offset_;
+ }
+ //! Adjustment forward or back made while DST is in effect
+ virtual time_duration_type dst_offset()const
+ {
+ return dst_offsets_.dst_adjust_;
+ }
+
+ //! Returns a POSIX time_zone string for this object
+ virtual string_type to_posix_string() const
+ {
+ // std offset dst [offset],start[/time],end[/time] - w/o spaces
+ stringstream_type ss;
+ ss.fill('0');
+ boost::shared_ptr<dst_calc_rule> no_rules;
+ // std
+ ss << std_zone_abbrev();
+ // offset
+ if(base_utc_offset().is_negative()) {
+ // inverting the sign guarantees we get two digits
+ ss << '-' << std::setw(2) << base_utc_offset().invert_sign().hours();
+ }
+ else {
+ ss << '+' << std::setw(2) << base_utc_offset().hours();
+ }
+ if(base_utc_offset().minutes() != 0 || base_utc_offset().seconds() != 0) {
+ ss << ':' << std::setw(2) << base_utc_offset().minutes();
+ if(base_utc_offset().seconds() != 0) {
+ ss << ':' << std::setw(2) << base_utc_offset().seconds();
+ }
+ }
+ if(dst_calc_rules_ != no_rules) {
+ // dst
+ ss << dst_zone_abbrev();
+ // dst offset
+ if(dst_offset().is_negative()) {
+ // inverting the sign guarantees we get two digits
+ ss << '-' << std::setw(2) << dst_offset().invert_sign().hours();
+ }
+ else {
+ ss << '+' << std::setw(2) << dst_offset().hours();
+ }
+ if(dst_offset().minutes() != 0 || dst_offset().seconds() != 0) {
+ ss << ':' << std::setw(2) << dst_offset().minutes();
+ if(dst_offset().seconds() != 0) {
+ ss << ':' << std::setw(2) << dst_offset().seconds();
+ }
+ }
+ // start/time
+ ss << ',' << date_time::convert_string_type<char, char_type>(dst_calc_rules_->start_rule_as_string()) << '/'
+ << std::setw(2) << dst_offsets_.dst_start_offset_.hours() << ':'
+ << std::setw(2) << dst_offsets_.dst_start_offset_.minutes();
+ if(dst_offsets_.dst_start_offset_.seconds() != 0) {
+ ss << ':' << std::setw(2) << dst_offsets_.dst_start_offset_.seconds();
+ }
+ // end/time
+ ss << ',' << date_time::convert_string_type<char, char_type>(dst_calc_rules_->end_rule_as_string()) << '/'
+ << std::setw(2) << dst_offsets_.dst_end_offset_.hours() << ':'
+ << std::setw(2) << dst_offsets_.dst_end_offset_.minutes();
+ if(dst_offsets_.dst_end_offset_.seconds() != 0) {
+ ss << ':' << std::setw(2) << dst_offsets_.dst_end_offset_.seconds();
+ }
+ }
+
+ return ss.str();
+ }
+ private:
+ time_zone_names zone_names_;
+ bool has_dst_;
+ time_duration_type base_utc_offset_;
+ dst_adjustment_offsets dst_offsets_;
+ boost::shared_ptr<dst_calc_rule> dst_calc_rules_;
+
+ /*! Extract time zone abbreviations for STD & DST as well
+ * as the offsets for the time shift that occurs and how
+ * much of a shift. At this time full time zone names are
+ * NOT extracted so the abbreviations are used in their place */
+ void calc_zone(const string_type& obj){
+ const char_type empty_string[2] = {'\0'};
+ stringstream_type ss(empty_string);
+ typename string_type::const_iterator sit = obj.begin();
+ string_type l_std_zone_abbrev, l_dst_zone_abbrev;
+
+ // get 'std' name/abbrev
+ while(std::isalpha(*sit)){
+ ss << *sit++;
+ }
+ l_std_zone_abbrev = ss.str();
+ ss.str(empty_string);
+
+ // get UTC offset
+ if(sit != obj.end()){
+ // get duration
+ while(sit != obj.end() && !std::isalpha(*sit)){
+ ss << *sit++;
+ }
+ base_utc_offset_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(ss.str());
+ ss.str(empty_string);
+
+ // base offset must be within range of -12 hours to +12 hours
+ if(base_utc_offset_ < time_duration_type(-12,0,0) ||
+ base_utc_offset_ > time_duration_type(12,0,0))
+ {
+ throw bad_offset(posix_time::to_simple_string(base_utc_offset_));
+ }
+ }
+
+ // get DST data if given
+ if(sit != obj.end()){
+ has_dst_ = true;
+
+ // get 'dst' name/abbrev
+ while(sit != obj.end() && std::isalpha(*sit)){
+ ss << *sit++;
+ }
+ l_dst_zone_abbrev = ss.str();
+ ss.str(empty_string);
+
+ // get DST offset if given
+ if(sit != obj.end()){
+ // get duration
+ while(sit != obj.end() && !std::isalpha(*sit)){
+ ss << *sit++;
+ }
+ dst_offsets_.dst_adjust_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(ss.str());
+ ss.str(empty_string);
+ }
+ else{ // default DST offset
+ dst_offsets_.dst_adjust_ = posix_time::hours(1);
+ }
+
+ // adjustment must be within +|- 1 day
+ if(dst_offsets_.dst_adjust_ <= time_duration_type(-24,0,0) ||
+ dst_offsets_.dst_adjust_ >= time_duration_type(24,0,0))
+ {
+ throw bad_adjustment(posix_time::to_simple_string(dst_offsets_.dst_adjust_));
+ }
+ }
+ // full names not extracted so abbrevs used in their place
+ zone_names_ = time_zone_names(l_std_zone_abbrev, l_std_zone_abbrev, l_dst_zone_abbrev, l_dst_zone_abbrev);
+ }
+
+ void calc_rules(const string_type& start, const string_type& end){
+ const char_type sep_chars[2] = {'/'};
+ char_separator_type sep(sep_chars);
+ tokenizer_type st_tok(start, sep);
+ tokenizer_type et_tok(end, sep);
+ tokenizer_iterator_type sit = st_tok.begin();
+ tokenizer_iterator_type eit = et_tok.begin();
+
+ // generate date spec
+ char_type x = string_type(*sit).at(0);
+ if(x == 'M'){
+ M_func(*sit, *eit);
+ }
+ else if(x == 'J'){
+ julian_no_leap(*sit, *eit);
+ }
+ else{
+ julian_day(*sit, *eit);
+ }
+
+ ++sit;
+ ++eit;
+ // generate durations
+ // starting offset
+ if(sit != st_tok.end()){
+ dst_offsets_.dst_start_offset_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(*sit);
+ }
+ else{
+ // default
+ dst_offsets_.dst_start_offset_ = posix_time::hours(2);
+ }
+ // start/end offsets must fall on given date
+ if(dst_offsets_.dst_start_offset_ < time_duration_type(0,0,0) ||
+ dst_offsets_.dst_start_offset_ >= time_duration_type(24,0,0))
+ {
+ throw bad_offset(posix_time::to_simple_string(dst_offsets_.dst_start_offset_));
+ }
+
+ // ending offset
+ if(eit != et_tok.end()){
+ dst_offsets_.dst_end_offset_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(*eit);
+ }
+ else{
+ // default
+ dst_offsets_.dst_end_offset_ = posix_time::hours(2);
+ }
+ // start/end offsets must fall on given date
+ if(dst_offsets_.dst_end_offset_ < time_duration_type(0,0,0) ||
+ dst_offsets_.dst_end_offset_ >= time_duration_type(24,0,0))
+ {
+ throw bad_offset(posix_time::to_simple_string(dst_offsets_.dst_end_offset_));
+ }
+ }
+
+ /* Parses out a start/end date spec from a posix time zone string.
+ * Date specs come in three possible formats, this function handles
+ * the 'M' spec. Ex "M2.2.4" => 2nd month, 2nd week, 4th day .
+ */
+ void M_func(const string_type& s, const string_type& e){
+ typedef gregorian::nth_kday_of_month nkday;
+ unsigned short sm=0,sw=0,sd=0,em=0,ew=0,ed=0; // start/end month,week,day
+ const char_type sep_chars[3] = {'M','.'};
+ char_separator_type sep(sep_chars);
+ tokenizer_type stok(s, sep), etok(e, sep);
+
+ tokenizer_iterator_type it = stok.begin();
+ sm = lexical_cast<unsigned short>(*it++);
+ sw = lexical_cast<unsigned short>(*it++);
+ sd = lexical_cast<unsigned short>(*it);
+
+ it = etok.begin();
+ em = lexical_cast<unsigned short>(*it++);
+ ew = lexical_cast<unsigned short>(*it++);
+ ed = lexical_cast<unsigned short>(*it);
+
+ dst_calc_rules_ = shared_ptr<dst_calc_rule>(
+ new nth_kday_dst_rule(
+ nth_last_dst_rule::start_rule(
+ static_cast<nkday::week_num>(sw),sd,sm),
+ nth_last_dst_rule::start_rule(
+ static_cast<nkday::week_num>(ew),ed,em)
+ )
+ );
+ }
+
+ //! Julian day. Feb29 is never counted, even in leap years
+ // expects range of 1-365
+ void julian_no_leap(const string_type& s, const string_type& e){
+ typedef gregorian::gregorian_calendar calendar;
+ const unsigned short year = 2001; // Non-leap year
+ unsigned short sm=1;
+ int sd=0;
+ sd = lexical_cast<int>(s.substr(1)); // skip 'J'
+ while(sd >= calendar::end_of_month_day(year,sm)){
+ sd -= calendar::end_of_month_day(year,sm++);
+ }
+ unsigned short em=1;
+ int ed=0;
+ ed = lexical_cast<int>(e.substr(1)); // skip 'J'
+ while(ed > calendar::end_of_month_day(year,em)){
+ ed -= calendar::end_of_month_day(year,em++);
+ }
+
+ dst_calc_rules_ = shared_ptr<dst_calc_rule>(
+ new partial_date_dst_rule(
+ partial_date_dst_rule::start_rule(
+ sd, static_cast<date_time::months_of_year>(sm)),
+ partial_date_dst_rule::end_rule(
+ ed, static_cast<date_time::months_of_year>(em))
+ )
+ );
+ }
+
+ //! Julian day. Feb29 is always counted, but exception thrown in non-leap years
+ // expects range of 0-365
+ void julian_day(const string_type& s, const string_type& e){
+ int sd=0, ed=0;
+ sd = lexical_cast<int>(s);
+ ed = lexical_cast<int>(e);
+ dst_calc_rules_ = shared_ptr<dst_calc_rule>(
+ new partial_date_dst_rule(
+ partial_date_dst_rule::start_rule(++sd),// args are 0-365
+ partial_date_dst_rule::end_rule(++ed) // pd expects 1-366
+ )
+ );
+ }
+
+ //! helper function used when throwing exceptions
+ static std::string td_as_string(const time_duration_type& td)
+ {
+ std::string s;
+#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
+ s = posix_time::to_simple_string(td);
+#else
+ std::stringstream ss;
+ ss << td;
+ s = ss.str();
+#endif
+ return s;
+ }
+ };
+
+ typedef posix_time_zone_base<char> posix_time_zone;
+
+} } // namespace boost::local_time
+
+
+#endif // _DATE_TIME_POSIX_TIME_ZONE__

Added: sandbox/SOC/2008/calendar/boost/date_time/local_time/tz_database.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time/tz_database.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,32 @@
+#ifndef BOOST_DATE_TIME_TZ_DATABASE_HPP__
+#define BOOST_DATE_TIME_TZ_DATABASE_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <string>
+#include "boost/date_time/local_time/custom_time_zone.hpp"
+#include "boost/date_time/local_time/dst_transition_day_rules.hpp"
+#include "boost/date_time/tz_db_base.hpp"
+
+
+namespace boost {
+namespace local_time {
+
+ using date_time::data_not_accessible;
+ using date_time::bad_field_count;
+
+ //! Object populated with boost::shared_ptr<time_zone_base> objects
+ /*! Object populated with boost::shared_ptr<time_zone_base> objects
+ * Database is populated from specs stored in external csv file. See
+ * date_time::tz_db_base for greater detail */
+ typedef date_time::tz_db_base<custom_time_zone, nth_kday_dst_rule> tz_database;
+
+}} // namespace
+
+#endif // BOOST_DATE_TIME_TZ_DATABASE_HPP__
+

Added: sandbox/SOC/2008/calendar/boost/date_time/local_time_adjustor.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_time_adjustor.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,213 @@
+#ifndef DATE_TIME_LOCAL_TIME_ADJUSTOR_HPP__
+#define DATE_TIME_LOCAL_TIME_ADJUSTOR_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+/*! @file local_time_adjustor.hpp
+ Time adjustment calculations for local times
+*/
+
+#include "boost/date_time/date_generators.hpp"
+#include "boost/date_time/dst_rules.hpp"
+#include <stdexcept>
+
+namespace boost {
+ namespace date_time {
+
+
+ //! Provides a base offset adjustment from utc
+ template<class time_duration_type,
+ short hours, unsigned short minutes = 0>
+ class utc_adjustment
+ {
+ public:
+ static time_duration_type local_to_utc_base_offset()
+ {
+ time_duration_type td(hours,minutes,0);
+ return td.invert_sign();
+ }
+ static time_duration_type utc_to_local_base_offset()
+ {
+ return time_duration_type(hours,minutes,0);
+ }
+ };
+
+
+
+ //! Allow sliding utc adjustment with fixed dst rules
+ template<class time_type, class dst_rules>
+ class dynamic_local_time_adjustor : public dst_rules
+ {
+ public:
+ typedef typename time_type::time_duration_type time_duration_type;
+ typedef typename time_type::date_type date_type;
+
+ dynamic_local_time_adjustor(time_duration_type utc_offset) :
+ utc_offset_(utc_offset)
+ {}
+
+ //! Presumes local time
+ time_duration_type utc_offset(bool is_dst)
+ {
+ if (is_dst) {
+ return utc_offset_ + this->dst_offset();
+ }
+ else {
+ return utc_offset_;
+ }
+
+ }
+ private:
+ time_duration_type utc_offset_;
+
+ };
+
+
+
+ //! Embed the rules for local time adjustments at compile time
+ template<class time_type, class dst_rules, class utc_offset_rules>
+ class static_local_time_adjustor: public dst_rules, public utc_offset_rules
+ {
+ public:
+ typedef typename time_type::time_duration_type time_duration_type;
+ typedef typename time_type::date_type date_type;
+
+ //! Calculates the offset from a utc time to local based on dst and utc offset
+ /*! @param t 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.
+ *
+ * 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.
+ */
+ static time_duration_type utc_to_local_offset(const time_type& t)
+ {
+ //get initial local time guess by applying utc offset
+ time_type initial = t + utc_offset_rules::utc_to_local_base_offset();
+ time_is_dst_result dst_flag =
+ dst_rules::local_is_dst(initial.date(), initial.time_of_day());
+ switch(dst_flag) {
+ case is_in_dst: return utc_offset_rules::utc_to_local_base_offset() + dst_rules::dst_offset();
+ case is_not_in_dst: return utc_offset_rules::utc_to_local_base_offset();
+ case invalid_time_label:return utc_offset_rules::utc_to_local_base_offset() + dst_rules::dst_offset();
+ case ambiguous: {
+ time_type retry = initial + dst_rules::dst_offset();
+ dst_flag = dst_rules::local_is_dst(retry.date(), retry.time_of_day());
+ //if still ambibuous then the utc time still translates to a dst time
+ if (dst_flag == ambiguous) {
+ return utc_offset_rules::utc_to_local_base_offset() + dst_rules::dst_offset();
+ }
+ // we are past the dst boundary
+ else {
+ return utc_offset_rules::utc_to_local_base_offset();
+ }
+ }
+ }//case
+ //TODO better excpetion type
+ throw std::out_of_range("Unreachable case");
+
+ }
+
+ //! Get the offset to UTC given a local time
+ static time_duration_type local_to_utc_offset(const time_type& t,
+ date_time::dst_flags dst=date_time::calculate)
+ {
+ switch (dst) {
+ case is_dst:
+ return utc_offset_rules::local_to_utc_base_offset() - dst_rules::dst_offset();
+ case not_dst:
+ return utc_offset_rules::local_to_utc_base_offset();
+ case calculate:
+ time_is_dst_result res =
+ dst_rules::local_is_dst(t.date(), t.time_of_day());
+ switch(res) {
+ case is_in_dst: return utc_offset_rules::local_to_utc_base_offset() - dst_rules::dst_offset();
+ case is_not_in_dst: return utc_offset_rules::local_to_utc_base_offset();
+ case ambiguous: return utc_offset_rules::local_to_utc_base_offset();
+ case invalid_time_label: throw std::out_of_range("Time label invalid");
+ }
+ }
+ throw std::out_of_range("Time label invalid");
+ }
+
+
+ private:
+
+ };
+
+ void dummy_to_prevent_msvc6_ice(); //why ask why?
+
+ //! 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.
+ *
+ * <b>Template Parameters</b>
+ * -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:
+ * @code
+ * //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;
+ @endcode
+
+ */
+ template<class time_type, short utc_offset, class dst_rule>
+ class local_adjustor
+ {
+ public:
+ typedef typename time_type::time_duration_type time_duration_type;
+ typedef typename time_type::date_type date_type;
+ typedef static_local_time_adjustor<time_type,
+ dst_rule,
+ utc_adjustment<time_duration_type,
+ utc_offset> > dst_adjustor;
+ //! Convert a utc time to local time
+ static time_type utc_to_local(const time_type& t)
+ {
+ time_duration_type td = dst_adjustor::utc_to_local_offset(t);
+ return t + td;
+ }
+ //! Convert a local time to utc
+ static time_type local_to_utc(const time_type& t,
+ date_time::dst_flags dst=date_time::calculate)
+ {
+ time_duration_type td = dst_adjustor::local_to_utc_offset(t, dst);
+ return t + td;
+ }
+ };
+
+
+ } } //namespace date_time
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/local_timezone_defs.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/local_timezone_defs.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,193 @@
+#ifndef DATE_TIME_LOCAL_TIMEZONE_DEFS_HPP__
+#define DATE_TIME_LOCAL_TIMEZONE_DEFS_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/dst_rules.hpp"
+
+namespace boost {
+ namespace date_time {
+
+ // Configurations for common dst rules cases:
+ // See http://www.wharton.co.uk/Support/sup_dst.htm for more
+ // information on how various locales use dst rules
+
+ //! Specification for daylight savings start rules in US
+ /*! This class is used to configure dst_calc_engine template typically
+ as follows:
+ @code
+ 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)
+ {
+
+ }
+
+ @endcode
+ 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.
+
+ */
+
+ template<class date_type>
+ struct us_dst_trait
+ {
+ typedef typename date_type::day_of_week_type day_of_week_type;
+ typedef typename date_type::month_type month_type;
+ typedef typename date_type::year_type year_type;
+ typedef date_time::nth_kday_of_month<date_type> start_rule_functor;
+ typedef date_time::first_kday_of_month<date_type> end_rule_functor;
+ typedef date_time::first_kday_of_month<date_type> start_rule_functor_pre2007;
+ typedef date_time::last_kday_of_month<date_type> end_rule_functor_pre2007;
+ static day_of_week_type start_day(year_type) {return Sunday;}
+ static month_type start_month(year_type y)
+ {
+ if (y < 2007) return Apr;
+ return Mar;
+ }
+ static day_of_week_type end_day(year_type y) {return Sunday;}
+ static month_type end_month(year_type y)
+ {
+ if (y < 2007) return Oct;
+ return Nov;
+ }
+ static date_type local_dst_start_day(year_type year)
+ {
+ if (year < 2007) {
+ start_rule_functor_pre2007 start1(start_day(year),
+ start_month(year));
+ return start1.get_date(year);
+ }
+ start_rule_functor start(start_rule_functor::second,
+ start_day(year),
+ start_month(year));
+ return start.get_date(year);
+
+ }
+ static date_type local_dst_end_day(year_type year)
+ {
+ if (year < 2007) {
+ end_rule_functor_pre2007 end_rule(end_day(year),
+ end_month(year));
+ return end_rule.get_date(year);
+ }
+ end_rule_functor end(end_day(year),
+ end_month(year));
+ return end.get_date(year);
+ }
+ static int dst_start_offset_minutes() { return 120;}
+ static int dst_end_offset_minutes() { return 120; }
+ static int dst_shift_length_minutes() { return 60; }
+ };
+
+ //!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)
+ */
+ template<class date_type>
+ struct eu_dst_trait
+ {
+ typedef typename date_type::day_of_week_type day_of_week_type;
+ typedef typename date_type::month_type month_type;
+ typedef typename date_type::year_type year_type;
+ typedef date_time::last_kday_of_month<date_type> start_rule_functor;
+ typedef date_time::last_kday_of_month<date_type> end_rule_functor;
+ static day_of_week_type start_day(year_type) {return Sunday;}
+ static month_type start_month(year_type) {return Mar;}
+ static day_of_week_type end_day(year_type) {return Sunday;}
+ static month_type end_month(year_type) {return Oct;}
+ static int dst_start_offset_minutes() { return 120;}
+ static int dst_end_offset_minutes() { return 180; }
+ 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);
+ }
+ };
+
+ //! Alternative dst traits for some parts of the United Kingdom
+ /* Several places in the UK 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).
+ */
+ template<class date_type>
+ struct uk_dst_trait : public eu_dst_trait<date_type>
+ {
+ static int dst_start_offset_minutes() { return 60;}
+ static int dst_end_offset_minutes() { return 120; }
+ static int dst_shift_length_minutes() { return 60; }
+ };
+
+ //Rules for Adelaide Australia
+ template<class date_type>
+ struct acst_dst_trait
+ {
+ typedef typename date_type::day_of_week_type day_of_week_type;
+ typedef typename date_type::month_type month_type;
+ typedef typename date_type::year_type year_type;
+ typedef date_time::last_kday_of_month<date_type> start_rule_functor;
+ typedef date_time::last_kday_of_month<date_type> end_rule_functor;
+ static day_of_week_type start_day(year_type) {return Sunday;}
+ static month_type start_month(year_type) {return Oct;}
+ static day_of_week_type end_day(year_type) {return Sunday;}
+ static month_type end_month(year_type) {return Mar;}
+ static int dst_start_offset_minutes() { return 120;}
+ static int dst_end_offset_minutes() { return 180; }
+ 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);
+ }
+ };
+
+
+
+
+
+
+} } //namespace boost::date_time
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/locale_config.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/locale_config.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,31 @@
+#ifndef DATE_TIME_LOCALE_CONFIG_HPP___
+#define DATE_TIME_LOCALE_CONFIG_HPP___
+
+/* 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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+// This file configures whether the library will support locales and hence
+// iostream based i/o. Even if a compiler has some support for locales,
+// any failure to be compatible gets the compiler on the exclusion list.
+//
+// At the moment this is defined for MSVC 6 and any compiler that
+// defines BOOST_NO_STD_LOCALE (gcc 2.95.x)
+
+#include "boost/config.hpp" //sets BOOST_NO_STD_LOCALE
+#include "boost/detail/workaround.hpp"
+
+//This file basically becomes a noop if locales are not properly supported
+#if (defined(BOOST_NO_STD_LOCALE) \
+ || (BOOST_WORKAROUND( BOOST_MSVC, < 1300)) \
+ || (BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT( 0x581 )) ) )
+#define BOOST_DATE_TIME_NO_LOCALE
+#endif
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/microsec_time_clock.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/microsec_time_clock.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,205 @@
+#ifndef DATE_TIME_HIGHRES_TIME_CLOCK_HPP___
+#define DATE_TIME_HIGHRES_TIME_CLOCK_HPP___
+
+/* 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
+ * $Date: 2008-04-16 19:36:30 +0100 (Wed, 16 Apr 2008) $
+ */
+
+
+/*! @file microsec_time_clock.hpp
+ This file contains a high resolution time clock implementation.
+*/
+
+#include <boost/detail/workaround.hpp>
+#include "boost/date_time/c_time.hpp"
+#include "boost/date_time/time_clock.hpp"
+#include "boost/cstdint.hpp"
+#include "boost/shared_ptr.hpp"
+
+#ifdef BOOST_HAS_FTIME
+#include <windows.h>
+#endif
+
+#ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
+
+namespace boost {
+namespace date_time {
+
+
+ //! 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.
+ */
+ template<class time_type>
+ class microsec_clock
+ {
+ public:
+ typedef typename time_type::date_type date_type;
+ typedef typename time_type::time_duration_type time_duration_type;
+ typedef typename time_duration_type::rep_type resolution_traits_type;
+
+ //! return a local time object for the given zone, based on computer clock
+ //JKG -- looks like we could rewrite this against universal_time
+ template<class time_zone_type>
+ static time_type local_time(shared_ptr<time_zone_type> tz_ptr) {
+ typedef typename time_type::utc_time_type utc_time_type;
+ typedef second_clock<utc_time_type> second_clock;
+ // we'll need to know the utc_offset this machine has
+ // in order to get a utc_time_type set to utc
+ utc_time_type utc_time = second_clock::universal_time();
+ time_duration_type utc_offset = second_clock::local_time() - utc_time;
+ // use micro clock to get a local time with sub seconds
+ // and adjust it to get a true utc time reading with sub seconds
+ utc_time = microsec_clock<utc_time_type>::local_time() - utc_offset;
+ return time_type(utc_time, tz_ptr);
+ }
+
+
+ private:
+ // we want this enum available for both platforms yet still private
+ enum TZ_FOR_CREATE { LOCAL, GMT };
+
+ public:
+
+#ifdef BOOST_HAS_GETTIMEOFDAY
+ //! Return the local time based on computer clock settings
+ static time_type local_time() {
+ return create_time(LOCAL);
+ }
+
+ //! Get the current day in universal date as a ymd_type
+ static time_type universal_time()
+ {
+ return create_time(GMT);
+ }
+
+ private:
+ static time_type create_time(TZ_FOR_CREATE tz) {
+ timeval tv;
+ gettimeofday(&tv, 0); //gettimeofday does not support TZ adjust on Linux.
+ std::time_t t = tv.tv_sec;
+ boost::uint32_t fs = tv.tv_usec;
+ std::tm curr, *curr_ptr = 0;
+ if (tz == LOCAL) {
+ curr_ptr = c_time::localtime(&t, &curr);
+ } else {
+ curr_ptr = c_time::gmtime(&t, &curr);
+ }
+ date_type d(curr_ptr->tm_year + 1900,
+ curr_ptr->tm_mon + 1,
+ curr_ptr->tm_mday);
+ //The following line will adjusts the fractional second tick in terms
+ //of the current time system. For example, if the time system
+ //doesn't support fractional seconds then res_adjust returns 0
+ //and all the fractional seconds return 0.
+ int adjust = resolution_traits_type::res_adjust()/1000000;
+
+ time_duration_type td(curr_ptr->tm_hour,
+ curr_ptr->tm_min,
+ curr_ptr->tm_sec,
+ fs*adjust);
+ return time_type(d,td);
+
+ }
+#endif // BOOST_HAS_GETTIMEOFDAY
+
+#ifdef BOOST_HAS_FTIME
+ //! Return the local time based on computer clock settings
+ static time_type local_time() {
+ FILETIME ft;
+ #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
+ // Some runtime library implementations expect local times as the norm for ctime.
+ FILETIME ft_utc;
+ GetSystemTimeAsFileTime(&ft_utc);
+ FileTimeToLocalFileTime(&ft_utc,&ft);
+ #elif defined(BOOST_NO_GETSYSTEMTIMEASFILETIME)
+ SYSTEMTIME st;
+ GetSystemTime( &st );
+ SystemTimeToFileTime( &st, &ft );
+ #else
+ GetSystemTimeAsFileTime(&ft);
+ #endif
+ return create_time(ft, LOCAL);
+ }
+
+ //! Return the UTC time based on computer settings
+ static time_type universal_time() {
+ FILETIME ft;
+ #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205))
+ // Some runtime library implementations expect local times as the norm for ctime.
+ FILETIME ft_utc;
+ GetSystemTimeAsFileTime(&ft_utc);
+ FileTimeToLocalFileTime(&ft_utc,&ft);
+ #elif defined(BOOST_NO_GETSYSTEMTIMEASFILETIME)
+ SYSTEMTIME st;
+ GetSystemTime( &st );
+ SystemTimeToFileTime( &st, &ft );
+ #else
+ GetSystemTimeAsFileTime(&ft);
+ #endif
+ return create_time(ft, GMT);
+ }
+
+ private:
+ static time_type create_time(FILETIME& ft, TZ_FOR_CREATE tz) {
+ // offset is difference (in 100-nanoseconds) from
+ // 1970-Jan-01 to 1601-Jan-01
+ boost::uint64_t c1 = 27111902;
+ boost::uint64_t c2 = 3577643008UL; // 'UL' removes compiler warnings
+ const boost::uint64_t OFFSET = (c1 << 32) + c2;
+
+ boost::uint64_t filetime = ft.dwHighDateTime;
+ filetime = filetime << 32;
+ filetime += ft.dwLowDateTime;
+ filetime -= OFFSET;
+ // filetime now holds 100-nanoseconds since 1970-Jan-01
+
+ // microseconds -- static casts supress warnings
+ boost::uint32_t sub_sec = static_cast<boost::uint32_t>((filetime % 10000000) / 10);
+
+ std::time_t t = static_cast<time_t>(filetime / 10000000); // seconds since epoch
+
+ std::tm curr, *curr_ptr = 0;
+ if (tz == LOCAL) {
+ curr_ptr = c_time::localtime(&t, &curr);
+ }
+ else {
+ curr_ptr = c_time::gmtime(&t, &curr);
+ }
+ date_type d(curr_ptr->tm_year + 1900,
+ curr_ptr->tm_mon + 1,
+ curr_ptr->tm_mday);
+
+ //The following line will adjusts the fractional second tick in terms
+ //of the current time system. For example, if the time system
+ //doesn't support fractional seconds then res_adjust returns 0
+ //and all the fractional seconds return 0.
+ int adjust = static_cast<int>(resolution_traits_type::res_adjust()/1000000);
+
+ time_duration_type td(curr_ptr->tm_hour,
+ curr_ptr->tm_min,
+ curr_ptr->tm_sec,
+ sub_sec * adjust);
+ //st.wMilliseconds * adjust);
+ return time_type(d,td);
+
+ }
+#endif // BOOST_HAS_FTIME
+ };
+
+
+} } //namespace date_time
+
+#endif //BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/parse_format_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/parse_format_base.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,29 @@
+#ifndef DATE_TIME_PARSE_FORMAT_BASE__
+#define DATE_TIME_PARSE_FORMAT_BASE__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+namespace boost {
+namespace date_time {
+
+ //! Enum for distinguishing parsing and formatting options
+ enum month_format_spec {month_as_integer, month_as_short_string,
+ month_as_long_string};
+
+ //! 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 */
+ enum ymd_order_spec {ymd_order_iso, //order is year-month-day
+ ymd_order_dmy, //day-month-year
+ ymd_order_us}; //order is month-day-year
+
+
+} }//namespace date_time
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/period.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/period.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,377 @@
+#ifndef DATE_TIME_PERIOD_HPP___
+#define DATE_TIME_PERIOD_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+/*! \file period.hpp
+ 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.
+
+*/
+
+#include "boost/operators.hpp"
+
+
+namespace boost {
+namespace date_time {
+ //!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).
+
+ */
+ template<class point_rep, class duration_rep>
+ class period : private
+ boost::less_than_comparable<period<point_rep, duration_rep>
+ , boost::equality_comparable< period<point_rep, duration_rep>
+ > >
+ {
+ public:
+ typedef point_rep point_type;
+ typedef duration_rep duration_type;
+
+ period(point_rep first_point, point_rep end_point);
+ period(point_rep first_point, duration_rep len);
+ point_rep begin() const;
+ point_rep end() const;
+ point_rep last() const;
+ duration_rep length() const;
+ bool is_null() const;
+ bool operator==(const period& rhs) const;
+ bool operator<(const period& rhs) const;
+ void shift(const duration_rep& d);
+ void expand(const duration_rep& d);
+ bool contains(const point_rep& point) const;
+ bool contains(const period& other) const;
+ bool intersects(const period& other) const;
+ bool is_adjacent(const period& other) const;
+ bool is_before(const point_rep& point) const;
+ bool is_after(const point_rep& point) const;
+ period intersection(const period& other) const;
+ period merge(const period& other) const;
+ period span(const period& other) const;
+ private:
+ point_rep begin_;
+ point_rep last_;
+ };
+
+ //! create a period from begin to last eg: [begin,end)
+ /*! If end <= begin then the period will be invalid
+ */
+ template<class point_rep, class duration_rep>
+ inline
+ period<point_rep,duration_rep>::period(point_rep first_point,
+ point_rep end_point) :
+ begin_(first_point),
+ last_(end_point - duration_rep::unit())
+ {}
+
+ //! create a period as [begin, begin+len)
+ /*! If len is <= 0 then the period will be invalid
+ */
+ template<class point_rep, class duration_rep>
+ inline
+ period<point_rep,duration_rep>::period(point_rep first_point, duration_rep len) :
+ begin_(first_point),
+ last_(first_point + len-duration_rep::unit())
+ { }
+
+
+ //! Return the first element in the period
+ template<class point_rep, class duration_rep>
+ inline
+ point_rep period<point_rep,duration_rep>::begin() const
+ {
+ return begin_;
+ }
+
+ //! Return one past the last element
+ template<class point_rep, class duration_rep>
+ inline
+ point_rep period<point_rep,duration_rep>::end() const
+ {
+ return last_ + duration_rep::unit();
+ }
+
+ //! Return the last item in the period
+ template<class point_rep, class duration_rep>
+ inline
+ point_rep period<point_rep,duration_rep>::last() const
+ {
+ return last_;
+ }
+
+ //! True if period is ill formed (length is zero or less)
+ template<class point_rep, class duration_rep>
+ inline
+ bool period<point_rep,duration_rep>::is_null() const
+ {
+ return end() <= begin_;
+ }
+
+ //! Return the length of the period
+ template<class point_rep, class duration_rep>
+ inline
+ duration_rep period<point_rep,duration_rep>::length() const
+ {
+ if(last_ < begin_){ // invalid period
+ return last_+duration_rep::unit() - begin_;
+ }
+ else{
+ return end() - begin_; // normal case
+ }
+ }
+
+ //! Equality operator
+ template<class point_rep, class duration_rep>
+ inline
+ bool period<point_rep,duration_rep>::operator==(const period& rhs) const
+ {
+ return ((begin_ == rhs.begin_) &&
+ (last_ == rhs.last_));
+ }
+
+ //! Strict as defined by rhs.last <= lhs.last
+ template<class point_rep, class duration_rep>
+ inline
+ bool period<point_rep,duration_rep>::operator<(const period& rhs) const
+ {
+ return (last_ < rhs.begin_);
+ }
+
+
+ //! Shift the start and end by the specified amount
+ template<class point_rep, class duration_rep>
+ inline
+ void period<point_rep,duration_rep>::shift(const duration_rep& d)
+ {
+ begin_ = begin_ + d;
+ last_ = last_ + d;
+ }
+
+ /** Expands the size of the period by the duration on both ends.
+ *
+ *So before expand
+ *@code
+ *
+ * [-------]
+ * ^ ^ ^ ^ ^ ^ ^
+ * 1 2 3 4 5 6 7
+ *
+ *@endcode
+ * After expand(2)
+ *@code
+ *
+ * [----------------------]
+ * ^ ^ ^ ^ ^ ^ ^
+ * 1 2 3 4 5 6 7
+ *
+ *@endcode
+ */
+ template<class point_rep, class duration_rep>
+ inline
+ void period<point_rep,duration_rep>::expand(const duration_rep& d)
+ {
+ begin_ = begin_ - d;
+ last_ = last_ + d;
+ }
+
+ //! True if the point is inside the period, zero length periods contain no points
+ template<class point_rep, class duration_rep>
+ inline
+ bool period<point_rep,duration_rep>::contains(const point_rep& point) const
+ {
+ return ((point >= begin_) &&
+ (point <= last_));
+ }
+
+
+ //! True if this period fully contains (or equals) the other period
+ template<class point_rep, class duration_rep>
+ inline
+ bool period<point_rep,duration_rep>::contains(const period<point_rep,duration_rep>& other) const
+ {
+ return ((begin_ <= other.begin_) && (last_ >= other.last_));
+ }
+
+
+ //! True if periods are next to each other without a gap.
+ /* In the example below, p1 and p2 are adjacent, but p3 is not adjacent
+ * with either of p1 or p2.
+ *@code
+ * [-p1-)
+ * [-p2-)
+ * [-p3-)
+ *@endcode
+ */
+ template<class point_rep, class duration_rep>
+ inline
+ bool
+ period<point_rep,duration_rep>::is_adjacent(const period<point_rep,duration_rep>& other) const
+ {
+ return (other.begin() == end() ||
+ begin_ == other.end());
+ }
+
+
+ //! True if all of the period is prior or t < start
+ /* In the example below only point 1 would evaluate to true.
+ *@code
+ * [---------])
+ * ^ ^ ^ ^ ^
+ * 1 2 3 4 5
+ *
+ *@endcode
+ */
+ template<class point_rep, class duration_rep>
+ inline
+ bool
+ period<point_rep,duration_rep>::is_after(const point_rep& t) const
+ {
+ if (is_null())
+ {
+ return false; //null period isn't after
+ }
+
+ return t < begin_;
+ }
+
+ //! True if all of the period is prior to the passed point or end <= t
+ /* In the example below points 4 and 5 return true.
+ *@code
+ * [---------])
+ * ^ ^ ^ ^ ^
+ * 1 2 3 4 5
+ *
+ *@endcode
+ */
+ template<class point_rep, class duration_rep>
+ inline
+ bool
+ period<point_rep,duration_rep>::is_before(const point_rep& t) const
+ {
+ if (is_null())
+ {
+ return false; //null period isn't before anything
+ }
+
+ return last_ < t;
+ }
+
+
+ //! True if the periods overlap in any way
+ /* In the example below p1 intersects with p2, p4, and p6.
+ *@code
+ * [---p1---)
+ * [---p2---)
+ * [---p3---)
+ * [---p4---)
+ * [-p5-)
+ * [-p6-)
+ *@endcode
+ */
+ template<class point_rep, class duration_rep>
+ inline
+ bool period<point_rep,duration_rep>::intersects(const period<point_rep,duration_rep>& other) const
+ {
+ return ( contains(other.begin_) ||
+ other.contains(begin_) ||
+ ((other.begin_ < begin_) && (other.last_ >= begin_)));
+ }
+
+ //! Returns the period of intersection or invalid range no intersection
+ template<class point_rep, class duration_rep>
+ inline
+ period<point_rep,duration_rep>
+ period<point_rep,duration_rep>::intersection(const period<point_rep,duration_rep>& other) const
+ {
+ if (begin_ > other.begin_) {
+ if (last_ <= other.last_) { //case2
+ return *this;
+ }
+ //case 1
+ return period<point_rep,duration_rep>(begin_, other.end());
+ }
+ else {
+ if (last_ <= other.last_) { //case3
+ return period<point_rep,duration_rep>(other.begin_, this->end());
+ }
+ //case4
+ return other;
+ }
+ //unreachable
+ }
+
+ //! Returns the union of intersecting periods -- or null period
+ /*!
+ */
+ template<class point_rep, class duration_rep>
+ inline
+ period<point_rep,duration_rep>
+ period<point_rep,duration_rep>::merge(const period<point_rep,duration_rep>& other) const
+ {
+ if (this->intersects(other)) {
+ if (begin_ < other.begin_) {
+ return period<point_rep,duration_rep>(begin_, last_ > other.last_ ? this->end() : other.end());
+ }
+
+ return period<point_rep,duration_rep>(other.begin_, last_ > other.last_ ? this->end() : other.end());
+
+ }
+ return period<point_rep,duration_rep>(begin_,begin_); // no intersect return null
+ }
+
+ //! 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)
+ *@code
+ * [---p1---)
+ * [---p2---)
+ * result:
+ * [-----------p3----------)
+ *@endcode
+ */
+ template<class point_rep, class duration_rep>
+ inline
+ period<point_rep,duration_rep>
+ period<point_rep,duration_rep>::span(const period<point_rep,duration_rep>& other) const
+ {
+ point_rep start((begin_ < other.begin_) ? begin() : other.begin());
+ point_rep newend((last_ < other.last_) ? other.end() : this->end());
+ return period<point_rep,duration_rep>(start, newend);
+ }
+
+
+} } //namespace date_time
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/period_formatter.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/period_formatter.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,196 @@
+
+#ifndef DATETIME_PERIOD_FORMATTER_HPP___
+#define DATETIME_PERIOD_FORMATTER_HPP___
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+
+namespace boost { namespace date_time {
+
+
+ //! 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:
+ *@code
+ * [period.start()/period.last()]
+ *@endcode
+ * So for a typical date_period this would be
+ *@code
+ * [2004-Jan-04/2004-Feb-01]
+ *@endcode
+ * where the date formatting is controlled by the date facet
+ */
+ template <class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
+ class period_formatter {
+ public:
+ typedef std::basic_string<CharT> string_type;
+ typedef CharT char_type;
+ typedef typename std::basic_string<char_type>::const_iterator const_itr_type;
+ typedef std::vector<std::basic_string<CharT> > collection_type;
+
+ static const char_type default_period_separator[2];
+ static const char_type default_period_start_delimeter[2];
+ static const char_type default_period_open_range_end_delimeter[2];
+ static const char_type default_period_closed_range_end_delimeter[2];
+
+ enum range_display_options { AS_OPEN_RANGE, AS_CLOSED_RANGE };
+
+ //! Constructor that sets up period formatter options -- default should suffice most cases.
+ period_formatter(range_display_options range_option_in = AS_CLOSED_RANGE,
+ const char_type* const period_separator = default_period_separator,
+ const char_type* const period_start_delimeter = default_period_start_delimeter,
+ const char_type* const period_open_range_end_delimeter = default_period_open_range_end_delimeter,
+ const char_type* const period_closed_range_end_delimeter = default_period_closed_range_end_delimeter) :
+ m_range_option(range_option_in),
+ m_period_separator(period_separator),
+ m_period_start_delimeter(period_start_delimeter),
+ m_open_range_end_delimeter(period_open_range_end_delimeter),
+ m_closed_range_end_delimeter(period_closed_range_end_delimeter)
+ {}
+
+ //! Puts the characters between period elements into stream -- default is /
+ OutItrT put_period_separator(OutItrT& oitr) const
+ {
+ const_itr_type ci = m_period_separator.begin();
+ while (ci != m_period_separator.end()) {
+ *oitr = *ci;
+ ci++;
+ }
+ return oitr;
+ }
+
+ //! Puts the period start characters into stream -- default is [
+ OutItrT put_period_start_delimeter(OutItrT& oitr) const
+ {
+ const_itr_type ci = m_period_start_delimeter.begin();
+ while (ci != m_period_start_delimeter.end()) {
+ *oitr = *ci;
+ ci++;
+ }
+ return oitr;
+ }
+
+ //! Puts the period end characters into stream as controled by open/closed range setting.
+ OutItrT put_period_end_delimeter(OutItrT& oitr) const
+ {
+
+ const_itr_type ci, end;
+ if (m_range_option == AS_OPEN_RANGE) {
+ ci = m_open_range_end_delimeter.begin();
+ end = m_open_range_end_delimeter.end();
+ }
+ else {
+ ci = m_closed_range_end_delimeter.begin();
+ end = m_closed_range_end_delimeter.end();
+ }
+ while (ci != end) {
+ *oitr = *ci;
+ ci++;
+ }
+ return oitr;
+ }
+
+ range_display_options range_option() const
+ {
+ return m_range_option;
+ }
+
+ //! Reset the range_option control
+ void
+ range_option(range_display_options option) const
+ {
+ m_range_option = option;
+ }
+ void delimiter_strings(const string_type& separator,
+ const string_type& start_delim,
+ const string_type& open_end_delim,
+ const string_type& closed_end_delim)
+ {
+ m_period_separator;
+ m_period_start_delimeter;
+ m_open_range_end_delimeter;
+ m_closed_range_end_delimeter;
+ }
+
+
+ //! 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:
+ *@code
+ *
+ * [March 01, 2004/June 07, 2004] <-- closed range
+ * [March 01, 2004/June 08, 2004) <-- open range
+ *
+ *@endcode
+ */
+ template<class period_type, class facet_type>
+ OutItrT put_period(OutItrT next,
+ std::ios_base& a_ios,
+ char_type a_fill,
+ const period_type& p,
+ const facet_type& facet) const {
+ put_period_start_delimeter(next);
+ next = facet.put(next, a_ios, a_fill, p.begin());
+ put_period_separator(next);
+ if (m_range_option == AS_CLOSED_RANGE) {
+ facet.put(next, a_ios, a_fill, p.last());
+ }
+ else {
+ facet.put(next, a_ios, a_fill, p.end());
+ }
+ put_period_end_delimeter(next);
+ return next;
+ }
+
+
+ private:
+ range_display_options m_range_option;
+ string_type m_period_separator;
+ string_type m_period_start_delimeter;
+ string_type m_open_range_end_delimeter;
+ string_type m_closed_range_end_delimeter;
+ };
+
+ template <class CharT, class OutItrT>
+ const typename period_formatter<CharT, OutItrT>::char_type
+ period_formatter<CharT, OutItrT>::default_period_separator[2] = {'/'};
+
+ template <class CharT, class OutItrT>
+ const typename period_formatter<CharT, OutItrT>::char_type
+ period_formatter<CharT, OutItrT>::default_period_start_delimeter[2] = {'['};
+
+ template <class CharT, class OutItrT>
+ const typename period_formatter<CharT, OutItrT>::char_type
+ period_formatter<CharT, OutItrT>::default_period_open_range_end_delimeter[2] = {')'};
+
+ template <class CharT, class OutItrT>
+ const typename period_formatter<CharT, OutItrT>::char_type
+ period_formatter<CharT, OutItrT>::default_period_closed_range_end_delimeter[2] = {']'};
+
+ } } //namespace boost::date_time
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/period_parser.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/period_parser.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,196 @@
+
+#ifndef DATETIME_PERIOD_PARSER_HPP___
+#define DATETIME_PERIOD_PARSER_HPP___
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/string_parse_tree.hpp"
+#include "boost/date_time/string_convert.hpp"
+
+
+namespace boost { namespace date_time {
+
+
+ //! 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
+ *@code
+ * [2004-Jan-04/2004-Feb-01]
+ *@endcode
+ * where the date format is controlled by the date facet
+ */
+ template<class date_type, typename CharT>
+ class period_parser {
+ public:
+ typedef std::basic_string<CharT> string_type;
+ typedef CharT char_type;
+ //typedef typename std::basic_string<char_type>::const_iterator const_itr_type;
+ typedef std::istreambuf_iterator<CharT> stream_itr_type;
+ typedef string_parse_tree<CharT> parse_tree_type;
+ typedef typename parse_tree_type::parse_match_result_type match_results;
+ typedef std::vector<std::basic_string<CharT> > collection_type;
+
+ static const char_type default_period_separator[2];
+ static const char_type default_period_start_delimeter[2];
+ static const char_type default_period_open_range_end_delimeter[2];
+ static const char_type default_period_closed_range_end_delimeter[2];
+
+ enum period_range_option { AS_OPEN_RANGE, AS_CLOSED_RANGE };
+
+ //! Constructor that sets up period parser options
+ period_parser(period_range_option range_option = AS_CLOSED_RANGE,
+ const char_type* const period_separator = default_period_separator,
+ const char_type* const period_start_delimeter = default_period_start_delimeter,
+ const char_type* const period_open_range_end_delimeter = default_period_open_range_end_delimeter,
+ const char_type* const period_closed_range_end_delimeter = default_period_closed_range_end_delimeter)
+ : m_range_option(range_option)
+ {
+ delimiters.push_back(string_type(period_separator));
+ delimiters.push_back(string_type(period_start_delimeter));
+ delimiters.push_back(string_type(period_open_range_end_delimeter));
+ delimiters.push_back(string_type(period_closed_range_end_delimeter));
+ }
+
+ period_parser(const period_parser<date_type,CharT>& p_parser)
+ {
+ this->delimiters = p_parser.delimiters;
+ this->m_range_option = p_parser.m_range_option;
+ }
+
+ period_range_option range_option() const
+ {
+ return m_range_option;
+ }
+ void range_option(period_range_option option)
+ {
+ m_range_option = option;
+ }
+ collection_type delimiter_strings() const
+ {
+ return delimiters;
+ }
+ void delimiter_strings(const string_type& separator,
+ const string_type& start_delim,
+ const string_type& open_end_delim,
+ const string_type& closed_end_delim)
+ {
+ delimiters.clear();
+ delimiters.push_back(separator);
+ delimiters.push_back(start_delim);
+ delimiters.push_back(open_end_delim);
+ delimiters.push_back(closed_end_delim);
+ }
+
+ //! 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:
+ *@code
+ *
+ * [March 01, 2004/June 07, 2004] <-- closed range
+ * [March 01, 2004/June 08, 2004) <-- open range
+ *
+ *@endcode
+ */
+ template<class period_type, class duration_type, class facet_type>
+ period_type get_period(stream_itr_type& sitr,
+ stream_itr_type& stream_end,
+ std::ios_base& a_ios,
+ const period_type& p,
+ const duration_type& dur_unit,
+ const facet_type& facet) const
+ {
+ // skip leading whitespace
+ while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
+
+ typedef typename period_type::point_type point_type;
+ point_type p1(not_a_date_time), p2(not_a_date_time);
+
+
+ consume_delim(sitr, stream_end, delimiters[START]); // start delim
+ facet.get(sitr, stream_end, a_ios, p1); // first point
+ consume_delim(sitr, stream_end, delimiters[SEPARATOR]); // separator
+ facet.get(sitr, stream_end, a_ios, p2); // second point
+
+ // period construction parameters are always open range [begin, end)
+ if (m_range_option == AS_CLOSED_RANGE) {
+ consume_delim(sitr, stream_end, delimiters[CLOSED_END]);// end delim
+ // add 1 duration unit to p2 to make range open
+ p2 += dur_unit;
+ }
+ else {
+ consume_delim(sitr, stream_end, delimiters[OPEN_END]); // end delim
+ }
+
+ return period_type(p1, p2);
+ }
+
+ private:
+ collection_type delimiters;
+ period_range_option m_range_option;
+
+ enum delim_ids { SEPARATOR, START, OPEN_END, CLOSED_END };
+
+ //! throws ios_base::failure if delimiter and parsed data do not match
+ void consume_delim(stream_itr_type& sitr,
+ stream_itr_type& stream_end,
+ const string_type& delim) const
+ {
+ /* string_parse_tree will not parse a string of punctuation characters
+ * without knowing exactly how many characters to process
+ * Ex [2000. Will not parse out the '[' string without knowing
+ * to process only one character. By using length of the delimiter
+ * string we can safely iterate past it. */
+ string_type s;
+ for(unsigned int i = 0; i < delim.length() && sitr != stream_end; ++i) {
+ s += *sitr;
+ ++sitr;
+ }
+ if(s != delim) {
+ throw std::ios_base::failure("Parse failed. Expected '" + convert_string_type<char_type,char>(delim) + "' but found '" + convert_string_type<char_type,char>(s) + "'");
+ }
+ }
+ };
+
+ template <class date_type, class char_type>
+ const typename period_parser<date_type, char_type>::char_type
+ period_parser<date_type, char_type>::default_period_separator[2] = {'/'};
+
+ template <class date_type, class char_type>
+ const typename period_parser<date_type, char_type>::char_type
+ period_parser<date_type, char_type>::default_period_start_delimeter[2] = {'['};
+
+ template <class date_type, class char_type>
+ const typename period_parser<date_type, char_type>::char_type
+ period_parser<date_type, char_type>::default_period_open_range_end_delimeter[2] = {')'};
+
+ template <class date_type, class char_type>
+ const typename period_parser<date_type, char_type>::char_type
+ period_parser<date_type, char_type>::default_period_closed_range_end_delimeter[2] = {']'};
+
+ } } //namespace boost::date_time
+
+#endif // DATETIME_PERIOD_PARSER_HPP___

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/conversion.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/conversion.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,93 @@
+#ifndef POSIX_TIME_CONVERSION_HPP___
+#define POSIX_TIME_CONVERSION_HPP___
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/posix_time/ptime.hpp"
+#include "boost/date_time/posix_time/posix_time_duration.hpp"
+#include "boost/date_time/filetime_functions.hpp"
+#include "boost/date_time/c_time.hpp"
+#include "boost/date_time/gregorian/conversion.hpp"
+
+namespace boost {
+
+namespace posix_time {
+
+
+ //! Function that converts a time_t into a ptime.
+ inline
+ ptime from_time_t(std::time_t t)
+ {
+ ptime start(gregorian::date(1970,1,1));
+ return start + seconds(static_cast<long>(t));
+ }
+
+ //! Convert a time to a tm structure truncating any fractional seconds
+ inline
+ std::tm to_tm(const boost::posix_time::ptime& t) {
+ std::tm timetm = boost::gregorian::to_tm(t.date());
+ boost::posix_time::time_duration td = t.time_of_day();
+ timetm.tm_hour = td.hours();
+ timetm.tm_min = td.minutes();
+ timetm.tm_sec = td.seconds();
+ timetm.tm_isdst = -1; // -1 used when dst info is unknown
+ return timetm;
+ }
+ //! Convert a time_duration to a tm structure truncating any fractional seconds and zeroing fields for date components
+ inline
+ std::tm to_tm(const boost::posix_time::time_duration& td) {
+ std::tm timetm;
+ timetm.tm_year = 0;
+ timetm.tm_mon = 0;
+ timetm.tm_mday = 0;
+ timetm.tm_wday = 0;
+ timetm.tm_yday = 0;
+
+ timetm.tm_hour = date_time::absolute_value(td.hours());
+ timetm.tm_min = date_time::absolute_value(td.minutes());
+ timetm.tm_sec = date_time::absolute_value(td.seconds());
+ timetm.tm_isdst = -1; // -1 used when dst info is unknown
+ return timetm;
+ }
+
+ //! Convert a tm struct to a ptime ignoring is_dst flag
+ inline
+ ptime ptime_from_tm(const std::tm& timetm) {
+ boost::gregorian::date d = boost::gregorian::date_from_tm(timetm);
+ return ptime(d, time_duration(timetm.tm_hour, timetm.tm_min, timetm.tm_sec));
+ }
+
+
+#if defined(BOOST_HAS_FTIME)
+
+ //! Function to create a time object from an initialized FILETIME struct.
+ /*! Function to create a time object from an initialized FILETIME struct.
+ * A FILETIME struct holds 100-nanosecond units (0.0000001). When
+ * built with microsecond resolution the FILETIME's sub second value
+ * will be truncated. Nanosecond resolution has no truncation.
+ *
+ * Note ftime is part of the Win32 API, so it is not portable to non-windows
+ * platforms.
+ */
+ template<class time_type>
+ inline
+ time_type from_ftime(const FILETIME& ft)
+ {
+ return boost::date_time::time_from_ftime<time_type>(ft);
+ }
+
+#endif // BOOST_HAS_FTIME
+
+} } //namespace boost::posix_time
+
+
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/date_duration_operators.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/date_duration_operators.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,114 @@
+#ifndef DATE_DURATION_OPERATORS_HPP___
+#define DATE_DURATION_OPERATORS_HPP___
+
+/* Copyright (c) 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/greg_duration_types.hpp"
+#include "boost/date_time/posix_time/ptime.hpp"
+
+namespace boost {
+namespace posix_time {
+
+ /*!@file date_duration_operators.hpp Operators for ptime and
+ * optional gregorian types. Operators use snap-to-end-of-month behavior.
+ * Further details on this behavior can be found in reference for
+ * date_time/date_duration_types.hpp and documentation for
+ * month and year iterators.
+ */
+
+
+ /*! Adds a months object and a ptime. Result will be same
+ * day-of-month as ptime unless original day was the last day of month.
+ * see date_time::months_duration for more details */
+ inline
+ ptime
+ operator+(const ptime& t, const boost::gregorian::months& m)
+ {
+ return t + m.get_offset(t.date());
+ }
+
+ /*! Adds a months object to a ptime. Result will be same
+ * day-of-month as ptime unless original day was the last day of month.
+ * see date_time::months_duration for more details */
+ inline
+ ptime
+ operator+=(ptime& t, const boost::gregorian::months& m)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return t += m.get_offset(t.date());
+ }
+
+ /*! Subtracts a months object and a ptime. Result will be same
+ * day-of-month as ptime unless original day was the last day of month.
+ * see date_time::months_duration for more details */
+ inline
+ ptime
+ operator-(const ptime& t, const boost::gregorian::months& m)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return t + m.get_neg_offset(t.date());
+ }
+
+ /*! Subtracts a months object from a ptime. Result will be same
+ * day-of-month as ptime unless original day was the last day of month.
+ * see date_time::months_duration for more details */
+ inline
+ ptime
+ operator-=(ptime& t, const boost::gregorian::months& m)
+ {
+ return t += m.get_neg_offset(t.date());
+ }
+
+ // ptime & years
+
+ /*! Adds a years object and a ptime. Result will be same
+ * month and day-of-month as ptime unless original day was the
+ * last day of month. see date_time::years_duration for more details */
+ inline
+ ptime
+ operator+(const ptime& t, const boost::gregorian::years& y)
+ {
+ return t + y.get_offset(t.date());
+ }
+
+ /*! Adds a years object to a ptime. Result will be same
+ * month and day-of-month as ptime unless original day was the
+ * last day of month. see date_time::years_duration for more details */
+ inline
+ ptime
+ operator+=(ptime& t, const boost::gregorian::years& y)
+ {
+ return t += y.get_offset(t.date());
+ }
+
+ /*! Subtracts a years object and a ptime. Result will be same
+ * month and day-of-month as ptime unless original day was the
+ * last day of month. see date_time::years_duration for more details */
+ inline
+ ptime
+ operator-(const ptime& t, const boost::gregorian::years& y)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return t + y.get_neg_offset(t.date());
+ }
+
+ /*! Subtracts a years object from a ptime. Result will be same
+ * month and day-of-month as ptime unless original day was the
+ * last day of month. see date_time::years_duration for more details */
+ inline
+ ptime
+ operator-=(ptime& t, const boost::gregorian::years& y)
+ {
+ // get_neg_offset returns a negative duration, so we add
+ return t += y.get_neg_offset(t.date());
+ }
+
+}} // namespaces
+
+#endif // DATE_DURATION_OPERATORS_HPP___

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,39 @@
+#ifndef POSIX_TIME_HPP___
+#define POSIX_TIME_HPP___
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+/*!@file posix_time.hpp Global header file to get all of posix time types
+ */
+
+#include "boost/date_time/compiler_config.hpp"
+#include "boost/date_time/posix_time/ptime.hpp"
+#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
+#include "boost/date_time/posix_time/date_duration_operators.hpp"
+#endif
+
+// output functions
+#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 // BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS
+
+// streaming operators
+#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
+#include "boost/date_time/posix_time/posix_time_legacy_io.hpp"
+#else
+#include "boost/date_time/posix_time/posix_time_io.hpp"
+#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
+
+#include "boost/date_time/posix_time/time_parsers.hpp"
+#include "boost/date_time/posix_time/conversion.hpp"
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_config.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_config.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,178 @@
+#ifndef POSIX_TIME_CONFIG_HPP___
+#define POSIX_TIME_CONFIG_HPP___
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/time_duration.hpp"
+#include "boost/date_time/time_resolution_traits.hpp"
+#include "boost/date_time/gregorian/gregorian_types.hpp"
+#include "boost/date_time/wrapping_int.hpp"
+#include "boost/limits.hpp"
+#include "boost/date_time/compiler_config.hpp"
+#include "boost/cstdint.hpp"
+#include <cmath>
+#include <cstdlib> //for MCW 7.2 std::abs(long long)
+
+namespace boost {
+namespace posix_time {
+
+//Remove the following line if you want 64 bit millisecond resolution time
+//#define BOOST_GDTL_POSIX_TIME_STD_CONFIG
+
+#ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
+ // set up conditional test compilations
+#define BOOST_DATE_TIME_HAS_MILLISECONDS
+#define BOOST_DATE_TIME_HAS_MICROSECONDS
+#define BOOST_DATE_TIME_HAS_NANOSECONDS
+ typedef date_time::time_resolution_traits<boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::nano,
+ 1000000000, 9 > time_res_traits;
+#else
+ // set up conditional test compilations
+#define BOOST_DATE_TIME_HAS_MILLISECONDS
+#define BOOST_DATE_TIME_HAS_MICROSECONDS
+#undef BOOST_DATE_TIME_HAS_NANOSECONDS
+ typedef date_time::time_resolution_traits<
+ boost::date_time::time_resolution_traits_adapted64_impl, boost::date_time::micro,
+ 1000000, 6 > time_res_traits;
+
+
+// #undef BOOST_DATE_TIME_HAS_MILLISECONDS
+// #undef BOOST_DATE_TIME_HAS_MICROSECONDS
+// #undef BOOST_DATE_TIME_HAS_NANOSECONDS
+// typedef date_time::time_resolution_traits<boost::int64_t, boost::date_time::tenth,
+// 10, 0 > time_res_traits;
+
+#endif
+
+
+ //! Base time duration type
+ /*! \ingroup time_basics
+ */
+ class time_duration :
+ public date_time::time_duration<time_duration, time_res_traits>
+ {
+ public:
+ typedef time_res_traits rep_type;
+ typedef time_res_traits::day_type day_type;
+ typedef time_res_traits::hour_type hour_type;
+ typedef time_res_traits::min_type min_type;
+ typedef time_res_traits::sec_type sec_type;
+ typedef time_res_traits::fractional_seconds_type fractional_seconds_type;
+ typedef time_res_traits::tick_type tick_type;
+ typedef time_res_traits::impl_type impl_type;
+ time_duration(hour_type hour,
+ min_type min,
+ sec_type sec,
+ fractional_seconds_type fs=0) :
+ date_time::time_duration<time_duration, time_res_traits>(hour,min,sec,fs)
+ {}
+ time_duration() :
+ date_time::time_duration<time_duration, time_res_traits>(0,0,0)
+ {}
+ //! Construct from special_values
+ time_duration(boost::date_time::special_values sv) :
+ date_time::time_duration<time_duration, time_res_traits>(sv)
+ {}
+ //Give duration access to ticks constructor -- hide from users
+ friend class date_time::time_duration<time_duration, time_res_traits>;
+ private:
+ explicit time_duration(impl_type ticks) :
+ date_time::time_duration<time_duration, time_res_traits>(ticks)
+ {}
+ };
+
+#ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
+
+ //! Simple implementation for the time rep
+ struct simple_time_rep
+ {
+ typedef gregorian::date date_type;
+ typedef time_duration time_duration_type;
+ simple_time_rep(date_type d, time_duration_type tod) :
+ day(d),
+ time_of_day(tod)
+ {
+ // make sure we have sane values for date & time
+ if(!day.is_special() && !time_of_day.is_special()){
+ if(time_of_day >= time_duration_type(24,0,0)) {
+ while(time_of_day >= time_duration_type(24,0,0)) {
+ day += date_type::duration_type(1);
+ time_of_day -= time_duration_type(24,0,0);
+ }
+ }
+ else if(time_of_day.is_negative()) {
+ while(time_of_day.is_negative()) {
+ day -= date_type::duration_type(1);
+ time_of_day += time_duration_type(24,0,0);
+ }
+ }
+ }
+ }
+ date_type day;
+ time_duration_type time_of_day;
+ bool is_special()const
+ {
+ return(is_pos_infinity() || is_neg_infinity() || is_not_a_date_time());
+ }
+ bool is_pos_infinity()const
+ {
+ return(day.is_pos_infinity() || time_of_day.is_pos_infinity());
+ }
+ bool is_neg_infinity()const
+ {
+ return(day.is_neg_infinity() || time_of_day.is_neg_infinity());
+ }
+ bool is_not_a_date_time()const
+ {
+ return(day.is_not_a_date() || time_of_day.is_not_a_date_time());
+ }
+ };
+
+ class posix_time_system_config
+ {
+ public:
+ typedef simple_time_rep time_rep_type;
+ typedef gregorian::date date_type;
+ typedef gregorian::date_duration date_duration_type;
+ typedef time_duration time_duration_type;
+ typedef time_res_traits::tick_type int_type;
+ typedef time_res_traits resolution_traits;
+#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
+#else
+ BOOST_STATIC_CONSTANT(boost::int64_t, tick_per_second = 1000000000);
+#endif
+ };
+
+#else
+
+ class millisec_posix_time_system_config
+ {
+ public:
+ typedef boost::int64_t time_rep_type;
+ //typedef time_res_traits::tick_type time_rep_type;
+ typedef gregorian::date date_type;
+ typedef gregorian::date_duration date_duration_type;
+ typedef time_duration time_duration_type;
+ typedef time_res_traits::tick_type int_type;
+ typedef time_res_traits::impl_type impl_type;
+ typedef time_res_traits resolution_traits;
+#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
+#else
+ BOOST_STATIC_CONSTANT(boost::int64_t, tick_per_second = 1000000);
+#endif
+ };
+
+#endif
+
+} }//namespace posix_time
+
+
+#endif
+
+

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_duration.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_duration.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,82 @@
+#ifndef POSIX_TIME_DURATION_HPP___
+#define POSIX_TIME_DURATION_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/posix_time/posix_time_config.hpp"
+
+namespace boost {
+namespace posix_time {
+
+ //! Allows expression of durations as an hour count
+ /*! \ingroup time_basics
+ */
+ class hours : public time_duration
+ {
+ public:
+ explicit hours(long h) :
+ time_duration(h,0,0)
+ {}
+ };
+
+ //! Allows expression of durations as a minute count
+ /*! \ingroup time_basics
+ */
+ class minutes : public time_duration
+ {
+ public:
+ explicit minutes(long m) :
+ time_duration(0,m,0)
+ {}
+ };
+
+ //! Allows expression of durations as a seconds count
+ /*! \ingroup time_basics
+ */
+ class seconds : public time_duration
+ {
+ public:
+ explicit seconds(long s) :
+ time_duration(0,0,s)
+ {}
+ };
+
+
+ //! Allows expression of durations as milli seconds
+ /*! \ingroup time_basics
+ */
+ typedef date_time::subsecond_duration<time_duration,1000> millisec;
+ typedef date_time::subsecond_duration<time_duration,1000> milliseconds;
+
+ //! Allows expression of durations as micro seconds
+ /*! \ingroup time_basics
+ */
+ typedef date_time::subsecond_duration<time_duration,1000000> microsec;
+ typedef date_time::subsecond_duration<time_duration,1000000> microseconds;
+
+ //This is probably not needed anymore...
+#if defined(BOOST_DATE_TIME_HAS_NANOSECONDS)
+
+ //! Allows expression of durations as nano seconds
+ /*! \ingroup time_basics
+ */
+ typedef date_time::subsecond_duration<time_duration,1000000000> nanosec;
+ typedef date_time::subsecond_duration<time_duration,1000000000> nanoseconds;
+
+
+#endif
+
+
+
+
+} }//namespace posix_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_io.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_io.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,246 @@
+#ifndef DATE_TIME_POSIX_TIME_IO_HPP__
+#define DATE_TIME_POSIX_TIME_IO_HPP__
+
+/* Copyright (c) 2004-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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/time_facet.hpp"
+#include "boost/date_time/period_formatter.hpp"
+#include "boost/date_time/posix_time/time_period.hpp"
+#include "boost/date_time/posix_time/posix_time_duration.hpp"
+//#include "boost/date_time/gregorian/gregorian_io.hpp"
+#include "boost/io/ios_state.hpp"
+#include <iostream>
+#include <locale>
+
+namespace boost {
+namespace posix_time {
+
+
+ //! wptime_facet is depricated and will be phased out. use wtime_facet instead
+ //typedef boost::date_time::time_facet<ptime, wchar_t> wptime_facet;
+ //! ptime_facet is depricated and will be phased out. use time_facet instead
+ //typedef boost::date_time::time_facet<ptime, char> ptime_facet;
+
+ //! wptime_input_facet is depricated and will be phased out. use wtime_input_facet instead
+ //typedef boost::date_time::time_input_facet<ptime,wchar_t> wptime_input_facet;
+ //! ptime_input_facet is depricated and will be phased out. use time_input_facet instead
+ //typedef boost::date_time::time_input_facet<ptime,char> ptime_input_facet;
+
+ typedef boost::date_time::time_facet<ptime, wchar_t> wtime_facet;
+ typedef boost::date_time::time_facet<ptime, char> time_facet;
+
+ typedef boost::date_time::time_input_facet<ptime, wchar_t> wtime_input_facet;
+ typedef boost::date_time::time_input_facet<ptime, char> time_input_facet;
+
+ template <class CharT, class TraitsT>
+ inline
+ std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os,
+ const ptime& p) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet;
+ typedef std::time_put<CharT> std_ptime_facet;
+ std::ostreambuf_iterator<CharT> oitr(os);
+ if (std::has_facet<custom_ptime_facet>(os.getloc()))
+ std::use_facet<custom_ptime_facet>(os.getloc()).put(oitr, os, os.fill(), p);
+ else {
+ //instantiate a custom facet for dealing with times since the user
+ //has not put one in the stream so far. This is for efficiency
+ //since we would always need to reconstruct for every time period
+ //if the locale did not already exist. Of course this will be overridden
+ //if the user imbues as some later point.
+ std::ostreambuf_iterator<CharT> oitr(os);
+ custom_ptime_facet* f = new custom_ptime_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(oitr, os, os.fill(), p);
+ }
+ return os;
+ }
+
+ //! input operator for ptime
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, ptime& pt)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<time_input_facet>(is.getloc())) {
+ std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, pt);
+ }
+ else {
+ time_input_facet* f = new time_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, pt);
+ }
+ }
+ catch(...) {
+ // mask tells us what exceptions are turned on
+ std::ios_base::iostate exception_mask = is.exceptions();
+ // if the user wants exceptions on failbit, we'll rethrow our
+ // date_time exception & set the failbit
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {} // ignore this one
+ throw; // rethrow original exception
+ }
+ else {
+ // if the user want's to fail quietly, we simply set the failbit
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+
+ template <class CharT, class TraitsT>
+ inline
+ std::basic_ostream<CharT, TraitsT>&
+ operator<<(std::basic_ostream<CharT, TraitsT>& os,
+ const boost::posix_time::time_period& p) {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet;
+ typedef std::time_put<CharT> std_time_facet;
+ std::ostreambuf_iterator<CharT> oitr(os);
+ if (std::has_facet<custom_ptime_facet>(os.getloc())) {
+ std::use_facet<custom_ptime_facet>(os.getloc()).put(oitr, os, os.fill(), p);
+ }
+ else {
+ //instantiate a custom facet for dealing with periods since the user
+ //has not put one in the stream so far. This is for efficiency
+ //since we would always need to reconstruct for every time period
+ //if the local did not already exist. Of course this will be overridden
+ //if the user imbues as some later point.
+ std::ostreambuf_iterator<CharT> oitr(os);
+ custom_ptime_facet* f = new custom_ptime_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(oitr, os, os.fill(), p);
+ }
+ return os;
+ }
+
+ //! input operator for time_period
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, time_period& tp)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<time_input_facet>(is.getloc())) {
+ std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, tp);
+ }
+ else {
+ time_input_facet* f = new time_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, tp);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+
+ //! ostream operator for posix_time::time_duration
+ // todo fix to use facet -- place holder for now...
+ template <class CharT, class Traits>
+ inline
+ std::basic_ostream<CharT, Traits>&
+ operator<<(std::basic_ostream<CharT, Traits>& os, const time_duration& td)
+ {
+ boost::io::ios_flags_saver iflags(os);
+ typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet;
+ typedef std::time_put<CharT> std_ptime_facet;
+ std::ostreambuf_iterator<CharT> oitr(os);
+ if (std::has_facet<custom_ptime_facet>(os.getloc()))
+ std::use_facet<custom_ptime_facet>(os.getloc()).put(oitr, os, os.fill(), td);
+ else {
+ //instantiate a custom facet for dealing with times since the user
+ //has not put one in the stream so far. This is for efficiency
+ //since we would always need to reconstruct for every time period
+ //if the locale did not already exist. Of course this will be overridden
+ //if the user imbues as some later point.
+ std::ostreambuf_iterator<CharT> oitr(os);
+ custom_ptime_facet* f = new custom_ptime_facet();
+ std::locale l = std::locale(os.getloc(), f);
+ os.imbue(l);
+ f->put(oitr, os, os.fill(), td);
+ }
+ return os;
+ }
+
+ //! input operator for time_duration
+ template <class CharT, class Traits>
+ inline
+ std::basic_istream<CharT, Traits>&
+ operator>>(std::basic_istream<CharT, Traits>& is, time_duration& td)
+ {
+ boost::io::ios_flags_saver iflags(is);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ if (strm_sentry) {
+ try {
+ typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
+
+ std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
+ if(std::has_facet<time_input_facet>(is.getloc())) {
+ std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, td);
+ }
+ else {
+ time_input_facet* f = new time_input_facet();
+ std::locale l = std::locale(is.getloc(), f);
+ is.imbue(l);
+ f->get(sit, str_end, is, td);
+ }
+ }
+ catch(...) {
+ std::ios_base::iostate exception_mask = is.exceptions();
+ if(std::ios_base::failbit & exception_mask) {
+ try { is.setstate(std::ios_base::failbit); }
+ catch(std::ios_base::failure&) {}
+ throw; // rethrow original exception
+ }
+ else {
+ is.setstate(std::ios_base::failbit);
+ }
+
+ }
+ }
+ return is;
+ }
+
+} } // namespaces
+#endif // DATE_TIME_POSIX_TIME_IO_HPP__

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_legacy_io.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_legacy_io.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,153 @@
+#ifndef POSIX_TIME_PRE133_OPERATORS_HPP___
+#define POSIX_TIME_PRE133_OPERATORS_HPP___
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+/*! @file posix_time_pre133_operators.hpp
+ * These input and output operators are for use with the
+ * pre 1.33 version of the date_time libraries io facet code.
+ * The operators used in version 1.33 and later can be found
+ * in posix_time_io.hpp */
+
+#include <iostream>
+#include <string>
+#include <sstream>
+#include "boost/date_time/compiler_config.hpp"
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include "boost/date_time/posix_time/posix_time_duration.hpp"
+#include "boost/date_time/posix_time/ptime.hpp"
+#include "boost/date_time/posix_time/time_period.hpp"
+#include "boost/date_time/time_parsing.hpp"
+
+namespace boost {
+namespace posix_time {
+
+
+//The following code is removed for configurations with poor std::locale support (eg: MSVC6, gcc 2.9x)
+#ifndef BOOST_DATE_TIME_NO_LOCALE
+#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
+ //! ostream operator for posix_time::time_duration
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os, const time_duration& td)
+ {
+ typedef boost::date_time::ostream_time_duration_formatter<time_duration, charT> duration_formatter;
+ duration_formatter::duration_put(td, os);
+ return os;
+ }
+
+ //! ostream operator for posix_time::ptime
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os, const ptime& t)
+ {
+ typedef boost::date_time::ostream_time_formatter<ptime, charT> time_formatter;
+ time_formatter::time_put(t, os);
+ return os;
+ }
+
+ //! ostream operator for posix_time::time_period
+ template <class charT, class traits>
+ inline
+ std::basic_ostream<charT, traits>&
+ operator<<(std::basic_ostream<charT, traits>& os, const time_period& tp)
+ {
+ typedef boost::date_time::ostream_time_period_formatter<time_period, charT> period_formatter;
+ period_formatter::period_put(tp, os);
+ return os;
+ }
+#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
+/******** input streaming ********/
+ template<class charT>
+ inline
+ std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is, time_duration& td)
+ {
+ // need to create a std::string and parse it
+ std::basic_string<charT> inp_s;
+ std::stringstream out_ss;
+ is >> inp_s;
+ typename std::basic_string<charT>::iterator b = inp_s.begin();
+ // need to use both iterators because there is no requirement
+ // for the data held by a std::basic_string<> be terminated with
+ // any marker (such as '\0').
+ typename std::basic_string<charT>::iterator e = inp_s.end();
+ while(b != e){
+ out_ss << out_ss.narrow(*b, 0);
+ ++b;
+ }
+
+ td = date_time::parse_delimited_time_duration<time_duration>(out_ss.str());
+ return is;
+ }
+
+ template<class charT>
+ inline
+ std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is, ptime& pt)
+ {
+ gregorian::date d(not_a_date_time);
+ time_duration td(0,0,0);
+ is >> d >> td;
+ pt = ptime(d, td);
+
+ return is;
+ }
+
+ /** operator>> for time_period. time_period must be in
+ * "[date time_duration/date time_duration]" format. */
+ template<class charT>
+ inline
+ std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is, time_period& tp)
+ {
+ gregorian::date d(not_a_date_time);
+ time_duration td(0,0,0);
+ ptime beg(d, td);
+ ptime end(beg);
+ std::basic_string<charT> s;
+ // get first date string and remove leading '['
+ is >> s;
+ {
+ std::basic_stringstream<charT> ss;
+ ss << s.substr(s.find('[')+1);
+ ss >> d;
+ }
+ // get first time_duration & second date string, remove the '/'
+ // and split into 2 strings
+ is >> s;
+ {
+ std::basic_stringstream<charT> ss;
+ ss << s.substr(0, s.find('/'));
+ ss >> td;
+ }
+ beg = ptime(d, td);
+ {
+ std::basic_stringstream<charT> ss;
+ ss << s.substr(s.find('/')+1);
+ ss >> d;
+ }
+ // get last time_duration and remove the trailing ']'
+ is >> s;
+ {
+ std::basic_stringstream<charT> ss;
+ ss << s.substr(0, s.find(']'));
+ ss >> td;
+ }
+ end = ptime(d, td);
+
+ tp = time_period(beg,end);
+ return is;
+ }
+
+
+#endif //BOOST_DATE_TIME_NO_LOCALE
+
+} } // namespaces
+
+#endif // POSIX_TIME_PRE133_OPERATORS_HPP___

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_system.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_system.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,68 @@
+#ifndef POSIX_TIME_SYSTEM_HPP___
+#define POSIX_TIME_SYSTEM_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/posix_time/posix_time_config.hpp"
+#include "boost/date_time/time_system_split.hpp"
+#include "boost/date_time/time_system_counted.hpp"
+#include "boost/date_time/compiler_config.hpp"
+
+
+namespace boost {
+namespace posix_time {
+
+#ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
+
+#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT)) //help bad compilers
+ typedef date_time::split_timedate_system<posix_time_system_config, 1000000000> posix_time_system;
+#else
+ typedef date_time::split_timedate_system<posix_time_system_config> posix_time_system;
+#endif
+
+#else
+
+ typedef date_time::counted_time_rep<millisec_posix_time_system_config> int64_time_rep;
+ typedef date_time::counted_time_system<int64_time_rep> posix_time_system;
+
+#endif
+
+} }//namespace posix_time
+
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_types.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/posix_time_types.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,55 @@
+/* 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
+ */
+#ifndef POSIX_TIME_TYPES_HPP___
+#define POSIX_TIME_TYPES_HPP___
+
+#include "boost/date_time/time_clock.hpp"
+#include "boost/date_time/microsec_time_clock.hpp"
+#include "boost/date_time/posix_time/ptime.hpp"
+#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
+#include "boost/date_time/posix_time/date_duration_operators.hpp"
+#endif
+#include "boost/date_time/posix_time/posix_time_duration.hpp"
+#include "boost/date_time/posix_time/posix_time_system.hpp"
+#include "boost/date_time/posix_time/time_period.hpp"
+#include "boost/date_time/time_iterator.hpp"
+#include "boost/date_time/dst_rules.hpp"
+
+namespace boost {
+
+//!Defines a non-adjusted time system with nano-second resolution and stable calculation properties
+namespace posix_time {
+
+ //! Iterator over a defined time duration
+ /*! \ingroup time_basics
+ */
+ typedef date_time::time_itr<ptime> time_iterator;
+ //! A time clock that has a resolution of one second
+ /*! \ingroup time_basics
+ */
+ typedef date_time::second_clock<ptime> second_clock;
+
+#ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
+ //! A time clock that has a resolution of one microsecond
+ /*! \ingroup time_basics
+ */
+ typedef date_time::microsec_clock<ptime> microsec_clock;
+#endif
+
+ //! Define a dst null dst rule for the posix_time system
+ typedef date_time::null_dst_rules<ptime::date_type, time_duration> no_dst;
+ //! Define US dst rule calculator for the posix_time system
+ typedef date_time::us_dst_rules<ptime::date_type, time_duration> us_dst;
+
+
+} } //namespace posix_time
+
+
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/ptime.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/ptime.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,65 @@
+#ifndef POSIX_PTIME_HPP___
+#define POSIX_PTIME_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/posix_time/posix_time_system.hpp"
+#include "boost/date_time/time.hpp"
+
+namespace boost {
+
+namespace posix_time {
+
+ //bring special enum values into the namespace
+ using date_time::special_values;
+ using date_time::not_special;
+ using date_time::neg_infin;
+ using date_time::pos_infin;
+ using date_time::not_a_date_time;
+ using date_time::max_date_time;
+ using date_time::min_date_time;
+
+ //! Time type with no timezone or other adjustments
+ /*! \ingroup time_basics
+ */
+ class ptime : public date_time::base_time<ptime, posix_time_system>
+ {
+ public:
+ typedef posix_time_system time_system_type;
+ typedef time_system_type::time_rep_type time_rep_type;
+ typedef time_system_type::time_duration_type time_duration_type;
+ typedef ptime time_type;
+ //! Construct with date and offset in day
+ ptime(gregorian::date d,time_duration_type td) : date_time::base_time<time_type,time_system_type>(d,td)
+ {}
+ //! Construct a time at start of the given day (midnight)
+ explicit ptime(gregorian::date d) : date_time::base_time<time_type,time_system_type>(d,time_duration_type(0,0,0))
+ {}
+ //! Copy from time_rep
+ ptime(const time_rep_type& rhs):
+ date_time::base_time<time_type,time_system_type>(rhs)
+ {}
+ //! Construct from special value
+ ptime(const special_values sv) : date_time::base_time<time_type,time_system_type>(sv)
+ {}
+#if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
+ // Default constructor constructs to not_a_date_time
+ ptime() : date_time::base_time<time_type,time_system_type>(gregorian::date(not_a_date_time), time_duration_type(not_a_date_time))
+ {}
+#endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR
+
+ };
+
+
+
+} }//namespace posix_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_formatters.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_formatters.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,289 @@
+#ifndef POSIXTIME_FORMATTERS_HPP___
+#define POSIXTIME_FORMATTERS_HPP___
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include "boost/date_time/compiler_config.hpp"
+#include "boost/date_time/iso_format.hpp"
+#include "boost/date_time/date_format_simple.hpp"
+#include "boost/date_time/posix_time/posix_time_types.hpp"
+#include "boost/date_time/time_formatting_streams.hpp"
+
+#include "boost/date_time/time_parsing.hpp"
+
+/* NOTE: The "to_*_string" code for older compilers, ones that define
+ * BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS, is located in
+ * formatters_limited.hpp
+ */
+
+namespace boost {
+
+namespace posix_time {
+
+ // template function called by wrapper functions:
+ // to_*_string(time_duration) & to_*_wstring(time_duration)
+ template<class charT>
+ inline std::basic_string<charT> to_simple_string_type(time_duration td) {
+ std::basic_ostringstream<charT> ss;
+ if(td.is_special()) {
+ /* simply using 'ss << td.get_rep()' won't work on compilers
+ * that don't support locales. This way does. */
+ // switch copied from date_names_put.hpp
+ switch(td.get_rep().as_special())
+ {
+ case not_a_date_time:
+ //ss << "not-a-number";
+ ss << "not-a-date-time";
+ break;
+ case pos_infin:
+ ss << "+infinity";
+ break;
+ case neg_infin:
+ ss << "-infinity";
+ break;
+ default:
+ ss << "";
+ }
+ }
+ else {
+ charT fill_char = '0';
+ if(td.is_negative()) {
+ ss << '-';
+ }
+ ss << std::setw(2) << std::setfill(fill_char)
+ << date_time::absolute_value(td.hours()) << ":";
+ ss << std::setw(2) << std::setfill(fill_char)
+ << date_time::absolute_value(td.minutes()) << ":";
+ ss << std::setw(2) << std::setfill(fill_char)
+ << date_time::absolute_value(td.seconds());
+ //TODO the following is totally non-generic, yelling FIXME
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ boost::int64_t frac_sec =
+ date_time::absolute_value(td.fractional_seconds());
+ // JDG [7/6/02 VC++ compatibility]
+ charT buff[32];
+ _i64toa(frac_sec, buff, 10);
+#else
+ time_duration::fractional_seconds_type frac_sec =
+ date_time::absolute_value(td.fractional_seconds());
+#endif
+ if (frac_sec != 0) {
+ ss << "." << std::setw(time_duration::num_fractional_digits())
+ << std::setfill(fill_char)
+
+ // JDG [7/6/02 VC++ compatibility]
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ << buff;
+#else
+ << frac_sec;
+#endif
+ }
+ }// else
+ return ss.str();
+ }
+ //! Time duration to string -hh::mm::ss.fffffff. Example: 10:09:03.0123456
+ /*!\ingroup time_format
+ */
+ inline std::string to_simple_string(time_duration td) {
+ return to_simple_string_type<char>(td);
+ }
+
+
+ // template function called by wrapper functions:
+ // to_*_string(time_duration) & to_*_wstring(time_duration)
+ template<class charT>
+ inline std::basic_string<charT> to_iso_string_type(time_duration td)
+ {
+ std::basic_ostringstream<charT> ss;
+ if(td.is_special()) {
+ /* simply using 'ss << td.get_rep()' won't work on compilers
+ * that don't support locales. This way does. */
+ // switch copied from date_names_put.hpp
+ switch(td.get_rep().as_special()) {
+ case not_a_date_time:
+ //ss << "not-a-number";
+ ss << "not-a-date-time";
+ break;
+ case pos_infin:
+ ss << "+infinity";
+ break;
+ case neg_infin:
+ ss << "-infinity";
+ break;
+ default:
+ ss << "";
+ }
+ }
+ else {
+ charT fill_char = '0';
+ if(td.is_negative()) {
+ ss << '-';
+ }
+ ss << std::setw(2) << std::setfill(fill_char)
+ << date_time::absolute_value(td.hours());
+ ss << std::setw(2) << std::setfill(fill_char)
+ << date_time::absolute_value(td.minutes());
+ ss << std::setw(2) << std::setfill(fill_char)
+ << date_time::absolute_value(td.seconds());
+ //TODO the following is totally non-generic, yelling FIXME
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ boost::int64_t frac_sec =
+ date_time::absolute_value(td.fractional_seconds());
+ // JDG [7/6/02 VC++ compatibility]
+ charT buff[32];
+ _i64toa(frac_sec, buff, 10);
+#else
+ time_duration::fractional_seconds_type frac_sec =
+ date_time::absolute_value(td.fractional_seconds());
+#endif
+ if (frac_sec != 0) {
+ ss << "." << std::setw(time_duration::num_fractional_digits())
+ << std::setfill(fill_char)
+
+ // JDG [7/6/02 VC++ compatibility]
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ << buff;
+#else
+ << frac_sec;
+#endif
+ }
+ }// else
+ return ss.str();
+ }
+ //! Time duration in iso format -hhmmss,fffffff Example: 10:09:03,0123456
+ /*!\ingroup time_format
+ */
+ inline std::string to_iso_string(time_duration td){
+ return to_iso_string_type<char>(td);
+ }
+
+ //! Time to simple format CCYY-mmm-dd hh:mm:ss.fffffff
+ /*!\ingroup time_format
+ */
+ template<class charT>
+ inline std::basic_string<charT> to_simple_string_type(ptime t)
+ {
+ // can't use this w/gcc295, no to_simple_string_type<>(td) available
+ std::basic_string<charT> ts = gregorian::to_simple_string_type<charT>(t.date());// + " ";
+ if(!t.time_of_day().is_special()) {
+ charT space = ' ';
+ return ts + space + to_simple_string_type<charT>(t.time_of_day());
+ }
+ else {
+ return ts;
+ }
+ }
+ inline std::string to_simple_string(ptime t){
+ return to_simple_string_type<char>(t);
+ }
+
+ // function called by wrapper functions to_*_string(time_period)
+ // & to_*_wstring(time_period)
+ template<class charT>
+ inline std::basic_string<charT> to_simple_string_type(time_period tp)
+ {
+ charT beg = '[', mid = '/', end = ']';
+ std::basic_string<charT> d1(to_simple_string_type<charT>(tp.begin()));
+ std::basic_string<charT> d2(to_simple_string_type<charT>(tp.last()));
+ return std::basic_string<charT>(beg + d1 + mid + d2 + end);
+ }
+ //! Convert to string of form [YYYY-mmm-DD HH:MM::SS.ffffff/YYYY-mmm-DD HH:MM::SS.fffffff]
+ /*!\ingroup time_format
+ */
+ inline std::string to_simple_string(time_period tp){
+ return to_simple_string_type<char>(tp);
+ }
+
+ // function called by wrapper functions to_*_string(time_period)
+ // & to_*_wstring(time_period)
+ template<class charT>
+ inline std::basic_string<charT> to_iso_string_type(ptime t)
+ {
+ std::basic_string<charT> ts = gregorian::to_iso_string_type<charT>(t.date());// + "T";
+ if(!t.time_of_day().is_special()) {
+ charT sep = 'T';
+ return ts + sep + to_iso_string_type<charT>(t.time_of_day());
+ }
+ else {
+ return ts;
+ }
+ }
+ //! Convert iso short form YYYYMMDDTHHMMSS where T is the date-time separator
+ /*!\ingroup time_format
+ */
+ inline std::string to_iso_string(ptime t){
+ return to_iso_string_type<char>(t);
+ }
+
+
+ // function called by wrapper functions to_*_string(time_period)
+ // & to_*_wstring(time_period)
+ template<class charT>
+ inline std::basic_string<charT> to_iso_extended_string_type(ptime t)
+ {
+ std::basic_string<charT> ts = gregorian::to_iso_extended_string_type<charT>(t.date());// + "T";
+ if(!t.time_of_day().is_special()) {
+ charT sep = 'T';
+ return ts + sep + to_simple_string_type<charT>(t.time_of_day());
+ }
+ else {
+ return ts;
+ }
+ }
+ //! Convert to form YYYY-MM-DDTHH:MM:SS where T is the date-time separator
+ /*!\ingroup time_format
+ */
+ inline std::string to_iso_extended_string(ptime t){
+ return to_iso_extended_string_type<char>(t);
+ }
+
+#if !defined(BOOST_NO_STD_WSTRING)
+ //! Time duration to wstring -hh::mm::ss.fffffff. Example: 10:09:03.0123456
+ /*!\ingroup time_format
+ */
+ inline std::wstring to_simple_wstring(time_duration td) {
+ return to_simple_string_type<wchar_t>(td);
+ }
+ //! Time duration in iso format -hhmmss,fffffff Example: 10:09:03,0123456
+ /*!\ingroup time_format
+ */
+ inline std::wstring to_iso_wstring(time_duration td){
+ return to_iso_string_type<wchar_t>(td);
+ }
+ inline std::wstring to_simple_wstring(ptime t){
+ return to_simple_string_type<wchar_t>(t);
+ }
+ //! Convert to wstring of form [YYYY-mmm-DD HH:MM::SS.ffffff/YYYY-mmm-DD HH:MM::SS.fffffff]
+ /*!\ingroup time_format
+ */
+ inline std::wstring to_simple_wstring(time_period tp){
+ return to_simple_string_type<wchar_t>(tp);
+ }
+ //! Convert iso short form YYYYMMDDTHHMMSS where T is the date-time separator
+ /*!\ingroup time_format
+ */
+ inline std::wstring to_iso_wstring(ptime t){
+ return to_iso_string_type<wchar_t>(t);
+ }
+ //! Convert to form YYYY-MM-DDTHH:MM:SS where T is the date-time separator
+ /*!\ingroup time_format
+ */
+ inline std::wstring to_iso_extended_wstring(ptime t){
+ return to_iso_extended_string_type<wchar_t>(t);
+ }
+
+#endif // BOOST_NO_STD_WSTRING
+
+
+} } //namespace posix_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_formatters_limited.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_formatters_limited.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,211 @@
+#ifndef POSIXTIME_FORMATTERS_LIMITED_HPP___
+#define POSIXTIME_FORMATTERS_LIMITED_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include "boost/date_time/compiler_config.hpp"
+#include "boost/date_time/iso_format.hpp"
+#include "boost/date_time/date_format_simple.hpp"
+#include "boost/date_time/posix_time/posix_time_types.hpp"
+#include "boost/date_time/time_formatting_streams.hpp"
+
+namespace boost {
+
+namespace posix_time {
+
+ //! Time duration to string -hh::mm::ss.fffffff. Example: 10:09:03.0123456
+ /*!\ingroup time_format
+ */
+ inline std::string to_simple_string(time_duration td) {
+ std::ostringstream ss;
+ if(td.is_special()) {
+ /* simply using 'ss << td.get_rep()' won't work on compilers
+ * that don't support locales. This way does. */
+ // switch copied from date_names_put.hpp
+ switch(td.get_rep().as_special())
+ {
+ case not_a_date_time:
+ //ss << "not-a-number";
+ ss << "not-a-date-time";
+ break;
+ case pos_infin:
+ ss << "+infinity";
+ break;
+ case neg_infin:
+ ss << "-infinity";
+ break;
+ default:
+ ss << "";
+ }
+ }
+ else {
+ if(td.is_negative()) {
+ ss << '-';
+ }
+ ss << std::setw(2) << std::setfill('0')
+ << date_time::absolute_value(td.hours()) << ":";
+ ss << std::setw(2) << std::setfill('0')
+ << date_time::absolute_value(td.minutes()) << ":";
+ ss << std::setw(2) << std::setfill('0')
+ << date_time::absolute_value(td.seconds());
+ //TODO the following is totally non-generic, yelling FIXME
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ boost::int64_t frac_sec =
+ date_time::absolute_value(td.fractional_seconds());
+ // JDG [7/6/02 VC++ compatibility]
+ char buff[32];
+ _i64toa(frac_sec, buff, 10);
+#else
+ time_duration::fractional_seconds_type frac_sec =
+ date_time::absolute_value(td.fractional_seconds());
+#endif
+ if (frac_sec != 0) {
+ ss << "." << std::setw(time_duration::num_fractional_digits())
+ << std::setfill('0')
+
+ // JDG [7/6/02 VC++ compatibility]
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ << buff;
+#else
+ << frac_sec;
+#endif
+ }
+ }// else
+ return ss.str();
+ }
+
+ //! Time duration in iso format -hhmmss,fffffff Example: 10:09:03,0123456
+ /*!\ingroup time_format
+ */
+ inline
+ std::string
+ to_iso_string(time_duration td)
+ {
+ std::ostringstream ss;
+ if(td.is_special()) {
+ /* simply using 'ss << td.get_rep()' won't work on compilers
+ * that don't support locales. This way does. */
+ // switch copied from date_names_put.hpp
+ switch(td.get_rep().as_special()) {
+ case not_a_date_time:
+ //ss << "not-a-number";
+ ss << "not-a-date-time";
+ break;
+ case pos_infin:
+ ss << "+infinity";
+ break;
+ case neg_infin:
+ ss << "-infinity";
+ break;
+ default:
+ ss << "";
+ }
+ }
+ else {
+ if(td.is_negative()) {
+ ss << '-';
+ }
+ ss << std::setw(2) << std::setfill('0')
+ << date_time::absolute_value(td.hours());
+ ss << std::setw(2) << std::setfill('0')
+ << date_time::absolute_value(td.minutes());
+ ss << std::setw(2) << std::setfill('0')
+ << date_time::absolute_value(td.seconds());
+ //TODO the following is totally non-generic, yelling FIXME
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ boost::int64_t frac_sec =
+ date_time::absolute_value(td.fractional_seconds());
+ // JDG [7/6/02 VC++ compatibility]
+ char buff[32];
+ _i64toa(frac_sec, buff, 10);
+#else
+ time_duration::fractional_seconds_type frac_sec =
+ date_time::absolute_value(td.fractional_seconds());
+#endif
+ if (frac_sec != 0) {
+ ss << "." << std::setw(time_duration::num_fractional_digits())
+ << std::setfill('0')
+
+ // JDG [7/6/02 VC++ compatibility]
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ << buff;
+#else
+ << frac_sec;
+#endif
+ }
+ }// else
+ return ss.str();
+ }
+
+ //! Time to simple format CCYY-mmm-dd hh:mm:ss.fffffff
+ /*!\ingroup time_format
+ */
+ inline
+ std::string
+ to_simple_string(ptime t)
+ {
+ std::string ts = gregorian::to_simple_string(t.date());// + " ";
+ if(!t.time_of_day().is_special()) {
+ return ts + " " + to_simple_string(t.time_of_day());
+ }
+ else {
+ return ts;
+ }
+ }
+
+ //! Convert to string of form [YYYY-mmm-DD HH:MM::SS.ffffff/YYYY-mmm-DD HH:MM::SS.fffffff]
+ /*!\ingroup time_format
+ */
+ inline
+ std::string
+ to_simple_string(time_period tp)
+ {
+ std::string d1(to_simple_string(tp.begin()));
+ std::string d2(to_simple_string(tp.last()));
+ return std::string("[" + d1 + "/" + d2 +"]");
+ }
+
+ //! Convert iso short form YYYYMMDDTHHMMSS where T is the date-time separator
+ /*!\ingroup time_format
+ */
+ inline
+ std::string to_iso_string(ptime t)
+ {
+ std::string ts = gregorian::to_iso_string(t.date());// + "T";
+ if(!t.time_of_day().is_special()) {
+ return ts + "T" + to_iso_string(t.time_of_day());
+ }
+ else {
+ return ts;
+ }
+ }
+
+ //! Convert to form YYYY-MM-DDTHH:MM:SS where T is the date-time separator
+ /*!\ingroup time_format
+ */
+ inline
+ std::string
+ to_iso_extended_string(ptime t)
+ {
+ std::string ts = gregorian::to_iso_extended_string(t.date());// + "T";
+ if(!t.time_of_day().is_special()) {
+ return ts + "T" + to_simple_string(t.time_of_day());
+ }
+ else {
+ return ts;
+ }
+ }
+
+
+} } //namespace posix_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_parsers.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_parsers.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,44 @@
+#ifndef POSIXTIME_PARSERS_HPP___
+#define POSIXTIME_PARSERS_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include "boost/date_time/time_parsing.hpp"
+#include "boost/date_time/posix_time/posix_time_types.hpp"
+
+
+namespace boost {
+
+namespace posix_time {
+
+ //! Creates a time_duration object from a delimited string
+ /*! Expected format for string is "[-]h[h][:mm][:ss][.fff]".
+ * A negative duration will be created if the first character in
+ * string is a '-', all other '-' will be treated as delimiters.
+ * Accepted delimiters are "-:,.". */
+ inline time_duration duration_from_string(const std::string& s) {
+ return date_time::parse_delimited_time_duration<time_duration>(s);
+ }
+
+ inline ptime time_from_string(const std::string& s) {
+ return date_time::parse_delimited_time<ptime>(s, ' ');
+ }
+
+ inline ptime from_iso_string(const std::string& s) {
+ return date_time::parse_iso_time<ptime>(s, 'T');
+ }
+
+
+
+} } //namespace posix_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_period.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_period.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,29 @@
+#ifndef POSIX_TIME_PERIOD_HPP___
+#define POSIX_TIME_PERIOD_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/period.hpp"
+#include "boost/date_time/posix_time/posix_time_duration.hpp"
+#include "boost/date_time/posix_time/ptime.hpp"
+
+namespace boost {
+namespace posix_time {
+
+ //! Time period type
+ /*! \ingroup time_basics
+ */
+ typedef date_time::period<ptime, time_duration> time_period;
+
+
+} }//namespace posix_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_serialize.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/posix_time/time_serialize.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,200 @@
+#ifndef POSIX_TIME_SERIALIZE_HPP___
+#define POSIX_TIME_SERIALIZE_HPP___
+
+/* Copyright (c) 2004-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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/gregorian/greg_serialize.hpp"
+#include "boost/serialization/split_free.hpp"
+
+
+// macros to split serialize functions into save & load functions
+// NOTE: these macros define template functions in the boost::serialization namespace.
+// They must be expanded *outside* of any namespace
+BOOST_SERIALIZATION_SPLIT_FREE(boost::posix_time::ptime)
+BOOST_SERIALIZATION_SPLIT_FREE(boost::posix_time::time_duration)
+BOOST_SERIALIZATION_SPLIT_FREE(boost::posix_time::time_period)
+
+namespace boost {
+namespace serialization {
+
+
+/*** time_duration ***/
+
+//! Function to save posix_time::time_duration objects using serialization lib
+/*! time_duration objects are broken down into 4 parts for serialization:
+ * types are hour_type, min_type, sec_type, and fractional_seconds_type
+ * as defined in the time_duration class
+ */
+template<class Archive>
+void save(Archive & ar,
+ const posix_time::time_duration& td,
+ unsigned int /*version*/)
+{
+ // serialize a bool so we know how to read this back in later
+ bool is_special = td.is_special();
+ ar & make_nvp("is_special", is_special);
+ if(is_special) {
+ std::string s = to_simple_string(td);
+ ar & make_nvp("sv_time_duration", s);
+ }
+ else {
+ typename posix_time::time_duration::hour_type h = td.hours();
+ typename posix_time::time_duration::min_type m = td.minutes();
+ typename posix_time::time_duration::sec_type s = td.seconds();
+ typename posix_time::time_duration::fractional_seconds_type fs = td.fractional_seconds();
+ ar & make_nvp("time_duration_hours", h);
+ ar & make_nvp("time_duration_minutes", m);
+ ar & make_nvp("time_duration_seconds", s);
+ ar & make_nvp("time_duration_fractional_seconds", fs);
+ }
+}
+
+//! Function to load posix_time::time_duration objects using serialization lib
+/*! time_duration objects are broken down into 4 parts for serialization:
+ * types are hour_type, min_type, sec_type, and fractional_seconds_type
+ * as defined in the time_duration class
+ */
+template<class Archive>
+void load(Archive & ar,
+ posix_time::time_duration & td,
+ unsigned int /*version*/)
+{
+ bool is_special = false;
+ ar & make_nvp("is_special", is_special);
+ if(is_special) {
+ std::string s;
+ ar & make_nvp("sv_time_duration", s);
+ posix_time::special_values sv = gregorian::special_value_from_string(s);
+ td = posix_time::time_duration(sv);
+ }
+ else {
+ typename posix_time::time_duration::hour_type h(0);
+ typename posix_time::time_duration::min_type m(0);
+ typename posix_time::time_duration::sec_type s(0);
+ typename posix_time::time_duration::fractional_seconds_type fs(0);
+ ar & make_nvp("time_duration_hours", h);
+ ar & make_nvp("time_duration_minutes", m);
+ ar & make_nvp("time_duration_seconds", s);
+ ar & make_nvp("time_duration_fractional_seconds", fs);
+ td = posix_time::time_duration(h,m,s,fs);
+ }
+}
+
+// no load_construct_data function provided as time_duration provides a
+// default constructor
+
+/*** ptime ***/
+
+//! Function to save posix_time::ptime objects using serialization lib
+/*! ptime objects are broken down into 2 parts for serialization:
+ * a date object and a time_duration onject
+ */
+template<class Archive>
+void save(Archive & ar,
+ const posix_time::ptime& pt,
+ unsigned int /*version*/)
+{
+ // from_iso_string does not include fractional seconds
+ // therefore date and time_duration are used
+ typename posix_time::ptime::date_type d = pt.date();
+ ar & make_nvp("ptime_date", d);
+ if(!pt.is_special()) {
+ typename posix_time::ptime::time_duration_type td = pt.time_of_day();
+ ar & make_nvp("ptime_time_duration", td);
+ }
+}
+
+//! Function to load posix_time::ptime objects using serialization lib
+/*! ptime objects are broken down into 2 parts for serialization:
+ * a date object and a time_duration onject
+ */
+template<class Archive>
+void load(Archive & ar,
+ posix_time::ptime & pt,
+ unsigned int /*version*/)
+{
+ // from_iso_string does not include fractional seconds
+ // therefore date and time_duration are used
+ typename posix_time::ptime::date_type d(posix_time::not_a_date_time);
+ typename posix_time::ptime::time_duration_type td;
+ ar & make_nvp("ptime_date", d);
+ if(!d.is_special()) {
+ ar & make_nvp("ptime_time_duration", td);
+ pt = boost::posix_time::ptime(d,td);
+ }
+ else {
+ pt = boost::posix_time::ptime(d.as_special());
+ }
+
+}
+
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar,
+ posix_time::ptime* pt,
+ const unsigned int /*file_version*/)
+{
+ // retrieve data from archive required to construct new
+ // invoke inplace constructor to initialize instance of date
+ new(pt) boost::posix_time::ptime(boost::posix_time::not_a_date_time);
+}
+
+/*** time_period ***/
+
+//! Function to save posix_time::time_period objects using serialization lib
+/*! time_period objects are broken down into 2 parts for serialization:
+ * a begining ptime object and an ending ptime object
+ */
+template<class Archive>
+void save(Archive & ar,
+ const posix_time::time_period& tp,
+ unsigned int /*version*/)
+{
+ posix_time::ptime beg(tp.begin().date(), tp.begin().time_of_day());
+ posix_time::ptime end(tp.end().date(), tp.end().time_of_day());
+ ar & make_nvp("time_period_begin", beg);
+ ar & make_nvp("time_period_end", end);
+}
+
+//! Function to load posix_time::time_period objects using serialization lib
+/*! time_period objects are broken down into 2 parts for serialization:
+ * a begining ptime object and an ending ptime object
+ */
+template<class Archive>
+void load(Archive & ar,
+ boost::posix_time::time_period & tp,
+ unsigned int /*version*/)
+{
+ posix_time::time_duration td(1,0,0);
+ gregorian::date d(gregorian::not_a_date_time);
+ posix_time::ptime beg(d,td);
+ posix_time::ptime end(d,td);
+ ar & make_nvp("time_period_begin", beg);
+ ar & make_nvp("time_period_end", end);
+ tp = boost::posix_time::time_period(beg, end);
+}
+
+//!override needed b/c no default constructor
+template<class Archive>
+inline void load_construct_data(Archive & ar,
+ boost::posix_time::time_period* tp,
+ const unsigned int /*file_version*/)
+{
+ posix_time::time_duration td(1,0,0);
+ gregorian::date d(gregorian::not_a_date_time);
+ posix_time::ptime beg(d,td);
+ posix_time::ptime end(d,td);
+ new(tp) boost::posix_time::time_period(beg,end);
+}
+
+} // namespace serialization
+} // namespace boost
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/special_defs.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/special_defs.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,25 @@
+#ifndef DATE_TIME_SPECIAL_DEFS_HPP__
+#define DATE_TIME_SPECIAL_DEFS_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+namespace boost {
+namespace date_time {
+
+ enum special_values {not_a_date_time,
+ neg_infin, pos_infin,
+ min_date_time, max_date_time,
+ not_special, NumSpecialValues};
+
+
+} } //namespace date_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/special_values_formatter.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/special_values_formatter.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,96 @@
+
+#ifndef DATETIME_SPECIAL_VALUE_FORMATTER_HPP___
+#define DATETIME_SPECIAL_VALUE_FORMATTER_HPP___
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <vector>
+#include <string>
+#include "boost/date_time/special_defs.hpp"
+
+namespace boost { namespace date_time {
+
+
+ //! 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.
+ *
+ */
+ template <class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
+ class special_values_formatter
+ {
+ public:
+ typedef std::basic_string<CharT> string_type;
+ typedef CharT char_type;
+ typedef std::vector<string_type> collection_type;
+ static const char_type default_special_value_names[3][17];
+
+ //! Construct special values formatter using default strings.
+ /*! Default strings are not-a-date-time -infinity +infinity
+ */
+ special_values_formatter()
+ {
+ std::copy(&default_special_value_names[0],
+ &default_special_value_names[3],
+ std::back_inserter(m_special_value_names));
+ }
+
+ //! 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.
+ *@code
+ * const char* const special_value_names[]={"nadt","-inf","+inf" };
+ *
+ * special_value_formatter svf(&special_value_names[0], &special_value_names[3]);
+ *@endcode
+ */
+ special_values_formatter(const char_type* const* begin, const char_type* const* end)
+ {
+ std::copy(begin, end, std::back_inserter(m_special_value_names));
+ }
+ special_values_formatter(typename collection_type::iterator beg, typename collection_type::iterator end)
+ {
+ std::copy(beg, end, std::back_inserter(m_special_value_names));
+ }
+
+ OutItrT put_special(OutItrT next,
+ const boost::date_time::special_values& value) const
+ {
+
+ unsigned int index = value;
+ if (index < m_special_value_names.size()) {
+ std::copy(m_special_value_names[index].begin(),
+ m_special_value_names[index].end(),
+ next);
+ }
+ return next;
+ }
+ protected:
+ collection_type m_special_value_names;
+ };
+
+ //! Storage for the strings used to indicate special values
+ /* using c_strings to initialize these worked fine in testing, however,
+ * a project that compiled its objects separately, then linked in a separate
+ * step wound up with redefinition errors for the values in this array.
+ * Initializing individual characters eliminated this problem */
+ template <class CharT, class OutItrT>
+ const typename special_values_formatter<CharT, OutItrT>::char_type special_values_formatter<CharT, OutItrT>::default_special_value_names[3][17] = {
+ {'n','o','t','-','a','-','d','a','t','e','-','t','i','m','e'},
+ {'-','i','n','f','i','n','i','t','y'},
+ {'+','i','n','f','i','n','i','t','y'} };
+
+ } } //namespace boost::date_time
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/special_values_parser.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/special_values_parser.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,159 @@
+
+#ifndef DATE_TIME_SPECIAL_VALUES_PARSER_HPP__
+#define DATE_TIME_SPECIAL_VALUES_PARSER_HPP__
+
+/* 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/string_parse_tree.hpp"
+#include "boost/date_time/special_defs.hpp"
+#include <string>
+#include <vector>
+
+namespace boost { namespace date_time {
+
+ //! 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
+ */
+ template<class date_type, typename charT>
+ class special_values_parser
+ {
+ public:
+ typedef std::basic_string<charT> string_type;
+ //typedef std::basic_stringstream<charT> stringstream_type;
+ typedef std::istreambuf_iterator<charT> stream_itr_type;
+ //typedef typename string_type::const_iterator const_itr;
+ //typedef typename date_type::year_type year_type;
+ //typedef typename date_type::month_type month_type;
+ typedef typename date_type::duration_type duration_type;
+ //typedef typename date_type::day_of_week_type day_of_week_type;
+ //typedef typename date_type::day_type day_type;
+ typedef string_parse_tree<charT> parse_tree_type;
+ typedef typename parse_tree_type::parse_match_result_type match_results;
+ typedef std::vector<std::basic_string<charT> > collection_type;
+
+ typedef charT char_type;
+ static const char_type nadt_string[16];
+ static const char_type neg_inf_string[10];
+ static const char_type pos_inf_string[10];
+ static const char_type min_date_time_string[18];
+ static const char_type max_date_time_string[18];
+
+ //! Creates a special_values_parser with the default set of "sv_strings"
+ special_values_parser()
+ {
+ sv_strings(string_type(nadt_string),
+ string_type(neg_inf_string),
+ string_type(pos_inf_string),
+ string_type(min_date_time_string),
+ string_type(max_date_time_string));
+ }
+
+ //! Creates a special_values_parser using a user defined set of element strings
+ special_values_parser(const string_type& nadt_str,
+ const string_type& neg_inf_str,
+ const string_type& pos_inf_str,
+ const string_type& min_dt_str,
+ const string_type& max_dt_str)
+ {
+ sv_strings(nadt_str, neg_inf_str, pos_inf_str, min_dt_str, max_dt_str);
+ }
+
+ special_values_parser(typename collection_type::iterator beg, typename collection_type::iterator end)
+ {
+ collection_type phrases;
+ std::copy(beg, end, std::back_inserter(phrases));
+ m_sv_strings = parse_tree_type(phrases, static_cast<int>(not_a_date_time));
+ }
+
+ special_values_parser(const special_values_parser<date_type,charT>& svp)
+ {
+ this->m_sv_strings = svp.m_sv_strings;
+ }
+
+ //! Replace special value strings
+ void sv_strings(const string_type& nadt_str,
+ const string_type& neg_inf_str,
+ const string_type& pos_inf_str,
+ const string_type& min_dt_str,
+ const string_type& max_dt_str)
+ {
+ collection_type phrases;
+ phrases.push_back(nadt_str);
+ phrases.push_back(neg_inf_str);
+ phrases.push_back(pos_inf_str);
+ phrases.push_back(min_dt_str);
+ phrases.push_back(max_dt_str);
+ m_sv_strings = parse_tree_type(phrases, static_cast<int>(not_a_date_time));
+ }
+
+ /* Does not return a special_value because if the parsing fails,
+ * the return value will always be not_a_date_time
+ * (mr.current_match retains its default value of -1 on a failed
+ * parse and that casts to not_a_date_time). */
+ //! Sets match_results.current_match to the corresponding special_value or -1
+ bool match(stream_itr_type& sitr,
+ stream_itr_type& str_end,
+ match_results& mr) const
+ {
+ unsigned int level = 0;
+ m_sv_strings.match(sitr, str_end, mr, level);
+ return (mr.current_match != match_results::PARSE_ERROR);
+ }
+ /*special_values match(stream_itr_type& sitr,
+ stream_itr_type& str_end,
+ match_results& mr) const
+ {
+ unsigned int level = 0;
+ m_sv_strings.match(sitr, str_end, mr, level);
+ if(mr.current_match == match_results::PARSE_ERROR) {
+ throw std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'");
+ }
+ return static_cast<special_values>(mr.current_match);
+ }*/
+
+
+ private:
+ parse_tree_type m_sv_strings;
+
+ };
+
+ template<class date_type, class CharT>
+ const typename special_values_parser<date_type, CharT>::char_type
+ special_values_parser<date_type, CharT>::nadt_string[16] =
+ {'n','o','t','-','a','-','d','a','t','e','-','t','i','m','e'};
+ template<class date_type, class CharT>
+ const typename special_values_parser<date_type, CharT>::char_type
+ special_values_parser<date_type, CharT>::neg_inf_string[10] =
+ {'-','i','n','f','i','n','i','t','y'};
+ template<class date_type, class CharT>
+ const typename special_values_parser<date_type, CharT>::char_type
+ special_values_parser<date_type, CharT>::pos_inf_string[10] =
+ {'+','i','n','f','i','n','i','t','y'};
+ template<class date_type, class CharT>
+ const typename special_values_parser<date_type, CharT>::char_type
+ special_values_parser<date_type, CharT>::min_date_time_string[18] =
+ {'m','i','n','i','m','u','m','-','d','a','t','e','-','t','i','m','e'};
+ template<class date_type, class CharT>
+ const typename special_values_parser<date_type, CharT>::char_type
+ special_values_parser<date_type, CharT>::max_date_time_string[18] =
+ {'m','a','x','i','m','u','m','-','d','a','t','e','-','t','i','m','e'};
+
+} } //namespace
+
+#endif // DATE_TIME_SPECIAL_VALUES_PARSER_HPP__
+

Added: sandbox/SOC/2008/calendar/boost/date_time/string_convert.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/string_convert.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,33 @@
+#ifndef _STRING_CONVERT_HPP___
+#define _STRING_CONVERT_HPP___
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/compiler_config.hpp"
+#include <string>
+
+namespace boost {
+namespace date_time {
+
+ //! 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. */
+ template<class InputT, class OutputT>
+ inline
+ std::basic_string<OutputT> convert_string_type(const std::basic_string<InputT>& inp_str)
+ {
+ typedef std::basic_string<InputT> input_type;
+ typedef std::basic_string<OutputT> output_type;
+ output_type result;
+ result.insert(result.begin(), inp_str.begin(), inp_str.end());
+ return result;
+ }
+
+}} // namespace boost::date_time
+
+#endif // _STRING_CONVERT_HPP___

Added: sandbox/SOC/2008/calendar/boost/date_time/string_parse_tree.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/string_parse_tree.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,278 @@
+#ifndef BOOST_DATE_TIME_STRING_PARSE_TREE___HPP__
+#define BOOST_DATE_TIME_STRING_PARSE_TREE___HPP__
+
+/* Copyright (c) 2004-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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/lexical_cast.hpp" //error without?
+#include "boost/algorithm/string/case_conv.hpp"
+#include <map>
+#include <string>
+#include <vector>
+#include <algorithm>
+
+namespace boost { namespace date_time {
+
+
+template<typename charT>
+struct parse_match_result
+{
+ parse_match_result() :
+ match_depth(0),
+ current_match(-1)// -1 is match_not-found value
+ {}
+ typedef std::basic_string<charT> string_type;
+ string_type remaining() const
+ {
+ if (match_depth == cache.size()) {
+ return string_type();
+ }
+ if (current_match == -1) {
+ return cache;
+ }
+ //some of the cache was used return the rest
+ return string_type(cache, match_depth);
+ }
+ charT last_char() const
+ {
+ return cache[cache.size()-1];
+ }
+ //! Returns true if more characters were parsed than was necessary
+ /*! Should be used in conjunction with last_char()
+ * to get the remaining character.
+ */
+ bool has_remaining() const
+ {
+ return (cache.size() > match_depth);
+ }
+
+ // cache will hold characters that have been read from the stream
+ string_type cache;
+ unsigned short match_depth;
+ short current_match;
+ enum PARSE_STATE { PARSE_ERROR= -1 };
+};
+
+ //for debug -- really only char streams...
+template<typename charT>
+std::basic_ostream<charT>&
+operator<<(std::basic_ostream<charT>& os, parse_match_result<charT>& mr)
+{
+ os << "cm: " << mr.current_match
+ << " C: '" << mr.cache
+ << "' md: " << mr.match_depth
+ << " R: " << mr.remaining();
+ return os;
+}
+
+
+
+//! 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.
+ */
+template<typename charT>
+struct string_parse_tree
+{
+#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
+ typedef std::multimap<charT, string_parse_tree< charT> > ptree_coll;
+#else
+ typedef std::multimap<charT, string_parse_tree > ptree_coll;
+#endif
+ typedef typename ptree_coll::value_type value_type;
+ typedef typename ptree_coll::iterator iterator;
+ typedef typename ptree_coll::const_iterator const_iterator;
+ typedef std::basic_string<charT> string_type;
+ typedef std::vector<std::basic_string<charT> > collection_type;
+ typedef parse_match_result<charT> parse_match_result_type;
+
+ /*! Parameter "starting_point" desingates 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 */
+ string_parse_tree(collection_type names, unsigned int starting_point=0)
+ {
+ // iterate thru all the elements and build the tree
+ unsigned short index = 0;
+ while (index != names.size() ) {
+ string_type s = boost::algorithm::to_lower_copy(names[index]);
+ insert(s, static_cast<unsigned short>(index + starting_point));
+ index++;
+ }
+ //set the last tree node = index+1 indicating a value
+ index++;
+ }
+
+
+ string_parse_tree(short value = -1) :
+ m_value(value)
+ {}
+ ptree_coll m_next_chars;
+ short m_value;
+
+ void insert(const string_type& s, unsigned short value)
+ {
+ unsigned int i = 0;
+ iterator ti;
+ while(i < s.size()) {
+ if (i==0) {
+ if (i == (s.size()-1)) {
+ ti = m_next_chars.insert(value_type(s[i],
+ string_parse_tree<charT>(value)));
+ }
+ else {
+ ti = m_next_chars.insert(value_type(s[i],
+ string_parse_tree<charT>()));
+ }
+ }
+ else {
+ if (i == (s.size()-1)) {
+ ti = ti->second.m_next_chars.insert(value_type(s[i],
+ string_parse_tree<charT>(value)));
+ }
+
+ else {
+ ti = ti->second.m_next_chars.insert(value_type(s[i],
+ string_parse_tree<charT>()));
+ }
+
+ }
+ i++;
+ }
+ }
+
+
+ //! 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. */
+ short
+ match(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end,
+ parse_match_result_type& result,
+ unsigned int& level) const
+ {
+
+ level++;
+ charT c;
+ // if we conditionally advance sitr, we won't have
+ // to consume the next character past the input
+ bool adv_itr = true;
+ if (level > result.cache.size()) {
+ if (sitr == stream_end) return 0; //bail - input exhausted
+ c = static_cast<charT>(std::tolower(*sitr));
+ //result.cache += c;
+ //sitr++;
+ }
+ else {
+ // if we're looking for characters from the cache,
+ // we don't want to increment sitr
+ adv_itr = false;
+ c = static_cast<charT>(std::tolower(result.cache[level-1]));
+ }
+ const_iterator litr = m_next_chars.lower_bound(c);
+ const_iterator uitr = m_next_chars.upper_bound(c);
+ while (litr != uitr) { // equal if not found
+ if(adv_itr) {
+ sitr++;
+ result.cache += c;
+ }
+ if (litr->second.m_value != -1) { // -1 is default value
+ if (result.match_depth < level) {
+ result.current_match = litr->second.m_value;
+ result.match_depth = static_cast<unsigned short>(level);
+ }
+ litr->second.match(sitr, stream_end,
+ result, level);
+ level--;
+ }
+ else {
+ litr->second.match(sitr, stream_end,
+ result, level);
+ level--;
+ }
+
+ if(level <= result.cache.size()) {
+ adv_itr = false;
+ }
+
+ litr++;
+ }
+ return result.current_match;
+
+ }
+
+ /*! 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).
+ */
+ parse_match_result_type
+ match(std::istreambuf_iterator<charT>& sitr,
+ std::istreambuf_iterator<charT>& stream_end) const
+ {
+ // lookup to_lower of char in tree.
+ unsigned int level = 0;
+ // string_type cache;
+ parse_match_result_type result;
+ match(sitr, stream_end, result, level);
+ return result;
+ }
+
+ void printme(std::ostream& os, int& level)
+ {
+ level++;
+ iterator itr = m_next_chars.begin();
+ iterator end = m_next_chars.end();
+ // os << "starting level: " << level << std::endl;
+ while (itr != end) {
+ os << "level: " << level
+ << " node: " << itr->first
+ << " value: " << itr->second.m_value
+ << std::endl;
+ itr->second.printme(os, level);
+ itr++;
+ }
+ level--;
+ }
+
+ void print(std::ostream& os)
+ {
+ int level = 0;
+ printme(os, level);
+ }
+
+ void printmatch(std::ostream& os, charT c)
+ {
+ iterator litr = m_next_chars.lower_bound(c);
+ iterator uitr = m_next_chars.upper_bound(c);
+ os << "matches for: " << c << std::endl;
+ while (litr != uitr) {
+ os << " node: " << litr->first
+ << " value: " << litr->second.m_value
+ << std::endl;
+ litr++;
+ }
+ }
+
+};
+
+
+} } //namespace
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/strings_from_facet.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/strings_from_facet.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,123 @@
+#ifndef DATE_TIME_STRINGS_FROM_FACET__HPP___
+#define DATE_TIME_STRINGS_FROM_FACET__HPP___
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <sstream>
+#include <string>
+#include <vector>
+#include <locale>
+
+namespace boost { namespace date_time {
+
+//! 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.
+ *
+ *@param charT The type of char to use when gathering typically char
+ * or wchar_t.
+ *@param locale The locale to use when gathering the strings
+ *@param short_strings True(default) to gather short strings,
+ * false for long strings.
+ *@return A vector of strings containing the strings in order. eg:
+ * Jan, Feb, Mar, etc.
+ */
+template<typename charT>
+std::vector<std::basic_string<charT> >
+gather_month_strings(const std::locale& locale, bool short_strings=true)
+{
+ typedef std::basic_string<charT> string_type;
+ typedef std::vector<string_type> collection_type;
+ typedef std::basic_ostringstream<charT> ostream_type;
+ typedef std::ostreambuf_iterator<charT> ostream_iter_type;
+ typedef std::basic_ostringstream<charT> stringstream_type;
+ typedef std::time_put<charT> time_put_facet_type;
+ charT short_fmt[3] = { '%', 'b' };
+ charT long_fmt[3] = { '%', 'B' };
+ collection_type months;
+ string_type outfmt(short_fmt);
+ if (!short_strings) {
+ outfmt = long_fmt;
+ }
+ {
+ //grab the needed strings by using the locale to
+ //output each month
+ for (int m=0; m < 12; m++) {
+ tm tm_value;
+ tm_value.tm_mon = m;
+ stringstream_type ss;
+ ostream_iter_type oitr(ss);
+ std::use_facet<time_put_facet_type>(locale).put(oitr, ss, ss.fill(),
+ &tm_value,
+ &*outfmt.begin(),
+ &*outfmt.begin()+outfmt.size());
+ months.push_back(ss.str());
+ }
+ }
+ return months;
+}
+
+//! 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.
+ *
+ *@param charT The type of char to use when gathering typically char
+ * or wchar_t.
+ *@param locale The locale to use when gathering the strings
+ *@param short_strings True(default) to gather short strings,
+ * false for long strings.
+ *@return A vector of strings containing the weekdays in order. eg:
+ * Sun, Mon, Tue, Wed, Thu, Fri, Sat
+ */
+template<typename charT>
+std::vector<std::basic_string<charT> >
+gather_weekday_strings(const std::locale& locale, bool short_strings=true)
+{
+ typedef std::basic_string<charT> string_type;
+ typedef std::vector<string_type> collection_type;
+ typedef std::basic_ostringstream<charT> ostream_type;
+ typedef std::ostreambuf_iterator<charT> ostream_iter_type;
+ typedef std::basic_ostringstream<charT> stringstream_type;
+ typedef std::time_put<charT> time_put_facet_type;
+ charT short_fmt[3] = { '%', 'a' };
+ charT long_fmt[3] = { '%', 'A' };
+
+ collection_type weekdays;
+
+
+ string_type outfmt(short_fmt);
+ if (!short_strings) {
+ outfmt = long_fmt;
+ }
+ {
+ //grab the needed strings by using the locale to
+ //output each month / weekday
+ for (int i=0; i < 7; i++) {
+ tm tm_value;
+ tm_value.tm_wday = i;
+ stringstream_type ss;
+ ostream_iter_type oitr(ss);
+ std::use_facet<time_put_facet_type>(locale).put(oitr, ss, ss.fill(),
+ &tm_value,
+ &*outfmt.begin(),
+ &*outfmt.begin()+outfmt.size());
+
+ weekdays.push_back(ss.str());
+ }
+ }
+ return weekdays;
+}
+
+} } //namespace
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/testfrmwk.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/testfrmwk.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,66 @@
+
+#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: 2008-03-23 13:03:24 +0000 (Sun, 23 Mar 2008) $
+ */
+
+
+#include <iostream>
+#include <string>
+
+//! 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_;
+};
+
+
+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;
+ }
+}
+
+
+int printTestStats()
+{
+ TestStats& stat = TestStats::instance();
+ stat.print();
+ return stat.testcount() - stat.passcount();
+}
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/time.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,190 @@
+#ifndef DATE_TIME_TIME_HPP___
+#define DATE_TIME_TIME_HPP___
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+/*! @file time.hpp
+ This file contains the interface for the time associated classes.
+*/
+#include "boost/date_time/time_defs.hpp"
+#include "boost/operators.hpp"
+#include <string>
+
+namespace boost {
+namespace date_time {
+
+ //! 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.
+
+ */
+
+ template <class T, class time_system>
+ class base_time : private
+ boost::less_than_comparable<T
+ , boost::equality_comparable<T
+ > >
+ {
+ public:
+ typedef T time_type;
+ typedef typename time_system::time_rep_type time_rep_type;
+ typedef typename time_system::date_type date_type;
+ typedef typename time_system::date_duration_type date_duration_type;
+ typedef typename time_system::time_duration_type time_duration_type;
+ //typedef typename time_system::hms_type hms_type;
+
+ base_time(const date_type& day,
+ const time_duration_type& td,
+ dst_flags dst=not_dst) :
+ time_(time_system::get_time_rep(day, td, dst))
+ {}
+ base_time(special_values sv) :
+ time_(time_system::get_time_rep(sv))
+ {}
+ base_time(const time_rep_type& rhs) :
+ time_(rhs)
+ {}
+ date_type date() const
+ {
+ return time_system::get_date(time_);
+ }
+ time_duration_type time_of_day() const
+ {
+ return time_system::get_time_of_day(time_);
+ }
+ /*! Optional 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::string zone_name(bool as_offset=false) const
+ {
+ return time_system::zone_name(time_);
+ }
+ /*! Optional 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::string zone_abbrev(bool as_offset=false) const
+ {
+ return time_system::zone_name(time_);
+ }
+ //! An empty string is returned for classes that do not use a time_zone
+ std::string zone_as_posix_string() const
+ {
+ return std::string("");
+ }
+
+ //! check to see if date is not a value
+ bool is_not_a_date_time() const
+ {
+ return time_.is_not_a_date_time();
+ }
+ //! check to see if date is one of the infinity values
+ bool is_infinity() const
+ {
+ return (is_pos_infinity() || is_neg_infinity());
+ }
+ //! check to see if date is greater than all possible dates
+ bool is_pos_infinity() const
+ {
+ return time_.is_pos_infinity();
+ }
+ //! check to see if date is greater than all possible dates
+ bool is_neg_infinity() const
+ {
+ return time_.is_neg_infinity();
+ }
+ //! check to see if time is a special value
+ bool is_special() const
+ {
+ return(is_not_a_date_time() || is_infinity());
+ }
+ //!Equality operator -- others generated by boost::equality_comparable
+ bool operator==(const time_type& rhs) const
+ {
+ return time_system::is_equal(time_,rhs.time_);
+ }
+ //!Equality operator -- others generated by boost::less_than_comparable
+ bool operator<(const time_type& rhs) const
+ {
+ return time_system::is_less(time_,rhs.time_);
+ }
+ //! difference between two times
+ time_duration_type operator-(const time_type& rhs) const
+ {
+ return time_system::subtract_times(time_, rhs.time_);
+ }
+ //! add date durations
+ time_type operator+(const date_duration_type& dd) const
+ {
+ return time_system::add_days(time_, dd);
+ }
+ time_type operator+=(const date_duration_type& dd)
+ {
+ time_ = (time_system::get_time_rep(date() + dd, time_of_day()));
+ return time_type(time_);
+ }
+ //! subtract date durations
+ time_type operator-(const date_duration_type& dd) const
+ {
+ return time_system::subtract_days(time_, dd);
+ }
+ time_type operator-=(const date_duration_type& dd)
+ {
+ time_ = (time_system::get_time_rep(date() - dd, time_of_day()));
+ return time_type(time_);
+ }
+ //! add time durations
+ time_type operator+(const time_duration_type& td) const
+ {
+ return time_type(time_system::add_time_duration(time_, td));
+ }
+ time_type operator+=(const time_duration_type& td)
+ {
+ time_ = (time_system::get_time_rep(date(), time_of_day() + td));
+ return time_type(time_);
+ }
+ //! subtract time durations
+ time_type operator-(const time_duration_type& rhs) const
+ {
+ return time_system::subtract_time_duration(time_, rhs);
+ }
+ time_type operator-=(const time_duration_type& td)
+ {
+ time_ = (time_system::get_time_rep(date(), time_of_day() - td));
+ return time_type(time_);
+ }
+
+ protected:
+ time_rep_type time_;
+ };
+
+
+
+
+
+} } //namespace date_time::boost
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/time_clock.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_clock.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,83 @@
+#ifndef DATE_TIME_TIME_CLOCK_HPP___
+#define DATE_TIME_TIME_CLOCK_HPP___
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+/*! @file time_clock.hpp
+ This file contains the interface for clock devices.
+*/
+
+#include "boost/date_time/c_time.hpp"
+#include "boost/shared_ptr.hpp"
+
+namespace boost {
+namespace date_time {
+
+
+ //! A clock providing time level services based on C time_t capabilities
+ /*! This clock provides resolution to the 1 second level
+ */
+ template<class time_type>
+ class second_clock
+ {
+ public:
+ typedef typename time_type::date_type date_type;
+ typedef typename time_type::time_duration_type time_duration_type;
+
+ static time_type local_time()
+ {
+ ::std::time_t t;
+ ::std::time(&t);
+ ::std::tm curr, *curr_ptr;
+ //curr_ptr = ::std::localtime(&t);
+ curr_ptr = c_time::localtime(&t, &curr);
+ return create_time(curr_ptr);
+ }
+
+
+ //! Get the current day in universal date as a ymd_type
+ static time_type universal_time()
+ {
+
+ ::std::time_t t;
+ ::std::time(&t);
+ ::std::tm curr, *curr_ptr;
+ //curr_ptr = ::std::gmtime(&t);
+ curr_ptr = c_time::gmtime(&t, &curr);
+ return create_time(curr_ptr);
+ }
+
+ template<class time_zone_type>
+ static time_type local_time(boost::shared_ptr<time_zone_type> tz_ptr)
+ {
+ typedef typename time_type::utc_time_type utc_time_type;
+ utc_time_type utc_time = second_clock<utc_time_type>::universal_time();
+ return time_type(utc_time, tz_ptr);
+ }
+
+
+ private:
+ static time_type create_time(::std::tm* current)
+ {
+ date_type d(static_cast<unsigned short>(current->tm_year + 1900),
+ static_cast<unsigned short>(current->tm_mon + 1),
+ static_cast<unsigned short>(current->tm_mday));
+ time_duration_type td(current->tm_hour,
+ current->tm_min,
+ current->tm_sec);
+ return time_type(d,td);
+ }
+
+ };
+
+
+} } //namespace date_time
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/time_defs.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_defs.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,33 @@
+#ifndef DATE_TIME_TIME_PRECISION_LIMITS_HPP
+#define DATE_TIME_TIME_PRECISION_LIMITS_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+
+/*! \file time_defs.hpp
+ This file contains nice definitions for handling the resoluion of various time
+ reprsentations.
+*/
+
+namespace boost {
+namespace date_time {
+
+ //!Defines some nice types for handling time level resolutions
+ enum time_resolutions {sec, tenth, hundreth, milli, ten_thousandth, micro, nano, NumResolutions };
+
+ //! Flags for daylight savings or summer time
+ enum dst_flags {not_dst, is_dst, calculate};
+
+
+} } //namespace date_time
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/time_duration.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_duration.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,281 @@
+#ifndef DATE_TIME_TIME_DURATION_HPP___
+#define DATE_TIME_TIME_DURATION_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/operators.hpp"
+#include "boost/date_time/time_defs.hpp"
+#include "boost/date_time/special_defs.hpp"
+#include "boost/date_time/compiler_config.hpp"
+
+namespace boost {
+namespace date_time {
+
+
+ //! 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.
+
+ @param T The subclass type
+ @param rep_type The time resolution traits for this duration type.
+ */
+ template<class T, typename rep_type>
+ class time_duration : private
+ boost::less_than_comparable<T
+ , boost::equality_comparable<T
+ > >
+ /* dividable, addable, and subtractable operator templates
+ * won't work with this class (MSVC++ 6.0). return type
+ * from '+=' is different than expected return type
+ * from '+'. multipliable probably wont work
+ * either (haven't tried) */
+ {
+ public:
+ typedef T duration_type; //the subclass
+ typedef rep_type traits_type;
+ typedef typename rep_type::day_type day_type;
+ typedef typename rep_type::hour_type hour_type;
+ typedef typename rep_type::min_type min_type;
+ typedef typename rep_type::sec_type sec_type;
+ typedef typename rep_type::fractional_seconds_type fractional_seconds_type;
+ typedef typename rep_type::tick_type tick_type;
+ typedef typename rep_type::impl_type impl_type;
+
+ time_duration() : ticks_(0) {}
+ time_duration(hour_type hours_in,
+ min_type minutes_in,
+ sec_type seconds_in=0,
+ fractional_seconds_type frac_sec_in = 0) :
+ ticks_(rep_type::to_tick_count(hours_in,minutes_in,seconds_in,frac_sec_in))
+ {}
+ // copy constructor required for dividable<>
+ //! Construct from another time_duration (Copy constructor)
+ time_duration(const time_duration<T, rep_type>& other)
+ : ticks_(other.ticks_)
+ {}
+ //! Construct from special_values
+ time_duration(special_values sv) : ticks_(impl_type::from_special(sv))
+ {}
+ //! Returns smallest representable duration
+ static duration_type unit()
+ {
+ return duration_type(0,0,0,1);
+ }
+ //! Return the number of ticks in a second
+ static tick_type ticks_per_second()
+ {
+ return rep_type::res_adjust();
+ }
+ //! Provide the resolution of this duration type
+ static time_resolutions resolution()
+ {
+ return rep_type::resolution();
+ }
+ //! Returns number of hours in the duration
+ hour_type hours() const
+ {
+ return static_cast<hour_type>(ticks() / (3600*ticks_per_second()));
+ }
+ //! Returns normalized number of minutes
+ min_type minutes() const
+ {
+ return static_cast<min_type>((ticks() / (60*ticks_per_second())) % 60);
+ }
+ //! Returns normalized number of seconds (0..60)
+ sec_type seconds() const
+ {
+ return static_cast<sec_type>((ticks()/ticks_per_second()) % 60);
+ }
+ //! Returns total number of seconds truncating any fractional seconds
+ sec_type total_seconds() const
+ {
+ return static_cast<sec_type>(ticks() / ticks_per_second());
+ }
+ //! Returns total number of milliseconds truncating any fractional seconds
+ tick_type total_milliseconds() const
+ {
+ if (ticks_per_second() < 1000) {
+ return ticks() * (static_cast<tick_type>(1000) / ticks_per_second());
+ }
+ return ticks() / (ticks_per_second() / static_cast<tick_type>(1000)) ;
+ }
+ //! Returns total number of nanoseconds truncating any sub millisecond values
+ tick_type total_nanoseconds() const
+ {
+ if (ticks_per_second() < 1000000000) {
+ return ticks() * (static_cast<tick_type>(1000000000) / ticks_per_second());
+ }
+ return ticks() / (ticks_per_second() / static_cast<tick_type>(1000000000)) ;
+ }
+ //! Returns total number of microseconds truncating any sub microsecond values
+ tick_type total_microseconds() const
+ {
+ if (ticks_per_second() < 1000000) {
+ return ticks() * (static_cast<tick_type>(1000000) / ticks_per_second());
+ }
+ return ticks() / (ticks_per_second() / static_cast<tick_type>(1000000)) ;
+ }
+ //! Returns count of fractional seconds at given resolution
+ fractional_seconds_type fractional_seconds() const
+ {
+ return (ticks() % ticks_per_second());
+ }
+ //! Returns number of possible digits in fractional seconds
+ static unsigned short num_fractional_digits()
+ {
+ return rep_type::num_fractional_digits();
+ }
+ duration_type invert_sign() const
+ {
+ return duration_type(ticks_ * (-1));
+ }
+ bool is_negative() const
+ {
+ return ticks_ < 0;
+ }
+ bool operator<(const time_duration& rhs) const
+ {
+ return ticks_ < rhs.ticks_;
+ }
+ bool operator==(const time_duration& rhs) const
+ {
+ return ticks_ == rhs.ticks_;
+ }
+ //! unary- Allows for time_duration td = -td1
+ duration_type operator-()const
+ {
+ return duration_type(ticks_ * (-1));
+ }
+ duration_type operator-(const duration_type& d) const
+ {
+ return duration_type(ticks_ - d.ticks_);
+ }
+ duration_type operator+(const duration_type& d) const
+ {
+ return duration_type(ticks_ + d.ticks_);
+ }
+ duration_type operator/(int divisor) const
+ {
+ return duration_type(ticks_ / divisor);
+ }
+ duration_type operator-=(const duration_type& d)
+ {
+ ticks_ = ticks_ - d.ticks_;
+ return duration_type(ticks_);
+ }
+ duration_type operator+=(const duration_type& d)
+ {
+ ticks_ = ticks_ + d.ticks_;
+ return duration_type(ticks_);
+ }
+ //! Division operations on a duration with an integer.
+ duration_type operator/=(int divisor)
+ {
+ ticks_ = ticks_ / divisor;
+ return duration_type(ticks_);
+ }
+ //! Multiplication operations an a duration with an integer
+ duration_type operator*(int rhs) const
+ {
+ return duration_type(ticks_ * rhs);
+ }
+ duration_type operator*=(int divisor)
+ {
+ ticks_ = ticks_ * divisor;
+ return duration_type(ticks_);
+ }
+ tick_type ticks() const
+ {
+ return traits_type::as_number(ticks_);
+ }
+
+ //! Is ticks_ a special value?
+ bool is_special()const
+ {
+ if(traits_type::is_adapted())
+ {
+ return ticks_.is_special();
+ }
+ else{
+ return false;
+ }
+ }
+ //! Is duration pos-infinity
+ bool is_pos_infinity()const
+ {
+ if(traits_type::is_adapted())
+ {
+ return ticks_.is_pos_infinity();
+ }
+ else{
+ return false;
+ }
+ }
+ //! Is duration neg-infinity
+ bool is_neg_infinity()const
+ {
+ if(traits_type::is_adapted())
+ {
+ return ticks_.is_neg_infinity();
+ }
+ else{
+ return false;
+ }
+ }
+ //! Is duration not-a-date-time
+ bool is_not_a_date_time()const
+ {
+ if(traits_type::is_adapted())
+ {
+ return ticks_.is_nan();
+ }
+ else{
+ return false;
+ }
+ }
+
+ //! Used for special_values output
+ impl_type get_rep()const
+ {
+ return ticks_;
+ }
+
+ protected:
+ explicit time_duration(impl_type in) : ticks_(in) {};
+ impl_type ticks_;
+ };
+
+
+
+ //! Template for instantiating derived adjusting durations
+ /* These templates are designed to work with multiples of
+ * 10 for frac_of_second and resoultion adjustment
+ */
+ template<class base_duration, boost::int64_t frac_of_second>
+ class subsecond_duration : public base_duration
+ {
+ public:
+ typedef typename base_duration::traits_type traits_type;
+ explicit subsecond_duration(boost::int64_t ss) :
+ base_duration(0,0,0,ss*traits_type::res_adjust()/frac_of_second)
+ {}
+ };
+
+
+
+} } //namespace date_time
+
+
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/time_facet.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_facet.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,1263 @@
+
+#ifndef _DATE_TIME_FACET__HPP__
+#define _DATE_TIME_FACET__HPP__
+
+/* Copyright (c) 2004-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: Martin Andrian, Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/date_facet.hpp"
+#include "boost/date_time/string_convert.hpp"
+#include "boost/algorithm/string/erase.hpp"
+#include <sstream>
+#include <iomanip>
+#include <exception>
+
+namespace boost {
+namespace date_time {
+
+ template <class CharT>
+ struct time_formats {
+ public:
+ typedef CharT char_type;
+ static const char_type fractional_seconds_format[3]; // f
+ static const char_type fractional_seconds_or_none_format[3]; // F
+ static const char_type seconds_with_fractional_seconds_format[3]; // s
+ static const char_type seconds_format[3]; // S
+ static const char_type standard_format[9]; // x X
+ static const char_type zone_abbrev_format[3]; // z
+ static const char_type zone_name_format[3]; // Z
+ static const char_type zone_iso_format[3]; // q
+ static const char_type zone_iso_extended_format[3]; // Q
+ static const char_type posix_zone_string_format[4]; // ZP
+ static const char_type duration_sign_negative_only[3]; // -
+ static const char_type duration_sign_always[3]; // +
+ static const char_type duration_seperator[2];
+ static const char_type negative_sign[2]; //-
+ static const char_type positive_sign[2]; //+
+ static const char_type iso_time_format_specifier[18];
+ static const char_type iso_time_format_extended_specifier[22];
+ //default ptime format is YYYY-Mon-DD HH:MM:SS[.fff...][ zzz]
+ static const char_type default_time_format[23];
+ // default_time_input_format uses a posix_time_zone_string instead of a time zone abbrev
+ static const char_type default_time_input_format[24];
+ //default time_duration format is HH:MM:SS[.fff...]
+ static const char_type default_time_duration_format[11];
+ };
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::fractional_seconds_format[3] = {'%','f'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::fractional_seconds_or_none_format[3] = {'%','F'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::seconds_with_fractional_seconds_format[3] =
+ {'%','s'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::seconds_format[3] = {'%','S'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ //time_formats<CharT>::standard_format[5] = {'%','c',' ','%','z'};
+ time_formats<CharT>::standard_format[9] = {'%','x',' ','%','X',' ','%','z'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::zone_abbrev_format[3] = {'%','z'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::zone_name_format[3] = {'%','Z'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::zone_iso_format[3] = {'%','q'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::zone_iso_extended_format[3] ={'%','Q'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::posix_zone_string_format[4] ={'%','Z','P'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::duration_seperator[2] = {':'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::negative_sign[2] = {'-'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::positive_sign[2] = {'+'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::duration_sign_negative_only[3] ={'%','-'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::duration_sign_always[3] ={'%','+'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::iso_time_format_specifier[18] =
+ {'%', 'Y', '%', 'm', '%', 'd', 'T',
+ '%', 'H', '%', 'M', '%', 'S', '%', 'F', '%','q' };
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::iso_time_format_extended_specifier[22] =
+ {'%', 'Y', '-', '%', 'm', '-', '%', 'd', ' ',
+ '%', 'H', ':', '%', 'M', ':', '%', 'S', '%', 'F','%','Q'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::default_time_format[23] =
+ {'%','Y','-','%','b','-','%','d',' ',
+ '%','H',':','%','M',':','%','S','%','F',' ','%','z'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::default_time_input_format[24] =
+ {'%','Y','-','%','b','-','%','d',' ',
+ '%','H',':','%','M',':','%','S','%','F',' ','%','Z','P'};
+
+ template <class CharT>
+ const typename time_formats<CharT>::char_type
+ time_formats<CharT>::default_time_duration_format[11] =
+ {'%','H',':','%','M',':','%','S','%','F'};
+
+
+
+ /*! 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"
+ */
+ template <class time_type,
+ class CharT,
+ class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
+ class time_facet :
+ public boost::date_time::date_facet<typename time_type::date_type , CharT, OutItrT> {
+ public:
+ typedef typename time_type::date_type date_type;
+ typedef typename time_type::time_duration_type time_duration_type;
+ typedef boost::date_time::period<time_type,time_duration_type> period_type;
+ typedef boost::date_time::date_facet<typename time_type::date_type, CharT, OutItrT> base_type;
+ typedef typename base_type::string_type string_type;
+ typedef typename base_type::char_type char_type;
+ typedef typename base_type::period_formatter_type period_formatter_type;
+ typedef typename base_type::special_values_formatter_type special_values_formatter_type;
+ typedef typename base_type::date_gen_formatter_type date_gen_formatter_type;
+ static const char_type* fractional_seconds_format; // %f
+ static const char_type* fractional_seconds_or_none_format; // %F
+ static const char_type* seconds_with_fractional_seconds_format; // %s
+ static const char_type* seconds_format; // %S
+ static const char_type* standard_format; // %x X
+ static const char_type* zone_abbrev_format; // %z
+ static const char_type* zone_name_format; // %Z
+ static const char_type* zone_iso_format; // %q
+ static const char_type* zone_iso_extended_format; // %Q
+ static const char_type* posix_zone_string_format; // %ZP
+ static const char_type* duration_seperator;
+ static const char_type* duration_sign_always; // %+
+ static const char_type* duration_sign_negative_only; // %-
+ static const char_type* negative_sign; //-
+ static const char_type* positive_sign; //+
+ static const char_type* iso_time_format_specifier;
+ static const char_type* iso_time_format_extended_specifier;
+
+ //default ptime format is YYYY-Mon-DD HH:MM:SS[.fff...][ zzz]
+ static const char_type* default_time_format;
+ //default time_duration format is HH:MM:SS[.fff...]
+ static const char_type* default_time_duration_format;
+ static std::locale::id id;
+
+#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
+ std::locale::id& __get_id (void) const { return id; }
+#endif
+
+ //! sets default formats for ptime, local_date_time, and time_duration
+ explicit time_facet(::size_t /* a_ref */ = 0)
+ //: base_type(standard_format),
+ : base_type(default_time_format),
+ m_time_duration_format(string_type(duration_sign_negative_only) + default_time_duration_format)
+ {}
+
+ //! Construct the facet with an explicitly specified format
+ explicit time_facet(const char_type* a_format,
+ period_formatter_type period_formatter = period_formatter_type(),
+ const special_values_formatter_type& special_value_formatter = special_values_formatter_type(),
+ date_gen_formatter_type dg_formatter = date_gen_formatter_type(),
+ ::size_t a_ref = 0)
+ : base_type(a_format,
+ period_formatter,
+ special_value_formatter,
+ dg_formatter,
+ a_ref),
+ m_time_duration_format(string_type(duration_sign_negative_only) + default_time_duration_format)
+ {}
+
+ //! Changes format for time_duration
+ void time_duration_format(const char_type* const format)
+ {
+ m_time_duration_format = format;
+ }
+
+ virtual void set_iso_format()
+ {
+ this->m_format = iso_time_format_specifier;
+ }
+ virtual void set_iso_extended_format()
+ {
+ this->m_format = iso_time_format_extended_specifier;
+ }
+
+ OutItrT put(OutItrT a_next,
+ std::ios_base& a_ios,
+ char_type a_fill,
+ const time_type& a_time) const
+ {
+ if (a_time.is_special()) {
+ return this->do_put_special(a_next, a_ios, a_fill,
+ a_time.date().as_special());
+ }
+ string_type format(this->m_format);
+ string_type frac_str;
+ if (format.find(seconds_with_fractional_seconds_format) != string_type::npos) {
+ // replace %s with %S.nnn
+ frac_str =
+ fractional_seconds_as_string(a_time.time_of_day(), false);
+ char_type sep = std::use_facet<std::numpunct<char_type> >(a_ios.getloc()).decimal_point();
+
+ string_type replace_string(seconds_format);
+ replace_string += sep;
+ replace_string += frac_str;
+ boost::algorithm::replace_all(format,
+ seconds_with_fractional_seconds_format,
+ replace_string);
+ }
+ /* NOTE: replacing posix_zone_string_format must be done BEFORE
+ * zone_name_format: "%ZP" & "%Z", if Z is checked first it will
+ * incorrectly replace a zone_name where a posix_string should go */
+ if (format.find(posix_zone_string_format) != string_type::npos) {
+ if(a_time.zone_abbrev().empty()) {
+ // if zone_abbrev() returns an empty string, we want to
+ // erase posix_zone_string_format from format
+ boost::algorithm::replace_all(format,
+ posix_zone_string_format,
+ "");
+ }
+ else{
+ boost::algorithm::replace_all(format,
+ posix_zone_string_format,
+ a_time.zone_as_posix_string());
+ }
+ }
+ if (format.find(zone_name_format) != string_type::npos) {
+ if(a_time.zone_name().empty()) {
+ /* TODO: this'll probably create problems if a user places
+ * the zone_*_format flag in the format with a ptime. This
+ * code removes the flag from the default formats */
+
+ // if zone_name() returns an empty string, we want to
+ // erase zone_name_format & one preceeding space
+ std::basic_ostringstream<char_type> ss;
+ ss << ' ' << zone_name_format;
+ boost::algorithm::replace_all(format,
+ ss.str(),
+ "");
+ }
+ else{
+ boost::algorithm::replace_all(format,
+ zone_name_format,
+ a_time.zone_name());
+ }
+ }
+ if (format.find(zone_abbrev_format) != string_type::npos) {
+ if(a_time.zone_abbrev(false).empty()) {
+ /* TODO: this'll probably create problems if a user places
+ * the zone_*_format flag in the format with a ptime. This
+ * code removes the flag from the default formats */
+
+ // if zone_abbrev() returns an empty string, we want to
+ // erase zone_abbrev_format & one preceeding space
+ std::basic_ostringstream<char_type> ss;
+ ss << ' ' << zone_abbrev_format;
+ boost::algorithm::replace_all(format,
+ ss.str(),
+ "");
+ }
+ else{
+ boost::algorithm::replace_all(format,
+ zone_abbrev_format,
+ a_time.zone_abbrev(false));
+ }
+ }
+ if (format.find(zone_iso_extended_format) != string_type::npos) {
+ if(a_time.zone_name(true).empty()) {
+ /* TODO: this'll probably create problems if a user places
+ * the zone_*_format flag in the format with a ptime. This
+ * code removes the flag from the default formats */
+
+ // if zone_name() returns an empty string, we want to
+ // erase zone_iso_extended_format from format
+ boost::algorithm::replace_all(format,
+ zone_iso_extended_format,
+ "");
+ }
+ else{
+ boost::algorithm::replace_all(format,
+ zone_iso_extended_format,
+ a_time.zone_name(true));
+ }
+ }
+
+ if (format.find(zone_iso_format) != string_type::npos) {
+ if(a_time.zone_abbrev(true).empty()) {
+ /* TODO: this'll probably create problems if a user places
+ * the zone_*_format flag in the format with a ptime. This
+ * code removes the flag from the default formats */
+
+ // if zone_abbrev() returns an empty string, we want to
+ // erase zone_iso_format from format
+ boost::algorithm::replace_all(format,
+ zone_iso_format,
+ "");
+ }
+ else{
+ boost::algorithm::replace_all(format,
+ zone_iso_format,
+ a_time.zone_abbrev(true));
+ }
+ }
+ if (format.find(fractional_seconds_format) != string_type::npos) {
+ // replace %f with nnnnnnn
+ if (!frac_str.size()) {
+ frac_str = fractional_seconds_as_string(a_time.time_of_day(), false);
+ }
+ boost::algorithm::replace_all(format,
+ fractional_seconds_format,
+ frac_str);
+ }
+
+ if (format.find(fractional_seconds_or_none_format) != string_type::npos) {
+ // replace %F with nnnnnnn or nothing if fs == 0
+ frac_str =
+ fractional_seconds_as_string(a_time.time_of_day(), true);
+ if (frac_str.size()) {
+ char_type sep = std::use_facet<std::numpunct<char_type> >(a_ios.getloc()).decimal_point();
+ string_type replace_string;
+ replace_string += sep;
+ replace_string += frac_str;
+ boost::algorithm::replace_all(format,
+ fractional_seconds_or_none_format,
+ replace_string);
+ }
+ else {
+ boost::algorithm::erase_all(format,
+ fractional_seconds_or_none_format);
+ }
+ }
+
+ return this->do_put_tm(a_next, a_ios, a_fill,
+ to_tm(a_time), format);
+ }
+
+ //! put function for time_duration
+ OutItrT put(OutItrT a_next,
+ std::ios_base& a_ios,
+ char_type a_fill,
+ const time_duration_type& a_time_dur) const
+ {
+ if (a_time_dur.is_special()) {
+ return this->do_put_special(a_next, a_ios, a_fill,
+ a_time_dur.get_rep().as_special());
+ }
+
+ string_type format(m_time_duration_format);
+ if (a_time_dur.is_negative()) {
+ // replace %- with minus sign. Should we use the numpunct facet?
+ boost::algorithm::replace_all(format,
+ duration_sign_negative_only,
+ negative_sign);
+ // remove all the %+ in the string with '-'
+ boost::algorithm::replace_all(format,
+ duration_sign_always,
+ negative_sign);
+ }
+ else { //duration is positive
+ // remove all the %- combos from the string
+ boost::algorithm::replace_all(format,
+ duration_sign_negative_only,
+ "");
+ // remove all the %+ in the string with '+'
+ boost::algorithm::replace_all(format,
+ duration_sign_always,
+ positive_sign);
+ }
+
+ string_type frac_str;
+ if (format.find(seconds_with_fractional_seconds_format) != string_type::npos) {
+ // replace %s with %S.nnn
+ frac_str =
+ fractional_seconds_as_string(a_time_dur, false);
+ char_type sep = std::use_facet<std::numpunct<char_type> >(a_ios.getloc()).decimal_point();
+
+ string_type replace_string(seconds_format);
+ replace_string += sep;
+ replace_string += frac_str;
+ boost::algorithm::replace_all(format,
+ seconds_with_fractional_seconds_format,
+ replace_string);
+ }
+ if (format.find(fractional_seconds_format) != string_type::npos) {
+ // replace %f with nnnnnnn
+ if (!frac_str.size()) {
+ frac_str = fractional_seconds_as_string(a_time_dur, false);
+ }
+ boost::algorithm::replace_all(format,
+ fractional_seconds_format,
+ frac_str);
+ }
+
+ if (format.find(fractional_seconds_or_none_format) != string_type::npos) {
+ // replace %F with nnnnnnn or nothing if fs == 0
+ frac_str =
+ fractional_seconds_as_string(a_time_dur, true);
+ if (frac_str.size()) {
+ char_type sep = std::use_facet<std::numpunct<char_type> >(a_ios.getloc()).decimal_point();
+ string_type replace_string;
+ replace_string += sep;
+ replace_string += frac_str;
+ boost::algorithm::replace_all(format,
+ fractional_seconds_or_none_format,
+ replace_string);
+ }
+ else {
+ boost::algorithm::erase_all(format,
+ fractional_seconds_or_none_format);
+ }
+ }
+
+ return this->do_put_tm(a_next, a_ios, a_fill,
+ to_tm(a_time_dur), format);
+ }
+
+ OutItrT put(OutItrT next, std::ios_base& a_ios,
+ char_type fill, const period_type& p) const
+ {
+ return this->m_period_formatter.put_period(next, a_ios, fill,p,*this);
+ }
+
+
+ protected:
+
+ static
+ string_type
+ fractional_seconds_as_string(const time_duration_type& a_time,
+ bool null_when_zero)
+ {
+ typename time_duration_type::fractional_seconds_type frac_sec =
+ a_time.fractional_seconds();
+
+ if (null_when_zero && (frac_sec == 0)) {
+ return string_type();
+ }
+
+ //make sure there is no sign
+ frac_sec = date_time::absolute_value(frac_sec);
+ std::basic_ostringstream<char_type> ss;
+ ss.imbue(std::locale::classic()); // don't want any formatting
+ ss << std::setw(time_duration_type::num_fractional_digits())
+ << std::setfill(static_cast<char_type>('0'));
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ // JDG [7/6/02 VC++ compatibility]
+ char_type buff[34];
+ ss << _i64toa(static_cast<boost::int64_t>(frac_sec), buff, 10);
+#else
+ ss << frac_sec;
+#endif
+ return ss.str();
+ }
+
+ private:
+ string_type m_time_duration_format;
+
+ };
+
+ template <class time_type, class CharT, class OutItrT>
+ std::locale::id time_facet<time_type, CharT, OutItrT>::id;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::fractional_seconds_format = time_formats<CharT>::fractional_seconds_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::fractional_seconds_or_none_format = time_formats<CharT>::fractional_seconds_or_none_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::seconds_with_fractional_seconds_format =
+ time_formats<CharT>::seconds_with_fractional_seconds_format;
+
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::zone_name_format = time_formats<CharT>::zone_name_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::zone_abbrev_format = time_formats<CharT>::zone_abbrev_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::zone_iso_extended_format =time_formats<CharT>::zone_iso_extended_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::posix_zone_string_format =time_formats<CharT>::posix_zone_string_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::zone_iso_format = time_formats<CharT>::zone_iso_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::seconds_format = time_formats<CharT>::seconds_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::standard_format = time_formats<CharT>::standard_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::duration_seperator = time_formats<CharT>::duration_seperator;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::negative_sign = time_formats<CharT>::negative_sign;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::positive_sign = time_formats<CharT>::positive_sign;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::duration_sign_negative_only = time_formats<CharT>::duration_sign_negative_only;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::duration_sign_always = time_formats<CharT>::duration_sign_always;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type,CharT, OutItrT>::char_type*
+ time_facet<time_type,CharT, OutItrT>::iso_time_format_specifier = time_formats<CharT>::iso_time_format_specifier;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::iso_time_format_extended_specifier = time_formats<CharT>::iso_time_format_extended_specifier;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::default_time_format =
+ time_formats<CharT>::default_time_format;
+
+ template <class time_type, class CharT, class OutItrT>
+ const typename time_facet<time_type, CharT, OutItrT>::char_type*
+ time_facet<time_type, CharT, OutItrT>::default_time_duration_format =
+ time_formats<CharT>::default_time_duration_format;
+
+
+ //! Facet for format-based input.
+ /*!
+ */
+ template <class time_type,
+ class CharT,
+ class InItrT = std::istreambuf_iterator<CharT, std::char_traits<CharT> > >
+ class time_input_facet :
+ public boost::date_time::date_input_facet<typename time_type::date_type , CharT, InItrT> {
+ public:
+ typedef typename time_type::date_type date_type;
+ typedef typename time_type::time_duration_type time_duration_type;
+ typedef typename time_duration_type::fractional_seconds_type fracional_seconds_type;
+ typedef boost::date_time::period<time_type,time_duration_type> period_type;
+ typedef boost::date_time::date_input_facet<typename time_type::date_type, CharT, InItrT> base_type;
+ typedef typename base_type::duration_type date_duration_type;
+ typedef typename base_type::year_type year_type;
+ typedef typename base_type::month_type month_type;
+ typedef typename base_type::day_type day_type;
+ typedef typename base_type::string_type string_type;
+ typedef typename string_type::const_iterator const_itr;
+ typedef typename base_type::char_type char_type;
+ typedef typename base_type::format_date_parser_type format_date_parser_type;
+ typedef typename base_type::period_parser_type period_parser_type;
+ typedef typename base_type::special_values_parser_type special_values_parser_type;
+ typedef typename base_type::date_gen_parser_type date_gen_parser_type;
+ typedef typename base_type::special_values_parser_type::match_results match_results;
+
+ static const char_type* fractional_seconds_format; // f
+ static const char_type* fractional_seconds_or_none_format; // F
+ static const char_type* seconds_with_fractional_seconds_format; // s
+ static const char_type* seconds_format; // S
+ static const char_type* standard_format; // x X
+ static const char_type* zone_abbrev_format; // z
+ static const char_type* zone_name_format; // Z
+ static const char_type* zone_iso_format; // q
+ static const char_type* zone_iso_extended_format; // Q
+ static const char_type* duration_seperator;
+ static const char_type* iso_time_format_specifier;
+ static const char_type* iso_time_format_extended_specifier;
+ static const char_type* default_time_input_format;
+ static const char_type* default_time_duration_format;
+ static std::locale::id id;
+
+ //! Constructor that takes a format string for a ptime
+ explicit time_input_facet(const string_type& format, ::size_t a_ref = 0)
+ : base_type(format, a_ref),
+ m_time_duration_format(default_time_duration_format)
+ { }
+
+ explicit time_input_facet(const string_type& format,
+ const format_date_parser_type& date_parser,
+ const special_values_parser_type& sv_parser,
+ const period_parser_type& per_parser,
+ const date_gen_parser_type& date_gen_parser,
+ ::size_t a_ref = 0)
+ : base_type(format,
+ date_parser,
+ sv_parser,
+ per_parser,
+ date_gen_parser,
+ a_ref),
+ m_time_duration_format(default_time_duration_format)
+ {}
+
+ //! sets default formats for ptime, local_date_time, and time_duration
+ explicit time_input_facet(::size_t a_ref = 0)
+ : base_type(default_time_input_format, a_ref),
+ m_time_duration_format(default_time_duration_format)
+ { }
+
+ //! Set the format for time_duration
+ void time_duration_format(const char_type* const format) {
+ m_time_duration_format = format;
+ }
+ virtual void set_iso_format()
+ {
+ this->m_format = iso_time_format_specifier;
+ }
+ virtual void set_iso_extended_format()
+ {
+ this->m_format = iso_time_format_extended_specifier;
+ }
+
+ InItrT get(InItrT& sitr,
+ InItrT& stream_end,
+ std::ios_base& a_ios,
+ period_type& p) const
+ {
+ p = this->m_period_parser.get_period(sitr,
+ stream_end,
+ a_ios,
+ p,
+ time_duration_type::unit(),
+ *this);
+ return sitr;
+ }
+
+ //default ptime format is YYYY-Mon-DD HH:MM:SS[.fff...][ zzz]
+ //default time_duration format is %H:%M:%S%F HH:MM:SS[.fff...]
+
+ InItrT get(InItrT& sitr,
+ InItrT& stream_end,
+ std::ios_base& a_ios,
+ time_duration_type& td) const
+ {
+ // skip leading whitespace
+ while((sitr != stream_end) && std::isspace(*sitr)) { ++sitr; }
+
+ bool use_current_char = false;
+
+ // num_get will consume the +/-, we may need a copy if special_value
+ char_type c = '\0';
+ if((sitr != stream_end) && (*sitr == '-' || *sitr == '+')) {
+ c = *sitr;
+ }
+
+ long hour = 0;
+ long min = 0;
+ long sec = 0;
+ typename time_duration_type::fractional_seconds_type frac(0);
+
+ typedef std::num_get<CharT, InItrT> num_get;
+ if(!std::has_facet<num_get>(a_ios.getloc())) {
+ num_get* ng = new num_get();
+ std::locale loc = std::locale(a_ios.getloc(), ng);
+ a_ios.imbue(loc);
+ }
+
+ const_itr itr(m_time_duration_format.begin());
+ while (itr != m_time_duration_format.end() && (sitr != stream_end)) {
+ if (*itr == '%') {
+ itr++;
+ if (*itr != '%') {
+ switch(*itr) {
+ case 'H':
+ {
+ match_results mr;
+ hour = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ if(hour == -1){
+ return check_special_value(sitr, stream_end, td, c);
+ }
+ break;
+ }
+ case 'M':
+ {
+ match_results mr;
+ min = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ if(min == -1){
+ return check_special_value(sitr, stream_end, td, c);
+ }
+ break;
+ }
+ case 'S':
+ {
+ match_results mr;
+ sec = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ if(sec == -1){
+ return check_special_value(sitr, stream_end, td, c);
+ }
+ break;
+ }
+ case 's':
+ {
+ match_results mr;
+ sec = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ if(sec == -1){
+ return check_special_value(sitr, stream_end, td, c);
+ }
+ // %s is the same as %S%f so we drop through into %f
+ //break;
+ }
+ case 'f':
+ {
+ // check for decimal, check special_values if missing
+ if(*sitr == '.') {
+ ++sitr;
+ parse_frac_type(sitr, stream_end, frac);
+ // sitr will point to next expected char after this parsing
+ // is complete so no need to advance it
+ use_current_char = true;
+ }
+ else {
+ return check_special_value(sitr, stream_end, td, c);
+ }
+ break;
+ }
+ case 'F':
+ {
+ // check for decimal, skip if missing
+ if(*sitr == '.') {
+ ++sitr;
+ parse_frac_type(sitr, stream_end, frac);
+ // sitr will point to next expected char after this parsing
+ // is complete so no need to advance it
+ use_current_char = true;
+ }
+ else {
+ // nothing was parsed so we don't want to advance sitr
+ use_current_char = true;
+ }
+ break;
+ }
+ default:
+ {} // ignore what we don't understand?
+ }// switch
+ }
+ else { // itr == '%', second consecutive
+ sitr++;
+ }
+
+ itr++; //advance past format specifier
+ }
+ else { //skip past chars in format and in buffer
+ itr++;
+ // set use_current_char when sitr is already
+ // pointing at the next character to process
+ if (use_current_char) {
+ use_current_char = false;
+ }
+ else {
+ sitr++;
+ }
+ }
+ }
+
+ td = time_duration_type(hour, min, sec, frac);
+ return sitr;
+ }
+
+
+ //! Parses a time object from the input stream
+ InItrT get(InItrT& sitr,
+ InItrT& stream_end,
+ std::ios_base& a_ios,
+ time_type& t) const
+ {
+ string_type tz_str;
+ return get(sitr, stream_end, a_ios, t, tz_str, false);
+ }
+ //! Expects a time_zone in the input stream
+ InItrT get_local_time(InItrT& sitr,
+ InItrT& stream_end,
+ std::ios_base& a_ios,
+ time_type& t,
+ string_type& tz_str) const
+ {
+ return get(sitr, stream_end, a_ios, t, tz_str, true);
+ }
+
+ protected:
+
+ InItrT get(InItrT& sitr,
+ InItrT& stream_end,
+ std::ios_base& a_ios,
+ time_type& t,
+ string_type& tz_str,
+ bool time_is_local) const
+ {
+ // skip leading whitespace
+ while((sitr != stream_end) && std::isspace(*sitr)) { ++sitr; }
+
+ bool use_current_char = false;
+ bool use_current_format_char = false; // used whith two character flags
+
+ // num_get will consume the +/-, we may need a copy if special_value
+ char_type c = '\0';
+ if((sitr != stream_end) && (*sitr == '-' || *sitr == '+')) {
+ c = *sitr;
+ }
+
+ // time elements
+ long hour = 0;
+ long min = 0;
+ long sec = 0;
+ typename time_duration_type::fractional_seconds_type frac(0);
+ // date elements
+ short day_of_year(0);
+ /* Initialized the following to their minimum values. These intermediate
+ * objects are used so we get specific exceptions when part of the input
+ * is unparsable.
+ * Ex: "205-Jan-15" will throw a bad_year, "2005-Jsn-15"- bad_month, etc.*/
+ year_type t_year(1400);
+ month_type t_month(1);
+ day_type t_day(1);
+
+ typedef std::num_get<CharT, InItrT> num_get;
+ if(!std::has_facet<num_get>(a_ios.getloc())) {
+ num_get* ng = new num_get();
+ std::locale loc = std::locale(a_ios.getloc(), ng);
+ a_ios.imbue(loc);
+ }
+
+ const_itr itr(this->m_format.begin());
+ while (itr != this->m_format.end() && (sitr != stream_end)) {
+ if (*itr == '%') {
+ itr++;
+ if (*itr != '%') {
+ // the cases are grouped by date & time flags - not alphabetical order
+ switch(*itr) {
+ // date flags
+ case 'Y':
+ case 'y':
+ {
+ char_type cs[3] = { '%', *itr };
+ string_type s(cs);
+ match_results mr;
+ try {
+ t_year = this->m_parser.parse_year(sitr, stream_end, s, mr);
+ }
+ catch(std::out_of_range bad_year) { // base class for bad_year exception
+ if(this->m_sv_parser.match(sitr, stream_end, mr)) {
+ t = time_type(static_cast<special_values>(mr.current_match));
+ return sitr;
+ }
+ else {
+ throw; // rethrow bad_year
+ }
+ }
+ break;
+ }
+ case 'B':
+ case 'b':
+ case 'm':
+ {
+ char_type cs[3] = { '%', *itr };
+ string_type s(cs);
+ match_results mr;
+ try {
+ t_month = this->m_parser.parse_month(sitr, stream_end, s, mr);
+ }
+ catch(std::out_of_range bad_month) { // base class for bad_month exception
+ if(this->m_sv_parser.match(sitr, stream_end, mr)) {
+ t = time_type(static_cast<special_values>(mr.current_match));
+ return sitr;
+ }
+ else {
+ throw; // rethrow bad_year
+ }
+ }
+ // did m_parser already advance sitr to next char?
+ if(mr.has_remaining()) {
+ use_current_char = true;
+ }
+ break;
+ }
+ case 'a':
+ case 'A':
+ case 'w':
+ {
+ // weekday is not used in construction but we need to get it out of the stream
+ char_type cs[3] = { '%', *itr };
+ string_type s(cs);
+ match_results mr;
+ typename date_type::day_of_week_type wd(0);
+ try {
+ wd = this->m_parser.parse_weekday(sitr, stream_end, s, mr);
+ }
+ catch(std::out_of_range bad_weekday) { // base class for bad_weekday exception
+ if(this->m_sv_parser.match(sitr, stream_end, mr)) {
+ t = time_type(static_cast<special_values>(mr.current_match));
+ return sitr;
+ }
+ else {
+ throw; // rethrow bad_weekday
+ }
+ }
+ // did m_parser already advance sitr to next char?
+ if(mr.has_remaining()) {
+ use_current_char = true;
+ }
+ break;
+ }
+ case 'j':
+ {
+ // code that gets julian day (from format_date_parser)
+ match_results mr;
+ day_of_year = fixed_string_to_int<unsigned short, CharT>(sitr, stream_end, mr, 3);
+ if(day_of_year == -1) {
+ if(this->m_sv_parser.match(sitr, stream_end, mr)) {
+ t = time_type(static_cast<special_values>(mr.current_match));
+ return sitr;
+ }
+ }
+ // these next two lines are so we get an exception with bad input
+ typedef typename time_type::date_type::day_of_year_type day_of_year_type;
+ day_of_year_type t_day_of_year(day_of_year);
+ break;
+ }
+ case 'd':
+ {
+ try {
+ t_day = this->m_parser.parse_day_of_month(sitr, stream_end);
+ }
+ catch(std::out_of_range bad_day_of_month) { // base class for exception
+ match_results mr;
+ if(this->m_sv_parser.match(sitr, stream_end, mr)) {
+ t = time_type(static_cast<special_values>(mr.current_match));
+ return sitr;
+ }
+ else {
+ throw; // rethrow bad_year
+ }
+ }
+ break;
+ }
+ // time flags
+ case 'H':
+ {
+ match_results mr;
+ hour = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ if(hour == -1){
+ return check_special_value(sitr, stream_end, t, c);
+ }
+ break;
+ }
+ case 'M':
+ {
+ match_results mr;
+ min = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ if(min == -1){
+ return check_special_value(sitr, stream_end, t, c);
+ }
+ break;
+ }
+ case 'S':
+ {
+ match_results mr;
+ sec = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ if(sec == -1){
+ return check_special_value(sitr, stream_end, t, c);
+ }
+ break;
+ }
+ case 's':
+ {
+ match_results mr;
+ sec = fixed_string_to_int<short, CharT>(sitr, stream_end, mr, 2);
+ if(sec == -1){
+ return check_special_value(sitr, stream_end, t, c);
+ }
+ // %s is the same as %S%f so we drop through into %f
+ //break;
+ }
+ case 'f':
+ {
+ // check for decimal, check SV if missing
+ if(*sitr == '.') {
+ ++sitr;
+ parse_frac_type(sitr, stream_end, frac);
+ // sitr will point to next expected char after this parsing
+ // is complete so no need to advance it
+ use_current_char = true;
+ }
+ else {
+ return check_special_value(sitr, stream_end, t, c);
+ }
+ break;
+ }
+ case 'F':
+ {
+ // check for decimal, skip if missing
+ if(*sitr == '.') {
+ ++sitr;
+ parse_frac_type(sitr, stream_end, frac);
+ // sitr will point to next expected char after this parsing
+ // is complete so no need to advance it
+ use_current_char = true;
+ }
+ else {
+ // nothing was parsed so we don't want to advance sitr
+ use_current_char = true;
+ }
+ break;
+ }
+ // time_zone flags
+ //case 'q':
+ //case 'Q':
+ //case 'z':
+ case 'Z':
+ {
+ if(time_is_local) { // skip if 't' is a ptime
+ ++itr;
+ if(*itr == 'P') {
+ // skip leading whitespace
+ while((sitr != stream_end) && std::isspace(*sitr)) { ++sitr; }
+ // parse zone
+ while((sitr != stream_end) && (!std::isspace(*sitr))) {
+ tz_str += *sitr;
+ ++sitr;
+ }
+ }
+ else {
+ use_current_format_char = true;
+ }
+
+ }
+ else {
+ // nothing was parsed so we don't want to advance sitr
+ use_current_char = true;
+ }
+
+ break;
+ }
+ default:
+ {} // ignore what we don't understand?
+ }// switch
+ }
+ else { // itr == '%', second consecutive
+ sitr++;
+ }
+
+ if(use_current_format_char) {
+ use_current_format_char = false;
+ }
+ else {
+ itr++; //advance past format specifier
+ }
+
+ }
+ else { //skip past chars in format and in buffer
+ itr++;
+ // set use_current_char when sitr is already
+ // pointing at the next character to process
+ if (use_current_char) {
+ use_current_char = false;
+ }
+ else {
+ sitr++;
+ }
+ }
+ }
+
+ date_type d(not_a_date_time);
+ if (day_of_year > 0) {
+ d = date_type(static_cast<unsigned short>(t_year-1),12,31) + date_duration_type(day_of_year);
+ }
+ else {
+ d = date_type(t_year, t_month, t_day);
+ }
+
+ time_duration_type td(hour, min, sec, frac);
+ t = time_type(d, td);
+ return sitr;
+ }
+
+ //! 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. */
+ template<class temporal_type>
+ inline
+ InItrT check_special_value(InItrT& sitr,InItrT& stream_end, temporal_type& tt, char_type c='\0') const
+ {
+ match_results mr;
+ if((c == '-' || c == '+') && (*sitr != c)) { // was the first character consumed?
+ mr.cache += c;
+ }
+ this->m_sv_parser.match(sitr, stream_end, mr);
+ if(mr.current_match == match_results::PARSE_ERROR) {
+ std::string tmp = convert_string_type<char_type, char>(mr.cache);
+ throw std::ios_base::failure("Parse failed. No match found for '" + tmp + "'");
+ }
+ tt = temporal_type(static_cast<special_values>(mr.current_match));
+ return sitr;
+ }
+
+ //! Helper function for parsing a fractional second type from the stream
+ void parse_frac_type(InItrT& sitr,
+ InItrT& stream_end,
+ fracional_seconds_type& frac) const
+ {
+ string_type cache;
+ while((sitr != stream_end) && std::isdigit(*sitr)) {
+ cache += *sitr;
+ ++sitr;
+ }
+ if(cache.size() > 0) {
+ unsigned short precision = time_duration_type::num_fractional_digits();
+ // input may be only the first few decimal places
+ if(cache.size() < precision) {
+ frac = lexical_cast<fracional_seconds_type>(cache);
+ frac = decimal_adjust(frac, static_cast<unsigned short>(precision - cache.size()));
+ }
+ else {
+ // if input has too many decimal places, drop excess digits
+ frac = lexical_cast<fracional_seconds_type>(cache.substr(0, precision));
+ }
+ }
+ }
+
+ private:
+ string_type m_time_duration_format;
+
+ //! Helper function to adjust trailing zeros when parsing fractional digits
+ template<class int_type>
+ inline
+ int_type decimal_adjust(int_type val, const unsigned short places) const
+ {
+ unsigned long factor = 1;
+ for(int i = 0; i < places; ++i){
+ factor *= 10; // shift decimal to the right
+ }
+ return val * factor;
+ }
+
+ };
+
+template <class time_type, class CharT, class InItrT>
+ std::locale::id time_input_facet<time_type, CharT, InItrT>::id;
+
+template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::fractional_seconds_format = time_formats<CharT>::fractional_seconds_format;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::fractional_seconds_or_none_format = time_formats<CharT>::fractional_seconds_or_none_format;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::seconds_with_fractional_seconds_format = time_formats<CharT>::seconds_with_fractional_seconds_format;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::seconds_format = time_formats<CharT>::seconds_format;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::standard_format = time_formats<CharT>::standard_format;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::zone_abbrev_format = time_formats<CharT>::zone_abbrev_format;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::zone_name_format = time_formats<CharT>::zone_name_format;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::zone_iso_format = time_formats<CharT>::zone_iso_format;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::zone_iso_extended_format = time_formats<CharT>::zone_iso_extended_format;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::duration_seperator = time_formats<CharT>::duration_seperator;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::iso_time_format_specifier = time_formats<CharT>::iso_time_format_specifier;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::iso_time_format_extended_specifier = time_formats<CharT>::iso_time_format_extended_specifier;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::default_time_input_format = time_formats<CharT>::default_time_input_format;
+
+ template <class time_type, class CharT, class InItrT>
+ const typename time_input_facet<time_type, CharT, InItrT>::char_type*
+ time_input_facet<time_type, CharT, InItrT>::default_time_duration_format = time_formats<CharT>::default_time_duration_format;
+
+
+} } // namespaces
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/time_formatting_streams.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_formatting_streams.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,119 @@
+#ifndef DATE_TIME_TIME_FORMATTING_STREAMS_HPP___
+#define DATE_TIME_TIME_FORMATTING_STREAMS_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/date_formatting_locales.hpp"
+#include "boost/date_time/time_resolution_traits.hpp"
+
+#ifndef BOOST_DATE_TIME_NO_LOCALE
+
+namespace boost {
+namespace date_time {
+
+
+ //! Put a time type into a stream using appropriate facets
+ template<class time_duration_type,
+ class charT = char>
+ class ostream_time_duration_formatter
+ {
+ public:
+ typedef std::basic_ostream<charT> ostream_type;
+ typedef typename time_duration_type::fractional_seconds_type fractional_seconds_type;
+
+ //! Put time into an ostream
+ static void duration_put(const time_duration_type& td,
+ ostream_type& os)
+ {
+ if(td.is_special()) {
+ os << td.get_rep();
+ }
+ else {
+ charT fill_char = '0';
+ if(td.is_negative()) {
+ os << '-';
+ }
+ os << std::setw(2) << std::setfill(fill_char)
+ << absolute_value(td.hours()) << ":";
+ os << std::setw(2) << std::setfill(fill_char)
+ << absolute_value(td.minutes()) << ":";
+ os << std::setw(2) << std::setfill(fill_char)
+ << absolute_value(td.seconds());
+ fractional_seconds_type frac_sec =
+ absolute_value(td.fractional_seconds());
+ if (frac_sec != 0) {
+ os << "."
+ << std::setw(time_duration_type::num_fractional_digits())
+ << std::setfill(fill_char)
+ << frac_sec;
+ }
+ } // else
+ } // duration_put
+ }; //class ostream_time_duration_formatter
+
+ //! Put a time type into a stream using appropriate facets
+ template<class time_type,
+ class charT = char>
+ class ostream_time_formatter
+ {
+ public:
+ typedef std::basic_ostream<charT> ostream_type;
+ typedef typename time_type::date_type date_type;
+ typedef typename time_type::time_duration_type time_duration_type;
+ typedef ostream_time_duration_formatter<time_duration_type, charT> duration_formatter;
+
+ //! Put time into an ostream
+ static void time_put(const time_type& t,
+ ostream_type& os)
+ {
+ date_type d = t.date();
+ os << d;
+ if(!d.is_infinity() && !d.is_not_a_date())
+ {
+ os << " "; //TODO: fix the separator here.
+ duration_formatter::duration_put(t.time_of_day(), os);
+ }
+
+ } // time_to_ostream
+ }; //class ostream_time_formatter
+
+
+ //! Put a time period into a stream using appropriate facets
+ template<class time_period_type,
+ class charT = char>
+ class ostream_time_period_formatter
+ {
+ public:
+ typedef std::basic_ostream<charT> ostream_type;
+ typedef typename time_period_type::point_type time_type;
+ typedef ostream_time_formatter<time_type, charT> time_formatter;
+
+ //! Put time into an ostream
+ static void period_put(const time_period_type& tp,
+ ostream_type& os)
+ {
+ os << '['; //TODO: facet or manipulator for periods?
+ time_formatter::time_put(tp.begin(), os);
+ os << '/'; //TODO: facet or manipulator for periods?
+ time_formatter::time_put(tp.last(), os);
+ os << ']';
+
+ } // period_put
+
+ }; //class ostream_time_period_formatter
+
+
+
+} } //namespace date_time
+
+#endif //BOOST_DATE_TIME_NO_LOCALE
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/time_iterator.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_iterator.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,52 @@
+#ifndef DATE_TIME_TIME_ITERATOR_HPP___
+#define DATE_TIME_TIME_ITERATOR_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+namespace boost {
+namespace date_time {
+
+
+ //! Simple time iterator skeleton class
+ template<class time_type>
+ class time_itr {
+ public:
+ typedef typename time_type::time_duration_type time_duration_type;
+ time_itr(time_type t, time_duration_type d) : current_(t), offset_(d) {};
+ time_itr& operator++()
+ {
+ current_ = current_ + offset_;
+ return *this;
+ }
+ time_itr& operator--()
+ {
+ current_ = current_ - offset_;
+ return *this;
+ }
+ time_type operator*() {return current_;};
+ time_type* operator->() {return &current_;};
+ bool operator< (const time_type& t) {return current_ < t;};
+ bool operator<= (const time_type& t) {return current_ <= t;};
+ bool operator!= (const time_type& t) {return current_ != t;};
+ bool operator== (const time_type& t) {return current_ == t;};
+ bool operator> (const time_type& t) {return current_ > t;};
+ bool operator>= (const time_type& t) {return current_ >= t;};
+
+ private:
+ time_type current_;
+ time_duration_type offset_;
+ };
+
+
+
+} }//namespace date_time
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/time_parsing.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_parsing.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,321 @@
+#ifndef _DATE_TIME_TIME_PARSING_HPP___
+#define _DATE_TIME_TIME_PARSING_HPP___
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/tokenizer.hpp"
+#include "boost/lexical_cast.hpp"
+#include "boost/date_time/date_parsing.hpp"
+#include "boost/cstdint.hpp"
+#include <iostream>
+
+namespace boost {
+namespace date_time {
+
+ //! computes exponential math like 2^8 => 256, only works with positive integers
+ //Not general purpose, but needed b/c std::pow is not available
+ //everywehere. Hasn't been tested with negatives and zeros
+ template<class int_type>
+ inline
+ int_type power(int_type base, int_type exponent)
+ {
+ int_type result = 1;
+ for(int i = 0; i < exponent; ++i){
+ result *= base;
+ }
+ return result;
+ }
+
+ //! 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 "-:,.".
+ */
+ template<class time_duration, class char_type>
+ inline
+ time_duration
+ str_from_delimited_time_duration(const std::basic_string<char_type>& s)
+ {
+ unsigned short min=0, sec =0;
+ int hour =0;
+ bool is_neg = (s.at(0) == '-');
+ boost::int64_t fs=0;
+ int pos = 0;
+
+ typedef typename std::basic_string<char_type>::traits_type traits_type;
+ typedef boost::char_separator<char_type, traits_type> char_separator_type;
+ typedef boost::tokenizer<char_separator_type,
+ typename std::basic_string<char_type>::const_iterator,
+ std::basic_string<char_type> > tokenizer;
+ typedef typename boost::tokenizer<char_separator_type,
+ typename std::basic_string<char_type>::const_iterator,
+ typename std::basic_string<char_type> >::iterator tokenizer_iterator;
+
+ char_type sep_chars[5] = {'-',':',',','.'};
+ char_separator_type sep(sep_chars);
+ tokenizer tok(s,sep);
+ for(tokenizer_iterator beg=tok.begin(); beg!=tok.end();++beg){
+ switch(pos) {
+ case 0: {
+ hour = boost::lexical_cast<int>(*beg);
+ break;
+ }
+ case 1: {
+ min = boost::lexical_cast<unsigned short>(*beg);
+ break;
+ }
+ case 2: {
+ sec = boost::lexical_cast<unsigned short>(*beg);
+ break;
+ };
+ case 3: {
+ int digits = static_cast<int>(beg->length());
+ //Works around a bug in MSVC 6 library that does not support
+ //operator>> thus meaning lexical_cast will fail to compile.
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ // msvc wouldn't compile 'time_duration::num_fractional_digits()'
+ // (required template argument list) as a workaround a temp
+ // time_duration object was used
+ time_duration td(hour,min,sec,fs);
+ int precision = td.num_fractional_digits();
+ // _atoi64 is an MS specific function
+ if(digits >= precision) {
+ // drop excess digits
+ fs = _atoi64(beg->substr(0, precision).c_str());
+ }
+ else {
+ fs = _atoi64(beg->c_str());
+ }
+#else
+ int precision = time_duration::num_fractional_digits();
+ if(digits >= precision) {
+ // drop excess digits
+ fs = boost::lexical_cast<boost::int64_t>(beg->substr(0, precision));
+ }
+ else {
+ fs = boost::lexical_cast<boost::int64_t>(*beg);
+ }
+#endif
+ if(digits < precision){
+ // trailing zeros get dropped from the string,
+ // "1:01:01.1" would yield .000001 instead of .100000
+ // the power() compensates for the missing decimal places
+ fs *= power(10, precision - digits);
+ }
+
+ break;
+ }
+ }//switch
+ pos++;
+ }
+ if(is_neg) {
+ return -time_duration(hour, min, sec, fs);
+ }
+ else {
+ return time_duration(hour, min, sec, fs);
+ }
+ }
+
+ //! 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 "-:,.".
+ */
+ template<class time_duration>
+ inline
+ time_duration
+ parse_delimited_time_duration(const std::string& s)
+ {
+ return str_from_delimited_time_duration<time_duration,char>(s);
+ }
+
+ //! Utility function to split appart string
+ inline
+ bool
+ split(const std::string& s,
+ char sep,
+ std::string& first,
+ std::string& second)
+ {
+ int sep_pos = static_cast<int>(s.find(sep));
+ first = s.substr(0,sep_pos);
+ second = s.substr(sep_pos+1);
+ return true;
+ }
+
+
+ template<class time_type>
+ inline
+ time_type
+ parse_delimited_time(const std::string& s, char sep)
+ {
+ typedef typename time_type::time_duration_type time_duration;
+ typedef typename time_type::date_type date_type;
+
+ //split date/time on a unique delimiter char such as ' ' or 'T'
+ std::string date_string, tod_string;
+ split(s, sep, date_string, tod_string);
+ //call parse_date with first string
+ date_type d = parse_date<date_type>(date_string);
+ //call parse_time_duration with remaining string
+ time_duration td = parse_delimited_time_duration<time_duration>(tod_string);
+ //construct a time
+ return time_type(d, td);
+
+ }
+
+ //! Parse time duration part of an iso time of form: [-]hhmmss[.fff...] (eg: 120259.123 is 12 hours, 2 min, 59 seconds, 123000 microseconds)
+ template<class time_duration>
+ inline
+ time_duration
+ parse_undelimited_time_duration(const std::string& s)
+ {
+ int precision = 0;
+ {
+ // msvc wouldn't compile 'time_duration::num_fractional_digits()'
+ // (required template argument list) as a workaround, a temp
+ // time_duration object was used
+ time_duration tmp(0,0,0,1);
+ precision = tmp.num_fractional_digits();
+ }
+ // 'precision+1' is so we grab all digits, plus the decimal
+ int offsets[] = {2,2,2, precision+1};
+ int pos = 0, sign = 0;
+ int hours = 0;
+ short min=0, sec=0;
+ boost::int64_t fs=0;
+ // increment one position if the string was "signed"
+ if(s.at(sign) == '-')
+ {
+ ++sign;
+ }
+ // stlport choked when passing s.substr() to tokenizer
+ // using a new string fixed the error
+ std::string remain = s.substr(sign);
+ /* We do not want the offset_separator to wrap the offsets, we
+ * will never want to process more than:
+ * 2 char, 2 char, 2 char, frac_sec length.
+ * We *do* want the offset_separator to give us a partial for the
+ * last characters if there were not enough provided in the input string. */
+ bool wrap_off = false;
+ bool ret_part = true;
+ boost::offset_separator osf(offsets, offsets+4, wrap_off, ret_part);
+ typedef boost::tokenizer<boost::offset_separator,
+ std::basic_string<char>::const_iterator,
+ std::basic_string<char> > tokenizer;
+ typedef boost::tokenizer<boost::offset_separator,
+ std::basic_string<char>::const_iterator,
+ std::basic_string<char> >::iterator tokenizer_iterator;
+ tokenizer tok(remain, osf);
+ for(tokenizer_iterator ti=tok.begin(); ti!=tok.end();++ti){
+ switch(pos) {
+ case 0:
+ {
+ hours = boost::lexical_cast<int>(*ti);
+ break;
+ }
+ case 1:
+ {
+ min = boost::lexical_cast<short>(*ti);
+ break;
+ }
+ case 2:
+ {
+ sec = boost::lexical_cast<short>(*ti);
+ break;
+ }
+ case 3:
+ {
+ std::string char_digits(ti->substr(1)); // digits w/no decimal
+ int digits = static_cast<int>(char_digits.length());
+
+ //Works around a bug in MSVC 6 library that does not support
+ //operator>> thus meaning lexical_cast will fail to compile.
+#if (defined(BOOST_MSVC) && (_MSC_VER <= 1200)) // 1200 == VC++ 6.0
+ // _atoi64 is an MS specific function
+ if(digits >= precision) {
+ // drop excess digits
+ fs = _atoi64(char_digits.substr(0, precision).c_str());
+ }
+ else if(digits == 0) {
+ fs = 0; // just in case _atoi64 doesn't like an empty string
+ }
+ else {
+ fs = _atoi64(char_digits.c_str());
+ }
+#else
+ if(digits >= precision) {
+ // drop excess digits
+ fs = boost::lexical_cast<boost::int64_t>(char_digits.substr(0, precision));
+ }
+ else if(digits == 0) {
+ fs = 0; // lexical_cast doesn't like empty strings
+ }
+ else {
+ fs = boost::lexical_cast<boost::int64_t>(char_digits);
+ }
+#endif
+ if(digits < precision){
+ // trailing zeros get dropped from the string,
+ // "1:01:01.1" would yield .000001 instead of .100000
+ // the power() compensates for the missing decimal places
+ fs *= power(10, precision - digits);
+ }
+
+ break;
+ }
+ };
+ pos++;
+ }
+ if(sign) {
+ return -time_duration(hours, min, sec, fs);
+ }
+ else {
+ return time_duration(hours, min, sec, fs);
+ }
+ }
+
+ //! Parse time string of form YYYYMMDDThhmmss where T is delimeter between date and time
+ template<class time_type>
+ inline
+ time_type
+ parse_iso_time(const std::string& s, char sep)
+ {
+ typedef typename time_type::time_duration_type time_duration;
+ typedef typename time_type::date_type date_type;
+
+ //split date/time on a unique delimiter char such as ' ' or 'T'
+ std::string date_string, tod_string;
+ split(s, sep, date_string, tod_string);
+ //call parse_date with first string
+ date_type d = parse_undelimited_date<date_type>(date_string);
+ //call parse_time_duration with remaining string
+ time_duration td = parse_undelimited_time_duration<time_duration>(tod_string);
+ //construct a time
+ return time_type(d, td);
+ }
+
+
+
+} }//namespace date_time
+
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/time_resolution_traits.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_resolution_traits.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,140 @@
+#ifndef DATE_TIME_TIME_RESOLUTION_TRAITS_HPP
+#define DATE_TIME_TIME_RESOLUTION_TRAITS_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/time_defs.hpp"
+#include "boost/date_time/int_adapter.hpp"
+#include "boost/cstdint.hpp"
+
+namespace boost {
+namespace date_time {
+
+ //! Simple function to calculate absolute value of a numeric type
+ template <typename T>
+ // JDG [7/6/02 made a template],
+ // moved here from time_duration.hpp 2003-Sept-4.
+ inline T absolute_value(T x)
+ {
+ return x < 0 ? -x : x;
+ }
+
+ //! traits struct for time_resolution_traits implementation type
+ struct time_resolution_traits_bi32_impl {
+ typedef boost::int32_t int_type;
+ typedef boost::int32_t impl_type;
+ static int_type as_number(impl_type i){ return i;}
+ //! Used to determine if implemented type is int_adapter or int
+ static bool is_adapted() { return false;}
+ };
+ //! traits struct for time_resolution_traits implementation type
+ struct time_resolution_traits_adapted32_impl {
+ typedef boost::int32_t int_type;
+ typedef boost::date_time::int_adapter<boost::int32_t> impl_type;
+ static int_type as_number(impl_type i){ return i.as_number();}
+ //! Used to determine if implemented type is int_adapter or int
+ static bool is_adapted() { return true;}
+ };
+ //! traits struct for time_resolution_traits implementation type
+ struct time_resolution_traits_bi64_impl {
+ typedef boost::int64_t int_type;
+ typedef boost::int64_t impl_type;
+ static int_type as_number(impl_type i){ return i;}
+ //! Used to determine if implemented type is int_adapter or int
+ static bool is_adapted() { return false;}
+ };
+ //! traits struct for time_resolution_traits implementation type
+ struct time_resolution_traits_adapted64_impl {
+ typedef boost::int64_t int_type;
+ typedef boost::date_time::int_adapter<boost::int64_t> impl_type;
+ static int_type as_number(impl_type i){ return i.as_number();}
+ //! Used to determine if implemented type is int_adapter or int
+ static bool is_adapted() { return true;}
+ };
+
+ template<typename frac_sec_type,
+ time_resolutions res,
+#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
+ boost::int64_t resolution_adjust,
+#else
+ typename frac_sec_type::int_type resolution_adjust,
+#endif
+ unsigned short frac_digits,
+ typename v_type = boost::int32_t >
+ class time_resolution_traits {
+ public:
+ typedef typename frac_sec_type::int_type fractional_seconds_type;
+ typedef typename frac_sec_type::int_type tick_type;
+ typedef typename frac_sec_type::impl_type impl_type;
+ typedef v_type day_type;
+ typedef v_type hour_type;
+ typedef v_type min_type;
+ typedef v_type sec_type;
+
+ // bring in function from frac_sec_type traits structs
+ static typename frac_sec_type::int_type as_number(typename frac_sec_type::impl_type i)
+ {
+ return frac_sec_type::as_number(i);
+ }
+ static bool is_adapted()
+ {
+ return frac_sec_type::is_adapted();
+ }
+
+ //Would like this to be frac_sec_type, but some compilers complain
+ BOOST_STATIC_CONSTANT(int, ticks_per_second = resolution_adjust);
+ // static const boost::int32_t ticks_per_second = resolution_adjust;
+
+ static time_resolutions resolution()
+ {
+ return res;
+ }
+ static unsigned short num_fractional_digits()
+ {
+ return frac_digits;
+ }
+ static fractional_seconds_type res_adjust()
+ {
+ return resolution_adjust;
+ }
+ //! Any negative argument results in a negative tick_count
+ static tick_type to_tick_count(hour_type hours,
+ min_type minutes,
+ sec_type seconds,
+ fractional_seconds_type fs)
+ {
+ if(hours < 0 || minutes < 0 || seconds < 0 || fs < 0)
+ {
+ hours = absolute_value(hours);
+ minutes = absolute_value(minutes);
+ seconds = absolute_value(seconds);
+ fs = absolute_value(fs);
+ return (((((fractional_seconds_type(hours)*3600)
+ + (fractional_seconds_type(minutes)*60)
+ + seconds)*res_adjust()) + fs) * -1);
+ }
+
+ return (((fractional_seconds_type(hours)*3600)
+ + (fractional_seconds_type(minutes)*60)
+ + seconds)*res_adjust()) + fs;
+ }
+
+ };
+
+ typedef time_resolution_traits<time_resolution_traits_adapted32_impl, milli, 1000, 3 > milli_res;
+ typedef time_resolution_traits<time_resolution_traits_adapted64_impl, micro, 1000000, 6 > micro_res;
+ typedef time_resolution_traits<time_resolution_traits_adapted64_impl, nano, 1000000000, 9 > nano_res;
+
+
+} } //namespace date_time
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/time_system_counted.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_system_counted.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,254 @@
+#ifndef DATE_TIME_TIME_SYSTEM_COUNTED_HPP
+#define DATE_TIME_TIME_SYSTEM_COUNTED_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)
+ * Author: Jeff Garland, Bart Garst
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+
+#include "boost/date_time/time_defs.hpp"
+#include <string>
+
+
+namespace boost {
+namespace date_time {
+
+ //! Time representation that uses a single integer count
+ template<class config>
+ struct counted_time_rep
+ {
+ typedef typename config::int_type int_type;
+ typedef typename config::date_type date_type;
+ typedef typename config::impl_type impl_type;
+ typedef typename date_type::duration_type date_duration_type;
+ typedef typename date_type::calendar_type calendar_type;
+ typedef typename date_type::ymd_type ymd_type;
+ typedef typename config::time_duration_type time_duration_type;
+ typedef typename config::resolution_traits resolution_traits;
+
+ counted_time_rep(const date_type& d, const time_duration_type& time_of_day)
+ : time_count_(1)
+ {
+ if(d.is_infinity() || d.is_not_a_date() || time_of_day.is_special()) {
+ time_count_ = time_of_day.get_rep() + d.day_count();
+ //std::cout << time_count_ << std::endl;
+ }
+ else {
+ time_count_ = (d.day_number() * frac_sec_per_day()) + time_of_day.ticks();
+ }
+ }
+ explicit counted_time_rep(int_type count) :
+ time_count_(count)
+ {}
+ explicit counted_time_rep(impl_type count) :
+ time_count_(count)
+ {}
+ date_type date() const
+ {
+ if(time_count_.is_special()) {
+ return date_type(time_count_.as_special());
+ }
+ else {
+ typename calendar_type::date_int_type dc = day_count();
+ //std::cout << "time_rep here:" << dc << std::endl;
+ ymd_type ymd = calendar_type::from_day_number(dc);
+ return date_type(ymd);
+ }
+ }
+ //int_type day_count() const
+ unsigned long day_count() const
+ {
+ /* resolution_traits::as_number returns a boost::int64_t &
+ * frac_sec_per_day is also a boost::int64_t so, naturally,
+ * the division operation returns a boost::int64_t.
+ * The static_cast to an unsigned long is ok (results in no data loss)
+ * because frac_sec_per_day is either the number of
+ * microseconds per day, or the number of nanoseconds per day.
+ * Worst case scenario: resolution_traits::as_number returns the
+ * maximum value an int64_t can hold and frac_sec_per_day
+ * is microseconds per day (lowest possible value).
+ * The division operation will then return a value of 106751991 -
+ * easily fitting in an unsigned long.
+ */
+ return static_cast<unsigned long>(resolution_traits::as_number(time_count_) / frac_sec_per_day());
+ }
+ int_type time_count() const
+ {
+ return resolution_traits::as_number(time_count_);
+ }
+ int_type tod() const
+ {
+ return resolution_traits::as_number(time_count_) % frac_sec_per_day();
+ }
+ static int_type frac_sec_per_day()
+ {
+ int_type seconds_per_day = 60*60*24;
+ int_type fractional_sec_per_sec(resolution_traits::res_adjust());
+ return seconds_per_day*fractional_sec_per_sec;
+ }
+ bool is_pos_infinity()const
+ {
+ return impl_type::is_pos_inf(time_count_.as_number());
+ }
+ bool is_neg_infinity()const
+ {
+ return impl_type::is_neg_inf(time_count_.as_number());
+ }
+ bool is_not_a_date_time()const
+ {
+ return impl_type::is_not_a_number(time_count_.as_number());
+ }
+ bool is_special()const
+ {
+ return time_count_.is_special();
+ }
+ impl_type get_rep()const
+ {
+ return time_count_;
+ }
+ private:
+ impl_type time_count_;
+ };
+
+ //! An unadjusted time system implementation.
+ template<class time_rep>
+ class counted_time_system
+ {
+ public:
+ typedef time_rep time_rep_type;
+ typedef typename time_rep_type::impl_type impl_type;
+ typedef typename time_rep_type::time_duration_type time_duration_type;
+ typedef typename time_duration_type::fractional_seconds_type fractional_seconds_type;
+ typedef typename time_rep_type::date_type date_type;
+ typedef typename time_rep_type::date_duration_type date_duration_type;
+
+
+ template<class T> static void unused_var(const T&) {}
+
+ static time_rep_type get_time_rep(const date_type& day,
+ const time_duration_type& tod,
+ date_time::dst_flags dst=not_dst)
+ {
+ unused_var(dst);
+ return time_rep_type(day, tod);
+ }
+
+ static time_rep_type get_time_rep(special_values sv)
+ {
+ switch (sv) {
+ case not_a_date_time:
+ return time_rep_type(date_type(not_a_date_time),
+ time_duration_type(not_a_date_time));
+ case pos_infin:
+ return time_rep_type(date_type(pos_infin),
+ time_duration_type(pos_infin));
+ case neg_infin:
+ return time_rep_type(date_type(neg_infin),
+ time_duration_type(neg_infin));
+ case max_date_time: {
+ time_duration_type td = time_duration_type(24,0,0,0) - time_duration_type(0,0,0,1);
+ return time_rep_type(date_type(max_date_time), td);
+ }
+ case min_date_time:
+ return time_rep_type(date_type(min_date_time), time_duration_type(0,0,0,0));
+
+ default:
+ return time_rep_type(date_type(not_a_date_time),
+ time_duration_type(not_a_date_time));
+
+ }
+
+ }
+
+ static date_type get_date(const time_rep_type& val)
+ {
+ return val.date();
+ }
+ static time_duration_type get_time_of_day(const time_rep_type& val)
+ {
+ if(val.is_special()) {
+ return time_duration_type(val.get_rep().as_special());
+ }
+ else{
+ return time_duration_type(0,0,0,val.tod());
+ }
+ }
+ static std::string zone_name(const time_rep_type&)
+ {
+ return "";
+ }
+ static bool is_equal(const time_rep_type& lhs, const time_rep_type& rhs)
+ {
+ return (lhs.time_count() == rhs.time_count());
+ }
+ static bool is_less(const time_rep_type& lhs, const time_rep_type& rhs)
+ {
+ return (lhs.time_count() < rhs.time_count());
+ }
+ static time_rep_type add_days(const time_rep_type& base,
+ const date_duration_type& dd)
+ {
+ if(base.is_special() || dd.is_special()) {
+ return(time_rep_type(base.get_rep() + dd.get_rep()));
+ }
+ else {
+ return time_rep_type(base.time_count() + (dd.days() * time_rep_type::frac_sec_per_day()));
+ }
+ }
+ static time_rep_type subtract_days(const time_rep_type& base,
+ const date_duration_type& dd)
+ {
+ if(base.is_special() || dd.is_special()) {
+ return(time_rep_type(base.get_rep() - dd.get_rep()));
+ }
+ else{
+ return time_rep_type(base.time_count() - (dd.days() * time_rep_type::frac_sec_per_day()));
+ }
+ }
+ static time_rep_type subtract_time_duration(const time_rep_type& base,
+ const time_duration_type& td)
+ {
+ if(base.is_special() || td.is_special()) {
+ return(time_rep_type(base.get_rep() - td.get_rep()));
+ }
+ else {
+ return time_rep_type(base.time_count() - td.ticks());
+ }
+ }
+ static time_rep_type add_time_duration(const time_rep_type& base,
+ time_duration_type td)
+ {
+ if(base.is_special() || td.is_special()) {
+ return(time_rep_type(base.get_rep() + td.get_rep()));
+ }
+ else {
+ return time_rep_type(base.time_count() + td.ticks());
+ }
+ }
+ static time_duration_type subtract_times(const time_rep_type& lhs,
+ const time_rep_type& rhs)
+ {
+ if(lhs.is_special() || rhs.is_special()) {
+ return(time_duration_type(
+ impl_type::to_special((lhs.get_rep() - rhs.get_rep()).as_number())));
+ }
+ else {
+ fractional_seconds_type fs = lhs.time_count() - rhs.time_count();
+ return time_duration_type(0,0,0,fs);
+ }
+ }
+
+ };
+
+
+} } //namespace date_time
+
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/time_system_split.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_system_split.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,213 @@
+#ifndef DATE_TIME_TIME_SYSTEM_SPLIT_HPP
+#define DATE_TIME_TIME_SYSTEM_SPLIT_HPP
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include <string>
+#include "boost/date_time/compiler_config.hpp"
+#include "boost/date_time/special_defs.hpp"
+
+namespace boost {
+namespace date_time {
+
+ //! An unadjusted time system implementation.
+#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT))
+ template<typename config, boost::int32_t ticks_per_second>
+#else
+ template<typename config>
+#endif
+ class split_timedate_system
+ {
+ public:
+ typedef typename config::time_rep_type time_rep_type;
+ typedef typename config::date_type date_type;
+ typedef typename config::time_duration_type time_duration_type;
+ typedef typename config::date_duration_type date_duration_type;
+ typedef typename config::int_type int_type;
+ typedef typename config::resolution_traits resolution_traits;
+
+ //86400 is number of seconds in a day...
+#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT))
+ typedef date_time::wrapping_int<int_type, INT64_C(86400) * ticks_per_second > wrap_int_type;
+#else
+ private:
+ BOOST_STATIC_CONSTANT(int_type, ticks_per_day = INT64_C(86400) * config::tick_per_second);
+ public:
+# if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0X581) )
+ typedef date_time::wrapping_int< split_timedate_system::int_type, split_timedate_system::ticks_per_day> wrap_int_type;
+# else
+ typedef date_time::wrapping_int<int_type, ticks_per_day> wrap_int_type;
+#endif
+#endif
+
+ static time_rep_type get_time_rep(special_values sv)
+ {
+ switch (sv) {
+ case not_a_date_time:
+ return time_rep_type(date_type(not_a_date_time),
+ time_duration_type(not_a_date_time));
+ case pos_infin:
+ return time_rep_type(date_type(pos_infin),
+ time_duration_type(pos_infin));
+ case neg_infin:
+ return time_rep_type(date_type(neg_infin),
+ time_duration_type(neg_infin));
+ case max_date_time: {
+ time_duration_type td = time_duration_type(24,0,0,0) - time_duration_type(0,0,0,1);
+ return time_rep_type(date_type(max_date_time), td);
+ }
+ case min_date_time:
+ return time_rep_type(date_type(min_date_time), time_duration_type(0,0,0,0));
+
+ default:
+ return time_rep_type(date_type(not_a_date_time),
+ time_duration_type(not_a_date_time));
+
+ }
+
+ }
+
+ static time_rep_type get_time_rep(const date_type& day,
+ const time_duration_type& tod,
+ date_time::dst_flags dst=not_dst)
+ {
+ if(day.is_special() || tod.is_special()) {
+ if(day.is_not_a_date() || tod.is_not_a_date_time()) {
+ return time_rep_type(date_type(not_a_date_time),
+ time_duration_type(not_a_date_time));
+ }
+ else if(day.is_pos_infinity()) {
+ if(tod.is_neg_infinity()) {
+ return time_rep_type(date_type(not_a_date_time),
+ time_duration_type(not_a_date_time));
+ }
+ else {
+ return time_rep_type(day, time_duration_type(pos_infin));
+ }
+ }
+ else if(day.is_neg_infinity()) {
+ if(tod.is_pos_infinity()) {
+ return time_rep_type(date_type(not_a_date_time),
+ time_duration_type(not_a_date_time));
+ }
+ else {
+ return time_rep_type(day, time_duration_type(neg_infin));
+ }
+ }
+ else if(tod.is_pos_infinity()) {
+ if(day.is_neg_infinity()) {
+ return time_rep_type(date_type(not_a_date_time),
+ time_duration_type(not_a_date_time));
+ }
+ else {
+ return time_rep_type(date_type(pos_infin), tod);
+ }
+ }
+ else if(tod.is_neg_infinity()) {
+ if(day.is_pos_infinity()) {
+ return time_rep_type(date_type(not_a_date_time),
+ time_duration_type(not_a_date_time));
+ }
+ else {
+ return time_rep_type(date_type(neg_infin), tod);
+ }
+ }
+ }
+ return time_rep_type(day, tod);
+ }
+ static date_type get_date(const time_rep_type& val)
+ {
+ return date_type(val.day);
+ }
+ static time_duration_type get_time_of_day(const time_rep_type& val)
+ {
+ return time_duration_type(val.time_of_day);
+ }
+ static std::string zone_name(const time_rep_type&)
+ {
+ return "";
+ }
+ static bool is_equal(const time_rep_type& lhs, const time_rep_type& rhs)
+ {
+ return ((lhs.day == rhs.day) && (lhs.time_of_day == rhs.time_of_day));
+ }
+ static bool is_less(const time_rep_type& lhs, const time_rep_type& rhs)
+ {
+ if (lhs.day < rhs.day) return true;
+ if (lhs.day > rhs.day) return false;
+ return (lhs.time_of_day < rhs.time_of_day);
+ }
+ static time_rep_type add_days(const time_rep_type& base,
+ const date_duration_type& dd)
+ {
+ return time_rep_type(base.day+dd, base.time_of_day);
+ }
+ static time_rep_type subtract_days(const time_rep_type& base,
+ const date_duration_type& dd)
+ {
+ return split_timedate_system::get_time_rep(base.day-dd, base.time_of_day);
+ }
+ static time_rep_type subtract_time_duration(const time_rep_type& base,
+ const time_duration_type& td)
+ {
+ if(base.day.is_special() || td.is_special())
+ {
+ return split_timedate_system::get_time_rep(base.day, -td);
+ }
+ if (td.is_negative()) {
+ time_duration_type td1 = td.invert_sign();
+ return add_time_duration(base,td1);
+ }
+
+ //std::cout << td.ticks() << std::endl;
+ wrap_int_type day_offset(base.time_of_day.ticks());
+ date_duration_type day_overflow(static_cast<typename date_duration_type::duration_rep_type>(day_offset.subtract(td.ticks())));
+// std::cout << "sub: " << base.time_of_day.ticks() << "|"
+// << day_offset.as_int() << "|"
+// << day_overflow.days() << std::endl;
+ return time_rep_type(base.day-day_overflow,
+ time_duration_type(0,0,0,day_offset.as_int()));
+ }
+ static time_rep_type add_time_duration(const time_rep_type& base,
+ time_duration_type td)
+ {
+ if(base.day.is_special() || td.is_special()) {
+ return split_timedate_system::get_time_rep(base.day, td);
+ }
+ if (td.is_negative()) {
+ time_duration_type td1 = td.invert_sign();
+ return subtract_time_duration(base,td1);
+ }
+ wrap_int_type day_offset(base.time_of_day.ticks());
+ typename date_duration_type::duration_rep_type doff = day_offset.add(td.ticks());
+// std::cout << "day overflow: " << doff << std::endl;
+// std::cout << "ticks: " << td.ticks() << std::endl;
+ date_duration_type day_overflow(doff);
+// std::cout << "base: " << to_simple_string(base.day) << std::endl;
+// std::cout << "overflow " << day_overflow.days() << std::endl;
+ return time_rep_type(base.day+day_overflow,
+ time_duration_type(0,0,0,day_offset.as_int()));
+ }
+ static time_duration_type subtract_times(const time_rep_type& lhs,
+ const time_rep_type& rhs)
+ {
+ date_duration_type dd = lhs.day - rhs.day;
+ time_duration_type td(dd.days()*24,0,0); //days * 24 hours
+ time_duration_type td2 = lhs.time_of_day - rhs.time_of_day;
+ return td+td2;
+ // return time_rep_type(base.day-dd, base.time_of_day);
+ }
+
+ };
+
+} } //namespace date_time
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/time_zone_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_zone_base.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,99 @@
+#ifndef _DATE_TIME_TIME_ZONE_BASE__
+#define _DATE_TIME_TIME_ZONE_BASE__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include <string>
+#include <sstream>
+
+namespace boost {
+namespace date_time {
+
+
+
+ //! 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.
+ */
+ template<typename time_type, typename CharT>
+ class time_zone_base {
+ public:
+ typedef CharT char_type;
+ typedef std::basic_string<CharT> string_type;
+ typedef std::basic_ostringstream<CharT> stringstream_type;
+ typedef typename time_type::date_type::year_type year_type;
+ typedef typename time_type::time_duration_type time_duration_type;
+
+ time_zone_base() {};
+ virtual ~time_zone_base() {};
+ //!String for the timezone when in daylight savings (eg: EDT)
+ virtual string_type dst_zone_abbrev() const=0;
+ //!String for the zone when not in daylight savings (eg: EST)
+ virtual string_type std_zone_abbrev() const=0;
+ //!String for the timezone when in daylight savings (eg: Eastern Daylight Time)
+ virtual string_type dst_zone_name() const=0;
+ //!String for the zone when not in daylight savings (eg: Eastern Standard Time)
+ virtual string_type std_zone_name() const=0;
+ //! True if zone uses daylight savings adjustments otherwise false
+ virtual bool has_dst() const=0;
+ //! Local time that DST starts -- undefined if has_dst is false
+ virtual time_type dst_local_start_time(year_type y) const=0;
+ //! Local time that DST ends -- undefined if has_dst is false
+ virtual time_type dst_local_end_time(year_type y) const=0;
+ //! Base offset from UTC for zone (eg: -07:30:00)
+ virtual time_duration_type base_utc_offset() const=0;
+ //! Adjustment forward or back made while DST is in effect
+ virtual time_duration_type dst_offset() const=0;
+ //! Returns a POSIX time_zone string for this object
+ virtual string_type to_posix_string() const =0;
+
+ private:
+
+ };
+
+
+ //! Structure which holds the time offsets associated with daylight savings time
+ /*!
+ *@param time_duration_type A type used to represent the offset
+ */
+ template<class time_duration_type>
+ class dst_adjustment_offsets
+ {
+ public:
+ dst_adjustment_offsets(const time_duration_type& dst_adjust,
+ const time_duration_type& dst_start_offset,
+ const time_duration_type& dst_end_offset) :
+ dst_adjust_(dst_adjust),
+ dst_start_offset_(dst_start_offset),
+ dst_end_offset_(dst_end_offset)
+ {}
+
+ //! Amount DST adjusts the clock eg: plus one hour
+ time_duration_type dst_adjust_;
+ //! Time past midnight on start transition day that dst starts
+ time_duration_type dst_start_offset_;
+ //! Time past midnight on end transition day that dst ends
+ time_duration_type dst_end_offset_;
+ };
+
+
+} } //namespace date_time
+
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/time_zone_names.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/time_zone_names.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,98 @@
+#ifndef DATE_TIME_TIME_ZONE_NAMES_HPP__
+#define DATE_TIME_TIME_ZONE_NAMES_HPP__
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <string>
+
+namespace boost {
+namespace date_time {
+
+ template<class CharT>
+ struct default_zone_names {
+ public:
+ typedef CharT char_type;
+ static const char_type standard_name[9];
+ static const char_type standard_abbrev[11];
+ static const char_type non_dst_identifier[7];
+ };
+ template <class CharT>
+ const typename default_zone_names<CharT>::char_type
+ default_zone_names<CharT>::standard_name[9] =
+ {'s','t','d','_','n','a','m','e'};
+
+ template <class CharT>
+ const typename default_zone_names<CharT>::char_type
+ default_zone_names<CharT>::standard_abbrev[11] =
+ {'s','t','d','_','a','b','b','r','e','v'};
+
+ template <class CharT>
+ const typename default_zone_names<CharT>::char_type
+ default_zone_names<CharT>::non_dst_identifier[7] =
+ {'n','o','-','d','s','t'};
+
+ //! 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.
+ *@parm CharT Allows class to support different character types
+ */
+ template<class CharT>
+ class time_zone_names_base
+ {
+ public:
+ typedef std::basic_string<CharT> string_type;
+ time_zone_names_base() :
+ std_zone_name_(default_zone_names<CharT>::standard_name),
+ std_zone_abbrev_(default_zone_names<CharT>::standard_abbrev),
+ dst_zone_name_(default_zone_names<CharT>::non_dst_identifier),
+ dst_zone_abbrev_(default_zone_names<CharT>::non_dst_identifier)
+ {}
+ time_zone_names_base(const string_type& std_zone_name_str,
+ const string_type& std_zone_abbrev_str,
+ const string_type& dst_zone_name_str,
+ const string_type& dst_zone_abbrev_str) :
+ std_zone_name_(std_zone_name_str),
+ std_zone_abbrev_(std_zone_abbrev_str),
+ dst_zone_name_(dst_zone_name_str),
+ dst_zone_abbrev_(dst_zone_abbrev_str)
+ {}
+ string_type dst_zone_abbrev() const
+ {
+ return dst_zone_abbrev_;
+ }
+ string_type std_zone_abbrev() const
+ {
+ return std_zone_abbrev_;
+ }
+ string_type dst_zone_name() const
+ {
+ return dst_zone_name_;
+ }
+ string_type std_zone_name() const
+ {
+ return std_zone_name_;
+ }
+ private:
+ string_type std_zone_name_;
+ string_type std_zone_abbrev_;
+ string_type dst_zone_name_;
+ string_type dst_zone_abbrev_;
+
+ };
+
+ //! Specialization of timezone names for standard char.
+ //typedef time_zone_names_base<char> time_zone_names;
+
+} } //namespace
+
+
+#endif

Added: sandbox/SOC/2008/calendar/boost/date_time/tz_db_base.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/tz_db_base.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,376 @@
+#ifndef DATE_TIME_TZ_DB_BASE_HPP__
+#define DATE_TIME_TZ_DB_BASE_HPP__
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/shared_ptr.hpp"
+#include "boost/date_time/time_zone_names.hpp"
+#include "boost/date_time/time_zone_base.hpp"
+#include "boost/date_time/time_parsing.hpp"
+#include "boost/tokenizer.hpp"
+#include <string>
+#include <sstream>
+#include <map>
+#include <vector>
+#include <stdexcept>
+#include <fstream>
+
+namespace boost {
+ namespace date_time {
+
+ //! Exception thrown when tz database cannot locate requested data file
+ class data_not_accessible : public std::logic_error
+ {
+ public:
+ data_not_accessible() :
+ std::logic_error(std::string("Unable to locate or access the required datafile."))
+ {}
+ data_not_accessible(const std::string& filespec) :
+ std::logic_error(std::string("Unable to locate or access the required datafile. Filespec: " + filespec))
+ {}
+ };
+
+ //! Exception thrown when tz database locates incorrect field structure in data file
+ class bad_field_count : public std::out_of_range
+ {
+ public:
+ bad_field_count(const std::string& s) :
+ std::out_of_range(s)
+ {}
+ };
+
+ //! 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:
+ * @code
+ * "America/Phoenix" <- string enclosed in quotes
+ * "" <- empty field
+ * @endcode
+ *
+ * Some fields represent a length of time. The format of these fields
+ * must be:
+ * @code
+ * "{+|-}hh:mm[:ss]" <- length-of-time format
+ * @endcode
+ * 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:
+ * @code
+ * 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
+ * @endcode
+ *
+ * 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.
+ */
+ template<class time_zone_type, class rule_type>
+ class tz_db_base {
+ public:
+ /* Having CharT as a template parameter created problems
+ * with posix_time::duration_from_string. Templatizing
+ * duration_from_string was not possible at this time, however,
+ * it should be possible in the future (when poor compilers get
+ * fixed or stop being used).
+ * Since this class was designed to use CharT as a parameter it
+ * is simply typedef'd here to ease converting in back to a
+ * parameter the future */
+ typedef char char_type;
+
+ typedef typename time_zone_type::base_type time_zone_base_type;
+ typedef typename time_zone_type::time_duration_type time_duration_type;
+ typedef time_zone_names_base<char_type> time_zone_names;
+ typedef dst_adjustment_offsets<time_duration_type> dst_adjustment_offsets;
+ typedef std::basic_string<char_type> string_type;
+
+ //! Constructs an empty database
+ tz_db_base() {}
+
+ //! Process csv data file, may throw exceptions
+ /*! May throw data_not_accessible, or bad_field_count exceptions */
+ void load_from_file(const std::string& pathspec)
+ {
+ string_type in_str;
+ std::string buff;
+
+ std::ifstream ifs(pathspec.c_str());
+ if(!ifs){
+ throw data_not_accessible(pathspec);
+ }
+ std::getline(ifs, buff); // first line is column headings
+
+ while( std::getline(ifs, buff)) {
+ parse_string(buff);
+ }
+ }
+
+ //! returns true if record successfully added to map
+ /*! Takes an id string 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. */
+ bool add_record(const string_type& id,
+ boost::shared_ptr<time_zone_base_type> tz)
+ {
+ typename map_type::value_type p(id, tz);
+ return (m_zone_map.insert(p)).second;
+ }
+
+ //! 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 */
+ boost::shared_ptr<time_zone_base_type>
+ time_zone_from_region(const string_type& region) const
+ {
+ // get the record
+ typename map_type::const_iterator record = m_zone_map.find(region);
+ if(record == m_zone_map.end()){
+ return boost::shared_ptr<time_zone_base_type>(); //null pointer
+ }
+ return record->second;
+ }
+
+ //! Returns a vector of strings holding the time zone regions in the database
+ std::vector<std::string> region_list() const
+ {
+ typedef std::vector<std::string> vector_type;
+ vector_type regions;
+ typename map_type::const_iterator itr = m_zone_map.begin();
+ while(itr != m_zone_map.end()) {
+ regions.push_back(itr->first);
+ ++itr;
+ }
+ return regions;
+ }
+
+ private:
+ typedef std::map<string_type, boost::shared_ptr<time_zone_base_type> > map_type;
+ map_type m_zone_map;
+
+ // start and end rule are of the same type
+ typedef typename rule_type::start_rule::week_num week_num;
+
+ /* TODO: mechanisms need to be put in place to handle different
+ * types of rule specs. parse_rules() only handles nth_kday
+ * rule types. */
+
+ //! parses rule specs for transition day rules
+ rule_type* parse_rules(const string_type& sr, const string_type& er) const
+ {
+ using namespace gregorian;
+ // start and end rule are of the same type,
+ // both are included here for readability
+ typedef typename rule_type::start_rule start_rule;
+ typedef typename rule_type::end_rule end_rule;
+
+ // these are: [start|end] nth, day, month
+ int s_nth = 0, s_d = 0, s_m = 0;
+ int e_nth = 0, e_d = 0, e_m = 0;
+ split_rule_spec(s_nth, s_d, s_m, sr);
+ split_rule_spec(e_nth, e_d, e_m, er);
+
+ typename start_rule::week_num s_wn, e_wn;
+ s_wn = get_week_num(s_nth);
+ e_wn = get_week_num(e_nth);
+
+
+ return new rule_type(start_rule(s_wn, s_d, s_m),
+ end_rule(e_wn, e_d, e_m));
+ }
+ //! helper function for parse_rules()
+ week_num get_week_num(int nth) const
+ {
+ typedef typename rule_type::start_rule start_rule;
+ switch(nth){
+ case 1:
+ return start_rule::first;
+ case 2:
+ return start_rule::second;
+ case 3:
+ return start_rule::third;
+ case 4:
+ return start_rule::fourth;
+ case 5:
+ case -1:
+ return start_rule::fifth;
+ default:
+ // shouldn't get here - add error handling later
+ break;
+ }
+ return start_rule::fifth; // silence warnings
+ }
+
+ //! splits the [start|end]_date_rule string into 3 ints
+ void split_rule_spec(int& nth, int& d, int& m, string_type rule) const
+ {
+ typedef boost::char_separator<char_type, std::char_traits<char_type> > char_separator_type;
+ typedef boost::tokenizer<char_separator_type,
+ std::basic_string<char_type>::const_iterator,
+ std::basic_string<char_type> > tokenizer;
+ typedef boost::tokenizer<char_separator_type,
+ std::basic_string<char_type>::const_iterator,
+ std::basic_string<char_type> >::iterator tokenizer_iterator;
+
+ const char_type sep_char[] = { ';', '\0'};
+ char_separator_type sep(sep_char);
+ tokenizer tokens(rule, sep); // 3 fields
+
+ tokenizer_iterator tok_iter = tokens.begin();
+ nth = std::atoi(tok_iter->c_str()); ++tok_iter;
+ d = std::atoi(tok_iter->c_str()); ++tok_iter;
+ m = std::atoi(tok_iter->c_str());
+ }
+
+
+ //! 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 */
+ bool parse_string(string_type& s)
+ {
+
+ std::vector<string_type> result;
+ typedef boost::token_iterator_generator<boost::escaped_list_separator<char_type>, string_type::const_iterator, string_type >::type token_iter_type;
+
+ token_iter_type i = boost::make_token_iterator<string_type>(s.begin(), s.end(),boost::escaped_list_separator<char_type>());
+
+ token_iter_type end;
+ while (i != end) {
+ result.push_back(*i);
+ i++;
+ }
+
+ enum db_fields { ID, STDABBR, STDNAME, DSTABBR, DSTNAME, GMTOFFSET,
+ DSTADJUST, START_DATE_RULE, START_TIME, END_DATE_RULE,
+ END_TIME, FIELD_COUNT };
+
+ //take a shot at fixing gcc 4.x error
+ const unsigned int expected_fields = static_cast<unsigned int>(FIELD_COUNT);
+ if (result.size() != expected_fields) {
+ std::stringstream msg;
+ msg << "Expecting " << FIELD_COUNT << " fields, got "
+ << result.size() << " fields in line: " << s;
+ throw bad_field_count(msg.str());
+ }
+
+ // initializations
+ bool has_dst = true;
+ if(result[DSTABBR] == std::string()){
+ has_dst = false;
+ }
+
+
+ // start building components of a time_zone
+ time_zone_names names(result[STDNAME], result[STDABBR],
+ result[DSTNAME], result[DSTABBR]);
+
+ time_duration_type utc_offset =
+ str_from_delimited_time_duration<time_duration_type,char_type>(result[GMTOFFSET]);
+
+ dst_adjustment_offsets adjust(time_duration_type(0,0,0),
+ time_duration_type(0,0,0),
+ time_duration_type(0,0,0));
+
+ boost::shared_ptr<rule_type> rules;
+
+ if(has_dst){
+ adjust = dst_adjustment_offsets(
+ str_from_delimited_time_duration<time_duration_type,char_type>(result[DSTADJUST]),
+ str_from_delimited_time_duration<time_duration_type,char_type>(result[START_TIME]),
+ str_from_delimited_time_duration<time_duration_type,char_type>(result[END_TIME])
+ );
+
+ rules =
+ boost::shared_ptr<rule_type>(parse_rules(result[START_DATE_RULE],
+ result[END_DATE_RULE]));
+ }
+ string_type id(result[ID]);
+ boost::shared_ptr<time_zone_base_type> zone(new time_zone_type(names, utc_offset, adjust, rules));
+ return (add_record(id, zone));
+
+ }
+
+ };
+
+} } // namespace
+
+#endif // DATE_TIME_TZ_DB_BASE_HPP__

Added: sandbox/SOC/2008/calendar/boost/date_time/wrapping_int.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/wrapping_int.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,163 @@
+#ifndef _DATE_TIME_WRAPPING_INT_HPP__
+#define _DATE_TIME_WRAPPING_INT_HPP__
+
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+namespace boost {
+namespace date_time {
+
+//! 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!
+ */
+template<typename int_type_, int_type_ wrap_val>
+class wrapping_int {
+public:
+ typedef int_type_ int_type;
+ //typedef overflow_type_ overflow_type;
+ static int_type wrap_value() {return wrap_val;}
+ //!Add, return true if wrapped
+ wrapping_int(int_type v) : value_(v) {};
+ //! Explicit converion method
+ int_type as_int() const {return value_;}
+ operator int_type() const {return value_;}
+ //!Add, 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 */
+ int_type add(int_type v)
+ {
+ int_type remainder = static_cast<int_type>(v % (wrap_val));
+ int_type overflow = static_cast<int_type>(v / (wrap_val));
+ value_ = static_cast<int_type>(value_ + remainder);
+ return calculate_wrap(overflow);
+ }
+ //! Subtract 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_type subtract(int_type v)
+ {
+ int_type remainder = static_cast<int_type>(v % (wrap_val));
+ int_type underflow = static_cast<int_type>(-(v / (wrap_val)));
+ value_ = static_cast<int_type>(value_ - remainder);
+ return calculate_wrap(underflow) * -1;
+ }
+private:
+ int_type value_;
+
+ int_type calculate_wrap(int_type wrap)
+ {
+ if ((value_) >= wrap_val)
+ {
+ wrap++;
+ value_ -= (wrap_val);
+ }
+ else if(value_ < 0)
+ {
+ wrap--;
+ value_ += (wrap_val);
+ }
+ return wrap;
+ }
+
+};
+
+
+//! 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.
+ */
+template<typename int_type_, int_type_ wrap_min, int_type_ wrap_max>
+class wrapping_int2 {
+public:
+ typedef int_type_ int_type;
+ static int_type wrap_value() {return wrap_max;}
+ static int_type min_value() {return wrap_min;}
+ /*! If initializing value is out of range of [wrap_min, wrap_max],
+ * value will be initialized to closest of min or max */
+ wrapping_int2(int_type v) : value_(v) {
+ if(value_ < wrap_min)
+ {
+ value_ = wrap_min;
+ }
+ if(value_ > wrap_max)
+ {
+ value_ = wrap_max;
+ }
+ }
+ //! Explicit converion method
+ int_type as_int() const {return value_;}
+ operator int_type() const {return value_;}
+ //!Add, 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 */
+ int_type add(int_type v)
+ {
+ int_type remainder = static_cast<int_type>(v % (wrap_max - wrap_min + 1));
+ int_type overflow = static_cast<int_type>(v / (wrap_max - wrap_min + 1));
+ value_ = static_cast<int_type>(value_ + remainder);
+ return calculate_wrap(overflow);
+ }
+ //! Subtract 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_type subtract(int_type v)
+ {
+ int_type remainder = static_cast<int_type>(v % (wrap_max - wrap_min + 1));
+ int_type underflow = static_cast<int_type>(-(v / (wrap_max - wrap_min + 1)));
+ value_ = static_cast<int_type>(value_ - remainder);
+ return calculate_wrap(underflow);
+ }
+
+private:
+ int_type value_;
+
+ int_type calculate_wrap(int_type wrap)
+ {
+ if ((value_) > wrap_max)
+ {
+ wrap++;
+ value_ -= (wrap_max - wrap_min + 1);
+ }
+ else if((value_) < wrap_min)
+ {
+ wrap--;
+ value_ += (wrap_max - wrap_min + 1);
+ }
+ return wrap;
+ }
+};
+
+
+
+} } //namespace date_time
+
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/boost/date_time/year_month_day.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/boost/date_time/year_month_day.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,45 @@
+#ifndef YearMonthDayBase_HPP__
+#define YearMonthDayBase_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)
+ * Author: Jeff Garland
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+namespace boost {
+namespace date_time {
+
+ //! Allow rapid creation of ymd triples of different types
+ template<typename YearType, typename MonthType, typename DayType>
+ struct year_month_day_base {
+ year_month_day_base(YearType year,
+ MonthType month,
+ DayType day);
+ YearType year;
+ MonthType month;
+ DayType day;
+ typedef YearType year_type;
+ typedef MonthType month_type;
+ typedef DayType day_type;
+ };
+
+
+ //! A basic constructor
+ template<typename YearType, typename MonthType, typename DayType>
+ inline
+ year_month_day_base<YearType,MonthType,DayType>::year_month_day_base(YearType y,
+ MonthType m,
+ DayType d) :
+ year(y),
+ month(m),
+ day(d)
+ {}
+
+} }//namespace date_time
+
+
+#endif
+

Added: sandbox/SOC/2008/calendar/libs/date_time/build/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/build/Jamfile.v2 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,34 @@
+# 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)
+#
+# Boost.date_time build and test Jamfile
+#
+# Based on boost.python Jamfile
+#
+# To run all tests quietly: jam test
+#
+# Declares the following targets:
+# 1. libboost_date_time, a static link library to be linked with all
+# Boost.date_time modules
+#
+
+
+project boost/date_time
+ : requirements
+ <define>DATE_TIME_INLINE
+ <link>shared:<define>BOOST_ALL_DYN_LINK=1
+ <link>static:<define>BOOST_DATE_TIME_STATIC_LINK
+ : usage-requirements
+ <define>DATE_TIME_INLINE
+ <link>shared:<define>BOOST_DATE_TIME_DYN_LINK=1
+ : source-location ../src
+ ;
+
+# Base names of the source files for libboost_date_time
+CPP_SOURCES = greg_month greg_weekday date_generators ;
+
+lib boost_date_time : gregorian/$(CPP_SOURCES).cpp ;
+
+boost-install boost_date_time ;

Added: sandbox/SOC/2008/calendar/libs/date_time/data/README.zone_spec_csv_file
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/data/README.zone_spec_csv_file 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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.

Added: sandbox/SOC/2008/calendar/libs/date_time/data/date_time_zonespec.csv
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/data/date_time_zonespec.csv 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,382 @@
+"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/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","EEST","EEST","+02:00:00","+01:00:00","-1;5;4","+00:00:00","-1;5;9","+00:00:00"
+"Africa/Casablanca","WET","WET","","","+00:00:00","+00:00:00","","","","+00: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","","","+00:00:00","+00:00:00","","","","+00: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/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/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","HAST","HAST","HADT","HADT","-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","BRST","BRST","-03:00:00","+01:00:00","2;0;10","+00:00:00","3;0;2","+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/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/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/Cancun","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
+"America/Caracas","VET","VET","","","-04:00: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/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/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/Cuiaba","AMT","AMT","AMST","AMST","-04:00:00","+01:00:00","2;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/Fortaleza","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","2;0;10","+00:00:00","3;0;2","+00: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","1;0;4","+00:01:00","-1;0;10","+00:01:00"
+"America/Grand_Turk","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+00:00:00","-1;0;10","+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","1;0;4","+00:00:00","-1;0;10","+01:00:00"
+"America/Hermosillo","MST","MST","","","-07:00:00","+00:00:00","","","","+00:00:00"
+"America/Indiana/Indianapolis","EST","EST","","","-05:00:00","+00:00:00","2;0;3","","1;0;11","+00:00:00"
+"America/Indiana/Knox","EST","EST","","","-05:00:00","+00:00:00","2;0;3","","1;0;11","+00:00:00"
+"America/Indiana/Marengo","EST","EST","","","-05:00:00","+00:00:00","2;0;3","","1;0;11","+00:00:00"
+"America/Indiana/Vevay","EST","EST","","","-05:00:00","+00:00:00","2;0;3","","1;0;11","+00:00:00"
+"America/Indianapolis","EST","EST","","","-05:00:00","+00:00:00","2;0;3","","1;0;11","+00: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/La_Paz","BOT","BOT","","","-04: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/Maceio","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","2;0;10","+00:00:00","3;0;2","+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/Martinique","AST","AST","","","-04:00:00","+00:00:00","","","","+00: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/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/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/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","1;0;4","+02:00:00","-1;0;10","+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/Center","CST","CST","CDT","CDT","-06: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/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/Port_of_Spain","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
+"America/Porto_Velho","AMT","AMT","","","-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","BRST","BRST","-03:00:00","+01:00:00","2;0;10","+00:00:00","3;0;2","+00:00:00"
+"America/Regina","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
+"America/Rio_Branco","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00"
+"America/Rosario","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
+"America/Santiago","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;10","+00:00:00","2;0;3","+00:00:00"
+"America/Santo_Domingo","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
+"America/Sao_Paulo","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","2;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/St_Johns","NST","NST","NDT","NDT","-03:30:00","+01:00:00","1;0;4","+00:01:00","-1;0;10","+00:01: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/Thule","AST","AST","","","-04:00:00","+00:00:00","2;0;3","","1;0;11","+00: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","1;0;4","+02:00:00","-1;0;10","+02:00:00"
+"America/Tortola","AST","AST","","","-04: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/Whitehorse","PST","PST","PDT","PDT","-08: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","+03: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","WST","WST","","","+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/Mawson","MAWT","MAWT","","","+06:00:00","+00:00:00","","","","+00:00:00"
+"Antarctica/McMurdo","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","1;0;10","+02:00:00","3;0;3","+03:00:00"
+"Antarctica/Palmer","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;10","+00:00:00","2;0;3","+00:00:00"
+"Antarctica/South_Pole","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","1;0;10","+02:00:00","3;0;3","+03:00:00"
+"Antarctica/Syowa","SYOT","SYOT","","","+03:00:00","+00:00:00","","","","+00: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","ALMST","ALMST","+06:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+00:00:00"
+"Asia/Amman","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;4;3","+00:00:00","-1;4;9","+01:00:00"
+"Asia/Anadyr","ANAT","ANAT","ANAST","ANAST","+12:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
+"Asia/Aqtau","AQTT","AQTT","AQTST","AQTST","+04:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+00:00:00"
+"Asia/Aqtobe","AQTT","AQTT","AQTST","AQTST","+05:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+00:00:00"
+"Asia/Ashgabat","TMT","TMT","","","+05:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Baghdad","AST","AST","ADT","ADT","+03:00:00","+01:00:00","1;0;4","+03:00:00","1;0;10","+04:00:00"
+"Asia/Bahrain","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Baku","AZT","AZT","AZST","AZST","+04:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+01: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","KGST","KGST","+05:00:00","+01:00:00","-1;0;3","+02:30:00","-1;0;10","+02:30: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/Choibalsan","CHOT","CHOT","","","+09:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Chongqing","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Colombo","LKT","LKT","","","+06:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Damascus","EET","EET","EEST","EEST","+02:00:00","+01:00:00","1;0;4","+00:00:00","1;0;10","+00:00:00"
+"Asia/Dhaka","BDT","BDT","","","+06:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Dili","TPT","TPT","","","+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","3;5;4","+00:00:00","3;5;10","+00:00:00"
+"Asia/Harbin","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Hong_Kong","HKT","HKT","","","+08:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Hovd","HOVT","HOVT","","","+07:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Irkutsk","IRKT","IRKT","IRKST","IRKST","+08:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03: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","WIT","WIT","","","+07:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Jayapura","EIT","EIT","","","+09:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Jerusalem","IST","IST","IDT","IDT","+02:00:00","+01:00:00","1;0;4","+01:00:00","1;0;10","+01:00:00"
+"Asia/Kabul","AFT","AFT","","","+04:30:00","+00:00:00","","","","+00:00:00"
+"Asia/Kamchatka","PETT","PETT","PETST","PETST","+12:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
+"Asia/Karachi","PKT","PKT","","","+05:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Kashgar","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Katmandu","NPT","NPT","","","+05:45:00","+00:00:00","","","","+00:00:00"
+"Asia/Krasnoyarsk","KRAT","KRAT","KRAST","KRAST","+07:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03: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","MAGST","MAGST","+11:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
+"Asia/Makassar","CIT","CIT","","","+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/Novosibirsk","NOVT","NOVT","NOVST","NOVST","+06:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
+"Asia/Omsk","OMST","OMST","OMSST","OMSST","+06:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
+"Asia/Oral","WST","WST","","","+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","WIT","WIT","","","+07:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Pyongyang","KST","KST","","","+09:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Qyzylorda","KST","KST","","","+06:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Qatar","AST","AST","","","+03: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","SAKST","SAKST","+10:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03: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/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","GEST","GEST","+04:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+00:00:00"
+"Asia/Tehran","IRT","IRT","","","+03:30: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","CIT","CIT","","","+08:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Ulaanbaatar","ULAT","ULAT","","","+08:00:00","+00:00:00","","","","+00:00:00"
+"Asia/Urumqi","CST","CST","","","+08: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","VLAST","VLAST","+10:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
+"Asia/Yakutsk","YAKT","YAKT","YAKST","YAKST","+09:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
+"Asia/Yekaterinburg","YEKT","YEKT","YEKST","YEKST","+05:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
+"Asia/Yerevan","AMT","AMT","AMST","AMST","+04:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03: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","1;0;4","+02:00:00","-1;0;10","+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/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/St_Helena","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
+"Atlantic/Stanley","FKT","FKT","FKST","FKST","-04:00:00","+01:00:00","1;0;9","+02:00:00","3;0;4","+02:00:00"
+"Australia/Adelaide","CST","CST","CST","CST","+09:30:00","+01:00:00","-1;0;10","+02:00:00","-1;0;3","+03:00:00"
+"Australia/Brisbane","EST","EST","","","+10:00:00","+00:00:00","","","","+00:00:00"
+"Australia/Broken_Hill","CST","CST","CST","CST","+09:30:00","+01:00:00","-1;0;10","+02:00:00","-1;0;3","+03:00:00"
+"Australia/Darwin","CST","CST","","","+09:30:00","+00:00:00","","","","+00:00:00"
+"Australia/Hobart","EST","EST","EST","EST","+10:00:00","+01:00:00","1;0;10","+02:00:00","-1;0;3","+03:00:00"
+"Australia/Lindeman","EST","EST","","","+10:00:00","+00:00:00","","","","+00:00:00"
+"Australia/Lord_Howe","LHST","LHST","LHST","LHST","+10:30:00","+00:30:00","-1;0;10","+02:00:00","-1;0;3","+02:00:00"
+"Australia/Melbourne","EST","EST","EST","EST","+10:00:00","+01:00:00","-1;0;10","+02:00:00","-1;0;3","+03:00:00"
+"Australia/Perth","WST","WST","","","+08:00:00","+00:00:00","","","","+00:00:00"
+"Australia/Sydney","EST","EST","EST","EST","+10:00:00","+01:00:00","-1;0;10","+02:00:00","-1;0;3","+03: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/Chisinau","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04: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/Helsinki","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04: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/Kaliningrad","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03: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/Minsk","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03: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","MSD","MSD","+03:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03: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/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","SAMST","SAMST","+04:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03: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","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04: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","","","+02:00:00","+00:00:00","","","","+00: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/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","","","+02: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"
+"Pacific/Apia","WST","WST","","","-11:00:00","+00:00:00","","","","+00:00:00"
+"Pacific/Auckland","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","1;0;10","+02:00:00","3;0;3","+03:00:00"
+"Pacific/Chatham","CHAST","CHAST","CHADT","CHADT","+12:45:00","+01:00:00","1;0;10","+02:45:00","3;0;3","+03:45:00"
+"Pacific/Easter","EAST","EAST","EASST","EASST","-06:00:00","+01:00:00","2;6;10","+22:00:00","2;6;3","+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","","","-10:00:00","+00:00:00","","","","+00:00:00"
+"Pacific/Fiji","FJT","FJT","","","+12:00:00","+00:00:00","","","","+00: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:30: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/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/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","TRUT","TRUT","","","+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","YAPT","YAPT","","","+10:00:00","+00:00:00","","","","+00:00:00"

Added: sandbox/SOC/2008/calendar/libs/date_time/doc/index.html
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/doc/index.html 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,13 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=../../../doc/html/date_time.html">
+</head>
+<body>
+Automatic redirection failed, please go to
+../../../doc/html/date_time.html
+<p>© Copyright CrystalClear Software, Inc 2003-2006</p>
+<p> Use, modification, and distribution are subject to the Boost Software
+License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
+www.boost.org/LICENSE_1_0.txt</a>)</p>
+</body>
+</html>

Added: sandbox/SOC/2008/calendar/libs/date_time/doc/time_duration_inherit.png
==============================================================================
Binary file. No diff available.

Added: sandbox/SOC/2008/calendar/libs/date_time/example/Jamfile
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/Jamfile 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,109 @@
+subproject libs/date_time/example ;
+
+local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_STATIC_LINK ;
+
+
+exe dates_as_strings : <lib>../build/boost_date_time
+ gregorian/dates_as_strings.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe days_alive : <lib>../build/boost_date_time
+ gregorian/days_alive.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe days_till_new_year : <lib>../build/boost_date_time
+ gregorian/days_till_new_year.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe days_between_new_years : <lib>../build/boost_date_time
+ gregorian/days_between_new_years.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe find_last_day_of_months : <lib>../build/boost_date_time
+ gregorian/find_last_day_of_months.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe month_add : <lib>../build/boost_date_time
+ gregorian/month_add.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe localization : gregorian/localization.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe print_holidays : <lib>../build/boost_date_time
+ gregorian/print_holidays.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe print_month : <lib>../build/boost_date_time
+ gregorian/print_month.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe period_calc : <lib>../build/boost_date_time
+ gregorian/period_calc.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe days_since_year_start : <lib>../build/boost_date_time
+ gregorian/days_since_year_start.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe local_utc_conversion : <lib>../build/boost_date_time
+ posix_time/local_utc_conversion.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
+ ;
+
+exe print_hours : <lib>../build/boost_date_time
+ posix_time/print_hours.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
+ ;
+
+exe time_math : <lib>../build/boost_date_time
+ posix_time/time_math.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
+ ;
+
+exe time_periods : <lib>../build/boost_date_time
+ posix_time/time_periods.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
+ ;
+
+exe simple_time_zone : <lib>../build/boost_date_time
+ local_time/simple_time_zone.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe calc_rules : <lib>../build/boost_date_time
+ local_time/calc_rules.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe seconds_since_epoch : <lib>../build/boost_date_time
+ local_time/seconds_since_epoch.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe flight : <lib>../build/boost_date_time
+ local_time/flight.cpp
+ : <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
+ ;
+
+exe io_tutorial : tutorial/io_tutorial.cpp
+ : <include>$(BOOST_ROOT)
+ ;
+
+# 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)
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/Jamfile.v2 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <library>../../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

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/date_serialization_demo.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/date_serialization_demo.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+#include <fstream>
+
+using namespace boost::gregorian;
+typedef std::set<date> date_set;
+typedef std::list<date> 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<class Archive>
+ 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/dates_as_strings.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/dates_as_strings.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+#include <string>
+
+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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_alive.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_alive.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <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;
+}
+
+
+/* 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_between_new_years.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_between_new_years.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,37 @@
+/* Provides a simple example of using a date_generator, and simple
+ * mathematical operatorations, to calculate the days since
+ * New Years day of this year, and days until next New Years day.
+ *
+ * Expected results:
+ * Adding together both durations will produce 366 (365 in a leap year).
+ */
+#include <iostream>
+#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;
+};
+
+
+/* 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_since_year_start.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_since_year_start.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,25 @@
+
+#include <iostream>
+#include "boost/date_time/gregorian/gregorian.hpp"
+
+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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_till_new_year.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/days_till_new_year.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+
+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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/end_of_month_day.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/end_of_month_day.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+
+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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/find_last_day_of_months.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/find_last_day_of_months.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,53 @@
+/* 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 <iostream>
+
+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;
+}
+
+/* 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/localization.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/localization.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+#include <algorithm>
+
+/* 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/month_add.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/month_add.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,52 @@
+/* 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 <iostream>
+
+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)
+ << "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-communitive, and may create problems for applications.\n"
+ << "Consider: \n"
+ << "Jan 30, 2004 + (1 month) + (1 month) != Jan 29, 2004 + (2 months)\n"
+ << "Why not? Because Jan 30, 2004 + 1 month is Feb 29 + 1 month is Mar 29th.\n"
+ << "while Jan 30, 2004 + 2 months is Mar 29th.\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";
+
+
+ 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/period_calc.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/period_calc.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <set>
+#include <algorithm>
+#include <iostream>
+
+typedef std::set<boost::gregorian::date_period> 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<date_period_set> 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/print_holidays.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/print_holidays.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <algorithm>
+#include <functional>
+#include <vector>
+#include <iostream>
+#include <set>
+
+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() {
+
+ std::cout << "Enter Year: ";
+ int year;
+ std::cin >> year;
+
+ using namespace boost::gregorian;
+
+ //define a collection of holidays fixed by month and day
+ std::vector<year_based_generator*> 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> date_set;
+ date_set all_holidays;
+
+ for(std::vector<year_based_generator*>::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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/print_month.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/gregorian/print_month.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,62 @@
+/* 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 <iostream>
+
+int
+main()
+{
+ std::cout << "Enter Year: ";
+ int year, month;
+ std::cin >> year;
+ std::cout << "Enter Month(1..12): ";
+ std::cin >> month;
+
+ using namespace boost::gregorian;
+ try {
+ //Use the calendar to get the last day of the month
+ int 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/local_time/calc_rules.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/local_time/calc_rules.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+
+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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/local_time/flight.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/local_time/flight.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,50 @@
+
+#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;
+
+}
+
+
+/* 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)
+ */

Added: sandbox/SOC/2008/calendar/libs/date_time/example/local_time/local_date_time.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/local_time/local_date_time.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+#include <locale>
+
+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<local_date_time, char> 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 00:00:00 EDT
+ std::cout.imbue(loc);
+ std::cout << ny_time << std::endl;
+ // 2004-Aug-30 00: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)
+ */

Added: sandbox/SOC/2008/calendar/libs/date_time/example/local_time/seconds_since_epoch.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/local_time/seconds_since_epoch.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+
+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(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 = 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)
+ */

Added: sandbox/SOC/2008/calendar/libs/date_time/example/local_time/simple_time_zone.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/local_time/simple_time_zone.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+
+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<dst_calc_rule> 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<dst_calc_rule> 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/Jamfile.v2 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <library>../../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 ;

Added: sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/local_utc_conversion.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/local_utc_conversion.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+
+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<ptime> 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<ptime, -5, us_dst> 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<ptime, -7, no_dst> 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/print_hours.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/print_hours.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+
+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 tommorrow = today + days(1);
+ ptime tommorrow_start(tommorrow); //midnight
+
+ //iterator adds by one hour
+ time_iterator titr(now,hours(1));
+ for (; titr < tommorrow_start; ++titr) {
+ std::cout << to_simple_string(*titr) << std::endl;
+ }
+
+ time_duration remaining = tommorrow_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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/time_math.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/time_math.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+
+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 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/time_periods.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/posix_time/time_periods.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+
+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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/example/tutorial/io_tutorial.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/example/tutorial/io_tutorial.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,194 @@
+#include <iostream>
+#include <boost/date_time/local_time/local_time.hpp>
+
+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<string> long_months(&month_names[0], &month_names[12]);
+ string day_names[7] = { "sunday", "monday", "tuesday", "wednesday",
+ "thursday", "friday", "saturday" };
+ vector<string> 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<string> 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<string> 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)
+ */
+

Added: sandbox/SOC/2008/calendar/libs/date_time/index.html
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/index.html 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,13 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0; URL=../../doc/html/date_time.html">
+</head>
+<body>
+Automatic redirection failed, please go to
+../../doc/html/date_time.html
+<p>© Copyright CrystalClear Software, 2003</p>
+<p> Use, modification, and distribution are subject to the Boost Software
+License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
+www.boost.org/LICENSE_1_0.txt</a>)</p>
+</body>
+</html>

Added: sandbox/SOC/2008/calendar/libs/date_time/src/date_time.doc
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/src/date_time.doc 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-03-03 12:11:25 +0000 (Mon, 03 Mar 2008) $
+ */
+
+
+/*! @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
+*/
+
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/date_generators.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/date_generators.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+
+#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
+
+
+
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_month.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_month.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,173 @@
+/* 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
+ * $Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+
+#ifndef BOOST_DATE_TIME_SOURCE
+#define BOOST_DATE_TIME_SOURCE
+#endif
+#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/compiler_config.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
+#include "boost/date_time/date_parsing.hpp"
+#include "boost/date_time/gregorian/parsers.hpp"
+
+#include "greg_names.hpp"
+namespace boost {
+namespace gregorian {
+
+ /*! Returns a shared pointer to a map of Month strings & numbers.
+ * Strings are both full names and abbreviations.
+ * Ex. ("jan",1), ("february",2), etc...
+ * Note: All characters are lowercase - for case insensitivity
+ */
+ greg_month::month_map_ptr_type greg_month::get_month_map_ptr()
+ {
+ static month_map_ptr_type month_map_ptr(new greg_month::month_map_type());
+
+ if(month_map_ptr->empty()) {
+ std::string s("");
+ for(unsigned short i = 1; i <= 12; ++i) {
+ greg_month m(static_cast<month_enum>(i));
+ s = m.as_long_string();
+ s = date_time::convert_to_lower(s);
+ month_map_ptr->insert(std::make_pair(s, i));
+ s = m.as_short_string();
+ s = date_time::convert_to_lower(s);
+ month_map_ptr->insert(std::make_pair(s, i));
+ }
+ }
+ return month_map_ptr;
+ }
+
+
+ //! Returns 3 char english string for the month ex: Jan, Feb, Mar, Apr
+ const char*
+ greg_month::as_short_string() const
+ {
+ return short_month_names[value_-1];
+ }
+
+ //! Returns full name of month as string in english ex: January, February
+ const char*
+ greg_month::as_long_string() const
+ {
+ return long_month_names[value_-1];
+ }
+
+ //! Return special_value from string argument
+ /*! Return special_value from string argument. If argument is
+ * not one of the special value names (defined in names.hpp),
+ * return 'not_special' */
+ special_values special_value_from_string(const std::string& s) {
+ short i = date_time::find_match(special_value_names,
+ special_value_names,
+ date_time::NumSpecialValues,
+ s);
+ if(i > date_time::NumSpecialValues) { // match not found
+ return not_special;
+ }
+ else {
+ return static_cast<special_values>(i);
+ }
+ }
+
+
+#ifndef BOOST_NO_STD_WSTRING
+ //! Returns 3 wchar_t english string for the month ex: Jan, Feb, Mar, Apr
+ const wchar_t*
+ greg_month::as_short_wstring() const
+ {
+ return w_short_month_names[value_-1];
+ }
+
+ //! Returns full name of month as wchar_t string in english ex: January, February
+ const wchar_t*
+ greg_month::as_long_wstring() const
+ {
+ return w_long_month_names[value_-1];
+ }
+#endif // BOOST_NO_STD_WSTRING
+
+#ifndef BOOST_DATE_TIME_NO_LOCALE
+ /*! creates an all_date_names_put object with the correct set of names.
+ * This function is only called in the event of an exception where
+ * the imbued locale containing the needed facet is for some reason
+ * unreachable.
+ */
+ BOOST_DATE_TIME_DECL
+ boost::date_time::all_date_names_put<greg_facet_config, char>*
+ create_facet_def(char type)
+ {
+ typedef
+ boost::date_time::all_date_names_put<greg_facet_config, char> facet_def;
+
+ return new facet_def(short_month_names,
+ long_month_names,
+ special_value_names,
+ short_weekday_names,
+ long_weekday_names);
+ }
+
+ //! generates a locale with the set of gregorian name-strings of type char*
+ BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, char type){
+ typedef boost::date_time::all_date_names_put<greg_facet_config, char> facet_def;
+ return std::locale(loc, new facet_def(short_month_names,
+ long_month_names,
+ special_value_names,
+ short_weekday_names,
+ long_weekday_names)
+ );
+ }
+
+#ifndef BOOST_NO_STD_WSTRING
+ /*! creates an all_date_names_put object with the correct set of names.
+ * This function is only called in the event of an exception where
+ * the imbued locale containing the needed facet is for some reason
+ * unreachable.
+ */
+ BOOST_DATE_TIME_DECL
+ boost::date_time::all_date_names_put<greg_facet_config, wchar_t>*
+ create_facet_def(wchar_t type)
+ {
+ typedef
+ boost::date_time::all_date_names_put<greg_facet_config,wchar_t> facet_def;
+
+ return new facet_def(w_short_month_names,
+ w_long_month_names,
+ w_special_value_names,
+ w_short_weekday_names,
+ w_long_weekday_names);
+ }
+
+ //! generates a locale with the set of gregorian name-strings of type wchar_t*
+ BOOST_DATE_TIME_DECL std::locale generate_locale(std::locale& loc, wchar_t type){
+ typedef boost::date_time::all_date_names_put<greg_facet_config, wchar_t> facet_def;
+ return std::locale(loc, new facet_def(w_short_month_names,
+ w_long_month_names,
+ w_special_value_names,
+ w_short_weekday_names,
+ w_long_weekday_names)
+ );
+ }
+#endif // BOOST_NO_STD_WSTRING
+#endif // BOOST_DATE_TIME_NO_LOCALE
+
+} } //namespace gregorian
+
+
+
+
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_names.hpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_names.hpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+
+#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___

Added: sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_weekday.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/greg_weekday.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+
+#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
+

Added: sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/gregorian_types.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/src/gregorian/gregorian_types.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+/** @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.
+ */
+
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/src/posix_time/posix_time_types.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/src/posix_time/posix_time_types.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+//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.
+ */
+
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/Jamfile.v2 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,235 @@
+
+
+local DATE_TIME_DYNAMIC_PROPERTIES = <define>BOOST_ALL_DYN_LINK <runtime-link>shared <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_ALL_NO_LIB ;
+local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_DATE_TIME_STATIC_LINK
+ # FIXME
+ #std::locale-support
+ <define>BOOST_ALL_NO_LIB ;
+
+
+test-suite date_time_core
+ :
+ [ 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 ]
+ ;
+
+ test-suite date_time_gregorian
+ :
+ [ run gregorian/testdate.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+ [ run gregorian/testdate_duration.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+ [ run gregorian/testgreg_durations.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+ [ run gregorian/testperiod.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+ [ run gregorian/testdate_iterator.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+ [ run gregorian/testformatters.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+### streaming
+ [ run gregorian/testdate_facet_new.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+ [ run gregorian/testdate_input_facet.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+###
+ [ run gregorian/testgenerators.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+ [ run gregorian/testgreg_cal.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+ [ run gregorian/testgreg_day.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+ [ run gregorian/testgreg_month.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+ [ run gregorian/testgreg_year.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) ]
+ ;
+test-suite date_time_gregorian_dll
+ :
+ [ run gregorian/testdate.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testdate_dll ]
+ [ run gregorian/testdate_duration.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testdate_duration_dll ]
+ [ run gregorian/testperiod.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testperiod_dll ]
+ [ run gregorian/testdate_iterator.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testdate_iterator_dll ]
+ [ run gregorian/testformatters.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testformatters_dll ]
+### streaming
+ [ run gregorian/testdate_facet_new.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testdate_facet_new_dll ]
+ [ run gregorian/testdate_input_facet.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testdate_input_facet_dll ]
+###
+ [ run gregorian/testgenerators.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testgenerators_dll ]
+ [ run gregorian/testgreg_cal.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testgreg_cal_dll ]
+ [ run gregorian/testgreg_day.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testgreg_day_dll ]
+ [ run gregorian/testgreg_month.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testgreg_month_dll ]
+ [ run gregorian/testgreg_year.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testgreg_year_dll ]
+ [ run gregorian/testgreg_durations.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) : testgreg_durations_dll ]
+ ;
+
+ test-suite date_time_posixtime
+ :
+ [ run posix_time/testfiletime_functions.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testlocal_adjustor.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testc_local_adjustor.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testclock.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testdst_rules.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testduration.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testiterator.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testparse_time.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testtime_period.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testtime.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testmicrosec_time_clock.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testtime_formatters.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testgreg_duration_operators.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+### streaming
+ [ run posix_time/testtime_facet.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run posix_time/testtime_input_facet.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+###
+
+ ;
+
+
+ test-suite date_time_wide_streaming
+ :
+ [ run gregorian/testgreg_wstream.cpp
+ ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) <define>USE_DATE_TIME_PRE_1_33_FACET_IO : testgreg_wstream ]
+ [ run posix_time/testtime_wstream.cpp
+ ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) <define>USE_DATE_TIME_PRE_1_33_FACET_IO : testtime_wstream ]
+ ;
+
+ test-suite date_time_pre_133_facet
+ :
+ [ run gregorian/testfacet.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) <define>USE_DATE_TIME_PRE_1_33_FACET_IO : testfacet_dll ]
+ # this next test is commented out because it crashes on VC6 (cause unknown):
+# [ run gregorian/testparse_date.cpp ../build//boost_date_time : : : $(DATE_TIME_DYNAMIC_PROPERTIES) <define>USE_DATE_TIME_PRE_1_33_FACET_IO : testparse_date_dll ]
+ [ run gregorian/testfacet.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) <define>USE_DATE_TIME_PRE_1_33_FACET_IO ]
+ [ run gregorian/testparse_date.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) <define>USE_DATE_TIME_PRE_1_33_FACET_IO ]
+
+ [ run posix_time/teststreams.cpp ../build//boost_date_time/<link>static : : : $(DATE_TIME_PROPERTIES) <define>USE_DATE_TIME_PRE_1_33_FACET_IO ]
+ ;
+
+local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG <define>BOOST_DATE_TIME_STATIC_LINK
+ # FIXME
+ #std::locale-support
+ <define>BOOST_ALL_NO_LIB ;
+
+ test-suite date_time_localtime
+ :
+ [ run local_time/testdst_transition_day_rule.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run local_time/testcustom_time_zone.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run local_time/testposix_time_zone.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run local_time/testwcustom_time_zone.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run local_time/testwposix_time_zone.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run local_time/testtz_database.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run local_time/testlocal_time.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run local_time/testlocal_time_iterator.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run local_time/testlocal_time_period.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+### streaming
+ [ run local_time/testlocal_time_facet.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ [ run local_time/testlocal_time_input_facet.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+###
+ [ run local_time/testclocks.cpp
+ ../build//boost_date_time/<link>static
+ : : : $(DATE_TIME_PROPERTIES) ]
+ ;
+
+ local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_STATIC_LINK <define>BOOST_ALL_NO_LIB <define>USE_DATE_TIME_PRE_1_33_FACET_IO
+ # FIXME
+ # std::locale-support toolset::require-boost-spirit-support
+ ;
+
+ test-suite date_time_serialization
+ :
+ # xml archive tests
+ [ run gregorian/testgreg_serialize.cpp
+ ../build//boost_date_time/<link>static
+ ../../serialization/build//boost_serialization
+ : : : $(DATE_TIME_PROPERTIES) <define>DATE_TIME_XML_SERIALIZE
+ : testgreg_serialize_xml ]
+ [ run posix_time/testtime_serialize.cpp
+ ../build//boost_date_time/<link>static
+ ../../serialization/build//boost_serialization
+ : : : $(DATE_TIME_PROPERTIES)
+<define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
+<define>DATE_TIME_XML_SERIALIZE
+ : testtime_serialize_xml_std_config ]
+ [ run posix_time/testtime_serialize.cpp
+ ../build//boost_date_time/<link>static
+ ../../serialization/build//boost_serialization
+ : : : $(DATE_TIME_PROPERTIES) <define>DATE_TIME_XML_SERIALIZE
+ : testtime_serialize_xml ]
+
+ # text archive tests
+ [ run gregorian/testgreg_serialize.cpp
+ ../build//boost_date_time/<link>static
+ ../../serialization/build//boost_serialization
+ : : : $(DATE_TIME_PROPERTIES)
+ : testgreg_serialize ]
+ [ run gregorian/testgreg_serialize.cpp
+ ../build//boost_date_time
+ ../../serialization/build//boost_serialization
+ : : : $(DATE_TIME_DYNAMIC_PROPERTIES)
+ : testgreg_serialize_dll ]
+ [ run posix_time/testtime_serialize.cpp
+ ../build//boost_date_time/<link>static
+ ../../serialization/build//boost_serialization
+ : : : $(DATE_TIME_PROPERTIES)
+<define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
+ : testtime_serialize_std_config ]
+ [ run posix_time/testtime_serialize.cpp
+ ../build//boost_date_time/<link>static
+ ../../serialization/build//boost_serialization
+ : : : $(DATE_TIME_PROPERTIES)
+ : testtime_serialize ]
+ ;
+
+
+# Copyright (c) 2000-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)
+
+
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testcurrent_day.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testcurrent_day.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+
+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;
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,293 @@
+/* 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 <iostream>
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+
+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 d(2000,1,1);
+ date d1(1900,1,1);
+ date d2 = d;
+ 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("1900-01-01 day is 01", d1.day() == 1);
+ check("1900-01-01 month is 01", d1.month() == 1);
+ check("1900-01-01 year is 1900", d1.year() == 1900);
+ check("2000-12-31 day is 31", d4.day() == 31);
+ check("2000-12-31 month is 12", d4.month() == 12);
+ check("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("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("ymd year", ymd.year == 1900);
+ check("ymd month", ymd.month == 1);
+ check("ymd day", ymd.day == 1);
+
+ //The max function will not compile with Borland 5.5
+ //Complains about must specialize basic_data<limits> ???
+// std::cout << "Max date is " << (date::max)() << std::endl;
+// //std::cout << "Max date is " << (basic_date< date_limits<unsigned int,1900> >::max)() << std::endl;
+// //std::cout << "Max date is " << (date_limits<unsigned int, 1900>::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("2000-03-01 - 2000-02-28 == 2 days", twoDays == (d7-d6));
+ check("2000-02-28 - 2000-03-01 == - 2 days", negtwoDays == (d6-d7));
+ check("2000-02-28 - 2000-02-28 == 0 days", zeroDays == (d6-d6));
+ check("2000-02-28 + 2 days == 2000-03-01 ", d6 + twoDays == d7);
+ check("2000-03-01 - 2 days == 2000-02-28 ", d7 - twoDays == d6);
+ check("Add duration to date", date(1999,1,1) + date_duration(365) == date(2000,1,1));
+ check("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("date + inf_dur", d + dd1 == date(pos_infin));
+ check("date + inf_dur", d + dd2 == date(neg_infin));
+ check("date + nan_dur", d + dd3 == date(not_a_date_time));
+ check("date - inf_dur", d - dd1 == date(neg_infin));
+ check("date - inf_dur", d - dd2 == date(pos_infin));
+ check("date - nan_dur", d - dd3 == date(not_a_date_time));
+ check("inf_date + inf_dur", date(pos_infin) + dd1 == date(pos_infin));
+ check("inf_date - inf_dur", date(pos_infin) - dd1 == date(not_a_date_time));
+ check("inf_date + inf_dur", date(neg_infin) + dd1 == date(not_a_date_time));
+ check("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("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("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("check julian day ", d15.julian_day() == 2232400);
+ check("check modjulian day ", d15.modjulian_day() == -167601);
+ date d16(2004,2,29);
+ check("check julian day ", d16.julian_day() == 2453065);
+ check("check modjulian day ", d16.modjulian_day() == 53064);
+
+ // most of this testing is in the gregorian_calendar tests
+ date d31(2000, Jun, 1);
+ check("check iso week number ", d31.week_number() == 22);
+ date d32(2000, Aug, 1);
+ check("check iso week number ", d32.week_number() == 31);
+ date d33(2000, Oct, 1);
+ check("check iso week number ", d33.week_number() == 39);
+ date d34(2000, Dec, 1);
+ check("check iso week number ", d34.week_number() == 48);
+ date d35(2000, Dec, 24);
+ check("check iso week number ", d35.week_number() == 51);
+ date d36(2000, Dec, 25);
+ check("check iso week number ", d36.week_number() == 52);
+ date d37(2000, Dec, 31);
+ check("check iso week number ", d37.week_number() == 52);
+ date d38(2001, Jan, 1);
+ check("check iso week number ", d38.week_number() == 1);
+
+ try {
+ int dayofyear1 = d38.day_of_year();
+ check("check day of year number", dayofyear1 == 1);
+ check("check day of year number", d37.day_of_year() == 366);
+ date d39(2001,Dec,31);
+ check("check day of year number", d39.day_of_year() == 365);
+ date d40(2000,Feb,29);
+ check("check day of year number", d40.day_of_year() == 60);
+ date d41(1400,Jan,1);
+ check("check day of year number", d41.day_of_year() == 1);
+ date d42(1400,Jan,1);
+ check("check day of year number", d42.day_of_year() == 1);
+ date d43(2002,Nov,17);
+ check("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("tm conversion functions 2000-1-1", date_from_tm(to_tm(d)) == d);
+ check("tm conversion functions 1900-1-1", date_from_tm(to_tm(d1)) == d1);
+ check("tm conversion functions min date 1400-1-1 ", date_from_tm(to_tm(d14)) == d14);
+ check("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);
+ }catch(std::out_of_range e){
+ check("Caught expected exception (special_value to_tm)", true);
+ }catch(...){
+ check("Caught un-expected exception (special_value to_tm)", false);
+ }
+
+ return printTestStats();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_duration.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_duration.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+
+
+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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_facet_new.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_facet_new.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,369 @@
+
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include "boost/date_time/date_facet.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+#include <sstream>
+
+
+template<class temporal_type, typename charT>
+inline
+void
+teststreaming(std::string testname,
+ temporal_type value,
+ std::basic_string<charT> expected_result,
+ const std::locale& locale = std::locale::classic())
+{
+ std::basic_stringstream<charT> ss;
+ ss.imbue(locale);
+ ss << value;
+ check(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<std::basic_string<char> > short_weekday_names;
+std::vector<std::basic_string<char> > long_weekday_names;
+std::vector<std::basic_string<char> > short_month_names;
+std::vector<std::basic_string<char> > 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));
+ }
+
+ {
+ 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));
+ }
+ {//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(int 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(int 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(int 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(int 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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_input_facet.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_input_facet.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,571 @@
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+#ifndef USE_DATE_TIME_PRE_1_33_FACET_IO
+// for tests that are expected to fail and throw exceptions
+template<class temporal_type, class exception_type>
+bool failure_test(temporal_type component,
+ const std::string& input,
+ exception_type /*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<class temporal_type>
+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<char> sitr(ss), str_end;
+
+ date_input_facet* f = new date_input_facet();
+ 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("Default format date", d == date(2005,Jan,15));
+ iss >> dd;
+ check("Default (only) format positive days", dd == days(21));
+ iss >> m;
+ check("Default format month", m == greg_month(2));
+ iss >> gw;
+ check("Default format weekday", gw == greg_weekday(2));
+ iss >> gd;
+ check("Default (only) format day of month", gd == greg_day(4));
+ iss >> gy;
+ check("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("ISO format date", d == date(2005,Jan,15));
+ iss >> dd;
+ check("Default (only) format negative days", dd == days(-55));
+ iss >> m;
+ check("Full format month", m == greg_month(2));
+ iss >> gw;
+ check("Full format weekday", gw == greg_weekday(2));
+ iss >> gy;
+ check("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 d(not_a_date_time);
+ greg_month m(1);
+ greg_weekday gw(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 >> d;
+ check("Literal '%' in date format", d == date(2005,Jun,14));
+ f->format("%%%d %Y-%b-%d");
+ ss.str("%14 2005-Jun-14");
+ ss >> d;
+ check("Multiple literal '%'s in date format", d == date(2005,Jun,14));
+
+ f->month_format("%%b %b");
+ ss.str("%b Jun");
+ ss >> m;
+ check("Literal '%' in month format", m == greg_month(6));
+ f->month_format("%%%b");
+ ss.str("%Jun");
+ ss >> m;
+ check("Multiple literal '%'s in month format", m == greg_month(6));
+
+ f->weekday_format("%%a %a");
+ ss.str("%a Tue");
+ ss >> gw;
+ check("Literal '%' in weekday format", gw == greg_weekday(2));
+ f->weekday_format("%%%a");
+ ss.str("%Tue");
+ ss >> gw;
+ check("Multiple literal '%'s in weekday format", gw == greg_weekday(2));
+
+ f->year_format("%%Y %Y");
+ ss.str("%Y 2005");
+ ss >> y;
+ check("Literal '%' in year format", y == greg_year(2005));
+ f->year_format("%%%Y");
+ ss.str("%2005");
+ ss >> y;
+ check("Multiple literal '%'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("ISO Extended format date", d == date(2005,Jan,15));
+
+ facet->format("%B %d, %Y");
+ iss.str("March 15, 2006");
+ iss >> d;
+ check("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("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("Default period (closed range)", dp == date_period(begin,len));
+ {
+ std::stringstream ss;
+ date d(not_a_date_time);
+ date d2 = day_clock::local_day();
+ date d3(neg_infin);
+ date d4(pos_infin);
+ date_period dp(d2, d); // date/nadt
+ date_period dp2(d, d); // nadt/nadt
+ date_period dp3(d3, d4);
+ ss << dp;
+ ss >> dp2;
+ check("Special values period (reversibility test)", dp == dp2);
+ ss.str("[-infinity/+infinity]");
+ ss >> dp2;
+ check("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("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("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("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("Default strings, partial_date",
+ pd.get_date(2004) == date(2004,Feb,29));
+ iss.str("second Mon of Mar");
+ iss >> nkd;
+ check("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("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("Default strings, last_day_of_the_week_in_month",
+ lkd.get_date(2004) == date(2004,May,26));
+ iss.str("Thu before");
+ iss >> fkb;
+ check("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("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("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("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("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("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("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("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("Special values, default strings, min_date_time date",
+ d == date(min_date_time));
+ check("Special values, default strings, pos_infin days",
+ dd == days(pos_infin));
+ iss.str("-infinity maximum-date-time");
+ iss >> d;
+ iss >> dd;
+ check("Special values, default strings, neg_infin date",
+ d == date(neg_infin));
+ check("Special values, default strings, max_date_time days",
+ dd == days(max_date_time));
+ iss.str("not-a-date-time");
+ iss >> d;
+ check("Special values, default strings, not_a_date_time date",
+ d == date(not_a_date_time));
+
+ // 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("Special values, custom strings, min_date_time date",
+ d == date(min_date_time));
+ check("Special values, custom strings, pos_infin days",
+ dd == days(pos_infin));
+ iss.str("MINF MAXDT");
+ iss >> d;
+ iss >> dd;
+ check("Special values, custom strings, neg_infin date",
+ d == date(neg_infin));
+ check("Special values, custom strings, max_date_time days",
+ dd == days(max_date_time));
+ iss.str("NADT");
+ iss >> dd;
+ check("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, char> 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,char> date_gen_parser;
+ date_gen_parser dg_parser("Zuerst","Zweitens","Dritt","Viert",
+ "Fünft","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 iss;
+ iss.imbue(std::locale(std::locale::classic(), de_facet));
+ // June 06 2005, Dec, minimum date, Tues
+ iss.str("Juni 06 2005 Dez Wenigstes Datum Die");
+ iss >> d;
+ iss >> m;
+ check("German names: date", d == date(2005, Jun, 6));
+ check("German names: month", m == greg_month(Dec));
+ iss >> d;
+ iss >> gw;
+ check("German names: special value date", d == date(min_date_time));
+ check("German names: short weekday", gw == greg_weekday(Tuesday));
+ de_facet->weekday_format("%A"); // long weekday
+ // Tuesday, Second Tuesday of Mar
+ iss.str("Dienstag Zweitens Dienstag von Mar");
+ iss >> gw;
+ iss >> nkd;
+ check("German names: long weekday", gw == greg_weekday(Tuesday));
+ check("German names, nth_day_of_the_week_in_month",
+ nkd.get_date(2005) == date(2005,Mar,8));
+ // Tuesday after
+ iss.str("Dienstag Nach");
+ iss >> fka;
+ check("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<std::basic_string<char> > short_weekday_names;
+ std::vector<std::basic_string<char> > long_weekday_names;
+ std::vector<std::basic_string<char> > short_month_names;
+ std::vector<std::basic_string<char> > 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 d(not_a_date_time);
+ date_input_facet* facet = new date_input_facet();
+ std::stringstream ss;
+ ss.imbue(std::locale(std::locale::classic(), facet));
+ facet->short_month_names(short_month_names);
+ facet->short_weekday_names(short_weekday_names);
+ facet->long_month_names(long_month_names);
+ facet->long_weekday_names(long_weekday_names);
+ facet->format("%a %b %d, %Y");
+ ss.str("day7 *apr* 23, 2005");
+ ss >> d;
+ check("Short custom names, set via accessor function", d.day_of_week() == greg_weekday(6));
+ check("Short custom names, set via accessor function", d.month() == greg_month(4));
+ ss.str("");
+ ss.str("Sun-0 **April** 24, 2005");
+ facet->format("%A %B %d, %Y");
+ ss >> d;
+ check("Long custom names, set via accessor function", d.day_of_week() == greg_weekday(0));
+ check("Long custom names, set via accessor function", d.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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_iterator.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testdate_iterator.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+
+
+void test_month_decrement_iterator(const boost::gregorian::date *Answers, int array_len){
+ using namespace boost::gregorian;
+ typedef boost::date_time::month_functor<date> mfg;
+
+ boost::date_time::date_itr<mfg, date> 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<date> dfg;
+
+ {
+ const date DayAnswers[] = {date(2000,Jan,20),date(2000,Jan,22),date(2000,Jan,24)};
+ boost::date_time::date_itr<dfg,date> 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<date> wfg;
+ {
+ const date WeekAnswers[] = {date(2000,Jan,20),date(2000,Jan,27),date(2000,Feb,3)};
+ boost::date_time::date_itr<wfg, date> 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<wfg, date> 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<wfg, date> 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<date> 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<mfg, date> 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<mfg, date> 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<mfg, date> 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<mfg, date> 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<date> 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<yfg, date> 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<yfg, date> 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<yfg, date> 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<yfg, date> 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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testfacet.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testfacet.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <sstream>
+#include <iostream>
+#include <fstream>
+
+#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 "boost/date_time/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<facet_config> date_facet;
+ typedef boost::date_time::date_names_put<facet_config> date_facet_base;
+ typedef boost::date_time::ostream_month_formatter<date_facet_base> 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<char> 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 m(Oct);
+ month_formatter::format_month(m, ss, gdnp);
+ check("check german short month: " + ss.str(),
+ ss.str() == std::string("Okt"));
+ ss.str(""); //reset string stream
+// month_formatter::format_month(m, 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<greg_year_month_day, date_facet_base> 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<date, date_facet_base> 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<date_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<boost::date_time::date_names_put<facet_config> >(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 ss2("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{
+ ss2 >> 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 ss2("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{
+ ss2 >> 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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformat_date_parser.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformat_date_parser.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,367 @@
+
+/* 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 "boost/date_time/testfrmwk.hpp"
+#include "boost/date_time/format_date_parser.hpp"
+#include <sstream>
+#include <algorithm>
+#include <iostream>
+
+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<std::basic_string<char> > short_month_names;
+std::vector<std::basic_string<wchar_t> > wshort_month_names;
+std::vector<std::basic_string<char> > long_month_names;
+std::vector<std::basic_string<wchar_t> > wlong_month_names;
+std::vector<std::basic_string<char> > short_week_names;
+std::vector<std::basic_string<wchar_t> > wshort_week_names;
+std::vector<std::basic_string<char> > long_week_names;
+std::vector<std::basic_string<wchar_t> > wlong_week_names;
+
+
+using namespace boost::gregorian;
+
+void
+wtest_format(const std::basic_string<wchar_t>& format,
+ const std::basic_string<wchar_t>& value,
+ const std::string testname,
+ boost::gregorian::date expected_res)
+{
+ typedef boost::date_time::format_date_parser<date, wchar_t> parser_type;
+ typedef std::basic_string<wchar_t> string_type;
+ typedef std::istreambuf_iterator<wchar_t> iter_type;
+ try {
+ // string_type format(format);
+ std::basic_stringstream<wchar_t> 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(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<char>& format,
+ const std::basic_string<char>& value,
+ const std::string testname,
+ boost::gregorian::date expected_res)
+{
+ typedef boost::date_time::format_date_parser<date, char> parser_type;
+ typedef std::basic_string<char> string_type;
+ typedef std::istreambuf_iterator<char> iter_type;
+ try {
+ string_type format(format);
+ std::basic_stringstream<char> 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(testname, d == expected_res);
+ }
+ catch(std::exception& e) {
+ std::cout << "Got an exception: " << e.what() << std::endl;
+ check(testname, false);
+
+ }
+}
+
+
+template<typename charT>
+void
+test_format2(boost::date_time::format_date_parser<date, charT>& 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(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<wchar_t> sitr(ws);
+ std::istreambuf_iterator<wchar_t> stream_end;
+
+ boost::date_time::format_date_parser<date,wchar_t> 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<std::basic_string<char> > 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<date,char> 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<date,char> 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();
+
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformatters.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testformatters.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgenerators.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgenerators.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,176 @@
+/* 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 "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+#include <string>
+#include <sstream>
+
+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 << to_simple_string(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 << to_simple_string(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 << to_simple_string(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 << to_simple_string(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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_cal.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_cal.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+
+
+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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_day.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_day.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+
+
+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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_durations.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_durations.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,223 @@
+/* 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 "boost/date_time/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 m1(5), m2(3), m3(10);
+ check("months & int multipliable", months(15) == m1 * 3);
+ m1 *= 3;
+ check("months & int multipliable", months(15) == m1);
+ //check("int * months", months(12) == 4 * m2);
+ check("months & int dividable", months(3) == m3 / 3);
+ m3 /= 3;
+ check("months & int dividable", months(3) == m3);
+ }
+ {
+ 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 y1(5), y2(3), y3(10);
+ check("years & int multipliable", years(15) == y1 * 3);
+ y1 *= 3;
+ check("years & int multipliable", years(15) == y1);
+ //check("int * years", years(12) == 4 * y2);
+ check("years & int dividable", years(3) == y3 / 3);
+ y3 /= 3;
+ check("years & int dividable", years(3) == y3);
+ }
+ {
+ 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);
+ }
+
+ }
+
+ /*** 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();
+
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_month.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_month.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+
+
+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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_serialize.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_serialize.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,195 @@
+/* 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 <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/archive/xml_oarchive.hpp>
+#include <boost/archive/xml_iarchive.hpp>
+
+#include <boost/date_time/gregorian/gregorian.hpp>
+#include <boost/date_time/gregorian/greg_serialize.hpp>
+#include <boost/date_time/testfrmwk.hpp>
+#include <fstream>
+
+using namespace boost;
+using namespace gregorian;
+
+template<class archive_type, class temporal_type>
+void save_to(archive_type& ar, const temporal_type& tt)
+{
+ ar << tt;
+}
+
+int main(){
+ std::ofstream ofs("tmp_file");
+
+ // 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(ofs);
+#else
+ std::cout << "Running text archive tests" << std::endl;
+ archive::text_oarchive oa(ofs);
+#endif
+
+ 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_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);
+
+ // load up the archive
+#if defined(DATE_TIME_XML_SERIALIZE)
+ try{
+ 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(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));
+ }catch(archive::archive_exception ae){
+ std::string s(ae.what());
+ check("Error writing to archive: " + s, false);
+ ofs.close();
+ return printTestStats();
+ }
+#else
+ try{
+ 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, 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);
+ }catch(archive::archive_exception ae){
+ std::string s(ae.what());
+ check("Error writing to archive: " + s, false);
+ ofs.close();
+ return printTestStats();
+ }
+#endif // DATE_TIME_XML_SERIALIZE
+ ofs.close();
+
+ std::ifstream ifs("tmp_file");
+#if defined(DATE_TIME_XML_SERIALIZE)
+ archive::xml_iarchive ia(ifs);
+#else
+ archive::text_iarchive ia(ifs);
+#endif
+
+ // 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_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);
+#if defined(DATE_TIME_XML_SERIALIZE)
+ try{
+ 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(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);
+ }catch(archive::archive_exception ae){
+ std::string s(ae.what());
+ check("Error reading from archive: " + s, false);
+ ifs.close();
+ return printTestStats();
+ }
+#else
+ try{
+ ia >> d2;
+ ia >> sv_d3;
+ ia >> sv_d4;
+ ia >> dd2;
+ ia >> sv_dd2;
+ ia >> dp2;
+ ia >> gm2;
+ ia >> gd2;
+ ia >> gwd2;
+ ia >> pd2;
+ ia >> nkd2;
+ ia >> fkd2;
+ ia >> lkd2;
+ ia >> fkdb2;
+ ia >> fkda2;
+ }catch(archive::archive_exception ae){
+ std::string s(ae.what());
+ check("Error reading from archive: " + s, false);
+ ifs.close();
+ return printTestStats();
+ }
+#endif // DATE_TIME_XML_SERIALIZE
+ ifs.close();
+
+ 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_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();
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_wstream.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_wstream.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+#include <iostream>
+#include <sstream>
+#include <boost/date_time/gregorian/gregorian.hpp>
+#include <boost/date_time/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 wss(L"2003-Aug-21");
+ date testdate(not_a_date_time);
+ wss >> 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 wss(L"August");
+ greg_month testmonth(not_a_date_time);
+ wss >> 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 wss(L"Thu");
+ greg_day_of_week testday(not_a_date_time);
+ wss >> 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 wss(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));
+ wss >> 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 wss(L"280");
+ date_duration testduration(not_a_date_time);
+ wss >> 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();
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_year.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testgreg_year.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,48 @@
+/* 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 "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+
+
+int
+main()
+{
+
+ using namespace boost::gregorian;
+ greg_year d1(1400);
+ check("Basic of min", d1 == 1400);
+ greg_year d2(10000);
+ check("Basic test of max", d2 == 10000);
+ try {
+ greg_year bad(0);
+ check("Bad year creation", false); //oh oh, fail
+ //unreachable
+ std::cout << "Shouldn't reach here: " << bad << std::endl;
+ }
+ catch(std::exception &) {
+ check("Bad year creation", true); //good
+
+ }
+ try {
+ greg_year bad(10001);
+ check("Bad year creation2", false); //oh oh, fail
+ //unreachable
+ std::cout << "Shouldn't reach here: " << bad << std::endl;
+ }
+ catch(std::exception&) {
+ check("Bad year creation2", true); //good
+
+ }
+ check("traits min year", (greg_year::min)() == 1400);
+ check("traits max year", (greg_year::max)() == 10000);
+
+ printTestStats();
+ return 0;
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testparse_date.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testparse_date.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,367 @@
+/* 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 "boost/date_time/testfrmwk.hpp"
+#include "boost/lexical_cast.hpp"
+#include <iostream>
+#include <string>
+
+// 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 s("20050229"); // no Feb-29 in 2005
+ date d(not_a_date_time);
+ try {
+ d = date_from_iso_string(s);
+ check("Expected exception not thrown: from ISO string (bad_day_of_month)", false);
+ std::cout << date_from_iso_string(s) << std::endl;
+ }
+ catch(bad_day_of_month& e) {
+ 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)
+ s = "2005022"; // missing a digit
+ try {
+ d = date_from_iso_string(s);
+ check("Expected exception not thrown: from ISO string (missing digit)", false);
+ std::cout << date_from_iso_string(s) << std::endl;
+ }
+ catch(bad_day_of_month& e) {
+ check("Caught expected exception: bad_day_of_month ", true);
+ }
+ catch(...) {
+ check("Caught unexpected exception", false);
+ }
+ */
+ s = "20050228"; // now it's correct
+ d = date_from_iso_string(s);
+ check("from ISO string", date(2005,Feb,28) == d);
+ }
+
+ 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<std::string> 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<std::wstring, wchar_t> 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<std::wstring>("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<boost::gregorian::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<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<gregorian::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
+ }
+ 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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testperiod.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/gregorian/testperiod.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+
+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 << to_simple_string(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;
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/README.poorly_formed_zonespec
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/README.poorly_formed_zonespec 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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.

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/poorly_formed_zonespec.csv
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/poorly_formed_zonespec.csv 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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"

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testclocks.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testclocks.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/local_time/local_time.hpp"
+#include <iostream>
+
+// 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<time_zone> az_tz(new posix_time_zone("MST-07"));
+ boost::shared_ptr<time_zone> ny_tz(new posix_time_zone("EST-05EDT,M4.1.0,M10.5.0"));
+
+ ptime tl = second_clock::local_time();
+ std::cout << to_simple_string(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 << to_simple_string(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;
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testcustom_time_zone.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testcustom_time_zone.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/local_time/local_time.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+
+int
+main()
+{
+
+ using namespace boost::gregorian;
+ using namespace boost::posix_time;
+ using namespace boost::local_time;
+
+
+ boost::shared_ptr<dst_calc_rule>
+ rule1(new partial_date_dst_rule(partial_date(30,Apr),
+ partial_date(30,Oct)));
+
+ boost::shared_ptr<dst_calc_rule>
+ 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<dst_calc_rule>
+ 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<dst_calc_rule> 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();
+}
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testdst_transition_day_rule.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testdst_transition_day_rule.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include "boost/date_time/local_time/dst_transition_day_rules.hpp"
+#include "boost/shared_ptr.hpp"
+#include "boost/date_time/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<dst_calc_rule>
+ 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<dst_calc_rule>
+ 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<dst_calc_rule>
+ 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<dst_calc_rule>
+ 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<dst_calc_rule>
+ 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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,368 @@
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#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 "boost/date_time/testfrmwk.hpp"
+//#include "boost/date_time/c_time.hpp"
+#include <iostream>
+
+#include <sstream>
+// 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 d(2004, Apr, 4);
+ time_duration td(2,30,0); // invalid local time in ny_tz
+ local_date_time calcop(d, td, ny_tz, local_date_time::NOT_DATE_TIME_ON_ERROR);
+ check("is NADT", calcop.is_not_a_date_time());
+ }
+ { // invalid exception
+ date d(2004, Apr, 4);
+ time_duration td(2,30,0); // invalid local time in ny_tz
+ try{
+ local_date_time calcop(d, 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 d(2004, Oct, 31);
+ time_duration td(1,30,0); // ambig local time in ny_tz
+ local_date_time calcop(d, td, ny_tz, local_date_time::NOT_DATE_TIME_ON_ERROR);
+ check("is NADT", calcop.is_not_a_date_time());
+ }
+ { // ambig exception
+ date d(2004, Oct, 31);
+ time_duration td(1,30,0); // ambig local time in ny_tz
+ try{
+ local_date_time calcop(d, 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& d){
+ check(std::string("Caught expected exception (dst_not_valid) ") + d.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 d(2004,Apr,4);
+ time_duration td(1,15,0); // local
+ local_date_time lt1(d,td,ny_tz,false);
+ local_date_time lt2(ptime(d,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 d(2004,Oct,31);
+ time_duration td(1,15,0); // local
+ local_date_time lt1(d,td,ny_tz,true);
+ /*try{
+ //local_date_time lt1(d,td,ny_tz,false);
+ local_date_time lt1(d,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(d,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 d(2004,Oct,31);
+ time_duration td(1,15,0); // local
+ local_date_time lt1(d,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 d(2004,Mar,28);
+ time_duration td(2,15,0); // local; sydney has a weird trans time
+ local_date_time lt1(d,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 d(2003, Aug, 28);
+ ptime sv_pt(pos_infin);
+ local_date_time sv_lt(sv_pt, ny_tz);
+ ptime utc_pt(d, 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(d, hours(5), az_tz, false); // 5am local std
+ local_date_time ny_lt(d, hours(8), ny_tz, true); // 8am local dst
+ local_date_time au_lt(d, 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);
+ }catch(std::out_of_range e){
+ 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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_facet.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_facet.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,181 @@
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <iostream>
+#include <sstream>
+#include <boost/shared_ptr.hpp>
+#include "boost/date_time/local_time/local_time.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+
+
+template<class temporal_type, typename charT>
+inline
+void
+teststreaming(std::string testname,
+ temporal_type value,
+ std::basic_string<charT> expected_result,
+ const std::locale& locale)
+{
+ std::basic_stringstream<charT> ss;
+ ss.imbue(locale);
+ ss << value;
+ check(testname, ss.str() == expected_result);
+}
+
+int main(){
+ /* 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("../data/date_time_zonespec.csv");
+ }
+ catch(const data_not_accessible& e) {
+ // couldn't find the data file so assume we are being run from
+ // boost_root/status and try again
+ try {
+ time_zones.load_from_file("../libs/date_time/data/date_time_zonespec.csv");
+ }
+ 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);
+
+
+ typedef boost::date_time::time_facet<local_date_time, char> 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<ptime, char> 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);
+
+ //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<local_date_time, wchar_t> 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);
+
+ //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();
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_input_facet.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_input_facet.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/local_time/local_time.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+#include <sstream>
+#include <string>
+
+// for tests that are expected to fail and throw exceptions
+template<class temporal_type, class exception_type>
+bool failure_test(temporal_type component,
+ const std::string& input,
+ exception_type /*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<class temporal_type>
+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 loc(std::locale::classic(), f);
+ iss.imbue(loc);
+ 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();
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_iterator.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_iterator.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <iostream>
+#include "boost/date_time/local_time/local_time.hpp"
+#include "boost/date_time/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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_period.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testlocal_time_period.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testposix_time_zone.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testposix_time_zone.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/gregorian/gregorian.hpp"
+//#include "boost/date_time/local_time/time_zone.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+
+#include "boost/date_time/local_time/posix_time_zone.hpp"
+
+#include <string>
+#include <iostream>
+
+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 e){
+ 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;
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testtz_database.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testtz_database.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,138 @@
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/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 <iostream>
+
+bool run_bad_field_count_test();
+
+int main(){
+ 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 e){
+ 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());
+
+ /* This test-file is usually run from either $BOOST_ROOT/status, or
+ * $BOOST_ROOT/libs/date_time/test. Therefore, the relative path
+ * to the data file this test depends on will be one of two
+ * possible paths.
+ *
+ * If the first attempt at opening the data file fails, an exception
+ * will be thrown. The handling of that exception consists of
+ * attempting to open it again but from a different location. If that
+ * also fails, we abort the test. */
+ tz_database tz_db;
+ try {
+ // first try to find the data file from the test dir
+ tz_db.load_from_file("../data/date_time_zonespec.csv");
+ }catch(data_not_accessible e) {
+ // couldn't find the data file so assume we are being run from
+ // boost_root/status and try again
+ tz_db.load_from_file("../libs/date_time/data/date_time_zonespec.csv");
+ }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()
+{
+ using namespace boost::local_time;
+ bool caught_bfc = false;
+ tz_database other_db;
+ try{
+ other_db.load_from_file("local_time/poorly_formed_zonespec.csv");
+ }catch(bad_field_count be){
+ caught_bfc = true;
+ }catch(...) {
+ // do nothing (file not found)
+ }
+ try{
+ other_db.load_from_file("../libs/date_time/test/local_time/poorly_formed_zonespec.csv");
+ }catch(bad_field_count be){
+ caught_bfc = true;
+ }catch(...) {
+ // do nothing (file not found)
+ }
+ return caught_bfc;
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwcustom_time_zone.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwcustom_time_zone.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/local_time/local_time.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+
+int
+main()
+{
+
+ using namespace boost::gregorian;
+ using namespace boost::posix_time;
+ using namespace boost::local_time;
+
+ typedef custom_time_zone_base<wchar_t> wcustom_time_zone;
+
+ boost::shared_ptr<dst_calc_rule>
+ rule1(new partial_date_dst_rule(partial_date(30,Apr),
+ partial_date(30,Oct)));
+
+ boost::shared_ptr<dst_calc_rule>
+ 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<dst_calc_rule>
+ 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<dst_calc_rule> 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();
+}
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwposix_time_zone.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/local_time/testwposix_time_zone.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+
+#include "boost/date_time/gregorian/gregorian.hpp"
+//#include "boost/date_time/local_time/time_zone.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+
+#include "boost/date_time/local_time/posix_time_zone.hpp"
+
+#include <string>
+#include <iostream>
+
+int main(){
+ using namespace boost::local_time;
+ using namespace boost::posix_time;
+ using namespace boost::gregorian;
+
+ typedef posix_time_zone_base<wchar_t> 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 e){
+ 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;
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testc_local_adjustor.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testc_local_adjustor.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,46 @@
+/* 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/c_local_time_adjustor.hpp"
+#include "boost/date_time/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<ptime> local_adj;
+
+ 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 << to_simple_string(t2) << " LOCAL is "
+ << to_simple_string(t1) << " UTC time "
+ << std::endl;
+ time_duration td1 = t2 - t1;
+ std::cout << "A difference of: " << to_simple_string(td1)
+ << std::endl;
+
+
+ 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 << to_simple_string(t4) << " LOCAL is "
+ << to_simple_string(t3) << " UTC time "
+ << std::endl;
+ time_duration td2 = t4 - t3;
+ std::cout << "A difference of: " << to_simple_string(td2)
+ << std::endl;
+
+ return printTestStats();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testclock.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testclock.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,41 @@
+/* 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 <iostream>
+
+int
+main()
+{
+
+ using namespace boost::posix_time;
+ ptime tl = second_clock::local_time();
+ std::cout << to_simple_string(tl) << std::endl;
+
+ ptime tu = second_clock::universal_time();
+ std::cout << to_simple_string(tu) << std::endl;
+
+#if (defined(_POSIX_TIMERS))
+ for (int i=0; i < 3; ++i) {
+ ptime t2 = second_clock::local_time();
+ std::cout << to_simple_string(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 << to_simple_string(t2) << std::endl;
+ }
+#endif // BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
+
+ return 0;
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testdst_rules.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testdst_rules.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/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<boost::gregorian::date> start_rule_functor;
+ typedef boost::date_time::partial_date<boost::gregorian::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<date, time_duration, 120, 60> us_dst;
+ 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_dst_start_day(2002) == dst_start);
+ check("dst end", us_dst::local_dst_end_day(2002) == dst_end);
+ check("dst boundary", us_dst::is_dst_boundary_day(dst_start));
+ check("dst boundary", us_dst::is_dst_boundary_day(dst_end));
+ check("check if time is dst -- not",
+ us_dst::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_is_dst(t3a.date(),t3a.time_of_day())==boost::date_time::invalid_time_label);
+ check("label on dst boundary invalid",
+ us_dst::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_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_is_dst(t5.date(),t5.time_of_day())==boost::date_time::is_in_dst);
+
+ check("check if time is dst -- not",
+ us_dst::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_is_dst(t7.date(),t7.time_of_day())==boost::date_time::ambiguous);
+ check("check if time is dst -- ambig",
+ us_dst::local_is_dst(t8.date(),t8.time_of_day())==boost::date_time::ambiguous);
+ check("check if time is dst -- not",
+ us_dst::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<date, time_duration> 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<date,time_duration> 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<date> us_dst_traits;
+ typedef boost::date_time::dst_calc_engine<date, time_duration, us_dst_traits>
+ 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<date> eu_dst_traits;
+ typedef boost::date_time::dst_calc_engine<date, time_duration, eu_dst_traits>
+ 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<date> uk_dst_traits;
+
+ typedef boost::date_time::dst_calc_engine<date, time_duration, uk_dst_traits> 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<date, time_duration,
+ paraguay_dst_traits> 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<date> acst_dst_traits;
+ typedef boost::date_time::dst_calc_engine<date, time_duration,
+ acst_dst_traits> 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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testduration.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testduration.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,263 @@
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#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 "boost/date_time/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"
+ td3 = time_duration(td1.hours(),td1.minutes(),td1.seconds());
+ check("total up elements-invered 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
+
+ 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(3600)*1000 == hours(3600000));
+
+ // 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<boost::int64_t>(3600)*1000000*1001; //ms per sec
+ check("total microseconds 1000 hours", hours(1001).total_microseconds() == tms);
+ tms = static_cast<boost::int64_t>(3600)*365*24*1000;
+ check("total milliseconds - one year", (t2-t1).total_milliseconds() == tms);
+ tms = 3600*365*24*static_cast<boost::int64_t>(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();
+
+}
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testfiletime_functions.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testfiletime_functions.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,69 @@
+/* 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 "boost/date_time/testfrmwk.hpp"
+#include "boost/date_time/filetime_functions.hpp"
+#include <cmath>
+
+#if defined(BOOST_HAS_FTIME)
+#include <windows.h>
+#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 int 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<ptime>(ft);
+
+ check("ptime year matches systemtime year",
+ st.wYear == pt.date().year());
+ check("ptime month matches systemtime month",
+ st.wMonth == pt.date().month());
+ check("ptime day matches systemtime day",
+ st.wDay == pt.date().day());
+ check("ptime hour matches systemtime hour",
+ st.wHour == pt.time_of_day().hours());
+ check("ptime minute matches systemtime minute",
+ st.wMinute == pt.time_of_day().minutes());
+ check("ptime second matches systemtime second",
+ st.wSecond == pt.time_of_day().seconds());
+ check("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
+
+#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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testformatters.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testformatters.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/testfrmwk.hpp"
+
+int
+main()
+{
+ //This has been deprecated for testtime_formatters.cpp
+ return 0;
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testgreg_duration_operators.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testgreg_duration_operators.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/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();
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testiterator.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testiterator.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include <iostream>
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/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 << to_simple_string(*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 << to_simple_string(*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 << to_simple_string(*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 << to_simple_string(*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 << to_simple_string(*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 << to_simple_string(*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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testlocal_adjustor.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testlocal_adjustor.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,177 @@
+/* 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 "boost/date_time/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<time_duration,-5> us_eastern_offset_adj;
+ //Type that embeds rules for UTC-5 plus DST offset
+ typedef boost::date_time::static_local_time_adjustor<ptime,
+ us_dst,
+ us_eastern_offset_adj> 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 << to_simple_string(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 << to_simple_string(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 << to_simple_string(t11_local) << " "
+ << to_simple_string(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<time_duration,-7> us_az_offset_adj;
+ typedef boost::date_time::null_dst_rules<date, time_duration> us_az_dst_adj;
+ //Type that embeds rules for UTC-7 with no dst
+ typedef boost::date_time::static_local_time_adjustor<ptime,
+ us_az_dst_adj,
+ us_az_offset_adj> 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<ptime, -7, no_dst> 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<ptime, -5, us_dst> 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<date> us_dst_traits;
+ typedef boost::date_time::dst_calc_engine<date, time_duration, us_dst_traits>
+ us_dst_calc2;
+
+ typedef boost::date_time::local_adjustor<ptime, -5, us_dst_calc2> 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<ptime, us_dst> 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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testmicrosec_time_clock.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,110 @@
+/* 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 "boost/date_time/testfrmwk.hpp"
+
+
+int
+main()
+{
+#ifdef BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
+
+ using namespace boost::posix_time;
+
+ // ptime last = boost::date_time::microsec_resolution_clock<ptime>::local_time();
+ ptime last = microsec_clock::local_time();
+
+ int max = 30;
+ int i = 0;
+ for (i = 0; i<max; i++)
+ {
+ for (int j=0; j<100000; j++)
+ {
+ // some systems loop too fast so "last is less" tests fail
+ // due to 'last' & 't2' being equal. These calls slow
+ // it down enough to make 'last' & 't2' different
+#if defined(BOOST_HAS_GETTIMEOFDAY)
+ timeval tv;
+ gettimeofday(&tv, 0);
+#endif
+#if defined(BOOST_HAS_FTIME)
+ SYSTEMTIME st;
+ GetSystemTime(&st);
+#endif
+ }
+
+ ptime t1 = second_clock::local_time();
+ std::cout << to_simple_string(t1) << std::endl;
+
+ ptime t2 = microsec_clock::local_time();
+ std::cout << to_simple_string(t2) << std::endl;
+ check("hours match", t1.time_of_day().hours() == t2.time_of_day().hours());
+ check("minutes match",
+ t1.time_of_day().minutes() == t2.time_of_day().minutes());
+ check("seconds match",
+ t1.time_of_day().minutes() == t2.time_of_day().minutes());
+ check("hours date", t1.date() == t2.date());
+ if( !check("last is less", last <= t2) ) {
+ std::cout << to_simple_string(last) << " < "
+ << to_simple_string(t2) << std::endl;
+ }
+ last = t2;
+
+
+ }
+
+
+ std::cout << "Now do the same test for universal time -- a few less iterations" << std::endl;
+ max = 10;
+ last = microsec_clock::universal_time();
+ for (i = 0; i<max; i++)
+ {
+ for (int j=0; j<100000; j++)
+ {
+ // some systems loop too fast so "last is less" tests fail
+ // due to 'last' & 't2' being equal. These calls slow
+ // it down enough to make 'last' & 't2' different
+#if defined(BOOST_HAS_GETTIMEOFDAY)
+ timeval tv;
+ gettimeofday(&tv, 0);
+#endif
+#if defined(BOOST_HAS_FTIME)
+ SYSTEMTIME st;
+ GetSystemTime(&st);
+#endif
+ }
+
+ ptime t1 = second_clock::universal_time();
+ std::cout << to_simple_string(t1) << std::endl;
+
+ ptime t2 = microsec_clock::universal_time();
+ std::cout << to_simple_string(t2) << std::endl;
+ check("hours match", t1.time_of_day().hours() == t2.time_of_day().hours());
+ check("minutes match",
+ t1.time_of_day().minutes() == t2.time_of_day().minutes());
+ check("seconds match",
+ t1.time_of_day().minutes() == t2.time_of_day().minutes());
+ check("hours date", t1.date() == t2.date());
+ //following check might be equal on a really fast machine
+ if( !check("last is less", last <= t2) ) {
+ std::cout << to_simple_string(last) << " < "
+ << to_simple_string(t2) << std::endl;
+ }
+ last = t2;
+
+
+ }
+
+#else
+ check("Get time of day micro second clock not supported due to inadequate compiler/platform", false);
+#endif
+ return printTestStats();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testparse_time.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testparse_time.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,224 @@
+/* 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/posix_time/posix_time.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+
+
+int
+main()
+{
+ using namespace boost::gregorian;
+ using namespace boost::posix_time;
+
+#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
+
+ std::string s1("12:11:10.123456789");
+ time_duration td1= duration_from_string(s1);
+ check("parse time duration: " + s1,
+ td1 == time_duration(12,11,10,123456789));
+ std::string s2("12:11:10,123456789");
+ time_duration td2= boost::date_time::parse_delimited_time_duration<time_duration>(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<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<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<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<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<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<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<time_duration>(s8b);
+ check("parse time duration: " + s8b,
+ td8b == time_duration(1,22,33,123456789)); // excess digits should be dropped
+#endif
+
+#if defined(BOOST_DATE_TIME_HAS_MICROSECONDS) && (!defined(BOOST_DATE_TIME_HAS_NANOSECONDS))
+ {
+ 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::string s2("12:11:10,123456");
+ time_duration td2= boost::date_time::parse_delimited_time_duration<time_duration>(s2);
+ check("parse time duration: " + s2,
+ td2 == time_duration(12,11,10,123456));
+ std::string s3("12:11:10");
+ time_duration td3= boost::date_time::parse_delimited_time_duration<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<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<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<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<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<time_duration>(s7b);
+ check("parse time duration: " + s7b,
+ td7b == time_duration(-1,0,0)-microsec(1000)); // we want 1/1000th
+
+ std::string s8b("1:22:33.123456321"); // too many digits
+ time_duration td8b= boost::date_time::parse_delimited_time_duration<time_duration>(s8b);
+ check("parse time duration: " + s8b,
+ td8b == time_duration(1,22,33,123456)); // excess digits should be dropped
+ }
+#endif
+
+#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
+
+ 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
+
+
+ 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 ts1("2002-01-20 23:59:59.");
+ ptime t1 = time_from_string(ts1);
+ check("parse time (decimal but no digits): " + ts1,
+ 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<time_duration>(s6);
+ check("parse time duration: " + s6,
+ td6 == time_duration(23,58,59));
+
+ s6 = "-235859";
+ td6= boost::date_time::parse_undelimited_time_duration<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)));
+#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)));
+#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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testperiod.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testperiod.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/posix_time/time_period.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+
+int main()
+{
+
+ //FILE OBSOLETE: replace by testtime_period.cpp
+
+ return 1;
+ // return printTestStats();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/teststreams.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/teststreams.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/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<greg_facet_config> 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 d1(2001,Aug,1), d2(2003,May,13);
+#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
+ time_duration td1(15,32,18,20304000), td2(1,2,3);
+#else
+ time_duration td1(15,32,18,20304), td2(1,2,3);
+#endif
+
+ time_period result(ptime(d1,td1), ptime(d2,td2));
+ 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 d1 = date(2004,Jan,1);
+ date d2 = date(2004,May,13);
+ time_duration td1 = time_duration(2,3,4);
+ time_duration td2 = time_duration(1,0,0);
+ time_period result = time_period(ptime(d1,td1), ptime(d2,td2));
+ 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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,327 @@
+/* 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 <iostream>
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/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 t9(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)",
+ t9+td3 == ptime(date(2001,Dec,1), time_duration(8,0,0)) );
+ std::cout << to_simple_string(t9-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)));
+
+ 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)));
+
+ 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)));
+
+ 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)));
+
+ 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)));
+
+ 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);
+ }catch(std::out_of_range e){
+ 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);
+ }catch(std::out_of_range e){
+ check("Caught expected exception (special_value to_tm)", true);
+ }catch(...){
+ check("Caught un-expected exception (special_value to_tm)", false);
+ }
+
+
+ return printTestStats();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_facet.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_facet.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,399 @@
+
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
+template<class temporal_type, typename charT>
+inline
+void
+teststreaming(std::string testname,
+ temporal_type value,
+ std::basic_string<charT> expected_result,
+ const std::locale& locale = std::locale::classic())
+{
+ std::basic_stringstream<charT> ss;
+ ss.imbue(locale);
+ ss << value;
+ check(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<std::basic_string<wchar_t> > de_short_month_names;
+std::vector<std::basic_string<wchar_t> > 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);
+ {
+ 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("");
+ }
+ { // 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());
+
+ }
+
+#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%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%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%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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_formatters.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_formatters.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,106 @@
+/* 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/testfrmwk.hpp"
+
+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));
+
+
+
+#ifdef BOOST_DATE_TIME_HAS_MILLISECONDS
+
+ 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);
+ }
+
+#endif
+
+#ifdef BOOST_DATE_TIME_HAS_MICROSECONDS
+
+ 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);
+ }
+#endif
+
+#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
+
+ 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);
+ }
+#endif
+
+
+ return printTestStats();
+
+
+}
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_input_facet.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_input_facet.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,435 @@
+/* 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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+
+#include "boost/date_time/gregorian/gregorian.hpp"
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+
+// for tests that are expected to fail and throw exceptions
+template<class temporal_type, class exception_type>
+bool failure_test(temporal_type component,
+ const std::string& input,
+ exception_type /*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<class temporal_type>
+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("Default format time_duration", td == time_duration(9,59,1,321987654));
+ check("Default format ptime", pt == ptime(date(2005,01,15),time_duration(10,15,3,123456789)));
+#else
+ check("Default format time_duration", td == time_duration(9,59,1,321987));
+ check("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("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("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("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("Required-frac_sec format time_duration", td == time_duration(14,13,12));
+
+ iss.str("12");
+ facet->time_duration_format("%H");
+ iss >> td;
+ check("Hours format", td == hours(12));
+
+ iss.str("05");
+ facet->time_duration_format("%M");
+ iss >> td;
+ check("Minutes format", td == minutes(5));
+
+ iss.str("45");
+ facet->time_duration_format("%S");
+ iss >> td;
+ check("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("Seconds w/ frac_sec format", td == time_duration(0,0,10,10000000));
+#else
+ check("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("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("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("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("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("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("Multiple literal '%'s in time_duration format", td == time_duration(15,15,0));
+
+ { /****** iso format tests (and custom 'scrunched-together formats) ******/
+ time_input_facet *facet = new time_input_facet();
+ facet->set_iso_format();
+ facet->time_duration_format("%H%M%S%F"); // iso format
+ std::stringstream ss;
+ ss.imbue(std::locale(std::locale::classic(), facet));
+ ptime pt(not_a_date_time);
+ time_duration td(not_a_date_time);
+ date d(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(d, td2);
+
+ ss.str("20021017T231217.12345");
+ ss >> pt;
+ check("iso_format ptime", pt == result);
+ ss.str("");
+ facet->set_iso_extended_format();
+ ss.str("2002-10-17 23:12:17.12345");
+ ss >> pt;
+ check("iso_extended_format ptime", pt == result);
+ ss.str("");
+ ss.str("231217.12345");
+ ss >> td;
+ check("iso_format time_duration", td == td2);
+ ss.str("");
+ ss.str("-infinity");
+ ss >> td;
+ check("iso_format time_duration (special_value)",
+ td == 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 {
+ facet->time_duration_format("%H%M%S%F");
+ ss.str("not-a-date-time");
+ ++count;
+ ss >> td;
+ check("special value w/ hours flag", td == nadt);
+ ss.str("");
+ facet->time_duration_format("%M%S%F");
+ ss.str("not-a-date-time");
+ ++count;
+ ss >> td;
+ check("special value w/ minutes flag", td == nadt);
+ ss.str("");
+ facet->time_duration_format("%S%F");
+ ss.str("not-a-date-time");
+ ++count;
+ ss >> td;
+ check("special value w/ seconds flag", td == nadt);
+ ss.str("");
+ facet->time_duration_format("%s");
+ ss.str("not-a-date-time");
+ ++count;
+ ss >> td;
+ check("special value w/ sec w/frac_sec (always) flag", td == nadt);
+ ss.str("");
+ facet->time_duration_format("%f");
+ ss.str("not-a-date-time");
+ ++count;
+ ss >> td;
+ check("special value w/ frac_sec (always) flag", td == 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("Special value: ptime %H flag", pt == ptime(pos_infin));
+ check("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("Special value: ptime %M flag", pt == ptime(not_a_date_time));
+ check("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("Special value: ptime %S flag", pt == ptime(neg_infin));
+ check("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("Special value: ptime %s flag", pt == ptime(pos_infin));
+ check("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("Special value: ptime %j flag", pt == ptime(not_a_date_time));
+ check("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 pt(not_a_date_time);
+ ptime pt2 = second_clock::local_time();
+ ptime pt3(neg_infin);
+ ptime pt4(pos_infin);
+ time_period tp(pt2, pt); // ptime/nadt
+ time_period tp2(pt, pt); // nadt/nadt
+ time_period tp3(pt3, pt4);
+ ss << tp;
+ ss >> tp2;
+ check("Special values period (reversibility test)", tp == tp2);
+ ss.str("[-infinity/+infinity]");
+ ss >> tp2;
+ check("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("Stream out one ptime then into another: default format", pt_io == pt);
+ ss.str("");
+ ss << td_io; // stream out td_io
+ ss >> td;
+ check("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("Stream out one ptime then into another: default format", pt_io == pt);
+ ss.str("");
+ ss << td_io; // stream out td_io
+ ss >> td;
+ check("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("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("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<date, char> fdp("%Y-%b-%d", std::locale::classic());
+ special_values_parser svp; // default constructor
+ period_parser pp; // default constructor
+ boost::date_time::date_generator_parser<date, char> dgp; // default constructor
+ time_input_facet tif("%Y-%m-%d %H:%M:%s", fdp, svp, pp, dgp);
+ }
+#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();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_period.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_period.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+#include "boost/date_time/posix_time/posix_time.hpp"
+#include "boost/date_time/posix_time/time_period.hpp"
+#include "boost/date_time/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 << 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)));
+ 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 << 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;
+ time_period p7 = p5.intersection(p6);
+ std::cout << to_simple_string(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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_serialize.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_serialize.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,127 @@
+/* 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 <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/archive/xml_oarchive.hpp>
+#include <boost/archive/xml_iarchive.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/date_time/posix_time/time_serialize.hpp>
+#include <boost/date_time/testfrmwk.hpp>
+#include <fstream>
+
+using namespace boost;
+using namespace posix_time;
+using namespace gregorian;
+
+template<class archive_type, class temporal_type>
+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::ofstream ofs("tmp_file");
+
+ // 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(ofs);
+#else
+ std::cout << "Running text archive tests" << std::endl;
+ archive::text_oarchive oa(ofs);
+#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, false);
+ ofs.close();
+ return printTestStats();
+ }
+
+ ofs.close();
+
+ std::ifstream ifs("tmp_file");
+#if defined(DATE_TIME_XML_SERIALIZE)
+ archive::xml_iarchive ia(ifs);
+#else
+ archive::text_iarchive ia(ifs);
+#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, false);
+ ifs.close();
+ return printTestStats();
+ }
+
+ ifs.close();
+
+ 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();
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_wstream.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/posix_time/testtime_wstream.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ */
+#include <iostream>
+#include <sstream>
+#include <boost/date_time/gregorian/gregorian.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/date_time/testfrmwk.hpp>
+#include <boost/lexical_cast.hpp>
+
+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();
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/testconstrained_value.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testconstrained_value.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/config.hpp"
+#include "boost/date_time/constrained_value.hpp"
+#include "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+
+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<int,1,10,range_error> one_to_ten_range_policy;
+
+int main()
+{
+ using namespace boost::CV;
+ constrained_value<day_value_policies> 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<one_to_ten_range_policy> cv2(11);
+ std::cout << "Not Reachable: " << cv2 << " ";
+ check("got range exception max", false);
+ }
+ catch(range_error& e) {
+ e = e; // removes compiler warning
+ check("got range exception max", true);
+ }
+
+ try {
+ constrained_value<one_to_ten_range_policy> cv3(0);
+ std::cout << "Not Reachable: " << cv3 << " ";
+ check("got range exception min", false);
+ }
+ catch(range_error& e) {
+ e = e; // removes compiler warning
+ check("got range exception min", true);
+ }
+
+ try {
+ constrained_value<one_to_ten_range_policy> cv4(1);
+ cv4 = 12;
+ check("range exception on assign", false);
+ }
+ catch(range_error& e) {
+ e = e; // removes compiler warning
+ check("range exception on assign", true);
+ }
+
+ return printTestStats();
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/testfrom_facet.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testfrom_facet.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $
+ *
+ * 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 <string>
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <fstream>
+
+#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<std::string> data;
+ std::vector<std::wstring> wdata;
+
+ data = gather_month_strings<char>(std::locale::classic());
+ print(data, std::cout);
+ data = gather_month_strings<char>(std::locale::classic(), false);
+ print(data, std::cout);
+ data = gather_weekday_strings<char>(std::locale::classic());
+ print(data, std::cout);
+ data = gather_weekday_strings<char>(std::locale::classic(), false);
+ print(data, std::cout);
+
+ wdata = gather_month_strings<wchar_t>(std::locale::classic());
+ std::wofstream wof("from_facet_test.out");
+ int i=0;
+ while (i < wdata.size()) {
+ wof << wdata[i] << std::endl;
+ i++;
+ }
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/testgeneric_period.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testgeneric_period.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,281 @@
+/* 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 <iostream>
+#include "boost/date_time/period.hpp"
+#include "boost/date_time/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 int_type>
+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<int_type> rhs) { return _val == rhs._val; }
+ bool operator<(duration_type<int_type> rhs) { return _val < rhs._val; }
+ bool operator>(duration_type<int_type> rhs) { return _val > rhs._val; }
+ private:
+ int_type _val;
+};
+//! To enable things like "cout << period.length()"
+template<class int_type>
+inline
+std::ostream& operator<<(std::ostream& os, duration_type<int_type> dt){
+ os << dt.get_rep();
+ return os;
+}
+//! this operator is needed because period adds a duration_rep to a point_rep
+template<class int_type>
+inline
+int_type operator+(int i, duration_type<int_type> dt){
+ return i + dt.get_rep();
+}
+
+//! this operator is needed because period adds a duration_rep to a point_rep
+template<class int_type>
+inline
+int_type operator-(int i, duration_type<int_type> dt){
+ return i - dt.get_rep();
+}
+
+
+int main(){
+ using namespace boost::date_time;
+ typedef period<int, duration_type<int> > a_period;
+
+ /*** check all functions - normal periods ***/
+
+ a_period p1(1, duration_type<int>(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 p1(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<int>(0));
+ check("Same beg & end == zero_length",
+ a_period(1,1) == a_period(1, duration_type<int>(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 p1(0, -2);
+ check("First", p1.begin() == 0);
+ check("Last", p1.last() == -3);
+ check("End", p1.end() == -2);
+ check("Length", p1.length() == -2);
+ check("is_null", p1.is_null());
+ }
+ {
+ std::cout << std::endl;
+ a_period p1(0, -1);
+ check("First", p1.begin() == 0);
+ check("Last", p1.last() == -2);
+ check("End", p1.end() == -1);
+ check("Length", p1.length() == -1);
+ check("is_null", p1.is_null());
+ }
+ {
+ std::cout << std::endl;
+ a_period p1(0, 0);
+ check("First", p1.begin() == 0);
+ check("Last", p1.last() == -1);
+ check("End", p1.end() == 0);
+ check("Length", p1.length() == 0);
+ check("is_null", p1.is_null());
+ }
+ {
+ std::cout << std::endl;
+ a_period p1(0, 1);
+ check("First", p1.begin() == 0);
+ check("Last", p1.last() == 0);
+ check("End", p1.end() == 1);
+ check("Length", p1.length() == 1);
+ check("is_null", !p1.is_null());
+ }
+ {
+ std::cout << std::endl;
+ a_period p1(0, 2);
+ check("First", p1.begin() == 0);
+ check("Last", p1.last() == 1);
+ check("End", p1.end() == 2);
+ check("Length", p1.length() == 2);
+ check("is_null", !p1.is_null());
+ }
+ {
+ std::cout << std::endl;
+ a_period p1(0, duration_type<int>(-1));
+ check("First", p1.begin() == 0);
+ check("Last", p1.last() == -2);
+ check("End", p1.end() == -1);
+ check("Length", p1.length() == -1);
+ check("is_null", p1.is_null());
+ }
+ {
+ std::cout << std::endl;
+ a_period p1(0, duration_type<int>(-2));
+ check("First", p1.begin() == 0);
+ check("Last", p1.last() == -3);
+ check("End", p1.end() == -2);
+ check("Length", p1.length() == -2);
+ check("is_null", p1.is_null());
+ }
+ {
+ std::cout << std::endl;
+ a_period p1(0, duration_type<int>(0));
+ check("First", p1.begin() == 0);
+ check("Last", p1.last() == -1);
+ check("End", p1.end() == 0);
+ check("Length", p1.length() == 0);
+ check("is_null", p1.is_null());
+ }
+ {
+ std::cout << std::endl;
+ a_period p1(0, duration_type<int>(1));
+ check("First", p1.begin() == 0);
+ check("Last", p1.last() == 0);
+ check("End", p1.end() == 1);
+ check("Length", p1.length() == 1);
+ check("is_null", !p1.is_null());
+ }
+ {
+ std::cout << std::endl;
+ a_period p1(0, duration_type<int>(2));
+ check("First", p1.begin() == 0);
+ check("Last", p1.last() == 1);
+ check("End", p1.end() == 2);
+ check("Length", p1.length() == 2);
+ check("is_null", !p1.is_null());
+ }
+ {
+ std::cout << std::endl;
+ a_period p1(1,1); // length should be 0
+ a_period p2(1,2); // length should be 1
+ a_period p3(1,3); // length should be 2
+ check("Length p1", p1.length() == 0);
+ check("Length p2", p2.length() == 1);
+ check("Length p3", p3.length() == 2);
+ check("is_null p1 (not)", p1.is_null());
+ check("is_null p2 (not)", !p2.is_null());
+ }
+
+ {
+ a_period p1(1,2); // length should be 1
+ p1.shift(duration_type<int>(1));
+ a_period p2(2,3); // shifted result
+ check("shift", p1 == p2);
+ }
+ {
+ a_period p1(5,duration_type<int>(3));
+ a_period p2(3,10); // expanded result
+ p1.expand(duration_type<int>(2)); //from 2000-Jan-01--2000-Jan-04
+ check("expand", p1 == p2);
+ }
+ return printTestStats();
+}

Added: sandbox/SOC/2008/calendar/libs/date_time/test/testgregorian_calendar.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testgregorian_calendar.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/testfrmwk.hpp"
+#include <iostream>
+
+int
+main()
+{
+ typedef boost::date_time::year_month_day_base<unsigned long,
+ unsigned short,
+ unsigned short > simple_ymd_type;
+
+ typedef boost::date_time::gregorian_calendar_base<simple_ymd_type, unsigned long>
+ 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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/testint64_range.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testint64_range.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <iostream>
+#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<boost::int64_t>::max)()
+ << std::endl;
+ std::cout << "uint64_t max: "
+ << (std::numeric_limits<boost::uint64_t>::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<boost::int64_t>::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;
+};
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/testint_adapter.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testint_adapter.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/testfrmwk.hpp"
+#include "boost/cstdint.hpp"
+#include <iostream>
+#include <sstream>
+
+template<typename int_type>
+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<typename int_type>
+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 l = i - int_type::pos_infinity();
+ check("value - +infinity", l == int_type::neg_infinity());
+ l = i + int_type::neg_infinity();
+ check("value + -infinity", l == 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<unsigned long> >();
+ test_int< int_adapter<unsigned long> >();
+ print< int_adapter<long> >();
+ test_int< int_adapter<long> >();
+ print< int_adapter<boost::int64_t> >();
+ test_int< int_adapter<boost::int64_t> >();
+
+
+ return printTestStats();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/testtime_resolution_traits.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testtime_resolution_traits.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 "boost/date_time/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();
+
+}
+

Added: sandbox/SOC/2008/calendar/libs/date_time/test/testwrapping_int.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/test/testwrapping_int.cpp 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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 <boost/test/test_tools.hpp>
+#include "boost/date_time/testfrmwk.hpp"
+#include "boost/cstdint.hpp"
+#include <iostream>
+
+
+int
+main()
+// int
+// test_main(int, char*[])
+{
+ using namespace boost::date_time;
+
+ wrapping_int<int, 3600> 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<short, 60> wi2(0);
+ check("add with wrap - return", wi2.add(121) == 2);
+ check("add with wrap - value", wi2 == 1);
+
+ wrapping_int<short, 60> wi3(-5);
+ check("signed int - add return", wi3.add(5) == 0);
+ check("signed int - value", wi3 == 0);
+
+ { // subtracting negative values
+ wrapping_int<short, 10> wi3(5);
+ check("subtract negative value to cause wrap",
+ (wi3.subtract(-8) == -1 && wi3 == 3));
+ check("reset", wi3.add(2) == 0 && wi3 ==5);
+ check("add negative value to cause wrap",
+ (wi3.add(-8) == -1 && wi3 == 7));
+ }
+
+ wrapping_int2<short, 1, 5> 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<short, 1, 12> 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<short, 2, 6> 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<short, 1, 12> wi7(6);
+ wrapping_int2<short, -5, 5> 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<boost::int64_t, 86400*100000LL> 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<boost::int64_t,86400000000LL> 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<int, 60> wi(121);
+// check("construction/conversion", wi == 121);
+// check("add with wrap", wi.add(1) == 1);
+
+ return printTestStats();
+
+}
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/Jamfile.v2 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,80 @@
+# 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 boostbook : boostbook ;
+import toolset ;
+import set ;
+toolset.using doxygen ;
+
+boostbook date_time : date_time.xml ;
+
+# 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 = [ 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) :
+ <doxygen:param>ENABLE_PREPROCESSING=NO
+ <xsl:param>boost.doxygen.reftitle="Date Time Reference"
+ <doxygen.doxproc.title>"Date Time Reference"
+ <doxygen.doxproc.id>"date_time_reference"
+ ;
+
+doxygen gregorian_autodoc :
+ $(gregorian_files) :
+ <doxygen:param>ENABLE_PREPROCESSING=NO
+ <xsl:param>boost.doxygen.reftitle="Gregorian Reference"
+ <doxygen.doxproc.title>"Gregorian Reference"
+ <doxygen.doxproc.id>"gregorian_reference"
+ ;
+
+doxygen posix_time_autodoc :
+ [ glob ../../../boost/date_time/posix_time/*.hpp ] :
+ <doxygen:param>ENABLE_PREPROCESSING=NO
+ <xsl:param>boost.doxygen.reftitle="Posix Time Reference"
+ <doxygen.doxproc.title>"Posix Time Reference"
+ <doxygen.doxproc.id>"posix_time_reference"
+ ;
+
+doxygen local_time_autodoc :
+ [ glob ../../../boost/date_time/local_time/*.hpp ] :
+ <doxygen:param>ENABLE_PREPROCESSING=NO
+ <xsl:param>boost.doxygen.reftitle="Local Time Reference"
+ <doxygen.doxproc.title>"Local Time Reference"
+ <doxygen.doxproc.id>"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.

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/README
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/README 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -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:
+<section ...
+
+/********************************/
+Including files into sections has some quirks to it. Unless there is a
+section in the parent file, the first included file will display
+instead of link.
+
+Example.
+In date_time.xml:
+
+ <xi:include href="subsection.xml" />
+
+And in subsection/xml:
+ <section id="date_time.my_subsection"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <para>
+ ...
+ </para>
+ <xi:include href="another.xml" />
+
+/********************************/
+To crosslink use:
+<link linkend="date_time.section.subsection">optional text</link>
+
+If you use '<link linkend="top">top</link>' 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)

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/acknowledgements.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/acknowledgements.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.acknowledgements">
+ <title>Acknowledgements</title>
+
+ <para>
+ 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.
+ </para>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/buildinfo.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/buildinfo.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.buildinfo">
+ <title>Build-Compiler Information</title>
+
+ <para>
+ <link linkend="overview">Overview</link> --
+ <link linkend="compile_options">Compilation Options</link> --
+ <link linkend="portability">Compiler/Portability Notes</link> --
+ <link linkend="dir_structure">Directory Structure</link> --
+ <link linkend="other_boost_libs">Required Boost Libraries</link>
+ </para>
+
+ <anchor id="overview" />
+ <bridgehead renderas="sect3">Overview</bridgehead>
+ <para>
+ 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.
+ </para>
+
+ <anchor id="compile_options" />
+ <bridgehead renderas="sect3">Compilation Options</bridgehead>
+ <para>
+ 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.
+ </para>
+ <para>
+ To use the alternate resolution (96 bit nanosecond) the variable <code>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG</code> 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.
+ </para>
+ <para>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 <code>USE_DATE_TIME_PRE_1_33_FACET_IO</code>.</para>
+
+ <para>As a convenience, <code>date_time</code> has provided some <link linkend="additional_duration_types">additional duration types</link>. Use of these types may have unexpected results due to the snap-to-end-of-month behavior (see <link linkend="snap_to_details">Reversibility of Operations Pitfall</link> for complete details and examples). These types are enabled by default. To disable these types, simply undefine <code>BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES</code> in your project file.</para>
+
+ <para>Another convenience is the default constructors for <code><link linkend="date_time.gregorian.date_class">date</link></code>, and <code><link linkend="date_time.posix_time.ptime_class">ptime</link></code>. These constructors are enabled by default. To disable them, simply define <code>DATE_TIME_NO_DEFAULT_CONSTRUCTOR</code> in your project file.</para>
+
+ <anchor id="portability" />
+ <bridgehead renderas="sect3">Compiler/Portability Notes</bridgehead>
+ <para>
+ 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:
+ <itemizedlist mark="bullet">
+ <listitem>Codewarrior 9.4 Windows</listitem>
+ <listitem>GCC 3.2 - 3.4, 4.x on Linux</listitem>
+ <listitem>GCC 3.3, 4.x on Darwin</listitem>
+ <listitem>GCC 3.3 - 3.4, 4.x on Solaris</listitem>
+ <listitem>GCC 3.3, 4.x on HP-UX</listitem>
+ <listitem>QCC 3.3.5 on QNX</listitem>
+ <listitem>MSVC 7.1 Windows </listitem>
+ <listitem>Intel 8.1-9.x Linux and Windows</listitem>
+ </itemizedlist>
+ </para>
+
+ <para>
+ 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
+
+ <ulink url="http://lists.boost.org/Archives/boost/2006/02/101122.php">mailing list archive</ulink> for more details.
+ </para>
+
+ <para>
+ In addition to the problem above, some versions of the VC8 library have limited
+ the range of allowed
+ values in the <code>std::tm</code> 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.
+ </para>
+
+ <para>
+ These compilers support all aspects of the library except <code>wstring/wstream</code>
+ output.
+ <itemizedlist mark="bullet">
+ <listitem>MinGW 3.2, 3.4, 3.5 *</listitem>
+ <listitem>GCC 3.2 (cygwin) *</listitem>
+ </itemizedlist>
+ </para>
+
+ <para>
+ 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:
+ <itemizedlist mark="bullet">
+ <listitem>Borland 5.6</listitem>
+ </itemizedlist>
+ </para>
+
+ <para>
+ Official support for some older compilers has now been dropped. This includes:
+ <itemizedlist mark="bullet">
+ <listitem>GCC 2.9x</listitem>
+ <listitem>Borland 5.1.1</listitem>
+ <listitem>MSVC 7.0 and 6 SP5 </listitem>
+ </itemizedlist>
+ </para>
+
+ <bridgehead renderas="sect5">Visual Studio &amp; STLPort</bridgehead>
+ <para>There is a known issue with Visual Studio (7.0 &amp; 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 <code>wchar_t</code>. The default build of STLPort does not support <code>wchar_t</code>. 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.
+ </para>
+ <para>To build date_time with no wide stream/string etc, execute the following command from <code>$BOOST_ROOT</code>:
+ <screen>bjam -a "-sTOOLS=vc-7_1-stlport" "-sSTLPORT_PATH=..." \
+ "-sBUILD=&lt;define>BOOST_NO_STD_WSTRING" \
+ --stagedir=... --with-date_time stage</screen>
+ (replace the ellipsis with the correct paths for the build system and adjust the <code>TOOLS</code> to the proper toolset if necessary)
+ </para>
+ <para>Rebuilding STLPort with <code>wchar_t</code> support involves placing <code>/Zc:wchar_t</code> in the STLPort makefile. Date_time should then be built with the following command from <code>$BOOST_ROOT</code>:
+ <screen>bjam -a "-sTOOLS=vc-7_1-stlport" "-sSTLPORT_PATH=..." \
+ "-sBUILD=&amp;native-wchar_t>on" \
+ --stagedir=... --with-date_time stage</screen>
+ (replace the ellipsis with the correct paths for the build system and adjust the <code>TOOLS</code> to the proper toolset if necessary)
+ </para>
+
+ <anchor id="dir_structure" />
+ <bridgehead renderas="sect3">Directory Structure</bridgehead>
+ <para>
+ The directory tree has the following structure:
+ <programlisting>/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/examples/gregorian -- example programs for dates
+/libs/date_time/examples/posix_time -- time example programs
+/libs/date_time/examples/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...)</programlisting>
+ </para>
+
+ <anchor id="other_boost_libs" />
+ <bridgehead renderas="sect3">Required Boost Libraries</bridgehead>
+ <para>
+ Various parts of date-time depend on other boost libraries. These include:
+ <itemizedlist mark="bullet">
+ <listitem><ulink url="../../libs/tokenizer/index.html">boost.tokenizer</ulink> </listitem>
+ <listitem><ulink url="../../libs/integer/cstdint.htm">boost.integer(cstdint)</ulink> </listitem>
+ <listitem><ulink url="../../libs/utility/operators.htm">boost.operators</ulink> </listitem>
+ <listitem><ulink url="../../libs/conversion/lexical_cast.htm">boost.lexical_cast </ulink> </listitem>
+ <listitem><ulink url="../../libs/smart_ptr/smart_ptr.htm">boost.smart_ptr (local time only)</ulink> </listitem>
+ <listitem><ulink url="../../libs/algorithm/string/">boost::string_algorithms </ulink> </listitem>
+ <listitem><ulink url="../../libs/serialization/index.html">boost::serialize (serialization code only) </ulink> </listitem>
+ </itemizedlist>
+ so these libraries need to be installed.
+ </para>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/calculations.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/calculations.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.calculations">
+ <title>Calculations</title>
+
+ <para>
+ <link linkend="timepoints">Timepoints</link> --
+ <link linkend="durations">Durations</link> --
+ <link linkend="intervals">Intervals (Periods)</link> --
+ <link linkend="special_value_handling">Special Value Handling</link>
+ </para>
+ <anchor id="timepoints" />
+ <bridgehead renderas="sect3">Timepoints</bridgehead>
+ <para>
+ 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:
+ <programlisting>
+ Timepoint + Duration --> Timepoint
+ Timepoint - Duration --> Timepoint
+ Timepoint - Timepoint --> Duration
+ </programlisting>
+ Unlike regular numeric types, the following operations are undefined:
+ <programlisting>
+ Duration + Timepoint --> Undefined
+ Duration - Timepoint --> Undefined
+ Timepoint + Timepoint --> Undefined
+ </programlisting>
+ </para>
+ <anchor id="durations" />
+ <bridgehead renderas="sect3">Durations</bridgehead>
+ <para>
+ 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:
+ <programlisting>
+ Duration + Duration --> Duration
+ Duration - Duration --> Duration
+
+ Duration * Integer --> Duration
+ Integer * Duration --> Duration
+ Duration / Integer --> Duration (Integer Division rules)
+ </programlisting>
+ </para>
+ <anchor id="intervals" />
+ <bridgehead renderas="sect3">Intervals (Periods)</bridgehead>
+ <para>
+ 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:
+ <programlisting>
+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)
+ </programlisting>
+ In addition, periods support various queries that calculate boolean results. The first set is caluculations with other time periods:
+ <programlisting>
+ Timeperiod == Timeperiod --> bool
+ Timeperiod &lt; Timeperiod --> bool (true if lhs.last &lt;= rhs.begin)
+ Timeperiod intersects Timeperiod --> bool
+ Timeperiod contains Timeperiod --> bool
+ Timeperiod is_adjacent Timeperiod --> bool
+ </programlisting>
+ The following calculations are performed versus the Timepoint.
+ <programlisting>
+ Timeperiod contains Timepoint --> bool
+ Timeperiod is_before Timepoint --> bool
+ Timeperiod is_after Timepoint --> bool
+ </programlisting>
+ </para>
+ <anchor id="special_value_handling" />
+ <bridgehead renderas="sect3">Special Value Handling</bridgehead>
+ <para>
+ 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.
+ <programlisting>
+ Timepoint(NADT) + Duration --> Timepoint(NADT)
+ Timepoint(&#8734;) + Duration --> Timepoint(&#8734;)
+ Timepoint + Duration(&#8734;) --> Timepoint(&#8734;)
+ Timepoint - Duration(&#8734;) --> Timepoint(-&#8734;)
+ </programlisting>
+ When performing operations on both positive and negative infinities, the library will produce results consistent with the following.
+ <programlisting>
+ Timepoint(+&#8734;) + Duration(-&#8734;) --> NADT
+ Duration(+&#8734;) + Duration(-&#8734;) --> NADT
+ Duration(&#177;&#8734;) * Zero --> NADT
+
+ Duration(&#8734;) * Integer(Not Zero) --> Duration(&#8734;)
+ Duration(+&#8734;) * -Integer --> Duration(-&#8734;)
+ Duration(&#8734;) / Integer --> Duration(&#8734;)
+ </programlisting>
+ </para>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/changes.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/changes.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,591 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2006 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.changes">
+ <title>Change History</title>
+
+ <!-- if each new change tgroup has a "Bug Fix" as the first "Type", the columns will line up nicely -->
+
+ <bridgehead renderas="sect3">Changes from Boost 1.33 to 1.34 (date_time 1.04 to 1.05)</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>Feature</entry>
+ <entry>
+ 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.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>
+ 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:
+ <code>static date_type local_dst_start_day(year_type year)</code> and
+ <code>static date_type local_dst_end_day(year_type year)</code>.
+ Implementers should see <code>date_time/local_timezone_defs.hpp</code> for
+ examples.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Fix DST traits for Austrialia (sf# 1672139) to set end of DST at 3:00 am instead of 2:00 am.
+
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Fix a problem with potential linking error with multiple definitions due
+ to I/O code.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Changes for tracker issue 1178092 -- change in convert_to_lower to make
+ local a const static and speed up parsing.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Patches from Ulrich Eckhardt to fix support for EVC++ 4.
+ </entry>
+ </row>
+
+ <row>
+ <entry>Feature</entry>
+ <entry>Reduce the usage of basic_stringstream as much a possible to work around
+ a bug in the VC8 standard library. See
+ <ulink url="http://lists.boost.org/Archives/boost/2006/02/101122.php">mailing list archive</ulink>
+ for more information.
+ </entry>
+ </row>
+
+
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>
+ </entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+
+ <bridgehead renderas="sect3">Changes from Boost 1.32 to 1.33 (date_time 1.03 to 1.04)</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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()).
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Previously, output streaming of <code>partial_date</code> 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').
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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 <link linkend="date_time.local_time">Date Time Local Time</link> for complete details).
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Input and output facets have been re-written to support format-based
+ redefinition of formats (see <link linkend="date_time.date_time_io">Date Time IO</link> for complete details).
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Functions have been added to facilitate conversions between <code>tm</code> structs for <code>date</code>, <code>ptime</code>, <code>time_duration</code>, and <code>local_date_time</code>. Functions for converting <code>FILETIME</code>, and <code>time_t</code> to <code>ptime</code> are also provided. See the individual sections for details.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>A <code>universal_time</code> function has been added to the <code>microsec_time_clock</code> (full details of this function can be found <link linkend="ptime_from_clock">here</link>).
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Functions have been added to facilitate conversions between <code>tm</code> structs for <code>date</code>, <code>ptime</code>, <code>time_duration</code>, and <code>local_date_time</code>. Functions for converting <code>FILETIME</code>, and <code>time_t</code> to <code>ptime</code> are also provided. See the individual sections for details.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>A <code>universal_time</code> function has been added to the <code>microsec_time_clock</code> (full details of this function can be found <link linkend="ptime_from_clock">here</link>).
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Date-time now uses reentrant POSIX functions on those platforms that
+ support them when BOOST_HAS_THREADS is defined.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Fixed multiple warnings generated with various platforms/compilers.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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 <code>ptime(date(2005,2,1), hours(-5))</code> -> "2005-Jan-31 19:00:00" &amp; <code>ptime(date(2005,2,1), hours(35))</code> -> "2005-Feb-02 11:00:00").
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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).
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Changes to the <code>boost::serialization</code> interface broke serialization compatibility for <code>date_time</code>. The user must provide a function to insure <code>date_time</code> objects are <code>const</code> before they are serialized. The function should be similar to:
+ <screen>template&lt;class archive_type, class temporal_type>
+void save_to(archive_type&amp; ar,
+ const temporal_type&amp; tt)
+{
+ ar &lt;&lt; tt;
+}</screen>
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Use of the depricated <code>boost::tokenizer</code> interface has been updated to the current interface. This fixes compiler errors on some older compilers.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Templatized formatters in the legacy IO system to accept char type. Also removed calls to <code>boost::lexical_cast</code>.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+
+ <bridgehead renderas="sect3">Changes from Boost 1.31 to 1.32 (date_time 1.02 to 1.03)</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Free function for creating a ptime object from a FILETIME struct. This function
+ is only available on platforms that define BOOST_HAS_FTIME.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Microsecond time clock is now available on most windows compilers as well as
+ Unix.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Removed incorrect usage of BOOST_NO_CWCHAR macro throughout library.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>New names added for some date classes. Original names are still valid but may
+ some day be deprecated. Changes are:
+ <simplelist type='horiz' columns='3'>
+ <member>date_duration</member>
+ <member>is now</member>
+ <member>days</member>
+ <member>nth_kday_of_month</member>
+ <member>is now</member>
+ <member>nth_day_of_the_week_in_month</member>
+ <member>first_kday_of_month</member>
+ <member>is now</member>
+ <member>first_day_of_the_week_in_month</member>
+ <member>last_kday_of_month</member>
+ <member>is now</member>
+ <member>last_day_of_the_week_in_month</member>
+ <member>first_kday_after</member>
+ <member>is now</member>
+ <member>first_day_of_the_week_after</member>
+ <member>first_kday_before</member>
+ <member>is now</member>
+ <member>first_day_of_the_week_before</member>
+ </simplelist>
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Free functions for date generators added. Functions are: days_until_weekday, days_before_weekday, next_weekday, and previous_weekday.
+ <screen>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);</screen>
+ Thanks to Bart Garst for this change.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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.
+
+ <screen>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</screen>
+ Input streaming is not yet implemented for these types.
+ Thanks to Bart Garst for this change.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Unifying base class for date_generators brought in to gregorian namespace. See <link linkend="date_time.examples.print_holidays">Print Holidays Example</link>.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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).
+ <screen>ptime p_nadt(not_a_date_time);
+ptime p_posinf(pos_infin);
+ptime p; // p == NADT
+date d; // d == NADT</screen>
+ Thanks to Bart Garst for this change.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Output streaming now supports wide stream output on compiler / standard library combinations that support wide streams. This allows code like:
+ <screen>std::wstringstream wss;
+date d(2003,Aug,21);
+wss &lt;&lt; d;</screen>
+ Thanks to Bart Garst for this change.
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Input streaming for date and time types is now supported on both wide and narrow streams:
+ <screen>date d(not_a_date_time);
+std::stringstream ss("2000-FEB-29");
+ss &gt;&gt; d; //Feb 29th, 2000
+std::wstringstream ws("2000-FEB-29");
+ws &gt;&gt; d; //Feb 29th, 2000</screen>
+ Thanks to Bart Garst for this change.
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry> 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
+ </entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <bridgehead renderas="sect3">Changes from Boost 1.30 to 1.31 (date_time 1.01 to 1.02)</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Build configuration updated so dll, statically, and dynamically linkable library files are now produced with MSVC compilers. See <link linkend="date_time.buildinfo">Build/Compiler Information</link> for more details.</entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Time_duration from_string is now correctly constructed from a negative value. (ie "-0:39:00.000") Code provided by Bart Garst.</entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Fixed many MSVC compiler warnings when compiled with warning level 4.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Added prefix decrement operator (--) for date and time iterators. See <link linkend="date_time.posix_time.time_iterators">Time Iterators</link> and <link linkend="date_time.gregorian.date_iterators">Date Iterators</link> for more details. Code provided by Bart Garst.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Special_values functionality added for date_duration, time_duration and time classes. Code provided by Bart Garst.</entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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.</entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>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 <link linkend="date_time.calculations">Calculations</link> has been improved.</entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Added typedefs to boost::gregorian gregorian_types.hpp various date_generator function classes.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Added from_time_t function to convert time_t to a ptime.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Added a span function for combining periods. See <link linkend="date_time.gregorian.date_period">date period</link> and <link linkend="date_time.posix_time.time_period">time period</link> docs.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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
+ <screen>seconds(1).total_milliseconds() == 1000
+seconds(1).total_microseconds() == 1000000
+hours(1).total_milliseconds() == 3600*1000 //3600 sec/hour
+seconds(1).total_nanoseconds() == 1000000000</screen>
+
+ </entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Added output streaming operators for the <link linkend="date_time.gregorian.date_algorithms">date generator</link> classes - partial_date, first_kday_after, first_kday_before, etc. Thanks to Bart Garst for this work.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Added unary- operators for durations for reversing the sign of a time duration. For example:
+ <screen>time_duration td(5,0,0); //5 hours
+td = -td; //-5 hours</screen>
+ Thanks to Bart Garst for this work.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>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 <link linkend="date_time.gregorian.date_class">Date Class</link> for more details.</entry>
+ </row>
+ <row>
+ <entry>Bug-Fix</entry><!-- leave '-' so table cell doesn't wrap -->
+ <entry>Various documentation fixes. Thanks to Bart Garst for updates.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <bridgehead renderas="sect3">Changes from Boost 1.29 to 1.30 (date_time 1.00 to 1.01)</bridgehead>
+ <para>
+ Notice: The interface to the partial_date class (see <link linkend="date_time.gregorian.date_algorithms">date_algorithms</link>) 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);
+ </para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Type</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Added new experimental feature for Daylight Savings Time calculations. This allows traits based specification of dst rules.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Added new interfaces to calculate julian day and modified julian day to the gregorian date class. See <link linkend="date_time.gregorian.date_class">boost::gregorian::date</link>.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Add new interface to calculate iso 8601 week number for a date. See <link linkend="date_time.gregorian.date_class">boost::gregorian::date</link>.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry>Add an iso 8601 time date-time format (eg: YYYYMMDDTHHHMMSS) parsing function. See <link linkend="date_time.posix_time.ptime_class">Class ptime</link> for more information.</entry>
+ </row>
+ <row>
+ <entry>Feature</entry>
+ <entry> Added a length function to the period template so that both date_periods and time_periods will now support this function.</entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Split Jamfiles so that libs/date_time/build/Jamfile only builds library and /libs/date_time/libs/test/Jamfile which runs tests.</entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Fixed many minor documentation issues.</entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Removed the DATE_TIME_INLINE macro which was causing link errors. This macro is no longer needed in projects using the library.</entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Added missing typedef for year_iterator to gregorian_types.hpp</entry>
+ </row>
+ <row>
+ <entry>Bug Fix</entry>
+ <entry>Fixed problem with gregorian ostream operators that prevented the use of wide streams.</entry>
+ </row>
+ <row>
+ <entry>Bug-Fix</entry><!-- leave '-' so table cell doesn't wrap -->
+ <entry>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.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/conceptual.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/conceptual.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.conceptual" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Conceptual</title>
+
+ <xi:include href="motivation.xml"/>
+ <xi:include href="domain_concepts.xml"/>
+ <xi:include href="design_concepts.xml"/>
+
+
+</section>
+

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/custom_time_zone.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/custom_time_zone.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,376 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.local_time.custom_time_zone">
+ <title>Custom Time Zone</title>
+
+ <link linkend="custom_time_zone_intro">Introduction</link> --
+ <link linkend="custom_time_zone_header">Header</link> --
+ <link linkend="custom_time_zone_constr">Construction</link> --
+ <link linkend="custom_time_zone_accessors">Accessors</link> --
+ <link linkend="custom_time_zone_dependents">Dependent Types</link>
+
+ <anchor id="custom_time_zone_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ 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 <link linkend="date_time.local_time.dst_calc_rules">dst_calc_rules</link>. These rules are handled via a boost::shared_ptr&lt;dst_calc_rules&gt;. Not all time zones utilize daylight savings, therefore, time_zone objects can be used with a NULL-assigned shared_ptr.
+ </para>
+ <para>
+ As a convenience, a typedef for shared_ptr&lt;dst_calc_rules&gt; is provided.
+ <programlisting>typedef boost::shared_ptr&lt;dst_calc_rules&gt; local_time::dst_calc_rule_ptr;</programlisting>
+ </para>
+ <anchor id="date_time.local_time.custom_time_zone_ptr" />
+ <para>
+ The time_zone objects are used via a boost::shared_ptr&lt;local_time::time_zone&gt;. As a convenience, a typedef for boost::shared_ptr&lt;local_time::time_zone&gt; is provided:
+ <programlisting>typedef boost::shared_ptr&lt;time_zone&gt; local_time::time_zone_ptr;</programlisting>
+ </para>
+
+ <anchor id="custom_time_zone_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ The inclusion of a single header will bring in all boost::local_time types, functions, and IO operators.
+ <programlisting>#include "boost/date_time/local_time/local_time.hpp"</programlisting>
+ </para>
+
+ <anchor id="custom_time_zone_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ Construction of a custom_time_zone is dependent on four objects: a
+ <link linkend="date_time.posix_time.time_duration">time_duration</link>, a <link linkend="time_zone_names">time_zone_names</link>, a <link linkend="dst_adjustment_offsets">dst_adjustment_offsets</link>, and a shared_ptr to a <link linkend="date_time.local_time.dst_calc_rules">dst_calc_rule</link>.
+ </para>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Syntax</entry>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>custom_time_zone(...)
+ Parameters:
+ <link linkend="time_zone_names">names</link>,
+ <link linkend="date_time.posix_time.time_duration">gmt_offset</link>,
+ <link linkend="dst_adjustment_offsets">dst_offsets</link>,
+ <link linkend="date_time.local_time.dst_calc_rules">dst_rules</link> </screen></entry>
+ <entry>See <link linkend="date_time.examples.simple_time_zone">simple_time_zone</link> example for time_zone usage</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="custom_time_zone_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string dst_zone_abbrev()</screen></entry>
+ <entry>Returns the daylight savings abbreviation for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr->dst_zone_abbrev();
+// "EDT"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string std_zone_abbrev()</screen></entry>
+ <entry>Returns the standard abbreviation for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr->std_zone_abbrev();
+// "EST"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string dst_zone_name()</screen></entry>
+ <entry>Returns the daylight savings name for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr->dst_zone_name();
+// "Eastern Daylight Time"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string std_zone_name()</screen></entry>
+ <entry>Returns the standard name for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr->std_zone_name();
+// "Eastern Standard Time"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool has_dst()</screen></entry>
+ <entry>Returns true when custom_time_zone's shared_ptr to dst_calc_rules is not NULL.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr->has_dst();
+// true
+phx_zone_sh_ptr->has_dst();
+// false</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>dst_local_start_time(...)
+ Return Type:
+ ptime
+ Parameter:
+ greg_year</screen></entry>
+ <entry>The date and time daylight savings time begins in given year. Returns not_a_date_time if this zone has no daylight savings.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_ptr->dst_local_start_time(2004);
+// 2004-Apr-04 02:00</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>dst_local_end_time(...)
+ Return Type:
+ ptime
+ Parameter:
+ greg_year</screen></entry>
+ <entry>The date and time daylight savings time ends in given year. Returns not_a_date_time if this zone has no daylight savings.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_ptr->dst_local_end_time(2004);
+// 2004-Oct-31 02:00</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration base_utc_offset()</screen></entry>
+ <entry>The amount of time offset from UTC (typically in hours).</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_ptr->base_utc_offset();
+// -05:00</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration dst_offset()</screen></entry>
+ <entry>The amount of time shifted during daylight savings.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr->dst_offset();
+// 01:00</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string to_posix_string()</screen></entry>
+ <entry>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 <link linkend="date_time.local_time.posix_time_zone">posix_time_zone</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>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"
+ </screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="custom_time_zone_dependents" />
+ <bridgehead renderas="sect3">Dependent Types</bridgehead>
+ <link linkend="time_zone_names">Time Zone Names</link> --
+ <link linkend="dst_adjustment_offsets">Dst Adjustment Offsets</link> --
+ <link linkend="date_time.local_time.dst_calc_rules">Daylight Savings Calc Rules</link>
+ <anchor id="time_zone_names" />
+ <bridgehead renderas="sect3">Time Zone Names</bridgehead>
+ <para>
+ 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&lt;char&gt;.
+ </para>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>time_zone_names(...)
+ Parameters:
+ string std_name
+ string std_abbrev
+ string dst_name
+ string dst_abbrev</screen></entry>
+ <entry>The only constructor, all four strings must be provided.</entry>
+ </row>
+ <row>
+ <entry><screen>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);</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string std_zone_name()</screen></entry>
+ <entry>Returns the standard zone name</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_names.std_zone_name();
+// "Eastern Standard Time"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string std_zone_abbrev()</screen></entry>
+ <entry>Returns the standard zone abbreviation</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_names.std_zone_abbrev();
+// "EST"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string dst_zone_name()</screen></entry>
+ <entry>Returns the daylight savings zone name</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_names.std_zone_name();
+// "Eastern Daylight Time"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string dst_zone_abbrev()</screen></entry>
+ <entry>Returns the daylight savings zone abbreviation</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_names.std_zone_abbrev();
+// "EDT"</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="dst_adjustment_offsets" />
+ <bridgehead renderas="sect3">Dst Adjustment Offsets</bridgehead>
+ <para>
+ The dst_adjustment_offsets type is a collection of three <link linkend="date_time.posix_time.time_duration">time_duration</link> objects.
+ </para>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>dst_adjustment_offsets(...)
+ Parameters:
+ time_duration dst_adjust
+ time_duration start_offset
+ time_duration end_offset</screen></entry>
+ <entry>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.</entry>
+ </row>
+ <row>
+ <entry><screen>
+dst_adjustment_offsets(hours(1),
+ hours(2),
+ hours(2));</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="date_time.local_time.dst_calc_rules" />
+ <bridgehead renderas="sect3">Daylight Savings Calc Rules</bridgehead>
+ <para>
+ Daylight savings calc rules, named dst_calc_rules, are a series of objects that group appropriate <link linkend="date_time.gregorian.date_algorithms">date_generators</link> together to form rule sets. The individual rules objects are used via dst_calc_rule_ptr.
+ </para>
+ <para>
+ For a complete example of all five dst_calc_rule types, see: <link linkend="date_time.examples.calc_rules">calc_rules example</link>.
+ </para>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>partial_date_dst_rule(...)
+ Parameters:
+ start_rule
+ end_rule</screen></entry>
+ <entry>Both the start and end rules are of type gregorian::partial_date.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>first_last_dst_rule(...)
+ Parameters:
+ start_rule
+ end_rule</screen></entry>
+ <entry>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.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>last_last_dst_rule(...)
+ Parameters:
+ start_rule
+ end_rule</screen></entry>
+ <entry>Both the start and end rules are of type gregorian::last_day_of_the_week_in_month.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>nth_last_dst_rule(...)
+ Parameters:
+ start_rule
+ end_rule</screen></entry>
+ <entry>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.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>nth_kday_dst_rule(...)
+ Parameters:
+ start_rule
+ end_rule)
+(see note* below)</screen>
+ </entry>
+ <entry>Both rules are of type gregorian::nth_day_of_the_week_in_month.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <para>
+ * 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.
+ </para>
+ </para>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_algorithms.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_algorithms.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,202 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.gregorian.date_algorithms">
+ <title>Date Generators/Algorithms</title>
+ <bridgehead renderas="sect2">Date Generators/Algorithms</bridgehead>
+ <link linkend="algo_intro">Introduction</link> --
+ <link linkend="algo_header">Header</link> --
+ <link linkend="algo_overview">Class Overview</link> --
+ <link linkend="algo_func_overview">Function Overview</link>
+
+ <anchor id="algo_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ 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.
+ <emphasis>Note</emphasis>: 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
+ </para>
+ <para>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.
+ </para>
+ <para>All date generator classes and functions are in the boost::gregorian namespace.
+ </para>
+ <para>
+ The <link linkend="date_time.examples.print_holidays">print holidays</link> example shows a detailed usage example.
+ </para>
+
+ <anchor id="algo_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para><programlisting>#include "boost/date_time/gregorian/gregorian.hpp"</programlisting>
+ </para>
+
+ <anchor id="algo_overview" />
+ <bridgehead renderas="sect3">Overview</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Class and get_date Parameter</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>year_based_generator
+date get_date(greg_year year)</screen></entry>
+ <entry>A unifying (abstract) date_generator base type for: <code>partial_date</code>, <code>nth_day_of_the_week_in_month</code>, <code>first_day_of_the_week_in_month</code>, and <code>last_day_of_the_week_in_month</code>.</entry>
+ </row>
+ <row>
+ <entry>The <link linkend="date_time.examples.print_holidays">print holidays</link> example shows a detailed usage example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>last_day_of_the_week_in_month(greg_weekday,
+ greg_month)
+date get_date(greg_year year)</screen></entry>
+ <entry>Calculate something like last Monday of January</entry>
+ </row>
+ <row>
+ <entry><screen>last_day_of_the_week_in_month lwdm(Monday,Jan);
+date d = lwdm.get_date(2002);
+//2002-Jan-28</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>first_day_of_the_week_in_month(greg_weekday,
+ greg_month)
+date get_date(greg_year year)</screen></entry>
+ <entry>Calculate something like first Monday of January</entry>
+ </row>
+ <row>
+ <entry><screen>first_day_of_the_week_in_month fdm(Monday,Jan);
+date d = fdm.get_date(2002);
+//2002-Jan-07</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>nth_day_of_the_week_in_month(week_num,
+ greg_weekday,
+ greg_month)
+date get_date(greg_year year)</screen></entry>
+ <entry><code>week_num</code> is a public enum member of <code>nth_day_of_the_week_in_month</code>. 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)</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>partial_date(greg_day, greg_month)
+date get_date(greg_year year)</screen></entry>
+ <entry>Generates a date by applying the year to the given month and day.</entry>
+ </row>
+ <row>
+ <entry><screen>partial_date pd(1,Jan);
+date d = pd.get_date(2002);
+//2002-Jan-01</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>first_day_of_the_week_after(greg_weekday)
+date get_date(date d)</screen></entry>
+ <entry>Calculate something like First Sunday after Jan 1,2002</entry>
+ </row>
+ <row>
+ <entry><screen>first_day_of_the_week_after fdaf(Monday);
+date d = fdaf.get_date(date(2002,Jan,1));
+//2002-Jan-07</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>first_day_of_the_week_before(greg_weekday)
+date get_date(date d)</screen></entry>
+ <entry>Calculate something like First Monday before Feb 1,2002</entry>
+ </row>
+ <row>
+ <entry><screen>first_day_of_the_week_before fdbf(Monday);
+date d = fdbf.get_date(date(2002,Feb,1));
+//2002-Jan-28</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+
+ <anchor id="algo_func_overview" />
+ <bridgehead renderas="sect3">Function Overview</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Function Prototype</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>days days_until_weekday date, greg_weekday)</screen></entry>
+ <entry> Calculates the number of days from given date until given weekday.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2004,Jun,1); // Tuesday
+greg_weekday gw(Friday);
+days_until_weekday(d, gw); // 3 days</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>days days_before_weekday(date, greg_weekday)</screen></entry>
+ <entry> Calculates the number of day from given date to previous given weekday.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2004,Jun,1); // Tuesday
+greg_weekday gw(Friday);
+days_before_weekday(d, gw); // 4 days</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date next_weekday(date, greg_weekday)</screen></entry>
+ <entry> Generates a date object representing the date of the following weekday from the given date.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2004,Jun,1); // Tuesday
+greg_weekday gw(Friday);
+next_weekday(d, gw); // 2004-Jun-4</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date previous_weekday(date, greg_weekday)</screen></entry>
+ <entry> Generates a date object representing the date of the previous weekday from the given date.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2004,Jun,1); // Tuesday
+greg_weekday gw(Friday);
+previous_weekday(d, gw); // 2004-May-28</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_class.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_class.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,524 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2007 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.gregorian.date_class">
+ <title>Date</title>
+
+ <link linkend="date_intro">Introduction</link> --
+ <link linkend="date_header">Header</link> --
+ <link linkend="date_construction">Construction</link> --
+ <link linkend="date_construct_from_string">Construct from String</link> --
+ <link linkend="date_construct_from_clock">Construct from Clock</link> --
+ <link linkend="date_accessors">Accessors</link> --
+ <link linkend="date_convert_to_string">Convert to String</link> --
+ <link linkend="date_operators">Operators</link> --
+ <link linkend="date_tm_funcs">Struct tm Functions</link>
+
+ <anchor id="date_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ 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
+ <link linkend="date_construct_from_clock">current date from the clock</link>,
+ using <link linkend="date_time.gregorian.date_iterators">date iterators</link>, and
+ <link linkend="date_time.gregorian.date_algorithms">date algorithms or generators</link>.
+ </para>
+
+ <para>
+ 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.
+ </para>
+
+ <para>
+ The construction of a date validates all input so that it is not possible to
+ construct and '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.
+ </para>
+
+ <anchor id="date_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ <programlisting>#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</programlisting>
+ </para>
+
+ <anchor id="date_construction" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>date(greg_year, greg_month, greg_day)</screen></entry>
+ <entry>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.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,10);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date(date d)</screen></entry>
+ <entry>Copy constructor</entry>
+ </row>
+ <row>
+ <entry><screen>date d1(d);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date(special_values sv)</screen></entry>
+ <entry>Constructor for infinities, not-a-date-time, max_date_time, and min_date_time</entry>
+ </row>
+ <row>
+ <entry><screen>date d1(neg_infin);
+date d2(pos_infin);
+date d3(not_a_date_time);
+date d4(max_date_time);
+date d5(min_date_time);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date()</screen></entry>
+ <entry>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)</entry>
+ </row>
+ <row>
+ <entry><screen>date d; // d =&gt; not_a_date_time</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <anchor id="date_construct_from_string" />
+ <bridgehead renderas="sect3">Construct from String</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>date from_string(std::string)</screen></entry>
+ <entry>From delimited date string where with order year-month-day eg: 2002-1-25</entry>
+ </row>
+ <row>
+ <entry><screen>std::string ds("2002/1/25");
+date d(from_string(ds));</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date from_undelimited_string(std::string)</screen></entry>
+ <entry>From iso type date string where with order year-month-day eg: 20020125</entry>
+ </row>
+ <row>
+ <entry><screen>std::string ds("20020125");
+date d(from_undelimited_string(ds));</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <anchor id="date_construct_from_clock" />
+ <bridgehead renderas="sect3">Construct from Clock</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>day_clock::local_day()</screen></entry>
+ <entry>Get the local day based on the time zone settings of the computer.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(day_clock::local_day());</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>day_clock::universal_day()</screen></entry>
+ <entry>Get the UTC day.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(day_clock::universal_day());</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <anchor id="date_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>greg_year year() const</screen></entry>
+ <entry>Get the year part of the date.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,10);
+d.year(); // --> 2002</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>greg_month month() const</screen></entry>
+ <entry>Get the month part of the date.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,10);
+d.month(); // --> 1</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>greg_day day() const</screen></entry>
+ <entry> Get the day part of the date.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,10);
+d.day(); // --> 10</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>greg_ymd year_month_day() const</screen></entry>
+ <entry>Return a year_month_day struct. More efficient when all 3 parts of the date are needed.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,10);
+date::ymd_type ymd = d.year_month_day();
+// ymd.year --> 2002,
+// ymd.month --> 1,
+// ymd.day --> 10</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>greg_day_of_week day_of_week() const</screen></entry>
+ <entry>Get the day of the week (eg: Sunday, Monday, etc.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,10);
+d.day(); // --> Thursday</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>greg_day_of_year day_of_year() const</screen></entry>
+ <entry>Get the day of the year. Number from 1 to 366 </entry>
+ </row>
+ <row>
+ <entry><screen>date d(2000,Jan,10);
+d.day_of_year(); // --> 10</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date end_of_month() const</screen></entry>
+ <entry>Returns a <code>date</code> object set to the last day of the calling objects current month.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2000,Jan,10);
+d.end_of_month(); // --> 2000-Jan-31</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_infinity() const</screen></entry>
+ <entry>Returns true if date is either positive or negative infinity</entry>
+ </row>
+ <row>
+ <entry><screen>date d(pos_infin);
+d.is_infinity(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_neg_infinity() const</screen></entry>
+ <entry>Returns true if date is negative infinity</entry>
+ </row>
+ <row>
+ <entry><screen>date d(neg_infin);
+d.is_neg_infinity(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_pos_infinity() const</screen></entry>
+ <entry>Returns true if date is positive infinity</entry>
+ </row>
+ <row>
+ <entry><screen>date d(neg_infin);
+d.is_pos_infinity(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_not_a_date() const</screen></entry>
+ <entry>Returns true if value is not a date</entry>
+ </row>
+ <row>
+ <entry><screen>date d(not_a_date_time);
+d.is_not_a_date(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_special() const</screen></entry>
+ <entry>Returns true if date is any <code>special_value</code></entry>
+ </row>
+ <row>
+ <entry><screen>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</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>special_value as_special() const</screen></entry>
+ <entry>Returns represented <code>special_value</code> or <code>not_special</code> if the represented date is a normal date.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>long modjulian_day() const</screen></entry>
+ <entry>Returns the modified julian day for the date.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>long julian_day() const</screen></entry>
+ <entry>Returns the julian day for the date.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>int week_number() const</screen></entry>
+ <entry>Returns the ISO 8601 week number for the date.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+ <row>
+ <entry valign="top" morerows="1"><screen>date end_of_month_day() const</screen></entry>
+ <entry>Returns the last day of the month for the date.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2000,Feb,1);
+//gets Feb 28 -- 2000 was leap year
+date eom = d.end_of_month_day();</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <anchor id="date_convert_to_string" />
+ <bridgehead renderas="sect3">Convert to String</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string to_simple_string(date d)</screen></entry>
+ <entry>To <code>YYYY-mmm-DD</code> string where <code>mmm</code> 3 char month name.</entry>
+ </row>
+ <row>
+ <entry><screen>"2002-Jan-01"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string to_iso_string(date d)</screen></entry>
+ <entry>To <code>YYYYMMDD</code> where all components are integers.</entry>
+ </row>
+ <row>
+ <entry><screen>"20020131"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string to_iso_extended_string(date d)</screen></entry>
+ <entry> To <code>YYYY-MM-DD</code> where all components are integers.</entry>
+ </row>
+ <row>
+ <entry><screen>"2002-01-31"</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <anchor id="date_operators" />
+ <bridgehead renderas="sect3">Operators</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;&lt;</screen></entry>
+ <entry>Stream output operator</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,1);
+std::cout &lt;&lt; d &lt;&lt; std::endl;</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&gt;&gt;</screen></entry>
+ <entry>Stream input operator. <emphasis role="strong">Note:</emphasis> As of version 1.33, streaming operations have been greatly improved. See <link linkend="date_time.date_time_io">Date Time IO System</link> for details on exceptions and error conditions.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(not_a_date_time);
+stringstream ss("2002-Jan-01");
+ss &gt;&gt; d;</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator==, operator!=,
+operator>, operator&lt;,
+operator>=, operator&lt;=</screen></entry>
+ <entry>A full complement of comparison operators</entry>
+ </row>
+ <row>
+ <entry><screen>d1 == d2, etc</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date operator+(date_duration) const</screen></entry>
+ <entry>Return a date adding a day offset</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,1);
+date_duration dd(1);
+date d2 = d + dd;</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date operator-(date_duration) const</screen></entry>
+ <entry>Return a date by adding a day offset</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,1);
+date_duration dd(1);
+date d2 = d - dd;</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_duration operator-(date) const</screen></entry>
+ <entry>Return a date_duration by subtracting two dates</entry>
+ </row>
+ <row>
+ <entry><screen>date d1(2002,Jan,1);
+date d2(2002,Jan,2);
+date_duration dd = d2-d1;</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <anchor id="date_tm_funcs" />
+ <bridgehead renderas="sect3">Struct tm Functions</bridgehead>
+ <para>Functions for converting a <code>date</code> object to, and from, a <code>tm</code> struct are provided.</para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>tm to_tm(date)</screen></entry>
+ <entry>A function for converting a <code>date</code> object to a <code>tm</code> struct. The fields: <code>tm_hour</code>, <code>tm_min</code>, and <code>tm_sec</code> are set to zero. The <code>tm_isdst</code> field is set to -1.</entry>
+ </row>
+ <row>
+ <entry><screen>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_isddst => -1 */</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date date_from_tm(tm datetm)</screen></entry>
+ <entry>A function for converting a <code>tm</code> struct to a <code>date</code> object. The fields: <code>tm_wday </code>, <code>tm_yday </code>, <code>tm_hour</code>, <code>tm_min</code>, <code>tm_sec</code>, and <code>tm_isdst</code> are ignored.</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_duration.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_duration.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,250 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section xmlns:xi="http://www.w3.org/2001/XInclude" id="date_time.gregorian.date_duration">
+ <title>Date Duration (aka Days)</title>
+
+ <link linkend="duration_intro">Introduction</link> --
+ <link linkend="duration_header">Header</link> --
+ <link linkend="duration_construction">Construction</link> --
+ <link linkend="duration_accessors">Accessors</link> --
+ <link linkend="duration_operators">Operators</link> --
+ <link linkend="additional_duration_types">Additional Duration Types</link>
+
+ <anchor id="duration_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ The class boost::gregorian::date_duration is a simple day count used for arithmetic with <link linkend="date_time.gregorian.date_class">gregorian::date</link>. A duration can be either positive or negative.
+ </para>
+ <para>
+ 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.
+ </para>
+
+ <anchor id="duration_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ <programlisting>#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</programlisting>
+ </para>
+
+ <anchor id="duration_construction" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>date_duration(long)</screen></entry>
+ <entry>Create a duration count.</entry>
+ </row>
+ <row>
+ <entry><screen>date_duration dd(3); //3 days</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>days(special_values sv)</screen></entry>
+ <entry>Constructor for infinities, not-a-date-time, max_date_time, and min_date_time</entry>
+ </row>
+ <row>
+ <entry><screen>days dd1(neg_infin);
+days dd2(pos_infin);
+days dd3(not_a_date_time);
+days dd4(max_date_time);
+days dd5(min_date_time);</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <anchor id="duration_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>long days() const</screen></entry>
+ <entry>Get the day count.</entry>
+ </row>
+ <row>
+ <entry><screen>date_duration dd(3); dd.days() --> 3</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_negative() const</screen></entry>
+ <entry>True if number of days is less than zero.</entry>
+ </row>
+ <row>
+ <entry><screen>date_duration dd(-1); dd.is_negative() --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>static date_duration unit()</screen></entry>
+ <entry>Return smallest possible unit of duration type.</entry>
+ </row>
+ <row>
+ <entry><screen>date_duration::unit() --> date_duration(1)</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_special() const</screen></entry>
+ <entry>Returns true if days is any <code>special_value</code></entry>
+ </row>
+ <row>
+ <entry><screen>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</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <anchor id="duration_operators" />
+ <bridgehead renderas="sect3">Operators</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;&lt;, operator&gt;&gt;</screen></entry>
+ <entry>Streaming operators. <emphasis role="strong">Note:</emphasis> As of version 1.33, streaming operations have been greatly improved. See <link linkend="date_time.date_time_io">Date Time IO System</link> for more details (including exceptions and error conditions).</entry>
+ </row>
+ <row>
+ <entry><screen>date d(not_a_date_time);
+stringstream ss("2002-Jan-01");
+ss &gt;&gt; d;
+std::cout &lt;&lt; d; // "2002-Jan-01"
+</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator==, operator!=,
+operator>, operator&lt;,
+operator>=, operator&lt;=</screen>
+ </entry>
+ <entry>A full complement of comparison operators</entry>
+ </row>
+ <row>
+ <entry><screen>dd1 == dd2, etc</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_duration operator+(date_duration) const</screen></entry>
+ <entry>Add date durations.</entry>
+ </row>
+ <row>
+ <entry><screen>date_duration dd1(3);
+date_duration dd2(5);
+date_duration dd3 = dd1 + dd2;</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_duration operator-(date_duration) const</screen></entry>
+ <entry>Subtract durations.</entry>
+ </row>
+ <row>
+ <entry><screen>date_duration dd1(3);
+date_duration dd2(5);
+date_duration dd3 = dd1 - dd2;</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <anchor id="additional_duration_types" />
+ <bridgehead renderas="sect3">Additional Duration Types</bridgehead>
+ <para>These additional types are logical representations of spans of days.</para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>months(int num_of_months)</screen></entry>
+ <entry>A logical month representation. Depending on the usage, this <code>months</code> 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. <emphasis role="strong">WARNING: this behavior may lead to unexpected results.</emphasis> See: <link linkend="snap_to_details">Reversibility of Operations Pitfall</link> for complete details and alternatives.</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>years(int num_of_years)</screen></entry>
+ <entry>A logical representation of a year. The <code>years</code> object has the same behavior as the <code>months</code> objects with regards to the end-of-the-month.</entry>
+ </row>
+ <row>
+ <entry><screen>years single(1);
+date(2003,Feb,28) + single;
+// results in => 2004-Feb-29
+date(2004,Feb,29) + single;
+// results in => 2005-Feb-28</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>weeks(int num_of_weeks)</screen></entry>
+ <entry>A duration type representing a number of <code>n * 7</code> days.</entry>
+ </row>
+ <row>
+ <entry><screen>weeks single(1);
+date(2005,Jan,1) + single; // => 2005-Jan-08</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <xi:include href="snap_to_details.xml"/>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_facet.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_facet.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,319 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.date_facet">
+ <title>Date Facet</title>
+
+ <link linkend="date_facet_intro">Introduction</link> -
+ <link linkend="date_facet_constr">Construction</link> -
+ <link linkend="date_facet_accessors">Accessors</link>
+
+ <anchor id="date_facet_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>The <code>boost::date_time::date_facet</code> enables users to have significant control over the output streaming of dates (and other gregorian objects). The date_facet is typedef'd in the <code>gregorian</code> namespace as <code>date_facet</code> and <code>wdate_facet</code>.
+ </para>
+
+ <anchor id="date_facet_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>date_facet()</screen></entry>
+ <entry>Default constructor</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>date_facet(...)
+ Parameters:
+ char_type* format
+ input_collection_type</screen></entry>
+ <entry>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.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>date_facet(...)
+ Parameters:
+ char_type* format
+ period_formatter_type
+ special_values_formatter_type
+ date_gen_formatter_type</screen></entry>
+ <entry>Format given will be used for date output. The remaining parameters are formatter objects. Further details on these objects can be found <link linkend="date_time.io_objects">here</link>. This constructor also provides default arguments for all parameters except the format. Therefore, <code>date_facet("%m %d %Y")</code> will work.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="date_facet_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>void format(char_type*)</screen></entry>
+ <entry>Set the format for dates.</entry>
+ </row>
+ <row>
+ <entry><screen>date_facet* f = new date_facet();
+f->format("%m %d %Y");</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void set_iso_format()</screen></entry>
+ <entry>Sets the date format to ISO</entry>
+ </row>
+ <row>
+ <entry><screen>f->set_iso_format();
+// "%Y%m%d"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void set_iso_extended_format()</screen></entry>
+ <entry>Sets the date format to ISO Extended</entry>
+ </row>
+ <row>
+ <entry><screen>f->set_iso_extended_format();
+// "%Y-%m-%d"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void month_format(char_type*)</screen></entry>
+ <entry>Set the format for months when they are 'put' individually.</entry>
+ </row>
+ <row>
+ <entry><screen>f->month_format("%B");
+ss &lt;&lt; greg_month(12); // "December"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void weekday_format(char_type*)</screen></entry>
+ <entry>Set the format for weekdays when they are 'put' individually.</entry>
+ </row>
+ <row>
+ <entry><screen>f->weekday_format("%a");
+ss &lt;&lt; greg_weekday(2); // "Tue"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void period_formatter(...)
+ Parameter:
+ period_formatter_type</screen></entry>
+ <entry>Replaces the period formatter object with a user created one.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void special_values_formatter(...)
+ Parameter:
+ special_values_formatter_type</screen></entry>
+ <entry>Replaces the special_values formatter object with a user created one.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void date_gen_phrase_strings(...)
+ Parameters:
+ input_collection_type
+ date_gen_formatter_type::
+ phrase_elements</screen></entry>
+ <entry>Sets new date generator phrase strings in date_gen_formatter. The input collection is a vector of strings (for details on these strings see <link linkend="io_objects.date_generators">date generator formatter/parser documentation</link>). 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.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void short_weekday_names(...)
+ Parameter:
+ input_collection_type</screen></entry>
+ <entry>Replace strings used when 'putting' short weekdays.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void long_weekday_names(...)
+ Parameter:
+ input_collection_type</screen></entry>
+ <entry>Replace strings used when 'putting' long weekdays.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void short_month_names(...)
+ Parameter:
+ input_collection_type</screen></entry>
+ <entry>Replace strings used when 'putting' short months.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void long_month_names(...)
+ Parameter:
+ input_collection_type</screen></entry>
+ <entry>Replace strings used when 'putting' long months.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(...)
+ Common parameters for all
+ 'put' functions:
+ OutItrT
+ ios_base
+ char_type
+ Unique parameter for 'put' funcs:
+ gregorian object</screen></entry>
+ <entry>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.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., date)</screen></entry>
+ <entry>Puts a date object into the stream using the format set by <code>format(...)</code> or the default.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., days)</screen></entry>
+ <entry>Puts a days object into the stream as a number.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., month)</screen></entry>
+ <entry>Puts a month object into the stream using the format set by <code>month_format(...)</code> or the default.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., day)</screen></entry>
+ <entry>Puts a day of month object into the stream as a two digit number.</entry>
+ </row>
+ <row>
+ <entry><screen>"01" // January 1st</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., day_of_week)</screen></entry>
+ <entry>Puts a day of week object into the stream using the format set by <code>weekday_format(...)</code> or the default.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., date_period)</screen></entry>
+ <entry>Puts a date_period into the stream. The format of the dates will use the format set by <code>format(..)</code> or the default date format. The type of period (open or closed range) and the delimiters used are those used by the period_formatter.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., partial_date)</screen></entry>
+ <entry>Puts a partial_date date_generator object into the stream. The month format used is set by <code>month_format(..)</code> or the default. The day of month is represented as a two digit number.</entry>
+ </row>
+ <row>
+ <entry><screen>"01 Jan" // default formats
+"01 January" // long month format</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., date_generator)
+ Date Generator Type:
+ nth_day_of_the_week_in_month</screen></entry>
+ <entry>Puts a nth_day_of_the_week_in_month object into the stream. The month format is set by <code>month_format(...)</code> or the default. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_formatter</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>"third Fri in May" // defaults</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., date_generator)
+ Date Generator Type:
+ first_day_of_the_week_in_month</screen></entry>
+ <entry>Puts a first_day_of_the_week_in_month object into the stream. The month format is set by <code>month_format(...)</code> or the default. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_formatter</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>"first Wed of Jun" // defaults</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., date_generator)
+ Date Generator Type:
+ last_day_of_the_week_in_month</screen></entry>
+ <entry>Puts a last_day_of_the_week_in_month object into the stream. The month format is set by <code>month_format(...)</code> or the default. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_formatter</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>"last Tue of Mar" // defaults</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., date_generator)
+ Date Generator Type:
+ first_day_of_the_week_after</screen></entry>
+ <entry>Puts a first_day_of_the_week_after object into the stream. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_formatter</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>"first Sat after" // defaults</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., date_generator)
+ Date Generator Type:
+ first_day_of_the_week_before</screen></entry>
+ <entry>Puts a first_day_of_the_week_before object into the stream. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_formatter</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>"first Mon before" // defaults</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+</section>
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_input_facet.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_input_facet.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,340 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.date_input_facet">
+ <title>Date Input Facet</title>
+
+ <link linkend="date_input_facet_intro">Introduction</link> -
+ <link linkend="date_input_facet_constr">Construction</link> -
+ <link linkend="date_input_facet_accessors">Accessors</link>
+
+ <anchor id="date_input_facet_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>The <code>boost::date_time::date_input_facet</code> enables users to have significant control how dates (and other gregorian objects) are streamed in. The date_input_facet is typedef'd in the <code>gregorian</code> namespace as <code>date_input_facet</code> and <code>wdate_input_facet</code>.
+ </para>
+
+ <anchor id="date_input_facet_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>date_input_facet()</screen></entry>
+ <entry>Default constructor</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>date_input_facet(string_type format)</screen></entry>
+ <entry>Format given will be used for date input. All other formats will use their defaults.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>date_input_facet(...)
+ Parameters:
+ string_type format
+ format_date_parser_type
+ special_values_parser_type
+ period_parser_type
+ date_gen_parser_type</screen></entry>
+ <entry>Format given will be used for date input. The remaining parameters are parser objects. Further details on these objects can be found <link linkend="date_time.io_objects">here</link>.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="date_input_facet_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>void format(char_type*)</screen></entry>
+ <entry>Set the format for dates.</entry>
+ </row>
+ <row>
+ <entry><screen>date_input_facet* f =
+ new date_input_facet();
+f->format("%m %d %Y");</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void set_iso_format()</screen></entry>
+ <entry>Sets the date format to ISO</entry>
+ </row>
+ <row>
+ <entry><screen>f->set_iso_format();
+// "%Y%m%d"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void set_iso_extended_format()</screen></entry>
+ <entry>Sets the date format to ISO Extended</entry>
+ </row>
+ <row>
+ <entry><screen>f->set_iso_extended_format();
+// "%Y-%m-%d"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void month_format(char_type*)</screen></entry>
+ <entry>Set the format when 'get'ing months individually.</entry>
+ </row>
+ <row>
+ <entry><screen>f->month_format("%B");
+ss.str("March");
+ss >> m; // March</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void weekday_format(char_type*)</screen></entry>
+ <entry>Set the format when 'get'ing weekdays individually.</entry>
+ </row>
+ <row>
+ <entry><screen>f->weekday_format("%a");
+ss.str("Sun");
+ss >> wd; // Sunday</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void year_format(char_type*)</screen></entry>
+ <entry>Set the format when 'get'ing years individually.</entry>
+ </row>
+ <row>
+ <entry><screen>f->weekday_format("%y");
+ss.str("04");
+ss >> year; // 2004</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void period_parser(...)
+ Parameter:
+ period_parser_type</screen></entry>
+ <entry>Replaces the period parser object with a user created one.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void special_values_parser(...)
+ Parameter:
+ special_values_parser_type</screen></entry>
+ <entry>Replaces the special_values parser object with a user created one.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void date_gen_phrase_strings(...)
+ Parameters:
+ input_collection_type</screen></entry>
+ <entry>Sets new date generator phrase strings in date_gen_parser. The input collection is a vector of strings (for details on these strings see <link linkend="io_objects.date_generators">date generator formatter/parser documentation</link>).</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void short_weekday_names(...)
+ Parameter:
+ input_collection_type</screen></entry>
+ <entry>Replace strings used when 'getting' short weekdays.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void long_weekday_names(...)
+ Parameter:
+ input_collection_type</screen></entry>
+ <entry>Replace strings used when 'getting' long weekdays.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void short_month_names(...)
+ Parameter:
+ input_collection_type</screen></entry>
+ <entry>Replace strings used when 'getting' short months.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void long_month_names(...)
+ Parameter:
+ input_collection_type</screen></entry>
+ <entry>Replace strings used when 'getting' long months.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(...)
+ Common parameters for all
+ 'get' functions:
+ InItrT from
+ InItrT to
+ ios_base
+ Unique parameter for 'get' funcs:
+ gregorian object</screen></entry>
+ <entry>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.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., date)</screen></entry>
+ <entry>Gets a date object from the stream using the format set by <code>format(...)</code> or the default.</entry>
+ </row>
+ <row>
+ <entry><screen>ss.str("2005-Jan-01");
+ss >> d; // default format</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., month)</screen></entry>
+ <entry>Gets a month object from the stream using the format set by <code>month_format(...)</code> or the default.</entry>
+ </row>
+ <row>
+ <entry><screen>ss.str("Feb");
+ss >> m; // default format</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., day_of_week)</screen></entry>
+ <entry>Gets a day of week object from the stream using the format set by <code>weekday_format(...)</code> or the default.</entry>
+ </row>
+ <row>
+ <entry><screen>ss.str("Sun");
+ss >> dow; // default format</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., day)</screen></entry>
+ <entry>Gets a day of month object from the stream as a two digit number.</entry>
+ </row>
+ <row>
+ <entry><screen>"01" // January 1st</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., year)</screen></entry>
+ <entry>Gets a year object from the stream as a number. The number of expected digits depends on the year format.</entry>
+ </row>
+ <row>
+ <entry><screen>ss/str("2005");
+ss >> y; // default format</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., days)</screen></entry>
+ <entry>Gets a days object from the stream as a number.</entry>
+ </row>
+ <row>
+ <entry><screen>ss.str("356");
+ss >> dys; // a full year</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., date_period)</screen></entry>
+ <entry>Gets a date_period from the stream. The format of the dates will use the format set by <code>format(..)</code> or the default date format. The type of period (open or closed range) and the delimiters used are those used by the period_parser.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., partial_date)</screen></entry>
+ <entry>Gets a partial_date date_generator object from the stream. The month format used is set by <code>month_format(..)</code> or the default. The day of month is represented as a two digit number.</entry>
+ </row>
+ <row>
+ <entry><screen>"01 Jan" // default formats
+"01 January" // long month format</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., date_generator)
+ Date Generator Type:
+ nth_day_of_the_week_in_month</screen></entry>
+ <entry>Gets a nth_day_of_the_week_in_month object from the stream. The month format is set by <code>month_format(...)</code> or the default. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_parser</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>"third Fri in May" // defaults</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., date_generator)
+ Date Generator Type:
+ first_day_of_the_week_in_month</screen></entry>
+ <entry>Gets a first_day_of_the_week_in_month object from the stream. The month format is set by <code>month_format(...)</code> or the default. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_parser</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>"first Wed of Jun" // defaults</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., date_generator)
+ Date Generator Type:
+ last_day_of_the_week_in_month</screen></entry>
+ <entry>Gets a last_day_of_the_week_in_month object from the stream. The month format is set by <code>month_format(...)</code> or the default. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_parser</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>"last Tue of Mar" // defaults</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., date_generator)
+ Date Generator Type:
+ first_day_of_the_week_after</screen></entry>
+ <entry>Gets a first_day_of_the_week_after object from the stream. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_parser</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>"first Sat after" // defaults</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., date_generator)
+ Date Generator Type:
+ first_day_of_the_week_before</screen></entry>
+ <entry>Gets a first_day_of_the_week_before object from the stream. The weekday format is set by <code>weekday_format(...)</code> or the default. The remaining phrase elements are set in the <link linkend ="io_objects.date_generators">date_generator_parser</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>"first Mon before" // defaults</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_iterators.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_iterators.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.gregorian.date_iterators">
+ <title>Date Iterators</title>
+
+ <link linkend="iterators_intro">Introduction</link> --
+ <link linkend="iterators_header">Header</link> --
+ <link linkend="iterators_overview">Overview</link>
+
+ <anchor id="iterators_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ Date iterators provide a standard mechanism for iteration through dates. Date iterators are a model of <ulink url="http://www.sgi.com/tech/stl/BidirectionalIterator.html">Bidirectional Iterator</ulink> and can be used to populate collections with dates and other date generation tasks. For example, the <link linkend="date_time.examples.print_month">print month</link> example iterates through all the days in a month and prints them.
+ </para>
+ <para>
+ All of the iterators here derive from boost::gregorian::date_iterator.
+ </para>
+
+ <anchor id="iterators_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ <programlisting>#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</programlisting>
+ </para>
+
+ <anchor id="iterators_overview" />
+ <bridgehead renderas="sect3">Overview</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>date_iterator</screen></entry>
+ <entry>Common (abstract) base class for all day level iterators.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>day_iterator(date start_date, int day_count=1)</screen></entry>
+ <entry>Iterate <code>day_count</code> days at a time. This iterator does not provide postfix increment/decrement operators. Only prefix operators are provided.</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>week_iterator(...)
+ Parameters:
+ date start_date
+ int week_offset (defaults to 1)</screen></entry>
+ <entry>Iterate <code>week_offset</code> weeks at a time. This iterator does not provide postfix increment/decrement operators. Only prefix operators are provided.</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>month_iterator(...)
+ Parameters:
+ date start_date
+ int month_offset (defaults to 1)</screen></entry>
+<entry>Iterate <code>month_offset</code> 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 <link linkend="snap_to_details">Reversibility of Operations Pitfall</link>. <emphasis role="strong">NOTE:</emphasis> the <code>month_iterator</code> is not effected by this pitfall.) This iterator does not provide postfix increment/decrement operators. Only prefix operators are provided.</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>year_iterator(...)
+ Parameters:
+ date start_date
+ int year_offset (defaults to 1)</screen></entry>
+ <entry>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.</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_period.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_period.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,432 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2006 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.gregorian.date_period">
+ <title>Date Period</title>
+
+ <link linkend="period_intro">Introduction</link> --
+ <link linkend="period_header">Header</link> --
+ <link linkend="period_construction">Construction</link> --
+ <link linkend="date_period_mutators">Mutators</link> --
+ <link linkend="period_accessors">Accessors</link> --
+ <link linkend="period_convert_to_string">Convert to String</link> --
+ <link linkend="period_operators">Operators</link>
+
+ <anchor id="period_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ 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 <link linkend="date_time.examples.date_period_calc">date period calculation example</link> provides an example of this.
+ </para>
+ <para>
+ 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 <code>last</code> point will always be one unit less that the <code>begin</code> point.
+ </para>
+ <para>
+ Date periods used in combination with infinity values have the ability to represent complex concepts such as 'until further notice'.
+ </para>
+
+ <anchor id="period_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ <programlisting>#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</programlisting>
+ </para>
+
+ <anchor id="period_construction" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period(date, date)</screen></entry>
+ <entry>Create a period as [begin, end). If end is &lt;= begin then the period will be invalid.</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp(date(2002,Jan,10),
+ date(2002,Jan,12));</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period(date, days)</screen></entry>
+ <entry>Create a period as [begin, begin+len) where end point would be begin+len. If len is &lt;= zero then the period will be defined as invalid.</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp(date(2002,Jan,10),
+ days(2));</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period(date_period)</screen></entry>
+ <entry> Copy constructor</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp1(dp);</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+
+ <anchor id="date_period_mutators" />
+ <bridgehead renderas="sect3">Mutators</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period shift(days)</screen></entry>
+ <entry>Add duration to both begin and end.</entry>
+ </row>
+ <row>
+ <entry>
+ <screen>
+date_period dp(date(2005,Jan,1), days(3));
+dp.shift(days(3));
+// dp == 2005-Jan-04 to 2005-Jan-07
+ </screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period expand(days)</screen></entry>
+ <entry>Add duration to both begin and end.</entry>
+ </row>
+ <row>
+ <screen>
+date_period dp(date(2005,Jan,2), days(2));
+dp.expand(days(1));
+// dp == 2005-Jan-01 to 2005-Jan-04
+ </screen>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="period_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>date begin()</screen></entry>
+ <entry> Return first day of period.</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp(date(2002,Jan,1),
+ date(2002,Jan,10));
+dp.begin() --> 2002-Jan-01</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date last()</screen></entry>
+ <entry>Return last date in the period</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp(date(2002,Jan,1),
+ date(2002,Jan,10));
+dp.last() --> 2002-Jan-09</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date end()</screen></entry>
+ <entry>Return one past the last in period</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp(date(2002,Jan,1),
+ date(2002,Jan,10));
+dp.end() --> 2002-Jan-10</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>days length()</screen></entry>
+ <entry>Return the length of the date_period</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp(date(2002,Jan,1),
+ days(2));
+dp.length() --> 2</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_null()</screen></entry>
+ <entry>True if period is not well formed. eg: end less than or equal to begin.</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp(date(2002,Jan,10),
+ date(2002,Jan,1));
+dp.begin() --> true</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool contains(date)</screen></entry>
+ <entry>True if date is within the period. Zero length periods cannot contain any points</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool contains(date_period)</screen></entry>
+ <entry>True if date period is within the period</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool intersects(date_period)</screen></entry>
+ <entry>True if periods overlap</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period intersection(date_period)</screen></entry>
+ <entry>Calculate the intersection of 2 periods. Null if no intersection.</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period is_adjacent(date_period)</screen></entry>
+ <entry>Check if two periods are adjacent, but not overlapping.</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period is_after(date)</screen></entry>
+ <entry>Determine the period is after a given date.</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp1(date(2002,Jan,10),
+ date(2002,Jan,30));
+date d(2002,Jan,3);
+dp1.is_after(d) --> true</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period is_before(date)</screen></entry>
+ <entry>Determine the period is before a given date.</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp1(date(2002,Jan,1),
+ date(2002,Jan,3));
+date d(2002,Jan,10);
+dp1.is_before(d) --> true</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period merge(date_period)</screen></entry>
+ <entry>Returns union of two periods. Null if no intersection.</entry>
+ </row>
+ <row>
+ <entry><screen>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</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period span(date_period)</screen></entry>
+ <entry>Combines two periods and any gap between them such that begin = min(p1.begin, p2.begin) and end = max(p1.end , p2.end)</entry>
+ </row>
+ <row>
+ <entry><screen>
+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</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period shift(days)</screen></entry>
+ <entry>Add duration to both begin and end.</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp1(date(2002,Jan,1),
+ date(2002,Jan,10));
+dp1.shift(days(1));
+// 2002-Jan-02/2002-Jan-11</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_period expand(days)</screen></entry>
+ <entry>Subtract duration from begin and add duration to end.</entry>
+ </row>
+ <row>
+ <entry><screen>date_period dp1(date(2002,Jan,4),
+ date(2002,Jan,10));
+dp1.expand(days(2));
+// 2002-Jan-02/2002-Jan-12</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+
+ <anchor id="period_convert_to_string" />
+ <bridgehead renderas="sect3">Convert to String</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string to_simple_string(date_period dp)</screen></entry>
+ <entry>To <code>[YYYY-mmm-DD/YYYY-mmm-DD]</code> string where <code>mmm</code> is 3 char month name.</entry>
+ </row>
+ <row>
+ <entry><screen>[2002-Jan-01/2002-Jan-31]</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+
+ <anchor id="period_operators" />
+ <bridgehead renderas="sect3">Operators</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;&lt;</screen></entry>
+ <entry>ostream operator for date_period. Uses facet to format time points. Typical output: [2002-Jan-01/2002-Jan-31].</entry>
+ </row>
+ <row>
+ <entry><screen>std::cout &lt;&lt; dp &lt;&lt; std::endl;</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&gt;&gt;</screen></entry>
+ <entry>istream operator for date_period. Uses facet to parse time points.</entry>
+ </row>
+ <row>
+ <entry><screen>"[2002-Jan-01/2002-Jan-31]"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator==, operator!=,
+operator&gt;, operator&lt;</screen>
+ </entry>
+ <entry>A full complement of comparison operators</entry>
+ </row>
+ <row>
+ <entry><screen>dp1 == dp2, etc</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;</screen></entry>
+ <entry>True if dp1.end() less than dp2.begin()</entry>
+ </row>
+ <row>
+ <entry><screen>dp1 &lt; dp2, etc</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&gt;</screen></entry>
+ <entry>True if dp1.begin() greater than dp2.end()</entry>
+ </row>
+ <row>
+ <entry><screen>dp1 &gt; dp2, etc</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<library name="Date Time" dirname="date_time"
+ xmlns:xi="http://www.w3.org/2001/XInclude" id="date_time"
+ last-revision="$Date: 2005-06-12 21:53:10 +0100 (Sun, 12 Jun 2005) $">
+<libraryinfo>
+ <author>
+ <firstname>Jeff</firstname>
+ <surname>Garland</surname>
+ </author>
+
+ <copyright>
+ <year>2001</year>
+ <year>2002</year>
+ <year>2003</year>
+ <year>2004</year>
+ <year>2005</year>
+ <holder>CrystalClear Software, Inc</holder>
+ </copyright>
+
+ <legalnotice>
+ <para>Subject to the Boost Software License, Version 1.0. (See accompanying file
+ <filename>LICENSE_1_0.txt</filename> or copy at <ulink
+ url="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt>)</para>
+ </legalnotice>
+
+ <librarypurpose>A set of facilities to ease programming with dates and times.
+ </librarypurpose>
+ <librarycategory name="category:misc"/>
+</libraryinfo>
+
+<title>Boost.Date_Time</title>
+<!-- <section id="date_time.intro"> -->
+ <bridgehead renderas="sect2">Introduction</bridgehead>
+
+ <para>
+ A set of date-time libraries based on generic programming concepts.
+ </para>
+
+ <para>This documentation is also available in PDF format. It can be found at:
+ <simplelist type="horiz" columns="1">
+ <member><ulink url="
http://www.crystalclearsoftware.com/libraries/date_time/date_time.pdf" /></member>
+ </simplelist>
+ In addition, a full doxygen reference can be found at:
+ <simplelist type="horiz" columns="1">
+ <member><ulink url="http://www.crystalclearsoftware.com/libraries/date_time/ref_guide/index.html" /></member>
+ </simplelist>
+ The most current version of the documentation can be found at:
+ <simplelist type="horiz" columns="1">
+ <member><ulink url="http://www.crystalclearsoftware.com/libraries/date_time/index.html" /></member>
+ </simplelist>
+ </para>
+ <!-- </section> -->
+
+ <xi:include href="conceptual.xml"/>
+ <xi:include href="usage_examples.xml"/>
+ <xi:include href="gregorian.xml"/>
+ <xi:include href="posix_time.xml"/>
+ <xi:include href="local_time.xml"/>
+ <xi:include href="date_time_io.xml"/>
+ <xi:include href="serialization.xml" />
+ <xi:include href="details.xml"/>
+ <xi:include href="examples.xml"/>
+ <xi:include href="doxy.xml"/>
+<!-- add more sections here -->
+<!-- <xi:include href="local_date_time.xml"/> -->
+
+</library>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time_docs_howto.html
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time_docs_howto.html 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+
+<head>
+ <title>Date Time Documentation Howto</title>
+ <meta name="GENERATOR" content="Quanta Plus">
+ <style type="text/css">
+ .copyright { color: #666666; font-size: small; }
+ .screen {
+ background: #EEF6FF;
+ font-family: monospace;
+ display: block;
+ margin-left: 4%;
+ margin-right: 4%;
+ padding: 0.5pc 0.5pc 0.5pc 0.5pc;
+ }
+ .fname { font-family: monospace; }
+ </style>
+</head>
+<body>
+ <h2>Date Time Documentation Howto</h2>
+ <h3>Instructions for:</h3>
+ <ol>
+ <li>Building Exclusive Date Time HTML Documentation</li>
+ <li>Building Exclusive Date Time PDF</li>
+ <li>Generating Date Time Doxygen Reference</li>
+ <li>Making further changes to the date_time_fo_stylesheet</li>
+ </ol>
+ <hr>
+ <A name="exclusive_html"><h3>Building Exclusive Date Time HTML Documentation</h3></A>
+ <p>No modifications are necessary to build an exclusive set of date time html documentation. Simply run bjam:<br>
+ <div class="screen">bjam --v2 date_time_doc</div><br>
+ The resulting html can be found in <font class="fname">xmldoc/html</font>. NOTE: the stylesheet may not be present. It can be copied from the <font class="fname">$BOOST_ROOT/doc/html</font> directory.</p>
+ <hr>
+ <a name="exclusive_pdf"><h3>Building Exclusive Date Time PDF</h3></a>
+ <p><strong>Prerequisite:</strong> bjam must be able to build documentation for 'fo' output (necessary aditions must have been added to <font class="fname">user-config.jam</font>).</p>
+
+ <p>Necessary modifications to build the date time pdf are:
+ <ol>
+ <li>Add the new stylesheet to <font class="fname">boostbook.jam</font>.<div class="screen">
+ <pre>
+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) ;
+}</pre></div></li>
+ <li>Build <font class="fname">exclusive_date_time.fo</font>.
+ <div class="screen">bjam --v2 date_time_doc fo</div></li>
+ <li>Build the pdf.<div class="screen">fop ../../../bin.v2/libs/date_time/.../exclusive_date_time.fo date_time.pdf</div></li>
+ </ol>
+ </p>
+ <p><strong>BUILD ERRORS:</strong> 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. <strong>Note:</strong> This does not mean there is an error in the xml. The anchor and link that is known to have an effect is <font class="fname">date_input_facet_intro</font> (change the 'd' to a 'f', or back, should do the trick).</p>
+ <hr>
+ <a name="doxy_ref"><h3>Generating Date Time Doxygen Reference</h3></a>
+ <p>Each doxygen reference file must be built, copied, and modified seperately. The steps to build all four <font class="fname">*.boostbook</font> reference files are:
+ <ol>
+ <li>Generate the <font class="fname">*.boostbook</font> files.</li>
+ <li>Copy the <font class="fname">*.boostbook</font> files to the xmldoc directory.</li>
+ <li>Fix the section tags and add copyright statement.</li>
+ </ol>
+ <div class="screen"><pre>
+bjam --v2 date_time_autodoc \
+ gregorian_autodoc \
+ posix_time_autodoc \
+ local_time_autodoc
+cp ../../../bin.v2/libs/.../*.boostbook .
+./ref_tag_fix.pl</pre></div>
+ </p>
+ <hr>
+ <a name="xsl_mods"><h3>Making further changes to the date_time_fo_stylesheet</h3></a>
+ <p>The stylesheet currently sets the left, right, and bottom margins. It also reduces the font-size for table cells that have the &#060;screen&#062; tags in them. The font-size reduction is accomplished by breaking the entire string (between the &#060;screen&#062; 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.</p>
+ <p>There are two variables used in adjusting the font-size: <font class="fname">char-per-cell</font> &#038; <font class="fname">min-reduction</font>. These hold the number of characters that can fit into a cell and the minimum percentage of reduction allowed (expressed as an integer).</p>
+ <p>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.</p>
+ <hr>
+ <div><p class="copyright">Copyright &#169; 2001-2005 CrystalClear Software, Inc</p></div>
+ <div class="legalnotice">
+ <p>Subject to the Boost Software License, Version 1.0. <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt="http://www.boost.org/LICENSE_1_0.txt"></p></div>
+ </body>
+</html>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time_fo_stylesheet.xsl
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time_fo_stylesheet.xsl 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,180 @@
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:sverb="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Verbatim"
+ xmlns:xverb="com.nwalsh.xalan.Verbatim"
+ xmlns:lxslt="http://xml.apache.org/xslt"
+ xmlns:exsl="http://exslt.org/common"
+ exclude-result-prefixes="sverb xverb lxslt exsl"
+ version='1.0'>
+
+<!-- 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)
+-->
+
+ <xsl:import href="../../../tools/boostbook/xsl/fo.xsl" />
+
+ <!-- reset the default margin parameters -->
+ <xsl:param name="page.margin.bottom" select="'0.25in'"/>
+ <xsl:param name="page.margin.inner">
+ <xsl:choose>
+ <xsl:when test="$double.sided != 0">1.25in</xsl:when>
+ <xsl:otherwise>0.65in</xsl:otherwise>
+ </xsl:choose>
+ </xsl:param>
+ <xsl:param name="page.margin.outer">
+ <xsl:choose>
+ <xsl:when test="$double.sided != 0">0.75in</xsl:when>
+ <xsl:otherwise>0.65in</xsl:otherwise>
+ </xsl:choose>
+ </xsl:param>
+
+ <!-- with the above margins, we can fit 38 monospace characters per table cell.
+ If the margins are changed, set min-reduction to 100 and generate a new pdf. Then
+ count the number of characters that fit in a cell. Not the slickest method but it works.-->
+ <xsl:variable name="char-per-cell" select="38"/>
+ <!-- prevent reducing the font size too much. An 80% reduction
+ gives us a width of 48 characters per cell -->
+ <xsl:variable name="min-reduction" select="80"/>
+
+ <!-- recursive font-size reduction template -->
+ <!-- the string may span multiple lines.
+ break it up and check the length of each line.
+ adjust font size according to longest line -->
+ <xsl:template name="font-size-reduction">
+ <xsl:param name="inp" />
+ <xsl:param name="max">1</xsl:param>
+ <xsl:variable name="result">
+ <xsl:choose>
+ <!-- &#x000A; is unicode line-feed character -->
+ <xsl:when test="contains($inp, '&#x000A;')">
+ <xsl:variable name="str" select="substring-before($inp, '&#x000A;')" />
+ <xsl:variable name="next" select="substring-after($inp, '&#x000A;')" />
+
+ <xsl:variable name="n_max">
+ <xsl:choose>
+ <xsl:when test="string-length($str) > $char-per-cell and string-length($str) > $max">
+ <xsl:value-of select="string-length($str)" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$max" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:choose>
+ <xsl:when test="contains($next, '&#x000A;')">
+ <xsl:call-template name="font-size-reduction">
+ <xsl:with-param name="inp" select="$next" />
+ <xsl:with-param name="max" select="$n_max" />
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="$n_max > $char-per-cell and $n_max > string-length($next)">
+ <!-- set size with next.len -->
+ <xsl:value-of select="round($char-per-cell div $n_max * 100)"/>
+ </xsl:when>
+ <xsl:when test="string-length($next) > $char-per-cell and string-length($next) > $n_max">
+ <!-- set size with n_max -->
+ <xsl:value-of select="round($char-per-cell div string-length($next) * 100)"/>
+ </xsl:when>
+ <xsl:otherwise>100</xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:choose>
+ <xsl:when test="string-length($inp) > $char-per-cell">
+ <!-- set size with inp.len -->
+ <xsl:value-of select="round($char-per-cell div string-length($inp) * 100)"/>
+ </xsl:when>
+ <xsl:otherwise>100</xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <!-- return either "result" or "min-reduction" -->
+ <xsl:choose>
+ <xsl:when test="$min-reduction > $result">
+ <xsl:value-of select="$min-reduction" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$result" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+
+ <!-- this template was copied directly from docbook/boostbook xsl and modified
+ to calculate and resize monospace font to fit cells based on length of string -->
+ <xsl:template match="entry/screen">
+ <xsl:param name="suppress-numbers" select="'0'"/>
+ <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
+
+ <xsl:variable name="content">
+ <xsl:choose>
+ <xsl:when test="$suppress-numbers = '0'
+ and @linenumbering = 'numbered'
+ and $use.extensions != '0'
+ and $linenumbering.extension != '0'">
+ <xsl:call-template name="number.rtf.lines">
+ <xsl:with-param name="rtf">
+ <xsl:apply-templates/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="font_size">
+ <xsl:call-template name="font-size-reduction">
+ <xsl:with-param name="inp" select="." />
+ </xsl:call-template>
+ </xsl:variable>
+
+
+ <!-- write out the tag now that font size has been calculated -->
+ <xsl:choose>
+ <xsl:when test="$shade.verbatim != 0">
+ <fo:block id="{$id}"
+ white-space-collapse='false'
+ white-space-treatment='preserve'
+ linefeed-treatment='preserve'
+ xsl:use-attribute-sets="monospace.verbatim.properties shade.verbatim.style" font-size="{$font_size}%">
+ <xsl:choose>
+ <xsl:when test="$hyphenate.verbatim != 0 and function-available('exsl:node-set')">
+ <xsl:apply-templates select="exsl:node-set($content)" mode="hyphenate.verbatim"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$content"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:block>
+ </xsl:when>
+ <xsl:otherwise>
+ <fo:block id="{$id}"
+ white-space-collapse='false'
+ white-space-treatment='preserve'
+ linefeed-treatment="preserve"
+ xsl:use-attribute-sets="monospace.verbatim.properties" font-size="{$font_size}%">
+ <xsl:choose>
+ <xsl:when test="$hyphenate.verbatim != 0 and function-available('exsl:node-set')">
+ <xsl:apply-templates select="exsl:node-set($content)" mode="hyphenate.verbatim"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:copy-of select="$content"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </fo:block>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+</xsl:stylesheet>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time_io.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/date_time_io.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.date_time_io"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Date Time Input/Output</title>
+ <using-namespace name="boost"/>
+ <using-namespace name="boost::date_time"/>
+ <bridgehead renderas="sect2">Date Time IO System</bridgehead>
+ <para>
+ <link linkend="streaming_exceptions">Exception Handling on Streams</link>
+ </para>
+
+ <para>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.</para>
+
+ <para>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.</para>
+
+ <para>It is important to note, that while all the examples shown here use narrow streams, there are wide stream facets available as well (see <link linkend="io_objects_table">IO Objects</link> for a complete list).</para>
+
+ <para>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 <code>date_time</code> versions is still available. The "legacy IO" is automatically selected for these compilers, however, the legacy IO system can be manually selected by defining <code>USE_DATE_TIME_PRE_1_33_FACET_IO</code>. See the <link linkend="date_time.buildinfo">Build-Compiler Information</link> for more information.</para>
+
+ <anchor id="streaming_exceptions" />
+ <bridgehead renderas="sect5">Exception Handling on Streams</bridgehead>
+ <para>When an error occurs during the input streaming process, the <code>std::ios_base::failbit</code> 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 <code>exceptions</code> function with a parameter of <code>std::ios_base::failbit</code>.</para>
+ <screen>// "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</screen>
+
+ <bridgehead renderas="sect5">A simple example of this new system:</bridgehead>
+ <screen>//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 &lt;&lt; d &lt;&lt; std::endl;
+// "Saturday June 25, 2005"</screen>
+
+ <xi:include href="format_flags.xml" />
+
+ <para>The following table lists the available facets.</para>
+
+ <anchor id="io_objects_table" />
+ <bridgehead renderas="sect3">IO Objects</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Output</entry>
+ <entry>Input</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><classname>date_facet</classname></entry>
+ <entry><classname>date_input_facet</classname></entry>
+ </row>
+ <row>
+ <entry><classname alt="boost::date_time::date_facet">wdate_facet</classname></entry>
+ <entry><classname alt="boost::date_time::date_input_facet">wdate_input_facet</classname></entry>
+ </row>
+ <row>
+ <entry><classname>time_facet</classname></entry>
+ <entry><classname>time_input_facet</classname></entry>
+ </row>
+ <row>
+ <entry><classname alt="boost::date_time::time_facet">wtime_facet</classname></entry>
+ <entry><classname alt="boost::date_time::time_input_facet">wtime_input_facet</classname></entry>
+ </row>
+ <row>
+ <entry><classname alt="boost::date_time::time_facet">local_time_facet</classname>*</entry>
+ <entry><classname alt="boost::date_time::time_input_facet">local_time_input_facet</classname>*</entry>
+ </row>
+ <row>
+ <entry><classname alt="boost::date_time::time_facet">wlocal_time_facet</classname>*</entry>
+ <entry><classname alt="boost::date_time::time_input_facet">wlocal_time_input_facet</classname>*</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ * These links lead to the <code>time_facet</code> and <code>time_input_facet</code> reference sections. They are not actual classes but typedefs.
+ </para>
+
+ <bridgehead renderas="sect3">Formatter/Parser Objects</bridgehead>
+ <para>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.</para>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Output</entry>
+ <entry>Input</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><classname>period_formatter</classname></entry>
+ <entry><classname>period_parser</classname></entry>
+ </row>
+ <row>
+ <entry><classname>date_generator_formatter</classname></entry>
+ <entry><classname>date_generator_parser</classname></entry>
+ </row>
+ <row>
+ <entry><classname>special_values_formatter</classname></entry>
+ <entry><classname>special_values_parser</classname></entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><classname>format_date_parser</classname></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <xi:include href="date_facet.xml" />
+ <xi:include href="date_input_facet.xml" />
+ <xi:include href="time_facet.xml" />
+ <xi:include href="time_input_facet.xml" />
+ <xi:include href="io_objects.xml" />
+ <xi:include href="io_tutorial.xml" />
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/design_concepts.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/design_concepts.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.design_concepts">
+ <title>Design Concepts</title>
+
+ <para>
+ 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.
+ </para>
+ <para>
+ 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.
+ </para>
+ <para>
+ 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 <link linkend="date_time.design_goals">summarized here</link>.
+ </para>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/design_goals.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/design_goals.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.design_goals">
+ <title>Design Goals</title>
+
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Category</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Functions</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1">Interfaces</entry>
+ <entry>Provide concrete classes for manipulation of dates and times</entry>
+ </row>
+ <row>
+ <entry>
+ <itemizedlist mark="bullet">
+ <listitem>date, time, date_duration, time_duration, date_period, time_period, etc</listitem>
+ <listitem>support for infinity - positive infinity, negative infinity</listitem>
+ <listitem>iterators over time and date ranges</listitem>
+ <listitem>allow date and time implementations to be separate as much as possible</listitem>
+ </itemizedlist>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top" morerows="1">Calculation</entry>
+ <entry>Provide a basis for performing efficient time calculations </entry>
+ </row>
+ <row>
+ <entry>
+ <itemizedlist mark="bullet">
+ <listitem>days between dates </listitem>
+ <listitem>durations of times </listitem>
+ <listitem>durations of dates and times together </listitem>
+ </itemizedlist>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1">Representation Flexibility</entry>
+ <entry>Provide the maximum possible reusability and flexibility</entry>
+ </row>
+ <row>
+ <entry>
+ <itemizedlist mark="bullet">
+ <listitem>traits based customization of internal representations for size versus resolution control</listitem>
+ <listitem>Allowing the use of different epochs and resolution (eg: seconds versus microseconds, dates starting at the year 2000 versus dates starting in 1700)</listitem>
+ <listitem>Options for configuring unique calendar representations (Gregorian + others)</listitem>
+ <listitem>the use of Julian Day number and the conversion between this and the Gregorian/Julian calendar date</listitem>
+ <listitem>Allow for flexible adjustments including leap seconds</listitem>
+ </itemizedlist>
+ </entry>
+ </row>
+
+
+ <row>
+ <entry valign="top" morerows="1">Date Calculations</entry>
+ <entry>Provide tools for date calculations</entry>
+ </row>
+ <row>
+ <entry>
+ <itemizedlist mark="bullet">
+ <listitem>provide basis for calculation of complex event specs like holidays</listitem>
+ <listitem>calendar to calendar conversions</listitem>
+ <listitem>provide for ability to extend to new calendar systems</listitem>
+ </itemizedlist>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1">Time Calculations</entry>
+ <entry>Provide concrete classes for manipulation of time</entry>
+ </row>
+ <row>
+ <entry>
+ <itemizedlist mark="bullet">
+ <listitem>provide the ability to handle cross time-zone issues</listitem>
+ <listitem>provide adjustments for daylight savings time (summer time)</listitem>
+ </itemizedlist>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1">Clock Interfaces</entry>
+ <entry>Provide classes for retrieving time current time</entry>
+ </row>
+ <row>
+ <entry>
+ <itemizedlist mark="bullet">
+ <listitem>access to a network / high resolution time sources </listitem>
+ <listitem>retrieving the current date time information to populate classes </listitem>
+ </itemizedlist>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1">I/O Interfaces</entry>
+ <entry>Provide input and output for time including</entry>
+ </row>
+ <row>
+ <entry>
+ <itemizedlist mark="bullet">
+ <listitem>multi-lingual support </listitem>
+ <listitem>provide ISO8601 compliant time facet </listitem>
+ <listitem>use I/O facets for different local behavior </listitem>
+ </itemizedlist>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/details.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/details.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.details" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Details</title>
+
+ <xi:include href="calculations.xml" />
+ <xi:include href="design_goals.xml" />
+ <xi:include href="tradeoffs.xml" />
+ <xi:include href="terminology.xml" />
+ <xi:include href="references.xml" />
+ <xi:include href="buildinfo.xml" />
+ <xi:include href="tests.xml" />
+ <xi:include href="changes.xml" />
+ <xi:include href="acknowledgements.xml" />
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/domain_concepts.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/domain_concepts.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.domain_concepts">
+ <title>Domain Concepts</title>
+
+ <para>
+ 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.
+ </para>
+ <para>
+ The library supports 3 basic temporal types:
+ <itemizedlist mark="bullet">
+ <listitem>
+ <emphasis role="strong">Time Point</emphasis> -- Specifier
+ for a location in the time continuum.
+ </listitem>
+ <listitem>
+ <emphasis role="strong">Time Duration</emphasis> -- A
+ length of time unattached to any point on the time continuum.
+ </listitem>
+ <listitem>
+ <emphasis role="strong">Time Interval</emphasis> -- A duration
+ of time attached to a specific point in the time continuum.
+ Also known as a time period.
+ </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Each of these temporal types has a <emphasis role="strong">Resolution</emphasis> which is defined by the smallest representable duration. A <emphasis role="strong">Time system</emphasis> provides all these categories of temporal types as well as the rules for labeling and calculating with time points. <emphasis role="strong">Calendar Systems</emphasis> are simply time systems with a maximum resolution of one day. The <emphasis role="strong">Gregorian</emphasis> 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. <emphasis role="strong">UTC (Coordinated Universal Time)</emphasis> 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 <emphasis role="strong">local time</emphasis> 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 <emphasis role="strong">daylight savings time (DST)</emphasis> adjustments to shift the daylight hours during the summer.
+ </para>
+ <para>
+ A <emphasis role="strong">Clock Device</emphasis> 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.
+ </para>
+ <para>
+ 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 <link linkend="date_time.tradeoffs">Stability, Predictability, and Approximations</link>.
+ </para>
+ <para>
+ <itemizedlist mark="bullet">
+ <listitem>
+ <link linkend="date_time.terminology">Basic Terminology</link>
+ </listitem>
+ <listitem>
+ <link linkend="date_time.calculations">Calculations</link>
+ </listitem>
+ <listitem>
+ <link linkend="date_time.tradeoffs">Stability, Predictability, and Approximations</link>
+ </listitem>
+ <listitem>
+ <link linkend="date_time.references">References</link>
+ </listitem>
+ </itemizedlist>
+ </para>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/doxy.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/doxy.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.doxy" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Library Reference</title>
+
+ <para>
+ 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.
+ </para>
+
+ <xi:include href="date_time_autodoc.xml"/>
+ <xi:include href="gregorian_autodoc.xml"/>
+ <xi:include href="posix_time_autodoc.xml"/>
+ <xi:include href="local_time_autodoc.xml"/>
+</section>
+

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_calc_rules.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_calc_rules.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.examples.calc_rules">
+ <title>Daylight Savings Calc Rules</title>
+
+ <para>
+ Example of creating various Daylight Savings Calc Rule objects.
+ </para>
+ <programlisting>
+ <![CDATA[
+ /* 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 <iostream>
+
+ 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;
+ }
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_date_period_calc.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_date_period_calc.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.date_period_calc">
+ <title>Date Period Calculations</title>
+
+ <para>
+ Calculates if a date is in an 'irregular' collection of periods using period calculation functions.
+ </para>
+ <programlisting>
+ <![CDATA[
+ /*
+ 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 <set>
+ #include <algorithm>
+ #include <iostream>
+
+ typedef std::set<boost::gregorian::date_period> 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<date_period_set> 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;
+
+ }
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_dates_as_strings.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_dates_as_strings.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.dates_as_strings">
+ <title>Dates as Strings</title>
+
+ <para>
+ Various parsing and output of strings.
+ </para>
+ <programlisting>
+ <![CDATA[
+
+ /* 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 <iostream>
+ #include <string>
+
+ 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;
+ }
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_days_alive.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_days_alive.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.days_alive">
+ <title>Days Alive</title>
+
+ <para>
+ Calculate the number of days you have been living using durations and dates.
+ </para>
+<programlisting>
+<literal>
+<phrase role="comment">/* 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.
+ */</phrase><phrase role="preprocessor">
+
+#include</phrase><phrase role="string"> &quot;boost/date_time/gregorian/gregorian.hpp&quot;</phrase><phrase role="preprocessor">
+#include</phrase><phrase role="special"> &lt;</phrase><phrase role="identifier">iostream</phrase><phrase role="special">&gt;</phrase><phrase role="keyword">
+
+int</phrase><phrase role="identifier">
+main</phrase><phrase role="special">()</phrase><phrase role="special">
+{</phrase><phrase role="keyword">
+
+ using</phrase><phrase role="keyword"> namespace</phrase><phrase role="identifier"> boost</phrase><phrase role="special">::</phrase><phrase role="identifier">gregorian</phrase><phrase role="special">;</phrase><phrase role="identifier">
+ std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase><phrase role="identifier"> s</phrase><phrase role="special">;</phrase><phrase role="identifier">
+ std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="string"> &quot;Enter birth day YYYY-MM-DD (eg: 2002-02-01): &quot;</phrase><phrase role="special">;</phrase><phrase role="identifier">
+ std</phrase><phrase role="special">::</phrase><phrase role="identifier">cin</phrase><phrase role="special"> &gt;&gt;</phrase><phrase role="identifier"> s</phrase><phrase role="special">;</phrase><phrase role="keyword">
+ try</phrase><phrase role="special"> {</phrase><phrase role="identifier">
+ date</phrase><phrase role="identifier"> birthday</phrase><phrase role="special">(</phrase><phrase role="identifier">from_simple_string</phrase><phrase role="special">(</phrase><phrase role="identifier">s</phrase><phrase role="special">));</phrase><phrase role="identifier">
+ date</phrase><phrase role="identifier"> today</phrase><phrase role="special"> =</phrase><phrase role="identifier"> day_clock</phrase><phrase role="special">::</phrase><phrase role="identifier">local_day</phrase><phrase role="special">();</phrase><phrase role="identifier">
+ days</phrase><phrase role="identifier"> days_alive</phrase><phrase role="special"> =</phrase><phrase role="identifier"> today</phrase><phrase role="special"> -</phrase><phrase role="identifier"> birthday</phrase><phrase role="special">;</phrase><phrase role="identifier">
+ days</phrase><phrase role="identifier"> one_day</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">);</phrase><phrase role="keyword">
+ if</phrase><phrase role="special"> (</phrase><phrase role="identifier">days_alive</phrase><phrase role="special"> ==</phrase><phrase role="identifier"> one_day</phrase><phrase role="special">)</phrase><phrase role="special"> {</phrase><phrase role="identifier">
+ std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="string"> &quot;Born yesterday, very funny&quot;</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase><phrase role="special">
+ }</phrase><phrase role="keyword">
+ else</phrase><phrase role="keyword"> if</phrase><phrase role="special"> (</phrase><phrase role="identifier">days_alive</phrase><phrase role="special"> &lt;</phrase><phrase role="identifier"> days</phrase><phrase role="special">(</phrase><phrase role="number">0</phrase><phrase role="special">))</phrase><phrase role="special"> {</phrase><phrase role="identifier">
+ std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="string"> &quot;Not born yet, hmm: &quot;</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> days_alive</phrase><phrase role="special">.</phrase><phrase role="identifier">days</phrase><phrase role="special">()</phrase><phrase role="special">
+ &lt;&lt;</phrase><phrase role="string"> &quot; days&quot;</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase><phrase role="special">
+ }</phrase><phrase role="keyword">
+ else</phrase><phrase role="special"> {</phrase><phrase role="identifier">
+ std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="string"> &quot;Days alive: &quot;</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> days_alive</phrase><phrase role="special">.</phrase><phrase role="identifier">days</phrase><phrase role="special">()</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase><phrase role="special">
+ }</phrase><phrase role="special">
+
+ }</phrase><phrase role="keyword">
+ catch</phrase><phrase role="special">(...)</phrase><phrase role="special"> {</phrase><phrase role="identifier">
+ std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="string"> &quot;Bad date entered: &quot;</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> s</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase><phrase role="special">
+ }</phrase><phrase role="keyword">
+ return</phrase><phrase role="number"> 0</phrase><phrase role="special">;</phrase><phrase role="special">
+}</phrase>
+</literal>
+</programlisting>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_days_between_new_years.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_days_between_new_years.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.days_between_new_year">
+ <title>Days Between New Years</title>
+
+ <para>
+ Calculate the number of days till new years
+ </para>
+ <programlisting>
+ <![CDATA[
+ /* Provides a simple example of using a date_generator, and simple
+ * mathematical operatorations, to calculate the days since
+ * New Years day of this year, and days until next New Years day.
+ *
+ * Expected results:
+ * Adding together both durations will produce 366 (365 in a leap year).
+ */
+ #include <iostream>
+ #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;
+ };
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_end_of_month_day.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_end_of_month_day.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.end_of_month_day">
+ <title>End of the Months</title>
+
+ <para>
+ Iterates accross the remaining months in a given year, always landing on the last day of the month.
+ </para>
+ <programlisting>
+ <![CDATA[
+ /* 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 <iostream>
+
+ 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;
+
+ }
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_find_last_day_of_months.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_find_last_day_of_months.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.examples.end_of_month_day">
+ <title>Last Day of the Months</title>
+
+ <para>
+ Example that gets a month and a year from the user and finds the last day of each remaining month of that year.
+ </para>
+ <programlisting>
+ <![CDATA[
+ /* 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 <iostream>
+
+ 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;
+ }
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_flight.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_flight.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.examples.flight">
+ <title>Flight Time Example</title>
+
+ <para>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).</para>
+
+<programlisting>
+<literal>
+<phrase role="preprocessor">#include</phrase><phrase role="string"> &quot;boost/date_time/local_time/local_time.hpp&quot;</phrase><phrase role="preprocessor">
+#include</phrase><phrase role="special"> &lt;</phrase><phrase role="identifier">iostream</phrase><phrase role="special">&gt;</phrase><phrase role="comment">
+
+/* 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).
+ *
+ *
+ */</phrase><phrase role="keyword">
+
+int</phrase><phrase role="identifier"> main</phrase><phrase role="special">()</phrase><phrase role="special">
+{</phrase><phrase role="keyword">
+ using</phrase><phrase role="keyword"> namespace</phrase><phrase role="identifier"> boost</phrase><phrase role="special">::</phrase><phrase role="identifier">gregorian</phrase><phrase role="special">;</phrase><phrase role="keyword">
+ using</phrase><phrase role="keyword"> namespace</phrase><phrase role="identifier"> boost</phrase><phrase role="special">::</phrase><phrase role="identifier">local_time</phrase><phrase role="special">;</phrase><phrase role="keyword">
+ using</phrase><phrase role="keyword"> namespace</phrase><phrase role="identifier"> boost</phrase><phrase role="special">::</phrase><phrase role="identifier">posix_time</phrase><phrase role="special">;</phrase><phrase role="comment">
+
+
+ //setup some timezones for creating and adjusting local times
+ //This user editable file can be found in libs/date_time/data.
+</phrase><phrase role="identifier"> tz_database</phrase><phrase role="identifier"> tz_db</phrase><phrase role="special">;</phrase><phrase role="identifier">
+ tz_db</phrase><phrase role="special">.</phrase><phrase role="identifier">load_from_file</phrase><phrase role="special">(</phrase><phrase role="string">&quot;date_time_zonespec.csv&quot;</phrase><phrase role="special">);</phrase><phrase role="identifier">
+ time_zone_ptr</phrase><phrase role="identifier"> nyc_tz</phrase><phrase role="special"> =</phrase><phrase role="identifier"> tz_db</phrase><phrase role="special">.</phrase><phrase role="identifier">time_zone_from_region</phrase><phrase role="special">(</phrase><phrase role="string">&quot;America/New_York&quot;</phrase><phrase role="special">);</phrase><phrase role="comment">
+ //Use a
+</phrase><phrase role="identifier"> time_zone_ptr</phrase><phrase role="identifier"> phx_tz</phrase><phrase role="special">(</phrase><phrase role="keyword">new</phrase><phrase role="identifier"> posix_time_zone</phrase><phrase role="special">(</phrase><phrase role="string">&quot;MST-07:00:00&quot;</phrase><phrase role="special">));</phrase><phrase role="comment">
+
+ //local departure time in phoenix is 11 pm on april 2 2005
+ // (ny changes to dst on apr 3 at 2 am)
+</phrase><phrase role="identifier"> local_date_time</phrase><phrase role="identifier"> phx_departure</phrase><phrase role="special">(</phrase><phrase role="identifier">date</phrase><phrase role="special">(</phrase><phrase role="number">2005</phrase><phrase role="special">,</phrase><phrase role="identifier"> Apr</phrase><phrase role="special">,</phrase><phrase role="number"> 2</phrase><phrase role="special">),</phrase><phrase role="identifier"> hours</phrase><phrase role="special">(</phrase><phrase role="number">23</phrase><phrase role="special">),</phrase><phrase role="identifier">
+ phx_tz</phrase><phrase role="special">,</phrase><phrase role="identifier">
+ local_date_time</phrase><phrase role="special">::</phrase><phrase role="identifier">NOT_DATE_TIME_ON_ERROR</phrase><phrase role="special">);</phrase><phrase role="identifier">
+
+ time_duration</phrase><phrase role="identifier"> flight_length</phrase><phrase role="special"> =</phrase><phrase role="identifier"> hours</phrase><phrase role="special">(</phrase><phrase role="number">4</phrase><phrase role="special">)</phrase><phrase role="special"> +</phrase><phrase role="identifier"> minutes</phrase><phrase role="special">(</phrase><phrase role="number">30</phrase><phrase role="special">);</phrase><phrase role="identifier">
+ local_date_time</phrase><phrase role="identifier"> phx_arrival</phrase><phrase role="special"> =</phrase><phrase role="identifier"> phx_departure</phrase><phrase role="special"> +</phrase><phrase role="identifier"> flight_length</phrase><phrase role="special">;</phrase><phrase role="identifier">
+ local_date_time</phrase><phrase role="identifier"> nyc_arrival</phrase><phrase role="special"> =</phrase><phrase role="identifier"> phx_arrival</phrase><phrase role="special">.</phrase><phrase role="identifier">local_time_in</phrase><phrase role="special">(</phrase><phrase role="identifier">nyc_tz</phrase><phrase role="special">);</phrase><phrase role="identifier">
+
+ std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="string"> &quot;departure phx time: &quot;</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> phx_departure</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase><phrase role="identifier">
+ std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="string"> &quot;arrival phx time: &quot;</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> phx_arrival</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase><phrase role="identifier">
+ std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="string"> &quot;arrival nyc time: &quot;</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> nyc_arrival</phrase><phrase role="special"> &lt;&lt;</phrase><phrase role="identifier"> std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase><phrase role="special">
+
+}</phrase>
+</literal>
+</programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_local_utc_conversion.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_local_utc_conversion.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.local_utc_conversion">
+ <title>Local to UTC Conversion</title>
+
+ <para>
+ Demonstrate utc to local and local to utc calculations including dst.
+ </para>
+ <programlisting>
+ <![CDATA[
+
+ /* 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 <iostream>
+
+ 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<ptime> 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<ptime, -5, us_dst> 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<ptime, -7, no_dst> 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;
+ }
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_localization.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_localization.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.examples.localization">
+ <title>Localization Demonstration</title>
+
+ <para>
+ The boost::date_time library provides the ability to create customized locale facets. Date ordering, language, seperators, and abbreviations can be customized.
+ </para>
+ <!-- <para>
+ This example uses the new (as of 1.33) date_time IO code. An example using the old code is also provided to demonstrate how much easier customized output is (see <link linkend="date_time.examples.legacy_localization">legacy_localization example</link>).
+ </para> -->
+ <programlisting>
+ <![CDATA[
+ /* 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 <iostream>
+ #include <algorithm>
+
+ /* 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;
+
+ }
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_meeting_planner.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_meeting_planner.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.examples.meeting_planner">
+ <title>Teleconference Scheduler (partial listing)</title>
+
+ <para>
+ The Teleconference Scheduler is a Qt based example (found in the examples/qt directory). Partial listings of <link linkend="meeting_planner_hpp">meeting_planner.hpp</link> and <link linkend="planner_form_cpp">planner_form.cpp</link> are provided to illustrate techniques for using the local_date_time and tz_database objects.
+ </para>
+
+ <anchor id="planner_form_cpp" />
+ <para>
+ 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.
+ </para>
+ <programlisting>
+ <![CDATA[
+
+ void planner_form::init() {
+ try{
+ tz_db.load_from_file("../../data/date_time_zonespec.csv");
+ }catch(boost::local_time::data_not_accessible dna) {
+ std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
+ exit(EXIT_FAILURE);
+ }catch(boost::local_time::bad_field_count bfc) {
+ std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
+ exit(EXIT_FAILURE);
+ }
+
+ // populate combo boxes with region names
+ typedef std::vector<std::string> 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("<Select Region>", 0);
+ comboBox2->insertItem("<Select Region>", 0);
+ comboBox3->insertItem("<Select Region>", 0);
+
+ // set up dateEdit
+ dateEdit2->setSeparator("-");
+
+ this->reset();
+ }
+
+ ]]>
+ </programlisting>
+
+ <anchor id="meeting_planner_hpp" />
+ <para>
+ This class coordinates local times across multiple time zones. It accomplishes this by iterating across a collection of time zones and verifying that the target time falls within a set period (a workday).
+ </para>
+ <programlisting>
+ <![CDATA[
+
+ /* The heart of the meeting_planner is the synchronization of different
+ * time zones to a single point in time.
+ * The class takes a vector of regions and a date. The default time
+ * range is 9am to 5pm but can be changed.
+ * The resulting time specs are returned as a vector of strings
+ */
+
+
+ #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 "boost/shared_ptr.hpp"
+ #include <string>
+ #include <vector>
+ #include <locale>
+
+ using namespace boost;
+ using namespace local_time;
+ using namespace posix_time;
+
+ //! Coordinates meeting times accounting for time zone differences
+ class meeting_planner {
+ public:
+ typedef std::vector<shared_ptr<time_zone_base> > vector_type;
+ // a multimap is used so time_zones can be sorted according to utc_offset
+ typedef std::multimap<posix_time::time_duration, shared_ptr<time_zone_base> > zone_map_type;
+ typedef std::vector<std::string> result_type;
+
+ meeting_planner(const gregorian::date& d, const vector_type& v)
+ : l_time(posix_time::not_a_date_time, shared_ptr<time_zone_base>()),
+ workday(ptime(d,hours(9)), time_duration(8,0,0,1))
+ {
+ vector_type::const_iterator iter = v.begin();
+ while(iter != v.end()) {
+ time_duration offset(0,0,0);
+ if(*iter == NULL) {
+ offset = hours(0);
+ }
+ else{
+ // null pointers may wind up in the vector
+ // TODO: this should be fixed in tz_database
+ offset = (*iter)->base_utc_offset();
+ }
+ zones.insert(zone_map_type::value_type(offset, *iter));
+ ++iter;
+ }
+
+ // set l_time to noon UTC
+ l_time = local_date_time(posix_time::ptime(d, posix_time::hours(12)),
+ shared_ptr<time_zone_base>());
+ }
+
+ //! Changes range of valid meeting times (ie. The hours in a workday) times are inclusive
+ void change_range(const time_duration& start, const time_duration& end)
+ {
+ ptime pt(l_time.date(), start);
+ // add one unit to make the give times inclusive
+ workday = time_period(pt, (end - start) + time_duration::unit());
+ }
+
+ //! strings returned in the form of "yyyy-Mon-dd: hh:mm Zzz [repeat]"
+ result_type coordinate_time() const
+ {
+ using namespace posix_time;
+
+ result_type result;
+ bool flag = true;
+ std::stringstream ss;
+ ss.str("");
+
+ // set the output format for local_date_time to only give
+ // time_of_day & zone offset
+ typedef boost::date_time::time_facet<local_date_time, char> ldt_facet;
+ ldt_facet* timefacet = new ldt_facet("%H:%M (%q)");
+ std::locale loc(std::locale::classic(), timefacet);
+ ss.imbue(loc);
+
+ // backup a full day and start iterating from there
+ // I went overkill because I've got no decent
+ // algorithm to set a starting point (yet)
+ local_date_time tmp = l_time - gregorian::days(1);
+ zone_map_type::const_iterator iter;
+ for(int i = 0; i < 48; ++i) {
+ iter = zones.begin();
+ flag = true;
+ tmp += posix_time::hours(1);
+
+ while(iter != zones.end() && flag) {
+ if(!workday.contains(tmp.local_time_in(iter->second).local_time())) {
+ flag = false;
+ }
+ ++iter;
+ }
+
+ if(flag) {
+ iter = zones.begin();
+ ss << tmp.date() << ':';
+ while(iter != zones.end()) {
+ ss << ' ' << tmp.local_time_in(iter->second);
+ ++iter;
+ if(iter != zones.end()) {
+ ss << ',';
+ }
+ }
+ result.push_back(ss.str());
+ ss.str("");
+ }
+ }
+ if(result.empty()) {
+ result.push_back("Scheduling within the time period given is not possible for these time zones.");
+ }
+ return result;
+ }
+
+ private:
+ zone_map_type zones;
+ local_date_time l_time;
+ time_period workday;
+ };
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_month_add.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_month_add.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.month_add">
+ <title>Month Adding</title>
+
+ <para>
+ Adding a month to a day without the use of iterators.
+ </para>
+ <programlisting>
+ <![CDATA[
+ /* Simple program that uses the gregorian calendar to progress by exactly
+ * one month, irregardless 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 <iostream>
+
+ int
+ main()
+ {
+
+ using namespace boost::gregorian;
+
+ date d = day_clock::local_day();
+ add_month mf(1);
+ date d2 = d + mf.get_offset(d);
+ std::cout << "Today is: " << to_simple_string(d) << ".\n"
+ << "One month from today will be: " << to_simple_string(d2)
+ << std::endl;
+
+ return 0;
+ }
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_print_holidays.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_print_holidays.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.print_holidays">
+ <title>Print Holidays</title>
+
+ <para>
+ This is an example of using functors to define a holiday schedule
+ </para>
+ <programlisting>
+ <![CDATA[
+
+ /* 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 <algorithm>
+ #include <functional>
+ #include <vector>
+ #include <iostream>
+ #include <set>
+
+ 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() {
+
+ std::cout << "Enter Year: ";
+ int year;
+ std::cin >> year;
+
+ using namespace boost::gregorian;
+
+ //define a collection of holidays fixed by month and day
+ std::vector<year_based_generator*> 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> date_set;
+ date_set all_holidays;
+
+ for(std::vector<year_based_generator*>::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;
+ }
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_print_hours.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_print_hours.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.print_hours">
+ <title>Print Hours</title>
+
+ <para>
+ Demonstrate time iteration, clock retrieval, and simple calculation.
+ </para>
+ <programlisting>
+ <![CDATA[
+ /* 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 <iostream>
+
+ 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 tommorrow = today + days(1);
+ ptime tommorrow_start(tommorrow); //midnight
+
+ //iterator adds by one hour
+ time_iterator titr(now,hours(1));
+ for (; titr < tommorrow_start; ++titr) {
+ std::cout << to_simple_string(*titr) << std::endl;
+ }
+
+ time_duration remaining = tommorrow_start - now;
+ std::cout << "Time left till midnight: "
+ << to_simple_string(remaining) << std::endl;
+ return 0;
+ }
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_print_month.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_print_month.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.print_month">
+ <title>Print Month</title>
+
+ <para>
+ Simple utility to print out days of the month with the days of a month. Demontstrates date iteration (date_time::date_itr).
+ </para>
+ <programlisting>
+ <![CDATA[
+ /* 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 <iostream>
+
+ int
+ main()
+ {
+ std::cout << "Enter Year: ";
+ int year, month;
+ std::cin >> year;
+ std::cout << "Enter Month(1..12): ";
+ std::cin >> month;
+
+ using namespace boost::gregorian;
+ try {
+ //Use the calendar to get the last day of the month
+ int 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() << "]"
+ << std::endl;
+ }
+ }
+ catch(std::exception& e) {
+
+ std::cout << "Error bad date, check your entry: \n"
+ << " Details: " << e.what() << std::endl;
+ }
+ return 0;
+ }
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_seconds_since_epoch.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_seconds_since_epoch.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.examples.seconds_since_epoch">
+ <title>Seconds Since Epoch</title>
+
+ <para>
+ Example of calculating seconds elapsed since epoch (1970-Jan-1) using local_date_time.
+ </para>
+ <programlisting>
+ <![CDATA[
+ /* 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 <iostream>
+
+ 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(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 = 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;
+
+ }
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_simple_time_zone.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_simple_time_zone.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.examples.simple_time_zone">
+ <title>Simple Time Zones</title>
+
+ <para>
+ Example usage of custom_time_zone as well as posix_time_zone.
+ </para>
+ <programlisting>
+ <![CDATA[
+ /* A simple example for using a custom_time_zone and a posix_time_zone.
+ */
+
+ #include "boost/date_time/local_time/local_time.hpp"
+ #include <iostream>
+
+ 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<dst_calc_rule> 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<dst_calc_rule> 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;
+ }
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_time_math.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_time_math.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.time_math">
+ <title>Time Math</title>
+
+ <para>
+ Various types of calculations with times and time durations.
+ </para>
+ <programlisting>
+ <![CDATA[
+ /* 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 <iostream>
+
+ 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 durations
+ ptime t1(d, hours(5)+minutes(4)+seconds(2)+millisec(1));
+ //construct a new time by subtracting some times
+ ptime t2 = t1 - hours(5)- minutes(4)- seconds(2)- millisec(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;
+ }
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_time_periods.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ex_time_periods.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.examples.time_periods">
+ <title>Time Periods</title>
+
+ <para>
+ Demonstrate some simple uses of time periods.
+ </para>
+ <programlisting>
+ <![CDATA[
+
+ /* 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 <iostream>
+
+ 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;
+ }
+
+ ]]>
+ </programlisting>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/examples.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/examples.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.examples" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Examples</title>
+
+ <!-- gregorian examples -->
+ <xi:include href="ex_dates_as_strings.xml"/>
+ <xi:include href="ex_days_alive.xml"/>
+ <xi:include href="ex_days_between_new_years.xml"/>
+ <xi:include href="ex_find_last_day_of_months.xml"/>
+ <xi:include href="ex_localization.xml"/>
+ <!-- <xi:include href="ex_legacy_localization.xml"/> -->
+ <xi:include href="ex_date_period_calc.xml"/>
+ <xi:include href="ex_print_holidays.xml"/>
+ <xi:include href="ex_print_month.xml"/>
+ <xi:include href="ex_month_add.xml"/>
+ <!-- posix_time examples -->
+ <xi:include href="ex_time_math.xml"/>
+ <xi:include href="ex_print_hours.xml"/>
+ <xi:include href="ex_local_utc_conversion.xml"/>
+ <xi:include href="ex_time_periods.xml"/>
+ <!-- local_time examples -->
+ <xi:include href="ex_simple_time_zone.xml"/>
+ <xi:include href="ex_calc_rules.xml"/>
+ <xi:include href="ex_flight.xml"/>
+ <xi:include href="ex_seconds_since_epoch.xml"/>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/exclusive_date_time.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/exclusive_date_time.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE boostbook PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+ "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2006 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)
+-->
+
+
+<boostbook xmlns:xi="http://www.w3.org/2001/XInclude"
+ last-revision="$Date: 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) $">
+ <title>The Boost Date Time Library</title>
+ <xi:include href="./date_time.xml"/>
+</boostbook>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/format_flags.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/format_flags.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,497 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.format_flags">
+ <title>Format Flags</title>
+
+ <para>Many of the format flags this new system uses for output are those used by <code>strftime(...)</code>, but not all. Some new flags have been added, and others overridden. The input system supports only specific flags, therefore, not all flags that work for output will work with input (we are currently working to correct this situation).</para>
+
+ <para>The following tables list the all the flags available for both date_time IO as well as strftime. Format flags marked with a single asterisk (*) have a behavior unique to date_time. Those flags marked with an exclamation point (!) are not usable for input (at this time). The first table is for dates, and the second table is for times.
+ </para>
+
+ <para>
+ <anchor id="date_time_io.date_format_flags" />
+ Date Facet Format Flags
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Format Specifier</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>%a</screen></entry>
+ <entry>Abbreviated weekday name</entry>
+ </row>
+ <row>
+ <entry><screen>"Mon" => Monday</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%A</screen></entry>
+ <entry>Long weekday name</entry>
+ </row>
+ <row>
+ <entry><screen>"Monday"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%b</screen></entry>
+ <entry>Abbreviated month name</entry>
+ </row>
+ <row>
+ <entry><screen>"Feb" => February</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%B</screen></entry>
+ <entry>Full month name</entry>
+ </row>
+ <row>
+ <entry><screen>"February"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%c !</screen></entry>
+ <entry>The preferred date and time representation for the current locale.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%C !</screen></entry>
+ <entry>The century number (year/100) as a 2-digit integer.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%d</screen></entry>
+ <entry>Day of the month as decimal 01 to 31</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%D !</screen></entry>
+ <entry>Equivalent to %m/%d/%y</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%e</screen></entry>
+ <entry>Like %d, the day of the month as a decimal number, but a leading zero is replaced by a space</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%G !</screen></entry>
+ <entry>This has the same format and value as %y, except that if the ISO week number belongs to the previous or next year, that year is used instead.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%g !</screen></entry>
+ <entry>Like %G, but without century.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%h !</screen></entry>
+ <entry> Equivalent to %b</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%j</screen></entry>
+ <entry>Day of year as decimal from 001 to 366 for leap years, 001 - 365 for non-leap years.</entry>
+ </row>
+ <row>
+ <entry><screen>"060" => Feb-29</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%m</screen></entry>
+ <entry>Month name as a decimal 01 to 12</entry>
+ </row>
+ <row>
+ <entry><screen>"01" => January</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%u !</screen></entry>
+ <entry>The day of the week as a decimal, range 1 to 7, Monday being 1.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%U</screen></entry>
+ <entry>The week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01. In 2005, Jan 1st falls on a Saturday, so therefore it falls within week 00 of 2005 (week 00 spans 2004-Dec-26 to 2005-Jan-01. This also happens to be week 53 of 2004).</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2005, Jan, 1); // Saturday
+ // with format %U
+ ss &lt;&lt; d; // "00"
+ d += day(1); // Sunday
+ ss &lt;&lt; d; // "01" beginning of week 1</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%V !</screen></entry>
+ <entry>The ISO 8601:1988 week number of the current year as a decimal number, range 01 to 53, where week 1 is the first week that has at least 4 days in the current year, and with Monday as the first day of the week.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%w</screen></entry>
+ <entry>Weekday as decimal number 0 to 6</entry>
+ </row>
+ <row>
+ <entry><screen>"0" => Sunday</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%W</screen></entry>
+ <entry>Week number 00 to 53 where Monday is first day of week 1</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2005, Jan, 2); // Sunday
+ // with format %W
+ ss &lt;&lt; d; // "00"
+ d += day(1); // Monday
+ ss &lt;&lt; d; // "01" beginning of week 1</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%x</screen></entry>
+ <entry>Implementation defined date format from the locale.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2005,Oct,31);
+ date_facet* f = new date_facet("%x");
+
+ locale loc = locale(locale("en_US"), f);
+ cout.imbue(loc);
+ cout &lt;&lt; d; // "10/31/2005"
+
+ loc = locale(locale("de_DE"), f);
+ cout.imbue(loc);
+ cout &lt;&lt; d; // "31.10.2005"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%y</screen></entry>
+ <entry>Two digit year</entry>
+ </row>
+ <row>
+ <entry><screen>"05" => 2005</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%Y</screen></entry>
+ <entry>Four digit year</entry>
+ </row>
+ <row>
+ <entry><screen>"2005"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%Y-%b-%d</screen></entry>
+ <entry>Default date format</entry>
+ </row>
+ <row>
+ <entry><screen>"2005-Apr-01"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%Y%m%d</screen></entry>
+ <entry>ISO format</entry>
+ </row>
+ <row>
+ <entry><screen>"20050401"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%Y-%m-%d</screen></entry>
+ <entry>ISO extended format</entry>
+ </row>
+ <row>
+ <entry><screen>"2005-04-01"</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+
+ <anchor id="date_time_io.time_format_flags" />
+ Time Facet Format Flags
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Format Specifier</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>%- *!</screen></entry>
+ <entry>Placeholder for the sign of a duration. Only displays when the duration is negative.</entry>
+ </row>
+ <row>
+ <entry><screen>"-13:15:16"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%+ *!</screen></entry>
+ <entry>Placeholder for the sign of a duration. Always displays for both positive and negative.</entry>
+ </row>
+ <row>
+ <entry><screen>"+13:15:16"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%f</screen></entry>
+ <entry>Fractional seconds are always used, even when their value is zero</entry>
+ </row>
+ <row>
+ <entry><screen>"13:15:16.000000"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%F *</screen></entry>
+ <entry>Fractional seconds are used only when their value is not zero.</entry>
+ </row>
+ <row>
+ <entry><screen>"13:15:16"
+ "05:04:03.001234"
+ </screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%I !</screen></entry>
+ <entry>The hour as a decimal number using a 12-hour clock</entry>
+ </row>
+ <row>
+ <entry></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%k !</screen></entry>
+ <entry>The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%l !</screen></entry>
+ <entry>The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%p !</screen></entry>
+ <entry>Either `AM' or `PM' according to the given time value, or the corresponding strings for the current locale.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%P !</screen></entry>
+ <entry>Like %p but in lowercase: `am' or `pm' or a corresponding string for the current locale.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%r !</screen></entry>
+ <entry>The time in a.m. or p.m. notation. In the POSIX locale this is equivalent to `%I:%M:%S %p'</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%R !</screen></entry>
+ <entry>The time in 24-hour notation (%H:%M)</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%s *</screen></entry>
+ <entry>Seconds with fractional seconds.</entry>
+ </row>
+ <row>
+ <entry><screen>"59.000000"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%S</screen></entry>
+ <entry>Seconds only</entry>
+ </row>
+ <row>
+ <entry><screen>"59"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%T !</screen></entry>
+ <entry>The time in 24-hour notation (%H:%M:%S)</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%q</screen></entry>
+ <entry>ISO time zone (output only). This flag is ignored when using the time_facet with a ptime.</entry>
+ </row>
+ <row>
+ <entry><screen>"-0700" // Mountain Standard Time</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%Q</screen></entry>
+ <entry>ISO extended time zone (output only). This flag is ignored when using the time_facet with a ptime.</entry>
+ </row>
+ <row>
+ <entry><screen>"-05:00" // Eastern Standard Time</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%z *!</screen></entry>
+ <entry>Abbreviated time zone (output only). This flag is ignored when using the time_facet with a ptime.</entry>
+ </row>
+ <row>
+ <entry><screen>"MST" // Mountain Standard Time</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%Z *!</screen></entry>
+ <entry>Full time zone name (output only). This flag is ignored when using the time_facet with a ptime.</entry>
+ </row>
+ <row>
+ <entry><screen>"EDT" // Eastern Daylight Time</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%ZP *</screen></entry>
+ <entry>Posix time zone string (available to both input and output). This flag is ignored when using the time_facet with a ptime. For complete details on posix time zone strings, see <link linkend="date_time.local_time.posix_time_zone">posix_time_zone class</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>"EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%x %X</screen></entry>
+ <entry>Implementation defined date/time format from the locale.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2005,Oct,31);
+ ptime pt(d, hours(20));
+ time_facet* f = new time_facet("%x %X");
+
+ locale loc = locale(locale("en_US"), f);
+ cout.imbue(loc);
+ cout &lt;&lt; pt; // "10/31/2005 08:00:00 PM"
+
+ loc = locale(locale("de_DE"), f);
+ cout.imbue(loc);
+ cout &lt;&lt; pt; // "31.10.2005 20:00:00"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%Y%m%dT%H%M%S%F%q</screen></entry>
+ <entry>ISO format</entry>
+ </row>
+ <row>
+ <entry><screen>"20051015T131211-0700"
+ // Oct 15, 2005 13:12:11 MST
+ </screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%Y-%m-%d %H:%M:%S%F%Q</screen></entry>
+ <entry>Extended ISO format</entry>
+ </row>
+ <row>
+ <entry><screen>"2005-10-15 13:12:11-07:00"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%Y-%b-%d %H:%M:%S%F %z</screen></entry>
+ <entry>Default format used when outputting ptime and local_date_time.</entry>
+ </row>
+ <row>
+ <entry><screen>"2005-Oct-15 13:12:11 MST"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%Y-%b-%d %H:%M:%S%F %ZP</screen></entry>
+ <entry>Default format used when inputting ptime and local_date_time.</entry>
+ </row>
+ <row>
+ <entry><screen>"2005-Oct-15 13:12:11 MST-07"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%-%H:%M:%S%F !</screen></entry>
+ <entry>Default time_duration format for output. Sign will only be displayed for negative durations.</entry>
+ </row>
+ <row>
+ <entry><screen>"-13:14:15.003400"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>%H:%M:%S%F</screen></entry>
+ <entry>Default time_duration format for input.</entry>
+ </row>
+ <row>
+ <entry><screen>"13:14:15.003400"</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+ <para>* Signifies flags that have a behavior unique to <code>date_time</code>.</para>
+ <para>! Signifies flags that currently do not work for input.</para>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/gregorian.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/gregorian.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.gregorian"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Gregorian</title>
+ <bridgehead renderas="sect2">Gregorian Date System</bridgehead>
+ <para>
+ <link linkend="greg_intro">Introduction</link> --
+ <link linkend="greg_ex">Usage Examples</link>
+ </para>
+
+ <anchor id="greg_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>The gregorian date system provides a date programming system based the Gregorian Calendar. The first introduction of the Gregorian calendar was in 1582 to fix an error in the Julian Calendar. However, many local jurisdictions did not adopt this change until much later. Thus there is potential confusion with historical dates.
+ </para>
+ <para>The implemented calendar is a "proleptic Gregorian calendar" which extends dates back prior to the Gregorian Calendar's first adoption in 1582. The current implementation supports dates in the range 1400-Jan-01 to 9999-Dec-31. Many references will represent dates prior to 1582 using the Julian Calendar, so caution is in order if accurate calculations are required on historic dates. See <ulink url="http://emr.cs.iit.edu/home/reingold/calendar-book/second-edition">Calendrical Calculations</ulink> by Reingold &amp; Dershowitz for more details. Date information from Calendrical Calculations has been used to cross-test the correctness of the Gregorian calendar implementation.
+ </para>
+ <para>All types for the gregorian system are found in namespace boost::gregorian. The library supports a convenience header boost/date_time/gregorian/gregorian_types.hpp that will include all the classes of the library with no input/output dependency. Another header boost/date_time/gregorian/gregorian.hpp will include the types and the input/output code.
+ </para>
+ <para>The class <link linkend="date_time.gregorian.date_class">boost::gregorian::date</link> is the primary temporal type for users. If you are interested in learning about writing programs do specialized date calculations such as finding the "first sunday in april" see the date <link linkend="date_time.gregorian.date_algorithms">generators and algorithms page</link>.
+ </para>
+
+ <anchor id="greg_ex" />
+ <bridgehead renderas="sect3">Usage Examples</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Example</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><literallayout>
+<link linkend="date_time.examples.days_alive">Days Alive</link> &nbsp;
+<link linkend="date_time.examples.days_between_new_year">Days Between New Years</link></literallayout></entry>
+ <entry>Simple date arithmetic. Retrieve current day from clock.</entry>
+ </row>
+ <row>
+ <entry valign="top"><literallayout><link linkend="date_time.examples.dates_as_strings">Dates as strings</link></literallayout></entry>
+ <entry>Simple parsing and formatting of dates from/to strings</entry>
+ </row>
+ <row>
+ <entry valign="top"><literallayout><link linkend="date_time.examples.date_period_calc">Date Period Calculations</link></literallayout></entry>
+ <entry>See if a date is in a set of date periods (eg: is it a holiday/weekend)</entry>
+ </row>
+ <row>
+ <entry valign="top"><literallayout><link linkend="date_time.examples.print_month">Print a month</link></literallayout></entry>
+ <entry>Small utility program which prints out all the days in a month from command line. Need to know if 1999-Jan-1 was a Friday or a Saturday? This program shows how to do it.</entry>
+ </row>
+ <row>
+ <entry valign="top"><literallayout><link linkend="date_time.examples.print_holidays">Print Holidays</link></literallayout></entry>
+ <entry>Uses date generators to convert abstract specification into concrete set of dates.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <xi:include href="date_class.xml" />
+ <xi:include href="date_duration.xml" />
+ <xi:include href="date_period.xml" />
+ <xi:include href="date_iterators.xml" />
+ <xi:include href="date_algorithms.xml" />
+ <xi:include href="gregorian_calendar.xml" />
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/gregorian_calendar.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/gregorian_calendar.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.gregorian.gregorian_calendar">
+ <title>Gregorian Calendar</title>
+
+ <link linkend="gregcal_intro">Introduction</link> --
+ <link linkend="gregcal_header">Header</link> --
+ <link linkend="gregcal_functions">Functions</link>
+
+ <anchor id="gregcal_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ The class boost::gregorian::gregorian_calendar implements the functions necessary to create the gregorian date system. It converts to the year-month-day form of a date to a day number representation and back.
+ </para>
+ <para>
+ For most purposes this class is simply accessed by <link linkend="date_time.gregorian.date_class">gregorian::date</link> and is not used directly by the user. However, there are useful functions that might be of use such as the end_of_month_day function.
+ </para>
+ <para>
+ The <link linkend="date_time.examples.print_month">print month</link> example demonstrates this.
+ </para>
+
+ <anchor id="gregcal_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ <programlisting>#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</programlisting>
+ </para>
+
+ <anchor id="gregcal_functions" />
+ <bridgehead renderas="sect3">Functions</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>static short day_of_week(ymd_type)</screen></entry>
+ <entry>Return the day of the week (0==Sunday, 1==Monday, etc)</entry>
+ </row>
+ <row>
+ <entry>See also <link linkend="date_time.gregorian.date_class">gregorian::date</link> day_of_week</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>static date_int_type day_number(ymd_type)</screen></entry>
+ <entry> Convert a ymd_type into a day number. The day number is an absolute number of days since the epoch start.</entry>
+ </row>
+ <row>
+ <entry></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>static short end_of_month_day(year_type,
+ month_type)</screen></entry>
+ <entry>Given a year and month determine the last day of the month.</entry>
+ </row>
+ <row>
+ <entry></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>static ymd_type from_day_number(date_int_type)</screen></entry>
+ <entry> Convert a day number to a ymd struct.</entry>
+ </row>
+ <row>
+ <entry></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>static bool is_leap_year(year_type)</screen></entry>
+ <entry>Returns true if specified year is a leap year.</entry>
+ </row>
+ <row>
+ <entry><screen>gregorian_calendar::is_leap_year(2000)
+//--> true</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/io_objects.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/io_objects.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,1101 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.io_objects"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Date Time Formatter/Parser Objects</title>
+ <!-- <using-namespace name="boost"/> -->
+ <using-namespace name="boost::date_time"/>
+ <bridgehead renderas="sect2">Date Time Formatter/Parser Objects</bridgehead>
+
+ <link linkend="io_objects.periods">Periods</link> |
+ <link linkend="io_objects.date_generators">Date Generators</link> |
+ <link linkend="io_objects.special_values">Special Values</link> |
+ <link linkend="io_objects.format_date_parser">Format Date Parser</link>
+
+ <anchor id="io_objects.periods" />
+ <bridgehead renderas="sect3">Periods</bridgehead>
+ <para>The period_formatter and period_parser provide a uniform interface for the input and output of date_periods, time_periods, and in a future release, local_date_time_periods. The user has control over the delimiters, formats of the date/time components, and the form the period takes. The format of the date/time components is controlled via the date_time input and output facets.</para>
+
+ <bridgehead renderas="sect4">Period Form</bridgehead>
+ <para>Periods are constructed with open ranged parameters. The first value is the starting point, and is included in the period. The end value is not included but immediately follows the last value: [begin/end). However, a period can be streamed as either an open range or a closed range.</para>
+ <screen>[2003-Jan-01/2003-Dec-31] &lt;-- period holding 365 days
+[2003-Jan-01/2004-Jan-01) &lt;-- period holding 365 days</screen>
+
+ <bridgehead renderas="sect4">Delimiters</bridgehead>
+ <para>There are four delimiters. The default values are<simplelist type="vert" columns="1">
+ <member>"\" - separator</member>
+ <member>"[" - start delimiter</member>
+ <member>")" - open range end delimiter</member>
+ <member>"]" - closed range end delimiter</member>
+ </simplelist>A user can provide a custom set of delimiters. Custom delimiters may contain spaces.</para>
+
+ <bridgehead renderas="sect4">Customization</bridgehead>
+ <para>The period form and delimiters can be set as construction parameters or by means of accessor functions. A custom period parser/formatter can then be used as a construction parameter to a new facet, or can be set in an existing facet via an accessor function.</para>
+
+
+ <bridgehead renderas="sect4">Period Formatter/Parser Reference</bridgehead>
+ The complete class reference can be found here: <classname alt="boost::date_time::period_formatter">Period Formatter Doxygen Reference</classname> and here: <classname alt="boost::date_time::period_parser">Period Parser Doxygen Reference</classname>
+
+ <para>
+ <bridgehead renderas="sect4">Period Formatter Construction</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>period_formatter(...)
+ Parameters:
+ range_display_options
+ char_type*
+ char_type*
+ char_type*
+ char_type*</screen></entry>
+ <entry>NOTE: All five construction parameters have default values so this constructor also doubles as the default constructor. The <code>range_display_options</code> is a public type enum of the <code>period_formatter</code> class. The possible choices are AS_OPEN_RANGE or AS_CLOSED_RANGE. The closed range is the default. A period has three significant points: the begining, the last, and the end. A closed range period takes the form [begin,end), where an open range period takes the form [begin,last]. The four char_type* parameters are: the period separator, the start delimiter, the open range end delimiter, and the closed range end delimiter.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <bridgehead renderas="sect4">Period Formatter Accessors</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>range_display_options range_option()</screen></entry>
+ <entry>Returns the current setting for the range display (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void range_option(...)
+ Parameter:
+ range_display_options</screen></entry>
+ <entry>Sets the option for range display (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void delimiter_strings(...)
+ Parameters:
+ string_type
+ string_type
+ string_type
+ string_type</screen></entry>
+ <entry>Set new delimiter strings in the formatter.</entry>
+ </row>
+ <row>
+ <entry><screen>string beg("->| ");
+string sep(" || ");
+string opn(" ->|");
+string clo(" |&lt;-");
+pf.delimiter_strings(beg, sep,
+ opn, clo);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>put_period_start_delimeter(...)
+ Return Type:
+ OutItrT
+ Parameter:
+ OutItrT</screen></entry>
+ <entry>Puts the start delimiter into the stream at position pointed to by OutItrT parameter.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>put_period_sepatator(...)
+ Return Type:
+ OutItrT
+ Parameter:
+ OutItrT</screen></entry>
+ <entry>Puts the separator into the stream at position pointed to by OutItrT parameter.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>put_period_end_delimeter(...)
+ Return Type:
+ OutItrT
+ Parameter:
+ OutItrT</screen></entry>
+ <entry>Puts the end delimiter into the stream at position pointed to by OutItrT parameter.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put_period(...)
+ Parameters:
+ OutItrT
+ ios_base
+ char_type
+ period_type
+ facet_type</screen></entry>
+ <entry>Puts a period into the stream using the set values for delimiters, separator, and range display. The facet parameter is used to put the date (or time) objects of the period.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+ <para>
+ <bridgehead renderas="sect4">Period Parser Construction</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>period_parser(...)
+ Parameters:
+ period_range_option
+ char_type*
+ char_type*
+ char_type*
+ char_type*</screen></entry>
+ <entry>NOTE: All five construction parameters have default values so this constructor also doubles as the default constructor. The <code>period_range_option</code> is a public type enum of the <code>period_parser</code> class. The possible choices are AS_OPEN_RANGE or AS_CLOSED_RANGE. The closed range is the default. A period has three significant points: the begining, the last, and the end. A closed range period takes the form [begin,end), where an open range period takes the form [begin,last]. The four char_type* parameters are: the period separator, the start delimiter, the open range end delimiter, and the closed range end delimiter.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>period_parser(period_parser)</screen></entry>
+ <entry>Copy constructor</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <bridgehead renderas="sect4">Period Parser Accessors</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>period_range_option range_option()</screen></entry>
+ <entry>Returns the current setting for the period range (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void range_option(...)
+ Parameter:
+ period_range_option </screen></entry>
+ <entry>Sets the option for period range (either AS_OPEN_RANGE or AS_CLOSED_RANGE).</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void delimiter_strings(...)
+ Parameters:
+ string_type
+ string_type
+ string_type
+ string_type</screen></entry>
+ <entry>Set new delimiter strings in the parser.</entry>
+ </row>
+ <row>
+ <entry><screen>string beg("->| ");
+string sep(" || ");
+string opn(" ->|");
+string clo(" |&lt;-");
+pp.delimiter_strings(beg, sep,
+ opn, clo);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>collection_type delimiter_strings()</screen></entry>
+ <entry>Returns the set of delimiter strings currently held in the parser.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>period_type get_period(...)
+ Parameters:
+ stream_itr_type
+ stream_itr_type
+ ios_base
+ period_type
+ duration_type
+ facet_type</screen></entry>
+<entry>Parses a period from the stream. The iterator parameters point to the begining and end of the stream. The duration_type is relevant to the period type, for example: A <code>date_period</code> would use <code>days</code> as a duration_type. The period will be parsed according to the formats and strings found in the facet parameter.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>_____________________________________________________</para>
+
+ <anchor id="io_objects.date_generators" />
+ <bridgehead renderas="sect3">Date Generators</bridgehead>
+ <para>The date_generator formatter and parser provide flexibility by allowing the user to use custom "phrase elements". These phrase elements are the "in-between" words in the date_generators. For example, in the date_generator "Second Monday of March", "Second" and "of" are the phrase elements, where "Monday" and "March" are the date elements. Customization of the date elements is done with the facet. The order of the date and phrase elements cannot be changed. When parsing, all elements of the date_generator phrase must parse correctly or an ios_base::failure exception will be thrown.</para>
+
+ <bridgehead renderas="sect4">Customization</bridgehead>
+ <para>The default "phrase_strings" are:
+ <simplelist type="horiz" columns="9">
+ <member>"first"</member>
+ <member>"second"</member>
+ <member>"third"</member>
+ <member>"fourth"</member>
+ <member>"fifth"</member>
+ <member>"last"</member>
+ <member>"before"</member>
+ <member>"after"</member>
+ <member>"of"</member>
+ </simplelist>
+ A custom set of phrase_strings must maintain this order of occurance (Ex: "1st", "2nd", "3rd", "4th", "5th", "last", "prior", "past", "in").</para>
+ <para> Examples using default phrase_strings and default facet formats for weekday &amp; month: <screen>"first Tue of Mar"</screen>And using custom phrase_strings: <screen>"1st Tue in Mar"</screen>
+ </para>
+ <para>The custom set of phrase elements can be set as construction parameters or through an accessor function.A custom date_generator parser/formatter can then be used as a construction parameter to a new facet, or can be set in an existing facet via an accessor function.</para>
+ <para>IMPORTANT NOTE: Prior to 1.33, partial_date was output as "1 Jan" with a single *or* double digit number for the day. The new behavior is to *always* place a double digit number for the day - "01 Jan".</para>
+
+ <bridgehead renderas="sect4">Date Generator Reference</bridgehead>
+ The complete class references can be found here: <classname alt="boost::date_time::date_generator_formatter">Date Generator Formatter Doxygen Reference</classname> and here: <classname alt="boost::date_time::date_generator_parser">Date Generator Parser Doxygen Reference</classname>
+
+ <para>
+ <bridgehead renderas="sect4">Date Generator Formatter Construction</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>date_generator_formatter()</screen></entry>
+ <entry>Uses the default date generator elements.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>date_generator_formatter(...)
+ Parameters:
+ string_type first_element
+ string_type second_element
+ string_type third_element
+ string_type fourth_element
+ string_type fifth_element
+ string_type last_element
+ string_type before_element
+ string_type after_element
+ string_type of_element</screen></entry>
+ <entry>Constructs a date_generator_formatter using the given element strings.</entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <bridgehead renderas="sect4">Date Generator Formatter Accessors</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>void elements(...)
+ Parameters:
+ collection_type
+ phrase_elements</screen></entry>
+ <entry>Replace the current phrase elements with a collection of new ones. The <code>phrase_elements</code> parameter is an enum that indicates what the first element in the new collection is (defaults to first).</entry>
+ </row>
+ <row>
+ <entry><screen>// col is a collection holding
+// "final", "prior", "following",
+// and "in"
+typedef date_generator_formatter dgf;
+dgf formatter();
+formatter.elements(col, dgf::last);
+// complete elements in dgf are now:
+"first", "second", "third",
+"fourth", "fifth", "final",
+"prior", "following", and "in"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>put_partial_date(...)
+ Return Type:
+ facet_type::OutItrT
+ Parameters:
+ OutItrT next
+ ios_base
+ char_type fill
+ partial_date
+ facet_type</screen></entry>
+ <entry>A put function for partial_date. This is a templated function that takes a facet_type as a parameter.</entry>
+ </row>
+ <row>
+ <entry>Put a partial_date => "dd Month".</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>put_nth_kday(...)
+ Return Type:
+ facet_type::OutItrT
+ Parameters:
+ OutItrT next
+ ios_base
+ char_type fill
+ nth_kday_type
+ facet_type</screen></entry>
+ <entry>A put function for nth_kday_type. This is a templated function that takes a facet_type as a parameter.</entry>
+ </row>
+ <row>
+ <entry>Put an nth_day_of_the_week_in_month => "nth weekday of month".</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>put_first_kday(...)
+ Return Type:
+ facet_type::OutItrT
+ Parameters:
+ OutItrT next
+ ios_base
+ char_type fill
+ first_kday_type
+ facet_type</screen></entry>
+ <entry>A put function for first_kday_type. This is a templated function that takes a facet_type as a parameter.</entry>
+ </row>
+ <row>
+ <entry>Put a first_day_of_the_week_in_month => "first weekday of month".</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>put_last_kday(...)
+ Return Type:
+ facet_type::OutItrT
+ Parameters:
+ OutItrT next
+ ios_base
+ char_type fill
+ last_kday_type
+ facet_type</screen></entry>
+ <entry>A put function for last_kday_type. This is a templated function that takes a facet_type as a parameter.</entry>
+ </row>
+ <row>
+ <entry>Put a last_day_of_the_week_in_month => "last weekday of month".</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>put_kday_before(...)
+ Return Type:
+ facet_type::OutItrT
+ Parameters:
+ OutItrT next
+ ios_base
+ char_type fill
+ kday_before_type
+ facet_type</screen></entry>
+ <entry>A put function for kday_before_type. This is a templated function that takes a facet_type as a parameter.</entry>
+ </row>
+ <row>
+ <entry>Put a first_day_of_the_week_before => "weekday before"</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>put_kday_after(...)
+ Return Type:
+ facet_type::OutItrT
+ Parameters:
+ OutItrT next
+ ios_base
+ char_type fill
+ kday_after_type
+ facet_type</screen></entry>
+ <entry>A put function for kday_after_type. This is a templated function that takes a facet_type as a parameter.</entry>
+ </row>
+ <row>
+ <entry>Put a first_day_of_the_week_after => "weekday after".</entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+ <para>
+ <bridgehead renderas="sect4">Date Generator Parser Construction</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>date_generator_parser()</screen></entry>
+ <entry>Uses the default date generator elements.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>date_generator_parser(...)
+ Parameter:
+ date_generator_parser</screen></entry>
+ <entry>Copy Constructor</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>date_generator_parser(...)
+ Parameters:
+ string_type first_element
+ string_type second_element
+ string_type third_element
+ string_type fourth_element
+ string_type fifth_element
+ string_type last_element
+ string_type before_element
+ string_type after_element
+ string_type of_element</screen></entry>
+ <entry>Constructs a date_generator_parser using the given element strings.</entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <bridgehead renderas="sect4">Date Generator Parser Accessors</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>void element_strings(...)
+ Parameter:
+ collection_type</screen></entry>
+ <entry>Replace the set of date generator element string with a new set.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void element_strings(...)
+ Parameters:
+ string_type first
+ string_type second
+ string_type third
+ string_type fourth
+ string_type fifth
+ string_type last
+ string_type before
+ string_type after
+ string_type of</screen></entry>
+ <entry>Replace the set of date generator elements with new values.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>get_partial_date_type(...)
+ Return Type:
+ facet_type::partial_date_type
+ Parameters:
+ stream_itr_type next
+ stream_itr_type str_end
+ ios_base
+ facet_type</screen></entry>
+ <entry>A templated function that parses a date_generator from the stream.</entry>
+ </row>
+ <row>
+ <entry>Parses a partial_date => "dd Month".</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>get_nth_kday_type(...)
+ Return Type:
+ facet_type::nth_kday_type
+ Parameters:
+ stream_itr_type next
+ stream_itr_type str_end
+ ios_base
+ facet_type</screen></entry>
+ <entry>A templated function that parses a date_generator from the stream.</entry>
+ </row>
+ <row>
+ <entry>Parses an nth_day_of_the_week_in_month => "nth weekday of month".</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>get_first_kday_type(...)
+ Return Type:
+ facet_type::firat_kday_type
+ Parameters:
+ stream_itr_type next
+ stream_itr_type str_end
+ ios_base
+ facet_type</screen></entry>
+ <entry>A templated function that parses a date_generator from the stream.</entry>
+ </row>
+ <row>
+ <entry>Parses a first_day_of_the_week_in_month => "first weekday of month".</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>get_last_kday_type(...)
+ Return Type:
+ facet_type::last_kday_type
+ Parameters:
+ stream_itr_type next
+ stream_itr_type str_end
+ ios_base
+ facet_type</screen></entry>
+ <entry>A templated function that parses a date_generator from the stream.</entry>
+ </row>
+ <row>
+ <entry>Parses a last_day_of_the_week_in_month => "last weekday of month".</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>get_kday_before_type(...)
+ Return Type:
+ facet_type::kday_before_type
+ Parameters:
+ stream_itr_type next
+ stream_itr_type str_end
+ ios_base
+ facet_type</screen></entry>
+ <entry>A templated function that parses a date_generator from the stream.</entry>
+ </row>
+ <row>
+ <entry>Parses a first_day_of_the_week_before => "weekday before"</entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>get_kday_after_type(...)
+ Return Type:
+ facet_type::kday_after_type
+ Parameters:
+ stream_itr_type next
+ stream_itr_type str_end
+ ios_base
+ facet_type</screen></entry>
+ <entry>A templated function that parses a date_generator from the stream.</entry>
+ </row>
+ <row>
+ <entry>Parses a first_day_of_the_week_after => "weekday after".</entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>_____________________________________________________</para>
+
+ <anchor id="io_objects.special_values" />
+ <bridgehead renderas="sect3">Special Values</bridgehead>
+ <para>The date_time library uses five special_values. They are:
+ <simplelist type="horiz" columns="5">
+ <member>not_a_date_time</member>
+ <member>neg_infin</member>
+ <member>pos_infin</member>
+ <member>min_date_time</member>
+ <member>max_date_time</member>
+ </simplelist>
+ </para>
+ <para>The default set of strings used to represent these types are: "not-a-date-time", "-infinity", "+infinity", "minimum-date-time", "maximum-date-time". When output, the min_date-time and max_date_time appear as normal date/time representations: "1400-Jan-01" and "9999-Dec-31" repectively.</para>
+
+ <bridgehead renderas="sect4">Customization</bridgehead>
+ <para>The special values parser/formatter allows the user to set custom strings for these special values. These strings can be set as construction parameters to a new facet, or can be set in an existing facet via an accessor function.</para>
+
+ <bridgehead renderas="sect4">Special Values Formatter/Parser Reference</bridgehead>
+ The complete class references can be found here: <classname alt="boost::date_time::special_values_formatter">Special Values Formatter Doxygen Reference</classname> and here: <classname alt="boost::date_time::special_values_parser">Special Values Parser Doxygen Reference</classname>
+
+ <para>
+ <bridgehead renderas="sect4">Special Values Formatter Constructor</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>special_values_formatter()</screen></entry>
+ <entry>Constructor uses defaults for special value strings.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>special_values_formatter(...)
+ Parameters:
+ collection_type::iterator
+ collection_type::iterator</screen></entry>
+ <entry>Constructs using values in collection. NOTE: Only the first three strings of the collection will be used. Strings for minimum_date_time and maximum_date_time are ignored as those special values are output as normal dates/times.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>special_values_formatter(...)
+ Parameters:
+ char_type*
+ char_type*</screen></entry>
+ <entry>Constructs special values formatter from an array of strings.</entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>
+ <bridgehead renderas="sect4">Special Values Formatter Accessors</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put_special(...)
+ Parameters:
+ OutItrT next
+ special_values value</screen></entry>
+ <entry>Puts the given special value into the stream.</entry>
+ </row>
+ <row>
+ <entry><screen>date d1(not_a_date_time);
+date d2(minimum_date_time);
+special_values_formatter formatter;
+formatter.put_special(itr, d1);
+// Puts: "not-a-date-time"
+formatter.put_special(itr, d2);
+// Puts: "1400-Jan-01"</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>
+ <bridgehead renderas="sect4">Special Values Parser Constructor</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>special_values_parser()</screen></entry>
+ <entry></entry>
+ </row>
+
+ <row>
+ <entry valign="top"><screen>special_values_parser(...)
+ Parameters:
+ collection_type::iterator
+ collection_type::iterator</screen></entry>
+ <entry>Constructs a special values parser using the strings in the collection.</entry>
+ </row>
+
+ <row>
+ <entry valign="top"><screen>special_values_parser(...)
+ Parameter:
+ scpecial_values_parser</screen></entry>
+ <entry>Copy constructor.</entry>
+ </row>
+
+ <row>
+ <entry valign="top"><screen>special_values_parser(...)
+ Parameters:
+ string_type nadt_str
+ string_type neg_inf_str
+ string_type pos_inf_str
+ string_type min_dt_str
+ string_type max_dt_str</screen></entry>
+ <entry>Constructs a special values parser using the supplied strings.</entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>
+ <bridgehead renderas="sect4">Special Values Parser Accessors</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>void sv_strings(...)
+ Parameters:
+ string_type nadt_str
+ string_type neg_inf_str
+ string_type pos_inf_str
+ string_type min_dt_str
+ string_type max_dt_str</screen></entry>
+ <entry>Replace the set of special value strings with the given ones.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool match(...)
+ Parameters:
+ stream_itr_type beg
+ stream_itr_type end
+ match_results</screen></entry>
+ <entry>Returns true if parse was successful. Upon a successful parse, <code>mr.current_match</code> will be set an int values corresponding to the equivalent special_value.</entry>
+ </row>
+ <row>
+ <entry><screen>// stream holds "maximum_date_time"
+typedef special_values_parser svp;
+svp parser;
+svp::match_results mr;
+if(parser.match(itr, str_end, mr)) {
+ d = date(static_cast&lt;special_values>(
+ mr.match_results))
+} else {
+ // error, failed parse
+}
+// d == "9999-Dec-31"</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>_____________________________________________________</para>
+
+ <anchor id="io_objects.format_date_parser" />
+ <bridgehead renderas="sect3">Format Date Parser</bridgehead>
+ <para>The format date parser is the object that holds the strings for months and weekday names, as well as their abbreviations. Custom sets of strings can be set at construction time, or, the strings in an existing format_date_parser can be replaced through accessor functions. Both the constructor and the accessor functions take a vector of strings as their arguments.</para>
+
+ <bridgehead renderas="sect4">Format Date Parser Reference</bridgehead>
+ The complete class reference can be found here: <classname alt="boost::date_time::format_date_parser">Doxygen Reference</classname>
+
+ <para>
+ <bridgehead renderas="sect4">Format Date Parser Constructor</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>format_date_parser(...)
+ Parameters:
+ string_type format
+ std::locale</screen></entry>
+ <entry>Creates a parser that uses the given format for parsing dates (in those functions where there is no format parameter). The names and abbreviations used are extracted from the given locale.</entry>
+ </row>
+
+ <row>
+ <entry valign="top"><screen>format_date_parser(...)
+ Parameters:
+ string_type format
+ input_collection_type
+ input_collection_type
+ input_collection_type
+ input_collection_type</screen></entry>
+ <entry>Creates a parser from using the given components. The input_collection_type parameters are for: short month names, long month names, short weekday names, and long weekday names (in that order). These collections must contain values for every month and every weekday (begining with January and Sunday).</entry>
+ </row>
+
+ <row>
+ <entry valign="top"><screen>format_date_parser(...)
+ Parameters:
+ format_date_parser</screen></entry>
+ <entry>Copy Constructor</entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>
+ <bridgehead renderas="sect4">Format Date Parser Accessors</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>string_type format()</screen></entry>
+ <entry>Returns the format that will be used when parsing dates in those functions where there is no format parameter.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void format(string_type)</screen></entry>
+ <entry>Sets the format that will be used when parsing dates in those functions where there is no format parameter.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void short_month_names(...)
+ Parameter:
+ input_collection_type names</screen></entry>
+ <entry>Replace the short month names used by the parser. The collection must contain values for each month, starting with January.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void long_month_names(...)
+ Parameter:
+ input_collection_type names</screen></entry>
+ <entry>Replace the long month names used by the parser. The collection must contain values for each month, starting with January.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void short_weekday_names(...)
+ Parameter:
+ input_collection_type names</screen></entry>
+ <entry>Replace the short weekday names used by the parser. The collection must contain values for each weekday, starting with Sunday.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void long_weekday_names(...)
+ Parameter:
+ input_collection_type names</screen></entry>
+ <entry>Replace the long weekday names used by the parser. The collection must contain values for each weekday, starting with Sunday.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_type parse_date(...)
+ Parameters:
+ string_type input
+ string_type format
+ special_values_parser</screen></entry>
+ <entry>Parse a date from the given input using the given format.</entry>
+ </row>
+ <row>
+ <entry><screen>string inp("2005-Apr-15");
+string format("%Y-%b-%d");
+date d;
+d = parser.parse_date(inp,
+ format,
+ svp);
+// d == 2005-Apr-15</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_type parse_date(...)
+ Parameters:
+ istreambuf_iterator input
+ istreambuf_iterator str_end
+ special_values_parser</screen></entry>
+ <entry>Parse a date from stream using the parser's format.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_type parse_date(...)
+ Parameters:
+ istreambuf_iterator input
+ istreambuf_iterator str_end
+ string_type format
+ special_values_parser</screen></entry>
+ <entry>Parse a date from stream using the given format.</entry>
+ </row>
+ <row>
+ <entry><screen>// stream holds "2005-04-15"
+string format("%Y-%m-%d");
+date d;
+d = parser.parse_date(itr,
+ str_end,
+ format,
+ svp);
+// d == 2005-Apr-15</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>month_type parse_month(...)
+ Parameters:
+ istreambuf_iterator input
+ istreambuf_iterator str_end
+ string_type format</screen></entry>
+ <entry>Parses a month from stream using given format. Throws bad_month if unable to parse.</entry>
+ </row>
+ <row>
+ <entry><screen>// stream holds "March"
+string format("%B");
+greg_month m;
+m = parser.parse_month(itr,
+ str_end,
+ format);
+// m == March</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>day_type parse_day_of_month(...)
+ Parameters:
+ istreambuf_iterator input
+ istreambuf_iterator str_end</screen></entry>
+ <entry>Parses a day_of_month from stream. The day must appear as a two digit number (01-31), or a bad_day_of_month will be thrown.</entry>
+ </row>
+ <row>
+ <entry><screen>// stream holds "01"
+greg_day d;
+d = parser.parse_day_of_month(itr,
+ str_end);
+// d == 1st</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>day_type parse_var_day_of_month(...)
+ Parameters:
+ istreambuf_iterator input
+ istreambuf_iterator str_end</screen></entry>
+ <entry>Parses a day_of_month from stream. The day must appear as a one or two digit number (1-31), or a bad_day_of_month will be thrown.</entry>
+ </row>
+ <row>
+ <entry><screen>// stream holds "1"
+greg_day d;
+d = parser.parse_var_day_of_month(itr,
+ str_end);
+// d == 1st</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>day_of_week_type parse_weekday(...)
+ Parameters:
+ istreambuf_iterator input
+ istreambuf_iterator str_end
+ string_type format</screen></entry>
+ <entry>Parse a weekday from stream according to the given format. Throws a bad_weekday if unable to parse.</entry>
+ </row>
+ <row>
+ <entry><screen>// stream holds "Tue"
+string format("%a");
+greg_weekday wd;
+wd = parser.parse_weekday(itr,
+ str_end,
+ format);
+// wd == Tuesday</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>year_type parse_year(...)
+ Parameters:
+ istreambuf_iterator input
+ istreambuf_iterator str_end
+ string_type format</screen></entry>
+ <entry>Parse a year from stream according to given format. Throws bad year if unable to parse.</entry>
+ </row>
+ <row>
+ <entry><screen>// stream holds "98"
+string format("%y");
+greg_year y;
+y = parser.parse_year(itr,
+ str_end,
+ format);
+// y == 1998</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/io_tutorial.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/io_tutorial.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,306 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.io_tutorial"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Date Time IO Tutorial</title>
+ <bridgehead renderas="sect2">Date Time IO Tutorial</bridgehead>
+
+ <link linkend="basic_use">Basic Use</link> |
+ <link linkend="format_strings">Format Strings</link> |
+ <link linkend="content_strings">Content Strings</link> |
+ <link linkend="tut_sv">Special Values</link> |
+ <link linkend="tut_dper">Date/Time Periods</link> |
+ <link linkend="tut_dgen">Date Generators</link>
+
+ <anchor id="basic_use" />
+ <bridgehead renderas="sect4">Basic Use</bridgehead>
+ <para>Facets are automatically imbued when operators '>>' and '&lt;&lt;' are called. The list of date_time objects that can be streamed are:</para>
+ <bridgehead renderas="sect5">Gregorian</bridgehead>
+ <para>
+ <code>date</code>,
+ <code>days</code>,
+ <code>date_period</code>,
+ <code>greg_month</code>,
+ <code>greg_weekday</code>,
+ <code>greg_year</code>,
+ <code>partial_date</code>,
+ <code>nth_day_of_the_week_in_month</code>,
+ <code>first_day_of_the_week_in_month</code>,
+ <code>last_day_of_the_week_in_month</code>,
+ <code>first_day_of_the_week_after</code>,
+ <code>first_day_of_the_week_before</code>
+ </para>
+ <bridgehead renderas="sect5">Posix_time</bridgehead>
+ <para>
+ <code>ptime</code>,
+ <code>time_period</code>,
+ <code>time_duration</code>
+ </para>
+ <bridgehead renderas="sect5">Local_time</bridgehead>
+ <para>
+ <code>local_date_time</code>
+ </para>
+
+ <para>
+ The following example is of the basic use of the new IO code, utilizing all the defaults. (this example can be found in the <code>libs/date_time/examples/tutorial</code> directory)
+ </para>
+ <programlisting>
+ <![CDATA[
+ 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"
+ ]]>
+ </programlisting>
+
+ <para>This example used the default settings for the input and output facets. The default formats are such that interoperability like that shown in the example is possible. NOTE: Input streaming of local_date_time can only be done with a <link linkend="date_time.local_time.posix_time_zone">posix time zone string</link>. The default output format uses a time zone abbreviation. The format can be changed so out and in match (as we will see later in this tutorial).</para>
+
+ <anchor id="format_strings" />
+ <bridgehead renderas="sect4">Format Strings</bridgehead>
+ <para>The format strings control the order, type, and style of the date/time elements used. The facets provide some predefined formats (iso_format_specifier, iso_format_extended_specifier, and default_date_format) but the user can easily create their own.</para>
+ (continued from previous example)
+ <programlisting>
+ <![CDATA[
+ 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"
+ ]]>
+ </programlisting>
+
+ <para>Format strings are not limited to date/time elements. Extra verbiage can be placed in a format string. NOTE: When extra verbiage is present in an input format, the data being input must also contain the exact verbiage.</para>
+ (continued from previous example)
+ <programlisting>
+ <![CDATA[
+ // 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;
+ ]]>
+ </programlisting>
+
+ <anchor id="content_strings" />
+ <bridgehead renderas="sect4">Content Strings</bridgehead>
+ <para>So far we've shown how a user can achieve a great deal of customization with very little effort by using formats. Further customization can be achieved through user defined elements (ie strings). The elements that can be customized are: Special value names, month names, month abbreviations, weekday names, weekday abbreviations, delimiters of the date/time periods, and the phrase elements of the date_generators.</para>
+ <para>The default values for these are as follows:</para>
+ <bridgehead renderas="sect5">Special values</bridgehead>
+ <para>
+ <code>not-a-date-time</code>,
+ <code>-infinity</code>,
+ <code>+infinity</code>,
+ <code>minimum-date-time</code>,
+ <code>maximum-date-time</code>
+ </para>
+ <bridgehead renderas="sect5">Months</bridgehead>
+ <para>
+ <code>English calendar and three letter abbreviations</code>
+ </para>
+ <bridgehead renderas="sect5">Weekdays</bridgehead>
+ <para>
+ <code>English calendar and three letter abbreviations</code>
+ </para>
+ <bridgehead renderas="sect5">Date generator phrase elements</bridgehead>
+ <para>
+ <code>first</code>,
+ <code>second</code>,
+ <code>third</code>,
+ <code>fourth</code>,
+ <code>fifth</code>,
+ <code>last</code>,
+ <code>before</code>,
+ <code>after</code>,
+ <code>of</code>
+ </para>
+ <para>NOTE: We've shown earlier that the components of a date/time representation can be re-ordered via the format string. This is not the case with date_generators. The elements themselves can be customized but their order cannot be changed.</para>
+
+ <bridgehead renderas="sect4">Content Strings</bridgehead>
+ <para>To illustrate the customization possibilities we will use custom strings for months and weekdays (we will only use long names, is all lowercase, for this example).</para>
+ (continued from previous example)
+ <programlisting>
+ <![CDATA[
+ // 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<string> long_months(&month_names[0], &month_names[12]);
+ string day_names[7] = { "sunday", "monday", "tuesday", "wednesday",
+ "thursday", "friday", "saturday" };
+ vector<string> 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"
+ ]]>
+ </programlisting>
+
+
+ <anchor id="tut_sv" />
+ <bridgehead renderas="sect4">Special Values</bridgehead>
+ <para>Customizing the input and output of special values is best done by creating a new special_values_parser and special_values_formatter. The new strings can be set at construction time (as in the example below).</para>
+ (continued from previous example)
+ <programlisting>
+ <![CDATA[
+ // 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<string> 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"
+ ]]>
+ </programlisting>
+ <para>NOTE: even though we sent in strings for min and max to the formatter, they are ignored because those special values construct to actual dates (as shown above).</para>
+
+
+ <anchor id="tut_dper" />
+ <bridgehead renderas="sect4">Date/Time Periods</bridgehead>
+ <para>Customizing the input and output of periods is best done by creating a new period_parser and period_formatter. The new strings can be set at construction time (as in the example below).</para>
+ (continued from previous example)
+ <programlisting>
+ <![CDATA[
+ // all formats set back to defaults (not shown for brevity)
+
+ // 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"
+ ]]>
+ </programlisting>
+
+ <anchor id="tut_dgen" />
+ <bridgehead renderas="sect4">Date Generators</bridgehead>
+ <para>Customizing the input and output of date_generators is done by replacing the existing strings (in the facet) with new strings.</para>
+ <para>NOTE: We've shown earlier that the components of a date/time representation can be re-ordered via the format string. This is not the case with date_generators. The elements themselves can be customized but their order cannot be changed.</para>
+ (continued from previous example)
+ <programlisting>
+ <![CDATA[
+ // custom date_generator phrases
+ string dg_phrases[9] = { "1st", "2nd", "3rd", "4th", "5th",
+ "final", "prior to", "following", "in" };
+ vector<string> 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"
+ ]]>
+ </programlisting>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/license.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/license.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Copyright (c) 2001-2006 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.license">
+ <title>Boost Date-Time Library License</title>
+ <bridgehead renderas="sect2">Boost Date-Time Library License</bridgehead>
+ <!--
+ <ulink url="../../../index.htm">
+ <imagedata align="left"
+ format="GIF"
+ fileref="../../../boost.png"
+ alt="C++ Boost" />
+ </ulink>-->
+ <!--hr /-->
+ <para>
+ The following is the overall license for the boost date_time
+ library. This notice is found in all source files related to the
+ library.
+ </para>
+ <para>
+ Copyright &#169; 2002 CrystalClear Software, Inc.
+ </para>
+ <para>
+ 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.
+ </para>
+ <!--hr / -->
+ <ulink url="mailto:jeff_at_[hidden]">Jeff Garland</ulink>
+ &#169; 2000-2002
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/local_date_time.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/local_date_time.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,463 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.local_time.local_date_time">
+ <title>Local Date Time</title>
+
+ <link linkend="local_date_time_intro">Introduction</link> --
+ <link linkend="local_date_time_header">Header</link> --
+ <link linkend="local_date_time_clock_constr">Construct From Clock</link> --
+ <link linkend="local_date_time_constr">Construction</link> --
+ <link linkend="local_date_time_accessors">Accessors</link> --
+ <link linkend="local_date_time_operators">Operators</link> --
+ <link linkend="local_date_time_tm_func">Struct tm Functions</link>
+
+ <anchor id="local_date_time_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ A local_date_time object is a point in time and an associated time zone. The time is represented internally as UTC.
+ </para>
+
+ <anchor id="local_date_time_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ The inclusion of a single header will bring in all boost::local_time types,
+functions, and IO operators.
+ <programlisting>
+ #include "boost/date_time/local_time/local_time.hpp"
+ </programlisting>
+ </para>
+
+ <anchor id="local_date_time_clock_constr" />
+ <bridgehead renderas="sect3">Construct From Clock</bridgehead>
+ <para>
+ Creation of a local_date_time object from clock is possible with either second, or sub second resolution.
+ </para>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Syntax</entry>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>local_microsec_clock(...)
+ Return Type:
+ local_date_time
+ Parameter:
+ time_zone_ptr</screen></entry>
+ <entry><screen>time_zone_ptr zone(
+ new posix_time_zone("MST-07")
+);
+local_date_time ldt =
+ local_microsec_clock::local_time(
+ zone);</screen>
+ </entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>local_sec_clock(...)
+ Return Type:
+ local_date_time
+ Parameter:
+ time_zone_ptr</screen></entry>
+ <entry><screen>time_zone_ptr zone(
+ new posix_time_zone("MST-07")
+);
+local_date_time ldt =
+ local_sec_clock::local_time(zone);</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="local_date_time_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ Construction of a local_date_time object can be done with a ptime and a time_zone_ptr where the ptime represents UTC time. Construction with a wall-clock representation takes the form of a date, a time_duration, a time_zone_ptr, and a fourth parameter that addresses the following complication.
+ </para>
+ <para>
+ Construction from a wall-clock rep may result in differing shifts for a particular time zone, depending on daylight savings rules for that zone. This means it is also possible to create a local_date_time with a non-existent, or duplicated, UTC representation. These cases occur during the forward shift in time that is the transition into daylight savings and during the backward shift that is the transition out of daylight savings. The user has two options for handling these cases: a bool flag that states if the time is daylight savings, or an enum that states what to do when either of these cases are encountered.
+ </para>
+ <para>
+ The bool flag is ignored when the given time_zone has no daylight savings specification. When the daylight savings status of a given time label is calculated and it does not match the flag, a <code>local_time::dst_not_valid</code> exception is thrown. If a time label is invalid (does not exist), a <code>local_time::time_label_invalid</code> exception is thrown.
+ </para>
+ <para>
+ There are two elements in the <code>local_date_time::DST_CALC_OPTIONS</code> enum: <code>EXCEPTION_ON_ERROR</code> and <code>NOT_DATE_TIME_ON_ERROR</code>. The possible exceptions thrown are a <code>local_time::ambiguous_result</code> or a <code>local_time::time_label_invalid</code>. The <code>NOT_DATE_TIME_ON_ERROR</code> sets the time value to the special value <code>local_time::not_a_date_time</code> in the event of either a invalid or an ambiguous time label.
+ </para>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>local_date_time(...)
+ Parameters:
+ posix_time::ptime
+ time_zone_ptr</screen></entry>
+ <entry>The given time is expected to be UTC. Therefore, the given time will be adjusted according to the offset described in the time zone.</entry>
+ </row>
+ <row>
+ <entry><screen>
+// 3am, 2004-Nov-05 local time
+ptime pt(date(2004,Nov,5),
+ hours(10));
+time_zone_ptr zone(
+ new posix_time_zone("MST-07"));
+local_date_time az(pt, zone);</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_date_time(...)
+ Parameters:
+ date
+ time_duration
+ time_zone_ptr
+ bool</screen></entry>
+<entry>The passed time information understood to be in the passed tz. The DST flag must be passed to indicate whether the time is in daylight savings or not. May throw a <code>dst_not_valid</code> or <code>time_label_invalid</code> exception.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2004,Nov,5);
+time_duration td(5,0,0,0);
+string z("PST-8PDT,M4.1.0,M10.1.0")
+time_zone_ptr zone(
+ new posix_time_zone(z));
+local_date_time nyc(d, td,
+ zone, false);</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_date_time(...)
+ Parameters:
+ date
+ time_duration
+ time_zone_ptr
+ DST_CALC_OPTIONS</screen></entry>
+ <entry>The passed time information understood to be in the passed tz. The DST flag is calculated according to the specified rule. May throw a <code>ambiguous_result</code> or <code>time_label_invalid</code> exception.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2004,Nov,5);
+time_duration td(5,0,0,0);
+string z("PST-8PDT,M4.1.0,M10.1.0")
+time_zone_ptr zone(
+ new posix_time_zone(z));
+local_date_time nyc(d, td, zone,
+ NOT_DATE_TIME_ON_ERROR);</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_date_time(local_date_time);</screen></entry>
+ <entry>Copy Constructor.</entry>
+ </row>
+ <row>
+ <entry><screen>local_date_time az_2(az);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_date_time(...)
+ Parameters:
+ special_values
+ time_zone_ptr</screen></entry>
+ <entry>Special Values constructor.</entry>
+ </row>
+ <row>
+ <entry><screen>time_zone_ptr zone(
+ new posix_time_zone("MST-07")
+);
+local_date_time nadt(not_a_date_time,
+ zone);
+// default NULL time_zone_ptr
+local_date_time nadt(pos_infin);</screen>
+ </entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="local_date_time_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>time_zone_ptr zone()</screen></entry>
+ <entry>Returns associated time_zone object via a time_zone_ptr</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_dst()</screen></entry>
+ <entry>Determines if time value is in DST for associated zone.</entry>
+ </row>
+ <row>
+ <entry></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime utc_time()</screen></entry>
+ <entry>Converts the local time value to a UTC value.</entry>
+ </row>
+ <row>
+ <entry><screen>ptime pt(date(2004,Nov,5),
+ hours(10));
+time_zone_ptr zone(
+ new posix_time_zone("MST-07"));
+local_date_time az(pt, zone);
+az.utc_time(); // 10am 2004-Nov-5</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime local_time()</screen></entry>
+ <entry>Returns the local time for this object (Wall-clock).</entry>
+ </row>
+ <row>
+ <entry><screen>ptime pt(date(2004,Nov,5),
+ hours(10));
+time_zone_ptr zone(
+ new posix_time_zone("MST-07"));
+local_date_time az(pt, zone);
+az.utc_time(); // 10am 2004-Nov-5
+az.local_time(); // 3am 2004-Nov-5</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_time_in(...)
+ Return Type:
+ local_date_time
+ Parameters:
+ time_zone_ptr
+ time_duration</screen></entry>
+ <entry>Returns a local_date_time representing the same UTC time as calling object, plus optional time_duration, with given time zone.</entry>
+ </row>
+ <row>
+ <entry><screen>local_date_time nyc = az.local_time_in(nyc_zone);
+// nyc == 7am 2004-Nov-5</screen>
+ </entry>
+ </row>
+ <!--
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string zone_name()</screen></entry>
+ <entry>Returns full zone name from associated time zone or "Coordinated Universal Time" if time_zone_ptr is NULL.</entry>
+ </row>
+ <row>
+ <entry>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string zone_abbrev()</screen></entry>
+ <entry>Returns zone abbreviation from associated time zone or "UTC" if time_zone_ptr is NULL.</entry>
+ </row>
+ <row>
+ <entry>
+ </entry>
+ </row>
+ -->
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_infinity() const</screen></entry>
+ <entry>Returns true if local_date_time is either positive or negative infinity</entry>
+ </row>
+ <row>
+ <entry><screen>local_date_time ldt(pos_infin);
+ldt.is_infinity(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_neg_infinity() const</screen></entry>
+ <entry>Returns true if local_date_time is negative infinity</entry>
+ </row>
+ <row>
+ <entry><screen>local_date_time ldt(neg_infin);
+ldt.is_neg_infinity(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_pos_infinity() const</screen></entry>
+ <entry>Returns true if local_date_time is positive infinity</entry>
+ </row>
+ <row>
+ <entry><screen>local_date_time ldt(neg_infin);
+ldt.is_pos_infinity(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_not_a_date_time() const</screen></entry>
+ <entry>Returns true if value is not a date</entry>
+ </row>
+ <row>
+ <entry><screen>local_date_time ldt(not_a_date_time);
+ldt.is_not_a_date_time(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_special() const</screen></entry>
+ <entry>Returns true if local_date_time is any <code>special_value</code></entry>
+ </row>
+ <row>
+ <entry><screen>local_date_time ldt(pos_infin);
+local_date_time ldt2(not_a_date_time);
+time_zone_ptr
+ mst(new posix_time_zone("MST-07"));
+local_date_time
+ ldt3(local_sec_clock::local_time(mst));
+ldt.is_special(); // --> true
+ldt2.is_special(); // --> true
+ldt3.is_special(); // --> false</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="local_date_time_operators" />
+ <bridgehead renderas="sect3">Operators</bridgehead>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;&lt;</screen></entry>
+ <entry>Output streaming operator. This operator is part of the v1.33 IO addition to date_time. For complete details on this feature see <link linkend="date_time.date_time_io">Date Time IO</link>. The default output is shown in this example.</entry>
+ </row>
+ <row>
+ <entry><screen>
+time_zone_ptr zone(new posix_time_zone("MST-07");
+local_date_time ldt(date(2005,Jul,4),
+ hours(20),
+ false);
+std::cout &lt;&lt; ldt &lt;&lt; std::endl;
+// "2005-Jul-04 20:00:00 MST"
+ </screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator>></screen></entry>
+ <entry>Input streaming operator. This operator is part of the v1.33 IO addition to date_time. For complete details on this feature see <link linkend="date_time.date_time_io">Date Time IO</link>. At this time, <code>local_date_time</code> objects can only be streamed in with a Posix Time Zone string. A complete description of a Posix Time Zone string can be found in the documentation for the <link linkend="posix_time_zone_intro">posix_time_zone</link> class.</entry>
+ </row>
+ <row>
+ <entry><screen>stringstream ss;
+ss.str("2005-Jul-04 20:00:00 MST-07");
+ss >> ldt;
+ </screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator==, operator!=,
+operator>, operator&lt;,
+operator>=, operator&lt;=</screen></entry>
+ <entry>A full complement of comparison operators</entry>
+ </row>
+ <row>
+ <entry><screen>ldt1 == ldt2, etc</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator+, operator+=,
+operator-, operator-=</screen></entry>
+ <entry>Addition, subtraction, and shortcut operators for <code>local_date_time</code> and date duration types. These include: <code>days</code>, <code>months</code>, and <code>years</code>.</entry>
+ </row>
+ <row>
+ <entry><screen>ldt + days(5), etc</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator+, operator+=,
+operator-, operator-=</screen></entry>
+ <entry>Addition, subtraction, and shortcut operators for <code>local_date_time</code> and <code>time_duration</code>.</entry>
+ </row>
+ <row>
+ <entry><screen>ldt + hours(5), etc</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <anchor id="local_date_time_tm_func" />
+ <bridgehead renderas="sect3">Struct tm Functions</bridgehead>
+ <para>Function for converting a <code>local_date_time</code> object to a <code>tm</code> struct is provided.</para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>tm to_tm(local_date_time)</screen></entry>
+ <entry>A function for converting a <code>local_date_time</code> object to a <code>tm</code> struct.</entry>
+ </row>
+ <row>
+ <entry><screen>
+// 6am, 2005-Jul-05 local time
+std::string z("EST-05EDT,M4.1.0,M10.1.0");
+ptime pt(date(2005,Jul,5),
+ hours(10));
+time_zone_ptr zone( new posix_time_zone(z));
+local_date_time ldt(pt, zone);
+tm ldt_tm = to_tm(ldt);
+/* tm_year => 105
+ tm_mon => 6
+ tm_mday => 5
+ tm_wday => 2 (Tuesday)
+ tm_yday => 185
+ tm_hour => 6
+ tm_min => 0
+ tm_sec => 0
+ tm_isddst => 1 */</screen>
+ </entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/local_time.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/local_time.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.local_time"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Local Time</title>
+ <bridgehead renderas="sect2">Local Time System</bridgehead>
+ <para>
+ <link linkend="local_intro">Introduction</link> --
+ <link linkend="local_ex">Usage Examples</link>
+ </para>
+
+ <anchor id="local_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ The library supports 4 main extensions for the management of local times. This includes
+ <simplelist>
+ <member>local_date_time -- locally adjusted time point</member>
+ <member>posix_time_zone -- time zone defined by posix string (eg: "EST10EDT,M10.5.0,M3.5.0/03")</member>
+ <member>time_zone_database -- get time zones by region from .csv file (eg: America/New York)</member>
+ <member>time_zone -- abstract time zone interface</member>
+ </simplelist>
+ </para>
+ <para>
+ Together, these extensions define a time system adjusted for recording times related to a specific earth location. This time system utilizes all the features and benefits of the posix_time system (see <link linkend="date_time.posix_time">posix_time</link> for full details). It uses a time_zone object which contains all the necessary data/rules to enable adjustments to and from various time zones. The time_zone objects used in date_time are handled via a boost::shared_ptr&lt;boost::local_time::time_zone&gt;.
+ </para>
+ <para>
+ The phrase "wall-clock" refers to the time that would be shown on a wall clock in a particular time zone at any point in time. Local_time uses a time zone object to account for differences in time zones and daylight savings adjustments. For example: While 5:00 pm, October 10, 2004 in Sydney Australia occurs at exactly the same instant as 3:00 am, October 10, 2004 in New York USA, it is a 14 hour difference in wall-clock times. However, a point in time just one day later will result in a 16 hour difference in wall-clock time due to daylight savings adjustments in both time zones. The local_time system tracks these by means of a time point, stored as UTC, and time_zone objects that contain all the necessary data to correctly calculate wall-clock times.
+ </para>
+
+ <anchor id="local_ex" />
+ <bridgehead renderas="sect3">Usage Examples</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Example</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><link linkend="date_time.examples.simple_time_zone">Simple Time Zone</link></entry>
+ <entry>Side by side examples of Time Zone usage. Both <type>custom_time_zone</type> and <type>posix_time_zone</type> are shown.</entry>
+ </row>
+ <row>
+ <entry><link linkend="date_time.examples.calc_rules">Daylight Savings Calc Rules</link></entry>
+ <entry>Simple example showing the creation of all five <type>dst_calc_rule</type> types.</entry>
+ </row>
+ <row>
+ <entry><link linkend="date_time.examples.seconds_since_epoch">Seconds Since Epoch</link></entry>
+ <entry>Example that calculates the total seconds elapsed since the epoch (1970-Jan-01) utilizing local_date_time.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <!-- this order chosen on 2005-Jan-30 -->
+ <xi:include href="time_zone_base.xml" />
+ <xi:include href="posix_time_zone.xml" />
+ <xi:include href="tz_database.xml" />
+ <xi:include href="custom_time_zone.xml" />
+ <xi:include href="local_date_time.xml" />
+ <xi:include href="local_time_period.xml" />
+ <!--<xi:include href=".xml" /> for serialization -->
+ <!-- includes here -->
+
+</section>
+

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/local_time_period.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/local_time_period.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,383 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.local_time.local_time_period">
+ <title>Local Time Period</title>
+
+ <link linkend="local_time_period_intro">Introduction</link> --
+ <link linkend="local_time_period_header">Header</link> --
+ <link linkend="local_time_period_constr">Construction</link> --
+ <link linkend="local_time_period_accessors">Accessors</link> --
+ <link linkend="local_time_period_operators">Operators</link>
+
+ <anchor id="local_time_period_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ The class <code>boost::local_time::local_time_period</code> provides direct representation for ranges between two local times. Periods provide the ability to simplify some types of calculations by simplifying the conditional logic of the program.
+ </para>
+ <para>
+ 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 <code>last</code> point will always be one unit less that the <code>begin</code> point.
+ </para>
+
+ <anchor id="local_time_period_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ <programlisting>#include "boost/date_time/local_time/local_time.hpp" //include all types plus i/o
+or
+#include "boost/date_time/local_time/local_time_types.hpp" //no i/o just types</programlisting>
+ </para>
+
+ <anchor id="local_time_period_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>local_time_period(...)
+ Parameters:
+ local_date_time beginning
+ local_date_time end</screen></entry>
+ <entry> Create a period as [begin, end). If end is &lt;= begin then the period will be defined as invalid.</entry>
+ </row>
+ <row>
+ <entry><screen>time_zone_ptr
+ zone(new posix_time_zone("MST-07"));
+local_date_time
+ beg(ptime(date(2005,Jan,1),hours(0)), zone);
+local_date_time
+ end(ptime(date(2005,Feb,1),hours(0)), zone);
+// period for the entire month of Jan 2005
+local_time_period ltp(beg, end);</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_time_period(...)
+ Parameters:
+ local_date_time beginning
+ time_duration length</screen></entry>
+ <entry>Create a period as [begin, begin+len) where end would be begin+len. If len is &lt;= zero then the period will be defined as invalid.</entry>
+ </row>
+ <row>
+ <entry><screen>time_zone_ptr
+ zone(new posix_time_zone("MST-07"));
+local_date_time
+ beg(ptime(date(2005,Jan,1),hours(0)), zone);
+// period for the whole day of 2005-Jan-01
+local_time_period ltp(beg, hours(24));</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_time_period(local_time_period rhs)</screen></entry>
+ <entry>Copy constructor</entry>
+ </row>
+ <row>
+ <entry><screen>local_time_period ltp1(ltp);</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="local_time_period_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>local_date_time begin()</screen></entry>
+ <entry>Return first local_date_time of the period.</entry>
+ </row>
+ <row>
+ <entry><screen>time_zone_ptr
+ zone(new posix_time_zone("MST-07"));
+local_date_time
+ ldt((ptime(date(2005,Jan,1)),hours(0)), zone);
+local_time_period ltp(ldt, hours(2));
+ltp.begin(); // => 2005-Jan-01 00:00:00</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_date_time last()</screen></entry>
+ <entry>Return last local_date_time in the period</entry>
+ </row>
+ <row>
+ <entry><screen>time_zone_ptr
+ zone(new posix_time_zone("MST-07"));
+local_date_time
+ ldt((ptime(date(2005,Jan,1),hours(0))), zone);
+local_time_period ltp(ldt, hours(2));
+ltp.last(); // => 2005-Jan-01 01:59:59.999999999</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_date_time end()</screen></entry>
+ <entry>Return one past the last in period</entry>
+ </row>
+ <row>
+ <entry><screen>time_zone_ptr
+ zone(new posix_time_zone("MST-07"));
+local_date_time
+ ldt((ptime(date(2005,Jan,1),hours(0))), zone);
+local_time_period ltp(ldt, hours(2));
+ltp.end(); // => 2005-Jan-01 02:00:00</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration length()</screen></entry>
+ <entry>Return the length of the local_time period.</entry>
+ </row>
+ <row>
+ <entry><screen>time_zone_ptr
+ zone(new posix_time_zone("MST-07"));
+local_date_time
+ ldt((ptime(date(2005,Jan,1),hours(0))), zone);
+local_time_period ltp(ldt, hours(2));
+ltp.length(); // => 02:00:00</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_null()</screen></entry>
+ <entry>True if period is not well formed. eg: end less than or equal to begin.</entry>
+ </row>
+ <row>
+ <entry><screen>time_zone_ptr
+ zone(new posix_time_zone("MST-07"));
+local_date_time
+ beg((ptime(date(2005,Feb,1),hours(0))), zone);
+local_date_time
+ end((ptime(date(2005,Jan,1),hours(0))), zone);
+local_time_period ltp(beg, end);
+ltp.is_null(); // => true</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool contains(local_date_time)</screen></entry>
+ <entry>True if local_date_time is within the period. Zero length periods cannot contain any points</entry>
+ </row>
+ <row>
+ <entry><screen>time_zone_ptr
+ zone(new posix_time_zone("MST-07"));
+local_date_time
+ beg((ptime(date(2005,Jan,1),hours(0))), zone);
+local_date_time
+ end((ptime(date(2005,Feb,1),hours(0))), zone);
+local_time_period jan_mst(beg, end);
+
+local_date_time
+ldt((ptime(date(2005,Jan,15),hours(12))), zone);
+jan_mst.contains(ldt); // => true
+
+local_time_period zero(beg, beg);
+zero.contains(beg); // false</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool contains(local_time_period)</screen></entry>
+ <entry>True if period is within the period</entry>
+ </row>
+ <row>
+ <entry><screen>// using jan_mst period from previous example
+
+local_date_time
+ beg((ptime(date(2005,Jan,7),hours(0))), zone);
+local_time_period ltp(beg, hours(24));
+
+jan_mst.contains(ltp); // => true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool intersects(local_time_period)</screen></entry>
+ <entry> True if periods overlap</entry>
+ </row>
+ <row>
+ <entry><screen>// using jan_mst period from previous example
+
+local_date_time
+ beg((ptime(date(2005,Jan,7),hours(0))), zone);
+local_date_time
+ end((ptime(date(2005,Feb,7),hours(0))), zone);
+local_time_period ltp(beg, end);
+
+jan_mst.intersects(ltp); // => true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_time_period intersection(local_time_period)</screen></entry>
+ <entry>Calculate the intersection of 2 periods. Null if no intersection.</entry>
+ </row>
+ <row>
+ <entry><screen>// using jan_mst period from previous example
+
+local_date_time
+ beg((ptime(date(2005,Jan,7),hours(0))), zone);
+local_date_time
+ end((ptime(date(2005,Feb,7),hours(0))), zone);
+local_time_period ltp(beg, end);
+
+local_time_period res(jan_mst.intersection(ltp));
+// res => 2005-Jan-07 00:00:00 through
+// 2005-Jan-31 23:59:59.999999999 (inclusive)</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_time_period merge(local_time_period)</screen></entry>
+ <entry>Returns union of two periods. Null if no intersection.</entry>
+ </row>
+ <row>
+ <entry><screen>// using jan_mst period from previous example
+
+local_date_time
+ beg((ptime(date(2005,Jan,7),hours(0))), zone);
+local_date_time
+ end((ptime(date(2005,Feb,7),hours(0))), zone);
+local_time_period ltp(beg, end);
+
+local_time_period res(jan_mst.merge(ltp));
+// res => 2005-Jan-07 00:00:00 through
+// 2005-Feb-06 23:59:59.999999999 (inclusive)</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>local_time_period span(local_time_period)</screen></entry>
+ <entry>Combines two periods and any gap between them such that begin = min(p1.begin, p2.begin) and end = max(p1.end , p2.end).</entry>
+ </row>
+ <row>
+ <entry><screen>// using jan_mst period from previous example
+
+local_date_time
+ beg((ptime(date(2005,Mar,1),hours(0))), zone);
+local_date_time
+ end((ptime(date(2005,Apr,1),hours(0))), zone);
+local_time_period mar_mst(beg, end);
+
+local_time_period res(jan_mst.span(mar_mst));
+// res => 2005-Jan-01 00:00:00 through
+// 2005-Mar-31 23:59:59.999999999 (inclusive)</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void shift(time_duration)</screen></entry>
+ <entry>Add duration to both begin and end.</entry>
+ </row>
+ <row>
+ <entry><screen>local_date_time
+ beg((ptime(date(2005,Mar,1),hours(0))), zone);
+local_date_time
+ end((ptime(date(2005,Apr,1),hours(0))), zone);
+local_time_period mar_mst(beg, end);
+
+mar_mst.shift(hours(48));
+// mar_mst => 2005-Mar-03 00:00:00 through
+// 2005-Apr-02 23:59:59.999999999 (inclusive)</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="local_time_period_operators" />
+ <bridgehead renderas="sect3">Operators</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <!-- TODO: the streaming operators have not bee changed from time_period to local_time_period
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;&lt;</screen></entry>
+ <entry>Output streaming operator for time duration. Uses facet to output [date time_of_day/date time_of_day]. The default is format is <code>[YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff]</code> string where <code>mmm</code> is 3 char month name and the fractional seconds are left out when zero.</entry>
+ </row>
+ <row>
+ <entry><screen>[2002-Jan-01 01:25:10.000000001/ \
+ 2002-Jan-31 01:25:10.123456789]</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&gt;&gt;</screen></entry>
+ <entry>Input streaming operator for time duration. Uses facet to read [date time_of_day/date time_of_day]. The default is format is <code>[YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff]</code> string where <code>mmm</code> is 3 char month name and the fractional seconds are left out when zero.</entry>
+ </row>
+ <row>
+ <entry><screen>[2002-Jan-01 01:25:10.000000001/ \
+ 2002-Jan-31 01:25:10.123456789]</screen></entry>
+ </row>
+ -->
+ <row>
+ <entry valign="top" morerows="1"><screen>operator==, operator!=</screen></entry>
+ <entry>Equality operators. Periods are equal if ltp1.begin == ltp2.begin &amp;&amp; ltp1.last == ltp2.last</entry>
+ </row>
+ <row>
+ <entry><screen>if (ltp1 == ltp2) {...</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;</screen></entry>
+ <entry>Ordering with no overlap. True if ltp1.end() less than ltp2.begin()</entry>
+ </row>
+ <row>
+ <entry><screen>if (ltp1 &lt; ltp2) {...</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&gt;</screen></entry>
+ <entry>Ordering with no overlap. True if ltp1.begin() greater than ltp2.end()</entry>
+ </row>
+ <row>
+ <entry><screen>if (ltp1 > ltp2) {... etc</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;=, operator&gt;=</screen></entry>
+ <entry>Defined in terms of the other operators.</entry>
+ </row>
+ <row>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/motivation.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/motivation.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Copyright (c) 2001-2006 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="Motivation">
+ <title>Motivation</title>
+
+ <para>
+ The motivation for this library comes from working with and helping build several date-time libraries on several projects. Date-time libraries provide fundamental infrastructure for most development projects. However, most of them have limitations in their ability to calculate, format, convert, or perform some other functionality. For example, most libraries do not correctly handle leap seconds, provide concepts such as infinity, or provide the ability to use high resolution or network time sources. These libraries also tend to be rigid in their representation of dates and times. Thus customized policies for a project or subproject are not possible.
+ </para>
+ <para>
+ Programming with dates and times should be almost as simple and natural as programming with strings and integers. Applications with lots of temporal logic can be radically simplified by having a robust set of operators and calculation capabilities. Classes should provide the ability to compare dates and times, add lengths or time durations, retrieve dates and times from clocks, and work naturally with date and time intervals.
+ </para>
+ <para>
+ Another motivation for development of the library was to apply modern C++ library design techniques to the date-time domain. Really to build a framework for the construction of building temporal types. For example, by providing iterators and traits classes to control fundamental properties of the library. To the authors knowledge this library is the only substantial attempt to apply modern C++ to a date-time library.
+ </para>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/posix_time.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/posix_time.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.posix_time"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Posix Time</title>
+ <bridgehead renderas="sect2">Posix Time System</bridgehead>
+ <para>
+ <link linkend="posix_intro">Introduction</link> --
+ <link linkend="posix_ex">Usage Examples</link>
+ </para>
+
+ <anchor id="posix_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ Defines a non-adjusted time system with nano-second/micro-second resolution and stable calculation properties. The nano-second resolution option uses 96 bits of underlying storage for each ptime while the micro-second resolution uses 64 bits per ptime (see <link linkend="date_time.buildinfo">Build Options</link> for details). This time system uses the Gregorian calendar to implement the date portion of the time representation.
+ </para>
+
+ <anchor id="posix_ex" />
+ <bridgehead renderas="sect3">Usage Examples</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Example</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><link linkend="date_time.examples.time_math">Time Math</link></entry>
+ <entry>A few simple calculations using ptime and time_durations.</entry>
+ </row>
+ <row>
+ <entry><link linkend="date_time.examples.print_hours">Print Hours</link></entry>
+ <entry>Retrieve time from clock, use a time_iterator.</entry>
+ </row>
+ <row>
+ <entry><link linkend="date_time.examples.local_utc_conversion">Local to UTC Conversion</link></entry>
+ <entry>Demonstrates a couple different ways to convert a local to UTC time including daylight savings rules.</entry>
+ </row>
+ <row>
+ <entry><link linkend="date_time.examples.time_periods">Time Periods</link></entry>
+ <entry>Some simple examples of intersection and display of time periods.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <xi:include href="ptime_class.xml" />
+ <xi:include href="time_duration.xml" />
+ <xi:include href="time_period.xml" />
+ <xi:include href="time_iterators.xml" />
+ <!-- includes here -->
+
+</section>
+

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/posix_time_zone.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/posix_time_zone.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,224 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.local_time.posix_time_zone">
+ <title>Posix Time Zone</title>
+
+ <link linkend="posix_time_zone_intro">Introduction</link> --
+ <link linkend="posix_time_zone_notes">Important Notes</link> --
+ <link linkend="posix_time_zone_header">Header</link> --
+ <link linkend="posix_time_zone_constr">Construction</link> --
+ <link linkend="posix_time_zone_accessors">Accessors</link>
+
+ <anchor id="posix_time_zone_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ A posix_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 <link linkend="date_time.local_time.dst_calc_rules">dst_calc_rules</link>. These rules are stored as a boost::shared_ptr&lt;dst_calc_rules&gt;.
+ </para>
+ <para>
+ As a convenience, a typedef for shared_ptr&lt;dst_calc_rules&gt; is provided.
+ <programlisting>typedef boost::shared_ptr&lt;dst_calc_rules&gt; local_time::dst_calc_rule_ptr;</programlisting>
+ </para>
+ <para>
+ A posix_time_zone is unique in that the object is created from a Posix time zone string (IEEE Std 1003.1). A POSIX time zone string takes the form of:
+ <literallayout>
+ "std offset dst [offset],start[/time],end[/time]" (w/no spaces).</literallayout>'std' specifies the abbrev of the time zone. 'offset' is the offset from UTC. 'dst' specifies the abbrev of the time zone during daylight savings time. The second offset is how many hours changed during DST. 'start' and 'end' are the dates when DST goes into (and out of) effect. 'offset' takes the form of:
+ <literallayout>
+ [+|-]hh[:mm[:ss]] {h=0-23, m/s=0-59}</literallayout>'time' and 'offset' take the same form. 'start' and 'end' can be one of three forms:
+ <literallayout>
+ Mm.w.d {month=1-12, week=1-5 (5 is always last), day=0-6}
+ Jn {n=1-365 Feb29 is never counted}
+ n {n=0-365 Feb29 is counted in leap years}</literallayout>
+ </para>
+ <para>
+ Exceptions will be thrown under the following conditions:
+ <itemizedlist>
+ <listitem>An exception will be thrown for an invalid date spec (see <link linkend="date_time.gregorian.date_class">date class</link>).</listitem>
+ <listitem>A boost::local_time::bad_offset exception will be thrown for:</listitem>
+ <listitem>A DST start or end offset that is negative or more than 24 hours.</listitem>
+ <listitem>A UTC zone that is greater than +12 or less than -12 hours.</listitem>
+ <listitem>A boost::local_time::bad_adjustment exception will be thrown for a DST adjustment that is 24 hours or more (positive or negative)</listitem>
+ </itemizedlist>
+ </para>
+ <para>As stated above, the 'offset' and '/time' portions of the string are not required. If they are not given they default to 01:00 for 'offset', and 02:00 for both occurrences of '/time'.
+ </para>
+ <para>
+ Some examples are:
+ <literallayout>
+ "PST-8PDT01:00:00,M4.1.0/02:00:00,M10.1.0/02:00:00"
+ "PST-8PDT,M4.1.0,M10.1.0"</literallayout>These two are actually the same specification (defaults were used in the second string). This zone lies eight hours west of GMT and makes a one hour shift forward during daylight savings time. Daylight savings for this zone starts on the first Sunday of April at 2am, and ends on the first Sunday of October at 2am.
+ <literallayout>
+ "MST-7"</literallayout>This zone is as simple as it gets. This zone lies seven hours west of GMT and has no daylight savings.
+ <literallayout>
+ "EST10EDT,M10.5.0,M3.5.0/03"</literallayout>This string describes the time zone for Sydney Australia. It lies ten hours east of GMT and makes a one hour shift forward during daylight savings. Being located in the southern hemisphere, daylight savings begins on the last Sunday in October at 2am and ends on the last Sunday in March at 3am.
+ <literallayout>
+ "FST+3FDT02:00,J60/00,J304/02"</literallayout>This specification describes a fictitious zone that lies three hours east of GMT. It makes a two hour shift forward for daylight savings which begins on March 1st at midnight, and ends on October 31st at 2am. The 'J' designation in the start/end specs signifies that counting starts at one and February 29th is never counted.
+ <literallayout>
+ "FST+3FDT,59,304"</literallayout>This specification is significant because of the '59'. The lack of 'J' for the start and end dates, indicates that the Julian day-count begins at zero and ends at 365. If you do the math, you'll see that allows for a total of 366 days. This is fine in leap years, but in non-leap years '59' (Feb-29) does not exist. This will construct a valid posix_time_zone object but an exception will be thrown if the date of '59' is accessed in a non-leap year. Ex:
+ <programlisting>posix_time_zone leap_day(std::string("FST+3FDT,59,304"));
+leap_day.dst_local_start_time(2004); // ok
+leap_day.dst_local_start_time(2003); // Exception thrown</programlisting>
+ </para>
+ <para>
+ The posix_time_zone objects are used via a boost::shared_ptr&lt;local_time::time_zone_base&gt;. As a convenience, a typedef for boost::shared_ptr&lt;local_time::time_zone_base&gt; is provided:
+ <programlisting>typedef boost::shared_ptr&lt;time_zone_base&gt; local_time::time_zone_ptr;</programlisting>
+ </para>
+ <para>
+ See <link linkend="date_time.examples.simple_time_zone">Simple time zone</link> for a side by side example of time_zone and posix_time_zone usage.
+ </para>
+
+ <anchor id="posix_time_zone_notes" />
+ <bridgehead renderas="sect3">Important Notes</bridgehead>
+ <itemizedlist>
+ <listitem>posix_time_zone objects use the standard and daylight savings abbreviations in place of the full names (see <link linkend="posix_time_zone_accessors">Accessors</link> below).</listitem>
+ <listitem>'Jn' and 'n' date specifications can not be mixed in a specification string. Ex: "FST+3FDT,59,J304" </listitem>
+ <listitem>'n' date specification of 59 represents Feb-29. Do not attempt to access in a non-leap year or an exception will be thrown.</listitem>
+ </itemizedlist>
+
+ <anchor id="posix_time_zone_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ The inclusion of a single header will bring in all boost::local_time types, functions, and IO operators.
+ <programlisting>#include "boost/date_time/local_time/local_time.hpp"</programlisting>
+ </para>
+
+ <anchor id="posix_time_zone_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Syntax</entry>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>posix_time_zone(std::string)</screen></entry>
+ <entry><screen>std::string nyc("EST-5EDT,M4.1.0,M10.5.0");
+time_zone_ptr zone(new posix_time_zone(nyc));</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="posix_time_zone_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string dst_zone_abbrev()</screen></entry>
+ <entry>Returns the daylight savings abbreviation for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr-&gt;dst_zone_abbrev(); // "EDT"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string std_zone_abbrev()</screen></entry>
+ <entry>Returns the standard abbreviation for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr-&gt;std_zone_abbrev(); // "EST"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string dst_zone_name()</screen></entry>
+ <entry>Returns the daylight savings ABBREVIATION for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr-&gt;dst_zone_name(); // "EDT"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string std_zone_name()</screen></entry>
+ <entry>Returns the standard ABBREVIATION for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr-&gt;std_zone_name(); // "EST"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool has_dst()</screen></entry>
+ <entry>Returns true when time_zone's shared_ptr to dst_calc_rules is not NULL.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr-&gt;has_dst(); // true
+phx_zone_sh_ptr-&gt;has_dst(); // false</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>
+ptime dst_local_start_time(greg_year)</screen></entry>
+ <entry>The date and time daylight savings time begins in given year. Returns not_a_date_time if this zone has no daylight savings.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr-&gt;dst_local_start_time(2004);
+// 2004-Apr-04 02:00</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>
+ptime dst_local_end_time(greg_year)</screen></entry>
+ <entry>The date and time daylight savings time ends in given year. Returns not_a_date_time if this zone has no daylight savings.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr-&gt;dst_local_end_time(2004);
+// 2004-Oct-31 02:00</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>
+time_duration base_utc_offset()</screen></entry>
+ <entry>The amount of time offset from UTC (typically in hours).</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr-&gt;base_utc_offset(); // -05:00</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>posix_time::time_duration dst_offset()</screen></entry>
+ <entry>The amount of time shifted during daylight savings.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr-&gt;dst_offset(); // 01:00</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string to_posix_string()</screen></entry>
+ <entry>Returns a posix time zone string representation of this time_zone_base 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 <link linkend="date_time.local_time.posix_time_zone">posix_time_zone</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>nyc_zone_sh_ptr-&gt;to_posix_string();
+// "EST-05EDT+01,M4.1.0/02:00,M10.5.0/02:00"
+phx_zone_sh_ptr-&gt;to_posix_string();
+// "MST-07"
+ </screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ptime_class.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ptime_class.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,565 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.posix_time.ptime_class">
+ <title>Ptime</title>
+
+ <link linkend="ptime_intro">Introduction</link> --
+ <link linkend="ptime_header">Header</link> --
+ <link linkend="ptime_constr">Construction</link> --
+ <link linkend="ptime_from_string">Construct from String</link> --
+ <link linkend="ptime_from_clock">Construct from Clock</link> --
+ <link linkend="ptime_from_funcs">Construct using Conversion functions</link> --
+ <link linkend="ptime_accessors">Accessors</link> --
+ <link linkend="ptime_to_string">Conversion To String</link> --
+ <link linkend="ptime_operators">Operators</link> --
+ <link linkend="ptime_struct_tm">Struct tm, time_t, and FILETIME Functions</link>
+
+ <anchor id="ptime_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ The class boost::posix_time::ptime is the primary interface for time point manipulation. In general, the ptime class is immutable once constructed although it does allow assignment.
+ </para>
+ <para>
+ Class ptime is dependent on <link linkend="date_time.gregorian.date_class">gregorian::date</link> for the interface to the date portion of a time point.
+ </para>
+ <para>
+ Other techniques for creating times include <link linkend="date_time.posix_time.time_iterators">time iterators</link>.
+ </para>
+
+ <anchor id="ptime_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ <programlisting>#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
+or
+#include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types</programlisting>
+ </para>
+
+ <anchor id="ptime_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime(date,time_duration)</screen></entry>
+ <entry>Construct from a date and offset</entry>
+ </row>
+ <row>
+ <entry><screen>ptime t1(date(2002,Jan,10),
+ time_duration(1,2,3));
+ptime t2(date(2002,Jan,10),
+ hours(1)+nanosec(5));</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime(ptime)</screen></entry>
+ <entry>Copy constructor</entry>
+ </row>
+ <row>
+ <entry><screen>ptime t3(t1)</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime(special_values sv)</screen></entry>
+ <entry>Constructor for infinities, not-a-date-time, max_date_time, and min_date_time</entry>
+ </row>
+ <row>
+ <entry><screen>ptime d1(neg_infin);
+ptime d2(pos_infin);
+ptime d3(not_a_date_time);
+ptime d4(max_date_time);
+ptime d5(min_date_time);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime;</screen></entry>
+ <entry>Default constructor. Creates a ptime object initialized to not_a_date_time. NOTE: this constructor can be disabled by defining DATE_TIME_NO_DEFAULT_CONSTRUCTOR (see compiler_config.hpp)</entry>
+ </row>
+ <row>
+ <entry><screen>ptime p; // p =&gt; not_a_date_time</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="ptime_from_string" />
+ <bridgehead renderas="sect3">Construct from String</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime time_from_string(std::string)</screen></entry>
+ <entry>From delimited string. NOTE: Excess digits in fractional seconds will be dropped. Ex: "1:02:03.123456999" =&gt; 1:02:03.123456. This behavior is affected by the precision the library is compiled with (see <link linkend="date_time.buildinfo">Build-Compiler Information</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>std::string ts("2002-01-20 23:59:59.000");
+ptime t(time_from_string(ts))</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime from_iso_string(std::string)</screen></entry>
+ <entry>From non delimited iso form string.</entry>
+ </row>
+ <row>
+ <entry><screen>std::string ts("20020131T235959");
+ptime t(from_iso_string(ts))</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="ptime_from_clock" />
+ <bridgehead renderas="sect3">Construct from Clock</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime second_clock::local_time()</screen></entry>
+ <entry>Get the local time, second level resolution, based on the time zone settings of the computer.</entry>
+ </row>
+ <row>
+ <entry><screen>ptime t(second_clock::local_time());</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime second_clock::universal_time()</screen></entry>
+ <entry>Get the UTC time.</entry>
+ </row>
+ <row>
+ <entry><screen>ptime t(second_clock::universal_time())</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime microsec_clock::local_time()</screen></entry>
+ <entry>Get the local time using a sub second resolution clock. On Unix systems this is implemented using GetTimeOfDay. On most Win32 platforms it is implemented using ftime. Win32 systems often do not achieve microsecond resolution via this API. If higher resolution is critical to your application test your platform to see the achieved resolution.</entry>
+ </row>
+ <row>
+ <entry><screen>ptime t(microsec_clock::local_time());</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime microsec_clock::universal_time()</screen></entry>
+ <entry>Get the UTC time using a sub second resolution clock. On Unix systems this is implemented using GetTimeOfDay. On most Win32 platforms it is implemented using ftime. Win32 systems often do not achieve microsecond resolution via this API. If higher resolution is critical to your application test your platform to see the achieved resolution.</entry>
+ </row>
+ <row>
+ <entry><screen>ptime t(microsec_clock::universal_time());</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="ptime_from_funcs" />
+ <bridgehead renderas="sect3">Construct using Conversion Functions</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime from_time_t(time_t t);</screen></entry>
+ <entry>Converts a time_t into a ptime.</entry>
+ </row>
+ <row>
+ <entry><screen>ptime t = from_time_t(tt);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime from_ftime&lt;ptime&gt;(FILETIME ft);</screen></entry>
+ <entry>Creates a ptime object from a FILETIME structure.</entry>
+ </row>
+ <row>
+ <entry><screen>ptime t = from_ftime&lt;ptime&gt;(ft);</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="ptime_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>date date()</screen></entry>
+ <entry>Get the date part of a time.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,10);
+ptime t(d, hour(1));
+t.date() --> 2002-Jan-10;</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration time_of_day()</screen></entry>
+ <entry>Get the time offset in the day.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,10);
+ptime t(d, hour(1));
+t.time_of_day() --> 01:00:00;</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_infinity() const</screen></entry>
+ <entry>Returns true if ptime is either positive or negative infinity</entry>
+ </row>
+ <row>
+ <entry><screen>ptime pt(pos_infin);
+pt.is_infinity(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_neg_infinity() const</screen></entry>
+ <entry>Returns true if ptime is negative infinity</entry>
+ </row>
+ <row>
+ <entry><screen>ptime pt(neg_infin);
+pt.is_neg_infinity(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_pos_infinity() const</screen></entry>
+ <entry>Returns true if ptime is positive infinity</entry>
+ </row>
+ <row>
+ <entry><screen>ptime pt(neg_infin);
+pt.is_pos_infinity(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_not_a_date_time() const</screen></entry>
+ <entry>Returns true if value is not a ptime</entry>
+ </row>
+ <row>
+ <entry><screen>ptime pt(not_a_date_time);
+pt.is_not_a_date_time(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_special() const</screen></entry>
+ <entry>Returns true if ptime is any <code>special_value</code></entry>
+ </row>
+ <row>
+ <entry><screen>ptime pt(pos_infin);
+ptime pt2(not_a_date_time);
+ptime pt3(date(2005,Mar,1), hours(10));
+pt.is_special(); // --> true
+pt2.is_special(); // --> true
+pt3.is_special(); // --> false</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="ptime_to_string" />
+ <bridgehead renderas="sect3">Conversion to String</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string to_simple_string(ptime)</screen></entry>
+ <entry>To <code>YYYY-mmm-DD HH:MM:SS.fffffffff</code> string where <code>mmm</code> 3 char month name. Fractional seconds only included if non-zero.</entry>
+ </row>
+ <row>
+ <entry><screen>2002-Jan-01 10:00:01.123456789</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string to_iso_string(ptime)</screen></entry>
+ <entry>Convert to form <code>YYYYMMDDTHHMMSS,fffffffff</code> where <code>T</code> is the date-time separator</entry>
+ </row>
+ <row>
+ <entry><screen>20020131T100001,123456789</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string to_iso_extended_string(ptime)</screen></entry>
+ <entry>Convert to form <code>YYYY-MM-DDTHH:MM:SS,fffffffff</code> where <code>T</code> is the date-time separator</entry>
+ </row>
+ <row>
+ <entry><screen>2002-01-31T10:00:01,123456789</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="ptime_operators" />
+ <bridgehead renderas="sect3">Operators</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;&lt;, operator&gt;&gt;</screen></entry>
+ <entry>Streaming operators. <emphasis role="strong">Note:</emphasis> As of version 1.33, streaming operations have been greatly improved. See <link linkend="date_time.date_time_io">Date Time IO System</link> for more details (including exceptions and error conditions).</entry>
+ </row>
+ <row>
+ <entry><screen>ptime pt(not_a_date_time);
+stringstream ss("2002-Jan-01 14:23:11");
+ss &gt;&gt; pt;
+std::cout &lt;&lt; pt; // "2002-Jan-01 14:23:11"
+ </screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator==, operator!=,
+operator>, operator&lt;,
+operator>=, operator&lt;=</screen>
+ </entry>
+ <entry>A full complement of comparison operators</entry>
+ </row>
+ <row>
+ <entry><screen>t1 == t2, etc</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime operator+(days)</screen></entry>
+ <entry>Return a ptime adding a day offset</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,1);
+ptime t(d,minutes(5));
+days dd(1);
+ptime t2 = t + dd;</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime operator-(days)</screen></entry>
+ <entry>Return a ptime subtracting a day offset</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,1);
+ptime t(d,minutes(5));
+days dd(1);
+ptime t2 = t - dd;</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime operator+(time_duration)</screen></entry>
+ <entry>Return a ptime adding a time duration</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,1);
+ptime t(d,minutes(5));
+ptime t2 = t + hours(1) + minutes(2);</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime operator-(time_duration)</screen></entry>
+ <entry>Return a ptime subtracting a time duration</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,1);
+ptime t(d,minutes(5));
+ptime t2 = t - minutes(2);</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration operator-(ptime)</screen></entry>
+ <entry>Take the difference between two times.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,1);
+ptime t1(d,minutes(5));
+ptime t2(d,seconds(5));
+time_duration t3 = t2 - t1;//negative result</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="ptime_struct_tm" />
+ <bridgehead renderas="sect3">Struct tm, time_t, and FILETIME Functions</bridgehead>
+ <para>Functions for converting posix_time objects to, and from, <code>tm</code> structs are provided as well as conversion from <code>time_t</code> and <code>FILETIME</code>.</para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>tm to_tm(ptime)</screen></entry>
+ <entry>A function for converting a <code>ptime</code> object to a <code>tm</code> struct. The <code>tm_isdst</code> field is set to -1.</entry>
+ </row>
+ <row>
+ <entry><screen>ptime pt(date(2005,Jan,1), time_duration(1,2,3));
+tm pt_tm = to_tm(pt);
+/* tm_year => 105
+ tm_mon => 0
+ tm_mday => 1
+ tm_wday => 6 (Saturday)
+ tm_yday => 0
+ tm_hour => 1
+ tm_min => 2
+ tm_sec => 3
+ tm_isddst => -1 */</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date date_from_tm(tm datetm)</screen></entry>
+ <entry>A function for converting a <code>tm</code> struct to a <code>date</code> object. The fields: <code>tm_wday </code>, <code>tm_yday </code>, and <code>tm_isdst</code> are ignored.</entry>
+ </row>
+ <row>
+ <entry><screen>tm pt_tm;
+pt_tm.tm_year = 105;
+pt_tm.tm_mon = 0;
+pt_tm.tm_mday = 1;
+pt_tm.tm_hour = 1;
+pt_tm.tm_min = 2;
+pt_tm.tm_sec = 3;
+ptime pt = ptime_from_tm(pt_tm);
+// pt => 2005-Jan-01 01:02:03</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>tm to_tm(time_duration)</screen></entry>
+ <entry>A function for converting a <code>time_duration</code> object to a <code>tm</code> struct. The fields: <code>tm_year</code>, <code>tm_mon</code>, <code>tm_mday</code>, <code>tm_wday</code>, <code>tm_yday</code> are set to zero. The <code>tm_isdst</code> field is set to -1.</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3);
+tm td_tm = to_tm(td);
+/* tm_year => 0
+ tm_mon => 0
+ tm_mday => 0
+ tm_wday => 0
+ tm_yday => 0
+ tm_hour => 1
+ tm_min => 2
+ tm_sec => 3
+ tm_isddst => -1 */</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime from_time_t(std::time_t)</screen></entry>
+ <entry>Creates a <code>ptime</code> from the time_t parameter. The seconds held in the time_t are added to a time point of 1970-Jan-01.</entry>
+ </row>
+ <row>
+ <entry><screen>ptime pt(not_a_date_time);
+std::time_t t;
+t = 1118158776;
+pt = from_time_t(t);
+// pt => 2005-Jun-07 15:39:36</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime from_ftime&lt;ptime>(FILETIME)</screen></entry>
+ <entry>A template function that constructs a <code>ptime</code> from a FILETIME struct.</entry>
+ </row>
+ <row>
+ <entry><screen>FILETIME ft;
+ft.dwHighDateTime = 29715317;
+ft.dwLowDateTime = 3865122988UL;
+ptime pt = from_ftime&lt;ptime>(ft);
+// pt => 2005-Jun-07 15:30:57.039582000</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ref_tag_fix.pl
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/ref_tag_fix.pl 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,114 @@
+#!/usr/bin/perl -w
+# Bart Garst - 7/1/2004
+# additional comments at bottom of file
+
+#############################################################################
+# Copyright (c) 2001-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) #
+#############################################################################
+
+use strict;
+
+# key-value of file name and id attribute
+# if the attributes are changed here it would be a good idea to
+# also change the links in doxy.xml
+my %files = (
+ 'date_time_autodoc.boostbook' => 'date_time_reference',
+ 'gregorian_autodoc.boostbook' => 'gregorian_reference',
+ 'posix_time_autodoc.boostbook' => 'posix_time_reference',
+ 'local_time_autodoc.boostbook' => 'local_time_reference'
+);
+
+
+foreach my $key(keys %files) {
+ rewrite_tags($key, $files{$key});
+}
+
+exit;
+
+### subroutines ###
+
+# separate words at underscores and capitalize first letter of each
+sub make_title {
+ my $a = shift || die "Missing required parameter to make_title()\n";
+ my @wrds = split(/_/, $a); # remove underscores
+ foreach(@wrds){
+ $_ = "\u$_"; # capitalize first letter
+ }
+ $a = join(" ",@wrds);
+
+ return $a;
+}
+
+sub rewrite_tags {
+ my $filename = shift || die "Error: argument 1 missing to sub $!";
+ my $id_tag = shift || die "Error: argument 2 missing to sub $!";
+ my ($line, @new_file, $title, $processed);
+
+ $processed = 1; # has this file already been processed?
+
+ print "...processing $filename...\n";
+
+ # prepare a title from id attribute
+ $title = make_title($id_tag);
+
+ # open & read file and change appropriate line
+ open(INP, "<$filename") || die "File open (read) failed: $!";
+ while($line = <INP>){
+ if($line =~ /<library-reference>/) {
+ push(@new_file, "<section id=\"$id_tag\">\n");
+ push(@new_file, "<title>$title</title>\n");
+ $processed = 0; # file had not been previously processed
+ }
+ elsif($line =~ /<\/library-reference>/) {
+ push(@new_file, "</section>\n");
+ }
+ else{
+ push(@new_file, $line);
+ }
+ }
+ close(INP);
+
+ # open & write new file w/ same name
+ open(OTP, ">$filename") || die "File open (write) failed: $!";
+ print OTP shift(@new_file);
+
+ if($processed == 0){ # has not been previously processed so add license
+ my($day, $year) = (localtime)[3,5];
+ my $month = (qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[(localtime)[4]];
+ $year += 1900; # adjust year
+ print OTP <<EO_LIC;
+<!-- Copyright (c) 2001-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)
+-->
+<!-- date source directory processed: $year-$month-$day -->
+EO_LIC
+ }
+
+ foreach(@new_file){
+ print OTP "$_";
+ }
+ close(OTP);
+}
+
+__END__
+
+Rewrites the library-reference tagset as a section tagset and adds
+a title to the generated *.boostbook files. It will NOT update a
+file that has already been rewritten.
+
+Change log
+7/19/2004
+ - rewrite library-reference tags as section tags and add title tags
+ - renamed fix_id sub to rewrite_tags.
+8/31/2004
+ - added license to this file and writes license to boostbook files
+11/01/2004
+ - fixed minor bug that placed multiple license statements in files if
+ input file had already had it's tags fixed.
+ - added a processed date to the license statement
+12/02/2005
+ - added local_time_autodoc.boostbook
+ - updated copyrights to 2005

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/references.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/references.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,124 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.references">
+ <title>References</title>
+
+ <para>The design of the library is currently being evolved using Wiki and email discussions. You can find more information at: <ulink url="http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl?GDTL">Boost Wiki GDTL Start Page</ulink>.
+ </para>
+
+ <para>
+ <itemizedlist mark="bullet">
+ <listitem><link linkend="date_ref">Date References</link></listitem>
+ <listitem><link linkend="time_ref">Time References</link></listitem>
+ <listitem><link linkend="other_c_libs">Other C/C++ Libraries</link></listitem>
+ <listitem><link linkend="java_libs">JAVA Date-Time Libraries</link></listitem>
+ <listitem><link linkend="script_libs">Scripting Language Libraries</link></listitem>
+ <listitem><link linkend="related">Related Commercial and Fanciful Pages</link></listitem>
+ <listitem><link linkend="resolution">Resolution, Precision, and Accuracy</link></listitem>
+ </itemizedlist>
+ </para>
+ <anchor id="date_ref" />
+ <bridgehead renderas="sect3">Date Calendar References</bridgehead>
+ <para>
+ <itemizedlist mark="bullet">
+ <listitem>ISO 8601 date time standard -- <ulink url="http://www.cl.cam.ac.uk/~mgk25/iso-time.html">Summary by Markus Kuhn</ulink> </listitem>
+ <listitem><ulink url="http://emr.cs.iit.edu/home/reingold/calendar-book/second-edition/">Calendrical Calculations</ulink> book by Reingold &amp; Dershowitz</listitem>
+ <listitem><ulink url="http://www.tondering.dk/claus/calendar.html">Calendar FAQ by Claus Tøndering</ulink></listitem>
+ <listitem>Calendar zone <ulink url="http://www.calendarzone.com" /> </listitem>
+ <listitem><ulink url="http://www.w3.org/TR/xmlschema-2/#dateTime">XML schema for date time</ulink> </listitem>
+ <listitem>Will Linden's <ulink url="http://www.ecben.net/calendar.shtml">Calendar Links</ulink> </listitem>
+ <listitem><ulink url="http://www21.brinkster.com/lonwolve/melt/index.htm">XMAS calendar melt</ulink> </listitem>
+ </itemizedlist>
+ </para>
+ <anchor id="time_ref" />
+ <bridgehead renderas="sect3">Time</bridgehead>
+ <para>
+ <itemizedlist mark="bullet">
+ <listitem>Martin Folwer on time patterns
+ <itemizedlist override="opencircle">
+ <listitem><ulink url="http://www.aw.com/cseng/titles/0-201-89542-0/apsupp/events2-1.html">Recurring Events for Calendars</ulink> </listitem>
+ <listitem>Patterns for things that <ulink url="http://martinfowler.com/ap2/timeNarrative.html">Change with time</ulink> </listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem>US National Institute of Standards and Technology <ulink url="http://nist.time.gov/exhibits.html">Time Exhibits</ulink> </listitem>
+ <listitem>Network Time Protocol at <ulink url="http://www.ntp.org/">NTP.org</ulink> </listitem>
+ <listitem>US Navy <ulink url="http://tycho.usno.navy.mil/systime.html">Systems of Time</ulink> </listitem>
+ <listitem><ulink url="http://www.bipm.fr/enus/5_Scientific/c_time/time_1.html">International Atomic Time</ulink> </listitem>
+ <listitem><ulink url="http://beta.zyprexia.com/docs/pgsql/user/datatype1130.htm">Date-Time type PostgreSQL</ulink> User Guide </listitem>
+ </itemizedlist>
+ </para>
+ <anchor id="other_c_libs" />
+ <bridgehead renderas="sect3">Other C/C++ Libraries</bridgehead>
+ <para>
+ <itemizedlist mark="bullet">
+ <listitem><ulink url="http://www.cplusplus.com/ref/ctime/index.html">ctime C</ulink> Standard library reference at cplusplus.com</listitem>
+ <listitem><ulink url="http://www.cl.cam.ac.uk/~mgk25/c-time/">XTime C extension</ulink> proposal</listitem>
+ <listitem><ulink url="http://david.tribble.com/text/c0xcalendar.html#author-info">Another C library extension proposal</ulink> by David Tribble</listitem>
+ <listitem><ulink url="http://cr.yp.to/libtai.html">libTAI</ulink> is a C based time library</listitem>
+ <listitem><ulink url="http://www.twinsun.com/tz/tz-link.htm">Time Zone Database</ulink> C library for managing timezones/places</listitem>
+ <listitem>International Components for Unicode by IBM (open source)
+ <itemizedlist override="opencircle">
+ <listitem><ulink url="http://icu.sourceforge.net/userguide/dateCalendar.html">Calendar Class</ulink></listitem>
+ <listitem><ulink url="http://icu.sourceforge.net/userguide/dateTime.html">Date Time Services</ulink></listitem>
+ <listitem><ulink url="http://oss.software.ibm.com/userguide/dateTimezone.html">Time Zone Class</ulink></listitem>
+ <listitem><ulink url="http://oss.software.ibm.com/userguide/formatDateTime.html">Date-Time Formatting</ulink></listitem>
+ </itemizedlist>
+ </listitem>
+ <listitem><ulink url="http://pds-rings.seti.org/toolkits/julian_133_html/aareadme.html">Julian Library in C by Mark Showalter -- NASA</ulink></listitem>
+ </itemizedlist>
+ </para>
+ <anchor id="java_libs" />
+ <bridgehead renderas="sect3">JAVA Date &amp; Time Library Quick Reference</bridgehead>
+ <para>
+ <itemizedlist mark="bullet">
+ <listitem><ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html">Calendar class</ulink></listitem>
+ <listitem><ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/GregorianCalendar.html">Gregorian calendar</ulink></listitem>
+ <listitem><ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html">Date class</ulink></listitem>
+ <listitem><ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Time.html">sql.time class</ulink></listitem>
+ <listitem><ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/DateFormatSymbols.html#_top_">Date format symbols</ulink></listitem>
+ <listitem><ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/DateFormat.html">Date format</ulink></listitem>
+ <listitem><ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/SimpleDateFormat.html">Simple Date Format</ulink></listitem>
+<listitem><ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/SimpleTimeZone.html">Simple Time Zone</ulink></listitem>
+ </itemizedlist>
+ </para>
+ <anchor id="script_libs" />
+ <bridgehead renderas="sect3">Scripting Language Libraries</bridgehead>
+ <para>
+ <itemizedlist mark="bullet">
+ <listitem>A python date library <ulink url="http://www.lemburg.com/files/python/mxDateTime.html">MX Date Time</ulink></listitem>
+ <listitem>Perl date-time
+ <itemizedlist override="opencircle">
+ <listitem><ulink url="http://search-dev.develooper.com/search?m=module&amp;q=date&amp;s=11">Date-Time packages at CPAN</ulink></listitem>
+ <listitem><ulink url="http://search-dev.develooper.com/~stbey/Date-Calc-5.4/Calc.pod">Date::Calc</ulink> at CPAN</listitem>
+ <listitem><ulink url="http://search.cpan.org/doc/MORTY/DateConvert-0.16/Convert.pm">Date::Convert</ulink> calendar conversions at CPAN</listitem>
+ </itemizedlist>
+ </listitem>
+ </itemizedlist>
+ </para>
+ <anchor id="related" />
+ <bridgehead renderas="sect3">Related Commercial and Fanciful Pages</bridgehead>
+ <para>
+ <itemizedlist mark="bullet">
+ <listitem><ulink url="http://www.craphound.com/est/">Eastern Standard Tribe</ulink> -- Cory Doctorow science fiction novel with time themes.</listitem>
+ <listitem><ulink url="http://www.leapsecond.com/java/gpsclock.htm">Leapsecond.com time</ulink> page</listitem>
+ <listitem><ulink url="http://www.worldtimeserver.com">World Time Server / TZ database</ulink></listitem>
+ <listitem><ulink url="http://www.longnow.org/10kclock/clock.htm">10000 year clock</ulink> at Long Now Foundation</listitem>
+ <listitem><ulink url="http://www.timezonesforpcs.com">Timezones for PCs</ulink></listitem>
+ </itemizedlist>
+ </para>
+ <anchor id="resolution" />
+ <bridgehead renderas="sect3">Resolution, Precision, and Accuracy</bridgehead>
+ <para>
+ <itemizedlist mark="bullet">
+ <listitem>Definitions with pictures from <ulink url="http://metrologyforum.tm.agilent.com/specs.shtml">Agilent Technologies</ulink></listitem>
+ <listitem>Definitions from <ulink url="http://www.solent.ac.uk/hydrography/notes/errorthe/accuracy.htm">Southampton Institute</ulink></listitem>
+ </itemizedlist>
+ </para>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/serialization.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/serialization.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.serialization">
+ <title>Serialization</title>
+
+ <para>
+ The boost::date_time library is compatible with the boost::serialization library's text and xml archives. The list of classes that are serializable are:
+ </para>
+
+ <bridgehead renderas="sect3">boost::gregorian</bridgehead>
+
+ <informaltable frame="all" pgwide="1">
+ <tgroup cols="3">
+ <tbody>
+ <row>
+ <entry><link linkend="date_time.gregorian.date_class">date</link></entry>
+ <entry><link linkend="date_time.gregorian.date_duration">date_duration</link></entry>
+ <entry><link linkend="date_time.gregorian.date_period">date_period</link></entry>
+ </row>
+ <row>
+ <entry><link linkend="date_time.gregorian.date_algorithms">partial_date</link></entry>
+ <entry><link linkend="date_time.gregorian.date_algorithms">nth_day_of_week_in_month</link></entry>
+ <entry><link linkend="date_time.gregorian.date_algorithms">first_day_of_week_in_month</link></entry>
+ </row>
+ <row>
+ <entry><link linkend="date_time.gregorian.date_algorithms">last_day_of_week_in_month</link></entry>
+ <entry><link linkend="date_time.gregorian.date_algorithms">first_day_of_week_before</link></entry>
+ <entry><link linkend="date_time.gregorian.date_algorithms">first_day_of_week_after</link></entry>
+ </row>
+ <row>
+ <entry>greg_month</entry> <!-- no docs to link to for these three -->
+ <entry>greg_day</entry>
+ <entry>greg_weekday</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <bridgehead renderas="sect3">boost::posix_time</bridgehead>
+
+ <informaltable frame="all" pgwide="1">
+ <tgroup cols="3">
+ <tbody>
+ <row>
+ <entry><link linkend="date_time.posix_time.ptime_class">ptime</link></entry>
+ <entry><link linkend="date_time.posix_time.time_duration">time_duration</link></entry>
+ <entry><link linkend="date_time.posix_time.time_period">time_period</link></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+ <para>
+ No extra steps are required to build the date_time library for serialization use.
+ </para>
+
+ <para>NOTE: due to a change in the serialization library interface, it is now required that all streamable objects be const prior to writing to the archive. The following template function will allow for this (and is used in the date_time tests). At this time no special steps are necessary to read from an archive.
+ <programlisting>
+ template&lt;class archive_type, class temporal_type>
+ void save_to(archive_type&amp; ar, const temporal_type&amp; tt)
+ {
+ ar &lt;&lt; tt;
+ }
+ </programlisting>
+ </para>
+
+ <para>
+ Example text_archive usage:
+ <programlisting>
+ using namespace boost::posix_time;
+ using namespace boost::gregorian;
+ ptime pt(date(2002, Feb, 14)), hours(10)), pt2(not_a_date_time);
+ std::ofstream ofs("tmp_file");
+ archive::test_oarchive oa(ofs);
+ save_to(oa, pt); // NOTE: no macro
+ ofs.close();
+ std::ifstream ifs("tmp_file");
+ archive::text_iarchive ia(ifs);
+ ia &gt;&gt; pt2; // NOTE: no macro
+ ifs.close();
+ pt == pt2; // true</programlisting>
+ </para>
+
+ <para>
+ Example xml_archive usage:
+ <programlisting>
+ using namespace boost::gregorian;
+ date d(2002, Feb, 14), d2(not_a_date_time);
+ std::ofstream ofs("tmp_file");
+ archive::xml_oarchive oa(ofs);
+ save_to(oa, BOOST_SERIALIZATION_NVP(d)); // macro required for xml_archive
+ ofs.close();
+ std::ifstream ifs("tmp_file");
+ archive::xml_iarchive ia(ifs);
+ ia &gt;&gt; BOOST_SERIALIZATION_NVP(d2); // macro required for xml_archive
+ ifs.close();
+ d == d2; // true</programlisting>
+ </para>
+
+ <para>
+ To use the date_time serialization code, the proper header files must be explicitly included. The header files are:
+ <programlisting>
+ boost/date_time/gregorian/greg_serialize.hpp</programlisting>
+ and
+ <programlisting>
+ boost/date_time/posix_time/time_serialize.hpp</programlisting>
+ </para>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/snap_to_details.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/snap_to_details.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+
+<para>
+<anchor id="snap_to_details" />
+<bridgehead renderas="sect4">Reversibility of Operations Pitfall</bridgehead>
+<para>A natural expectation when adding a number of months to a date, and then subtracting the same number of months, is to end up exactly where you started. This is most often the result the <code>date_time</code> library provides but there is one significant exception: The snap-to-end-of-month behavior implemented by the <link linkend="additional_duration_types">months</link> duration type. The <link linkend="additional_duration_types">months</link> duration type may provide unexpected results when the starting day is the 28th, 29th, or 30th in a 31 day month. The <link linkend="iterators_intro">month_iterator</link> is not effected by this issue and is therefore included in the examples to illustrate a possible alternative.
+</para>
+
+<para>When the starting date is in the middle of a month, adding or subtracting any number of months will result in a date that is the same day of month (e.g. if you start on the 15th, you will end on the 15th). When a date is the last day of the month, adding or subtracting any number of months will give a result that is also the last day of the month (e.g if you start on Jan 31st, you will land on: Feb 28th, Mar 31st, etc).
+ <programlisting>
+ // using months duration type
+ date d(2005, Nov, 30); // last day of November
+ d + months(1); // result is last day of December "2005-Dec-31"
+ d - months(1); // result is last day of October "2005-Oct-31"
+
+ // using month_iterator
+ month_iterator itr(d); // last day of November
+ ++itr; // result is last day of December "2005-Dec-31"
+ --itr; // back to original starting point "2005-Nov-30"
+ --itr; // last day of October "2005-Oct-31"
+ </programlisting>
+</para>
+
+<para>If the start date is the 28th, 29th, or 30th in a 31 day month, the result of adding or subtracting a month may result in the snap-to-end-of-month behavior kicking in unexpectedly. This would cause the final result to be different that the starting date.
+ <programlisting>
+ // using months duration type
+ date d(2005, Nov, 29);
+ d += months(1); // "2005-Dec-29"
+ d += months(1); // "2006-Jan-29"
+ d += months(1); // "2006-Feb-28" --> snap-to-end-of-month behavior kicks in
+ d += months(1); // "2006-Mar-31" --> unexpected result
+ d -= months(4); // "2005-Nov-30" --> unexpected result, not where we started
+
+ // using month_iterator
+ month_iterator itr(date(2005, Dec, 30));
+ ++itr; // "2006-Jan-30" --> ok
+ ++itr; // "2006-Feb-28" --> snap-to DOES NOT kick in
+ ++itr; // "2006-Mar-30" --> ok
+ --itr; // "2006-Feb-28" --> ok
+ --itr; // "2006-Jan-30" --> ok
+ --itr; // "2005-Dec-30" --> ok, back where we started
+ </programlisting>
+</para>
+
+<para>The additional duration types (<code>months</code>, <code>years</code>, and <code>weeks</code>) are provided as a convenience and can be easily removed to insure this pitfall never occurs. To remove these types simply undefine BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES.</para>
+</para>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/table_template.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/table_template.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,32 @@
+<!-- Copyright (c) 2004-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)
+-->
+
+<!-- this file is here simply to make the creation of new tables easier and uniform in their layout -->
+
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>time_zone_ptr zone()</screen></entry>
+ <entry>Returns associated time_zone object via a time_zone_ptr</entry>
+ </row>
+ <row>
+ <entry><screen>the example...</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/terminology.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/terminology.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.terminology">
+ <title>Terminology</title>
+
+ <para>
+ The following are a number of terms relevant to the date-time domain.
+ </para>
+ <para>
+ A taxonomy of temporal types:
+ <itemizedlist mark="bullet">
+ <listitem>Timepoint -- Specifier for a location in the time continuum. Similar to a number on a ruler.</listitem>
+ <listitem>Timelength -- A duration of time unattached to any point on the time continuum.</listitem>
+ <listitem>Timeinterval -- A duration of time attached to a specific point in the time continuum.</listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ And some other terms:
+ <itemizedlist mark="bullet">
+ <listitem>Accuracy -- A measure of error, the difference between the reading of a clock and the true time.</listitem>
+ <listitem>Calendar System -- A system for labeling time points with day level resolution.</listitem>
+ <listitem>Clock Device -- A software component (tied to some hardware) that provides the current date or time with respect to a calendar or clock system.</listitem>
+ <listitem>Precision -- A measure of repeatability of a clock.</listitem>
+ <listitem>Resolution -- A specification of the smallest representable duration (eg: 1 second, 1 century) for a clock/calendar system or temporal type.</listitem>
+ <listitem>Stability -- The property of a class which says that the underlying representation (implementation) associated with a particular (abstract) value will never change.</listitem>
+ <listitem>Time System -- A system for labeling time points with higher resolution than day-level. </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Some standard date-time terminology:
+ <itemizedlist mark="bullet">
+ <listitem>Epoch -- Starting time point of a calendar or clock system.</listitem>
+ <listitem>DST -- Daylight savings time - a local time adjustment made in some regions during the summer to shift the clock time of the daylight hours</listitem>
+ <listitem>Time zone -- A region of the earth that provides for a 'local time' defined by DST rules and UT offset.</listitem>
+ <listitem>UTC Time -- Coordinated Universal Time - Civil time system as measured at longitude zero. Kept adjusted to earth rotation by use of leap seconds. Also known as Zulu Time. Replaced the similar system known as Greenwich Mean Time. For more see <ulink url="http://aa.usno.navy.mil/faq/docs/UT.html" /></listitem>
+ <listitem>TAI Time -- A high-accuracy monotonic (need better term) time system measured to .1 microsecond resolution by atomic clocks around the world. Not adjusted to earth rotation. For more see <ulink url="http://www.bipm.fr/enus/5_Scientific/c_time/time_server.html" /></listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Some more experimental ones:
+ <itemizedlist mark="bullet">
+ <listitem>Local Time -- A time measured in a specific location of the universe.</listitem>
+ <listitem>Time Label -- A tuple that either completely or partially specifies a specific date-time with respect to a calendar or clock system. This is the year-month-day representation.</listitem>
+ <listitem>Adjusting Time Length -- A duration that represents varying physical durations depending on the moment in time. For example, a 1 month duration is typically not a fixed number of days and it depends on the date it is measured from to determine the actual length. </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ These are design sorts of terms:
+ <itemizedlist mark="bullet">
+ <listitem>Generation function -- A function that generates a specific set of time points, lengths, or intervals based on one or more parameters. </listitem>
+ </itemizedlist>
+ </para>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/tests.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/tests.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.tests">
+ <title>Tests</title>
+
+ <para>
+ The library provides a large number of tests in the
+ <programlisting>
+ libs/date_time/test
+ libs/date_time/test/gregorian
+ libs/date_time/test/posix_time
+ libs/date_time/test/local_time
+ </programlisting>
+ directories. Building and executing these tests assures that the installation is correct and that the library is functioning correctly. In addition, these tests facilitate the porting to new compilers. Finally, the tests provide examples of many functions not explicitly described in the usage examples.
+ </para>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_duration.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_duration.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,592 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.posix_time.time_duration">
+ <title>Time Duration</title>
+
+ <link linkend="time_duration_intro">Introduction</link> --
+ <link linkend="time_duration_header">Header</link> --
+ <link linkend="time_duration_constr">Construction</link> --
+ <link linkend="time_duration_count_constr">Count Based Construction</link> --
+ <link linkend="time_duration_from_string">Construct from String</link> --
+ <link linkend="time_duration_accessors">Accessors</link> --
+ <link linkend="time_duration_to_string">Conversion To String</link> --
+ <link linkend="time_duration_operators">Operators</link> --
+ <link linkend="time_duration_struct_tm">Struct tm Functions</link>
+
+ <anchor id="time_duration_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ The class boost::posix_time::time_duration the base type responsible for representing a length of time. A duration can be either positive or negative. The general time_duration class provides a constructor that takes a count of the number of hours, minutes, seconds, and fractional seconds count as shown in the code fragment below. The resolution of the time_duration is configure able at compile time. See <link linkend="date_time.buildinfo">Build-Compiler Information</link> for more information.
+ </para>
+ <para>
+ <programlisting>using namespace boost::posix_time;
+time_duration td(1,2,3,4); //01:02:03.000000004 when resolution is nano seconds
+time_duration td(1,2,3,4); //01:02:03.000004 when resolution is micro seconds</programlisting>
+ </para>
+ <para>
+ Several small helper classes that derive from a base time_duration, as shown below, to adjust for different resolutions. These classes can shorten code and make the intent clearer.
+ </para>
+ <imagedata fileref="../../libs/date_time/doc/time_duration_inherit.png" />
+ <para>
+ As an example:
+ <programlisting>using namespace boost::posix_time;
+
+time_duration td = hours(1) + seconds(10); //01:00:01
+td = hours(1) + nanoseconds(5); //01:00:00.000000005</programlisting>
+ Note that the existence of the higher resolution classes (eg: nanoseconds) depends on the installation of the library. See <link linkend="date_time.buildinfo">Build-Compiler Information</link> for more information.
+ </para>
+
+ <para>
+ Another way to handle this is to utilize the ticks_per_second() method of time_duration to
+ write code that is portable no matter how the library is compiled. The general equation
+ for calculating a resolution independent count is as follows:
+
+ <programlisting>
+count*(time_duration_ticks_per_second / count_ticks_per_second)
+ </programlisting>
+
+ For example, let's suppose we want to construct using a count that represents tenths
+ of a second. That is, each tick is 0.1 second.
+ <programlisting>
+int number_of_tenths = 5;
+//create a resolution independent count -- divide by 10 since there are
+//10 tenths in a second.
+int count = number_of_tenths*(time_duration::ticks_per_second()/10);
+time_duration td(1,2,3,count); //01:02:03.5 //no matter the resolution settings
+ </programlisting>
+ </para>
+
+ <anchor id="time_duration_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ <programlisting>#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
+or
+#include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types</programlisting>
+ </para>
+
+ <anchor id="time_duration_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration(hours,
+ minutes,
+ seconds,
+ fractional_seconds)</screen></entry>
+ <entry>Construct a duration from the counts. The fractional_second parameter is a number of units and is therefore affected by the resolution the application is compiled with (see <link linkend="compile_options">Build-Compiler Information</link>). If the fractional_seconds argument exceeds the limit of the compiled precision, the excess value will be "carried over" into the seconds field. See above for techniques to creating a resolution independent count.</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3,9);
+//1 hr 2 min 3 sec 9 nanoseconds
+time_duration td2(1,2,3,123456789);
+time_duration td3(1,2,3,1000);
+// with microsecond resolution (6 digits)
+// td2 => "01:04:06.456789"
+// td3 => "01:02:03.001000"
+// with nanosecond resolution (9 digits)
+// td2 => "01:02:03.123456789"
+// td3 => "01:02:03.000001000"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top"><screen>time_duration(special_value sv)</screen></entry>
+ <entry>Special values constructor. <emphasis role="strong">Important note</emphasis>: When a time_duration is a special value, either by construction or other means, the following accessor functions will give unpredictable results: <screen>hours(), minutes(), seconds(), ticks(),
+fractional_seconds(), total_nanoseconds(),
+total_microseconds(), total_milliseconds(),
+total_seconds()</screen>The remaining accessor functions will work as expected.</entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="time_duration_count_constr" />
+ <bridgehead renderas="sect3">Count Based Construction</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>hours(long)</screen></entry>
+ <entry>Number of hours</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td = hours(3);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>minutes(long)</screen></entry>
+ <entry>Number of minutes</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td = minutes(3);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>seconds(long)</screen></entry>
+ <entry> Number of seconds</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td = seconds(3);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>milliseconds(long)</screen></entry>
+ <entry>Number of milliseconds.</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td = milliseconds(3);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>microseconds(long)</screen></entry>
+ <entry>Number of microseconds.</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td = microseconds(3);</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>nanoseconds(long)</screen></entry>
+ <entry>Number of nanoseconds.</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td = nanoseconds(3);</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="time_duration_from_string" />
+ <bridgehead renderas="sect3">Construct from String</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration duration_from_string(std::string)</screen></entry>
+ <entry>From delimited string. NOTE: Excess digits in fractional seconds will be dropped. Ex: "1:02:03.123456999" =&gt; 1:02:03.123456. This behavior is affected by the precision the library is compiled with (see <link linkend="date_time.buildinfo">Build-Compiler Information</link>.</entry>
+ </row>
+ <row>
+ <entry><screen>std::string ts("23:59:59.000");
+time_duration td(duration_from_string(ts));</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="time_duration_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>long hours()</screen></entry>
+ <entry>Get the number of normalized hours (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3);
+time_duration neg_td(-1,2,3);
+td.hours(); // --> 1
+neg_td.hours(); // --> -1</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>long minutes()</screen></entry>
+ <entry>Get the number of minutes normalized +/-(0..59) (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3);
+time_duration neg_td(-1,2,3);
+td.minutes(); // --> 2
+neg_td.minutes(); // --> -2</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>long seconds()</screen></entry>
+ <entry>Get the normalized number of second +/-(0..59) (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3);
+time_duration neg_td(-1,2,3);
+td.seconds(); // --> 3
+neg_td.seconds(); // --> -3</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>long total_seconds()</screen></entry>
+ <entry>Get the total number of seconds truncating any fractional seconds (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3,10);
+td.total_seconds();
+// --> (1*3600) + (2*60) + 3 == 3723</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>long total_milliseconds()</screen></entry>
+ <entry>Get the total number of milliseconds truncating any remaining digits (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3,123456789);
+td.total_milliseconds();
+// HMS --> (1*3600) + (2*60) + 3 == 3723 seconds
+// milliseconds is 3 decimal places
+// (3723 * 1000) + 123 == 3723123</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>long total_microseconds()</screen></entry>
+ <entry>Get the total number of microseconds truncating any remaining digits (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3,123456789);
+td.total_microseconds();
+// HMS --> (1*3600) + (2*60) + 3 == 3723 seconds
+// microseconds is 6 decimal places
+// (3723 * 1000000) + 123456 == 3723123456</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>long total_nanoseconds()</screen></entry>
+ <entry>Get the total number of nanoseconds truncating any remaining digits (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3,123456789);
+td.total_nanoseconds();
+// HMS --> (1*3600) + (2*60) + 3 == 3723 seconds
+// nanoseconds is 9 decimal places
+// (3723 * 1000000000) + 123456789
+// == 3723123456789</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>long fractional_seconds()</screen></entry>
+ <entry>Get the number of fractional seconds (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3, 1000);
+td.fractional_seconds(); // --> 1000</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_negative()</screen></entry>
+ <entry>True if duration is negative.</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(-1,0,0);
+td.is_negative(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration invert_sign()</screen></entry>
+ <entry>Generate a new duration with the sign inverted/</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(-1,0,0);
+td.invert_sign(); // --> 01:00:00</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>date_time::time_resolutions resolution()</screen></entry>
+ <entry>Describes the resolution capability of the time_duration class. time_resolutions is an enum of resolution possibilities ranging from seconds to nanoseconds.</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration::resolution() --> nano</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration::num_fractional_digits()</screen></entry>
+ <entry>Returns an unsigned short holding the number of fractional digits the time resolution has.</entry>
+ </row>
+ <row>
+ <entry><screen>unsigned short secs;
+secs = time_duration::num_fractional_digits();
+// 9 for nano, 6 for micro, etc.</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration::ticks_per_second()</screen></entry>
+ <entry>Return the number of ticks in a second. For example, if the duration supports nanoseconds then the returned result will be 1,000,000,000 (1e+9).</entry>
+ </row>
+ <row>
+ <entry><screen>std::cout &lt;&lt; time_duration::ticks_per_second();</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>boost::int64_t ticks()</screen></entry>
+ <entry>Return the raw count of the duration type (will give unpredictable results if calling <code>time_duration</code> is a <code>special_value</code>).</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(0,0,0, 1000);
+td.ticks() // --> 1000</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration unit()</screen></entry>
+ <entry>Return smallest possible unit of duration type (1 nanosecond).</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration::unit() --> time_duration(0,0,0,1)</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_neg_infinity() const</screen></entry>
+ <entry>Returns true if time_duration is negative infinity</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(neg_infin);
+td.is_neg_infinity(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_pos_infinity() const</screen></entry>
+ <entry>Returns true if time_duration is positive infinity</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(neg_infin);
+td.is_pos_infinity(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_not_a_date_time() const</screen></entry>
+ <entry>Returns true if value is not a time</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(not_a_date_time);
+td.is_not_a_date_time(); // --> true</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_special() const</screen></entry>
+ <entry>Returns true if time_duration is any <code>special_value</code></entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(pos_infin);
+time_duration td2(not_a_date_time);
+time_duration td3(2,5,10);
+td.is_special(); // --> true
+td2.is_special(); // --> true
+td3.is_special(); // --> false</screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="time_duration_to_string" />
+ <bridgehead renderas="sect3">Conversion To String</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string to_simple_string(time_duration)</screen></entry>
+ <entry>To <code>HH:MM:SS.fffffffff</code> were <code>fff</code> is fractional seconds that are only included if non-zero.</entry>
+ </row>
+ <row>
+ <entry><screen>10:00:01.123456789</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string to_iso_string(time_duration)</screen></entry>
+ <entry>Convert to form <code>HHMMSS,fffffffff</code>.</entry>
+ </row>
+ <row>
+ <entry><screen>100001,123456789</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="time_duration_operators" />
+ <bridgehead renderas="sect3">Operators</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;&lt;, operator&gt;&gt;</screen></entry>
+ <entry>Streaming operators. <emphasis role="strong">Note:</emphasis> As of version 1.33, streaming operations have been greatly improved. See <link linkend="date_time.date_time_io">Date Time IO System</link> for more details (including exceptions and error conditions).</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(0,0,0);
+stringstream ss("14:23:11.345678");
+ss &gt;&gt; td;
+std::cout &lt;&lt; td; // "14:23:11.345678"
+ </screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator==, operator!=,
+operator>, operator&lt;,
+operator>=, operator&lt;=</screen>
+ </entry>
+ <entry>A full complement of comparison operators</entry>
+ </row>
+ <row>
+ <entry><screen>dd1 == dd2, etc</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration operator+(time_duration)</screen></entry>
+ <entry>Add durations.</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td1(hours(1)+minutes(2));
+time_duration td2(seconds(10));
+time_duration td3 = td1 + td2;</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration operator-(time_duration)</screen></entry>
+ <entry>Subtract durations.</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td1(hours(1)+nanoseconds(2));
+time_duration td2 = td1 - minutes(1);</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration operator/(int)</screen></entry>
+ <entry>Divide the length of a duration by an integer value. Discards any remainder.</entry>
+ </row>
+ <row>
+ <entry><screen>hours(3)/2 == time_duration(1,30,0);
+nanosecond(3)/2 == nanosecond(1);</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration operator*(int)</screen></entry>
+ <entry>Multiply the length of a duration by an integer value.</entry>
+ </row>
+ <row>
+ <entry><screen>hours(3)*2 == hours(6);</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="time_duration_struct_tm" />
+ <bridgehead renderas="sect3">Struct tm, time_t, and FILETIME Functions</bridgehead>
+ <para>Function for converting a time_duration to a <code>tm</code> struct is provided.</para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>tm to_tm(time_duration)</screen></entry>
+ <entry>A function for converting a <code>time_duration</code> object to a <code>tm</code> struct. The fields: <code>tm_year</code>, <code>tm_mon</code>, <code>tm_mday</code>, <code>tm_wday</code>, <code>tm_yday</code> are set to zero. The <code>tm_isdst</code> field is set to -1.</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3);
+tm td_tm = to_tm(td);
+/* tm_year => 0
+ tm_mon => 0
+ tm_mday => 0
+ tm_wday => 0
+ tm_yday => 0
+ tm_hour => 1
+ tm_min => 2
+ tm_sec => 3
+ tm_isddst => -1 */</screen>
+ </entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_facet.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_facet.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.time_facet">
+ <title>Time Facet</title>
+
+ <link linkend="time_facet_intro">Introduction</link> -
+ <link linkend="time_facet_constr">Construction</link> -
+ <link linkend="time_facet_accessors">Accessors</link>
+
+ <anchor id="time_facet_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>The <code>boost::date_time::time_facet</code> is an extension of the <code>boost::date_time::date_facet</code>. The time_facet is typedef'ed in the <code>posix_time</code> namespace as <code>time_facet</code> and <code>wtime_facet</code>. It is typedef'd in the <code>local_time</code> namespace as <code>local_time_facet</code> and <code>wlocal_time_facet</code>.
+ </para>
+
+ <anchor id="time_facet_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>time_facet()</screen></entry>
+ <entry>Default constructor</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>time_facet(...)
+ Parameters:
+ char_type* format
+ period_formatter_type
+ special_values_formatter_type
+ date_gen_formatter_type</screen></entry>
+ <entry>Format given will be used for time output. The remaining parameters are formatter objects. Further details on these objects can be found <link linkend="date_time.io_objects">here</link>. This constructor also provides default arguments for all parameters except the format. Therefore, <code>time_facet("%H:%M:S %m %d %Y")</code> will work.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="time_facet_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ The time_facet inherits all the public date_facet methods. Therefore, the date_facet methods are not listed here. Instead, they can be found by following <link linkend="date_time.date_facet">this</link> link.
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>void time_duration_format(...)
+ Parameter:
+ char_type*</screen></entry>
+ <entry>Sets the time_duration format. The time_duration format has the ability to display the sign of the duration. The <code>'%+'</code> flag will always display the sign. The <code>'%-'</code> will only display if the sign is negative. Currently the '-' and '+' characters are used to denote the sign.</entry>
+ </row>
+ <row>
+ <entry><screen>f->time_duration_format("%+%H:%M");
+// hours and minutes only w/ sign always displayed
+time_duration td1(3, 15, 56);
+time_duration td2(-12, 25, 32);
+ss &lt;&lt; td1; // "+03:15:56"
+ss &lt;&lt; td2; // "-12:25:56"
+ </screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void set_iso_format()</screen></entry>
+ <entry>Sets the date and time format to ISO.</entry>
+ </row>
+ <row>
+ <entry><screen>f->set_iso_format();
+// "%Y%m%dT%H%M%S%F%q"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void set_iso_extended_format()</screen></entry>
+ <entry>Sets the date and time format to ISO Extended</entry>
+ </row>
+ <row>
+ <entry><screen>f->set_iso_extended_format();
+// "%Y-%m-%d %H:%M:%S%F%Q"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(...)
+ Common parameters for all
+ 'put' functions:
+ OutItrT
+ ios_base
+ char_type
+ Unique parameter for 'put' funcs:
+ posix_time object</screen></entry>
+ <entry>There are 3 put functions in the time_facet. The common parameters are: an iterator pointing to the next item in the stream, an ios_base object, and the fill character. Each unique posix_time object has it's own put function. Each unique put function is described below.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., ptime)</screen></entry>
+ <entry>Puts a ptime object into the stream using the format set by <code>format(...)</code> or the default.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., time_duration)</screen></entry>
+ <entry>Puts a time_duration object into the stream using the format set by <code>time_duration_format(...)</code> or the default.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>OutItrT put(..., time_period)</screen></entry>
+ <entry>Puts a time_period into the stream. The format of the dates and times will use the format set by <code>format(..)</code> or the default date/time format. The type of period (open or closed range) and the delimiters used are those used by the period_formatter.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+</section>
+
+

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_input_facet.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_input_facet.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.time_input_facet">
+ <title>Time Input Facet</title>
+
+ <link linkend="time_input_facet_intro">Introduction</link> -
+ <link linkend="time_input_facet_constr">Construction</link> -
+ <link linkend="time_input_facet_accessors">Accessors</link>
+
+ <anchor id="time_input_facet_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>The <code>boost::date_time::time_input_facet</code> is an extension of the <code>date_input_facet</code>. It is typedef'ed in the <code>boost::posix_time</code> namespace as <code>time_input_facet</code> and <code>wtime_input_facet</code>. It is typedef'ed in the <code>boost::local_time</code> namespace as <code>local_time_input_facet</code> and <code>wlocal_time_input_facet</code>.
+ </para>
+
+ <anchor id="time_input_facet_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>time_input_facet()</screen></entry>
+ <entry>Default constructor</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>time_input_facet(string_type)</screen></entry>
+ <entry>Format given will be used for date/time input. All other formats will use their defaults.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>time_input_facet(...)
+ Parameters:
+ string_type format
+ format_date_parser_type
+ special_values_parser_type
+ period_parser_type
+ date_gen_parser_type</screen></entry>
+<entry>Format given will be used for date/time input. The remaining parameters are parser objects. Further details on these objects can be found <link linkend="date_time.io_objects">here</link>.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="time_input_facet_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ The time_input_facet inherits all the public date_input_facet methods. Therefore, the date_input_facet methods are not listed here. Instead, they can be found by following <link linkend="date_time.date_input_facet">this</link> link.
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void set_iso_format()</screen></entry>
+ <entry>Sets the time format to ISO</entry>
+ </row>
+ <row>
+ <entry><screen>f->set_iso_format();
+// "%Y%m%dT%H%M%S%F%q"
+"20051225T132536.789-0700"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void set_iso_extended_format()</screen></entry>
+ <entry>Sets the date format to ISO Extended</entry>
+ </row>
+ <row>
+ <entry><screen>f->set_iso_extended_format();
+// "%Y-%m-%d %H:%M:%S%F %Q"
+"2005-12-25 13:25:36.789 -07:00"</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>void time_duration_format(...)
+ Parameter:
+ char_type*</screen></entry>
+ <entry>Sets the time_duration format.</entry>
+ </row>
+ <row>
+ <entry><screen>f->time_duration_format("%H:%M");
+// hours and minutes only</screen></entry>
+ </row>
+
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(...)
+ Common parameters for all
+ 'get' functions:
+ InItrT from
+ InItrT to
+ ios_base
+ Unique parameter for 'get' funcs:
+ gregorian object</screen></entry>
+ <entry>There are 3 get functions in the time_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.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., ptime)</screen></entry>
+ <entry>Gets a ptime object from the stream using the format set by <code>format(...)</code> or the default.</entry>
+ </row>
+ <row>
+ <entry><screen>ss.str("2005-Jan-01 13:12:01");
+ss >> pt; // default format</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., time_duration)</screen></entry>
+ <entry>Gets a time_duration object from the stream using the format set by <code>time_duration_format(...)</code> or the default.</entry>
+ </row>
+ <row>
+ <entry><screen>ss.str("01:25:15.000123000");
+ss >> td; // default format</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get(..., time_period)</screen></entry>
+ <entry>Gets a time_period from the stream. The format of the dates/times will use the format set by <code>format(..)</code> or the default date and time format. The type of period (open or closed range) and the delimiters used are those used by the period_parser.</entry>
+ </row>
+ <row>
+ <entry>see the <link linkend="date_time.io_tutorial">tutorial</link> for a complete example.</entry>
+ </row>
+
+ <!-- This should be changed later
+ <row>
+ <entry valign="top" morerows="1"><screen>InItrT get_local_time(..., local_date_time)</screen></entry>
+ <entry>Gets a local_date_time object from the stream using the format set by <code>format(...)</code> or the default.</entry>
+ </row>
+ <row>
+ <entry><screen></screen></entry>
+ </row>
+ -->
+
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_iterators.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_iterators.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.posix_time.time_iterators">
+ <title>Time Iterators</title>
+
+ <link linkend="time_iter_intro">Introduction</link> --
+ <link linkend="time_iter_header">Header</link> --
+ <link linkend="time_iter_overview">Overview</link> --
+ <link linkend="time_iter_operators">Operators</link>
+
+ <anchor id="time_iter_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ Time iterators provide a mechanism for iteration through times. Time iterators are similar to <ulink url="http://www.sgi.com/tech/stl/BidirectionalIterator.html">Bidirectional Iterators</ulink>. However, time_iterators are different than standard iterators in that there is no underlying sequence, just a calculation function. In addition, time_iterators are directly comparable against instances of <link linkend="date_time.posix_time.ptime_class">class ptime</link>. Thus a second iterator for the end point of the iteration is not required, but rather a point in time can be used directly. For example, the following code iterates using a 15 minute iteration interval. The <link linkend="date_time.examples.print_hours">print hours</link> example also illustrates the use of the time_iterator.
+ </para>
+ <para>
+ <programlisting>
+ <![CDATA[
+ #include "boost/date_time/posix_time/posix_time.hpp"
+ #include <iostream>
+
+
+ int
+ main()
+ {
+ using namespace boost::gregorian;
+ using namespace boost::posix_time;
+ date d(2000,Jan,20);
+ ptime start(d);
+ ptime end = start + hours(1);
+ time_iterator titr(start,minutes(15)); //increment by 15 minutes
+ //produces 00:00:00, 00:15:00, 00:30:00, 00:45:00
+ while (titr < end) {
+ std::cout << to_simple_string(*titr) << std::endl;
+ ++titr;
+ }
+ std::cout << "Now backward" << std::endl;
+ //produces 01:00:00, 00:45:00, 00:30:00, 00:15:00
+ while (titr > start) {
+ std::cout << to_simple_string(*titr) << std::endl;
+ --titr;
+ }
+ }
+ ]]>
+ </programlisting>
+ </para>
+
+ <anchor id="time_iter_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ <programlisting>#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
+or
+#include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types</programlisting>
+ </para>
+
+ <anchor id="time_iter_overview" />
+ <bridgehead renderas="sect3">Overview</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Class</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Construction Parameters</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>time_iterator</screen></entry>
+ <entry>Iterate incrementing by the specified duration.</entry>
+ </row>
+ <row>
+ <entry><screen>ptime start_time, time_duration increment</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="time_iter_operators" />
+ <bridgehead renderas="sect3">Operators</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>operator==(const ptime&amp; rhs),
+operator!=(const ptime&amp; rhs),
+operator>, operator&lt;,
+operator>=, operator&lt;=</screen>
+ </entry>
+ <entry>A full complement of comparison operators</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,1);
+ptime start_time(d, hours(1));
+//increment by 10 minutes
+time_iterator titr(start_time, minutes(10));
+ptime end_time = start_time + hours(2);
+if (titr == end_time) // false
+if (titr != end_time) // true
+if (titr >= end_time) // false
+if (titr &lt;= end_time) // true</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>prefix increment</screen></entry>
+ <entry>Increment the iterator by the specified duration.</entry>
+ </row>
+ <row>
+ <entry><screen>//increment by 10 milli seconds
+time_iterator titr(start_time, milliseconds(10));
+++titr; // == start_time + 10 milliseconds</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>prefix decrement</screen></entry>
+ <entry>Decrement the iterator by the specified time duration.</entry>
+ </row>
+ <row>
+ <entry><screen>time_duration td(1,2,3);
+time_iterator titr(start_time, td);
+--titr; // == start_time - 01:02:03</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_period.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_period.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,394 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2006 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.posix_time.time_period">
+ <title>Time Period</title>
+
+ <link linkend="time_period_intro">Introduction</link> --
+ <link linkend="time_period_header">Header</link> --
+ <link linkend="time_period_constr">Construction</link> --
+ <link linkend="time_period_mutators">Mutators</link> --
+ <link linkend="time_period_accessors">Accessors</link> --
+ <link linkend="time_period_to_string">Conversion To String</link> --
+ <link linkend="time_period_operators">Operators</link>
+
+ <anchor id="time_period_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ The class boost::posix_time::time_period provides direct representation for ranges between two times. Periods provide the ability to simplify some types of calculations by simplifying the conditional logic of the program.
+ </para>
+ <para>
+ 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 <code>last</code> point will always be one unit less that the <code>begin</code> point.
+ </para>
+ <para>
+ The <link linkend="date_time.examples.time_periods">time periods example</link> provides an example of using time periods.
+ </para>
+
+ <anchor id="time_period_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ <programlisting>#include "boost/date_time/posix_time/posix_time.hpp" //include all types plus i/o
+or
+#include "boost/date_time/posix_time/posix_time_types.hpp" //no i/o just types</programlisting>
+ </para>
+
+ <anchor id="time_period_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>time_period(ptime,
+ ptime)</screen></entry>
+ <entry> Create a period as [begin, end). If end is &lt;= begin then the period will be defined as invalid.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,01);
+ptime t(d, seconds(10)); //10 sec after midnight
+time_period tp(t, hours(3));</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_period(ptime,
+ time_duration)</screen></entry>
+ <entry> Create a period as [begin, begin+len) where end would be begin+len. If len is &lt;= zero then the period will be defined as invalid.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,01);
+ptime t1(d, seconds(10)); //10 sec after midnight
+ptime t2(d, hours(10)); //10 hours after midnight
+time_period tp(t1, t2);</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_period(time_period rhs)</screen></entry>
+ <entry> Copy constructor</entry>
+ </row>
+ <row>
+ <entry><screen>time_period tp1(tp);</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="time_period_mutators" />
+ <bridgehead renderas="sect3">Mutators</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_period shift(time_duration)</screen></entry>
+ <entry>Add duration to both begin and end.</entry>
+ </row>
+ <row>
+ <entry>
+ <screen>
+time_period tp(ptime(date(2005,Jan,1),hours(1)), hours(2));
+tp.shift(minutes(5));
+// tp == 2005-Jan-01 01:05:00 to 2005-Jan-01 03:05:00
+ </screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_period expand(days)</screen></entry>
+ <entry>Add duration to both begin and end.</entry>
+ </row>
+ <row>
+ <screen>
+time_period tp(ptime(date(2005,Jan,1),hours(1)), hours(2));
+tp.expand(minutes(5));
+// tp == 2005-Jan-01 00:55:00 to 2005-Jan-01 03:05:00
+ </screen>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="time_period_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime begin()</screen></entry>
+ <entry>Return first time of period.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,01);
+ptime t1(d, seconds(10)); //10 sec after midnight
+ptime t2(d, hours(10)); //10 hours after midnight
+time_period tp(t1, t2);
+tp.begin(); // --> 2002-Jan-01 00:00:10</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime last()</screen></entry>
+ <entry>Return last time in the period</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,01);
+ptime t1(d, seconds(10)); //10 sec after midnight
+ptime t2(d, hours(10)); //10 hours after midnight
+time_period tp(t1, t2);
+tp.last();// --> 2002-Jan-01 09:59:59.999999999</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>ptime end()</screen></entry>
+ <entry> Return one past the last in period</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,01);
+ptime t1(d, seconds(10)); //10 sec after midnight
+ptime t2(d, hours(10)); //10 hours after midnight
+time_period tp(t1, t2);
+tp.last(); // --> 2002-Jan-01 10:00:00</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_duration length()</screen></entry>
+ <entry>Return the length of the time period.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,01);
+ptime t1(d); //midnight
+time_period tp(t1, hours(1));
+tp.length() --> 1 hour</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool is_null()</screen></entry>
+ <entry>True if period is not well formed. eg: end is less than or equal to begin.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,01);
+ptime t1(d, hours(12)); // noon on Jan 1st
+ptime t2(d, hours(9)); // 9am on Jan 1st
+time_period tp(t1, t2);
+tp.is_null(); // true</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool contains(ptime)</screen></entry>
+ <entry>True if ptime is within the period. Zero length periods cannot contain any points.</entry>
+ </row>
+ <row>
+ <entry><screen>date d(2002,Jan,01);
+ptime t1(d, seconds(10)); //10 sec after midnight
+ptime t2(d, hours(10)); //10 hours after midnight
+ptime t3(d, hours(2)); //2 hours after midnight
+time_period tp(t1, t2);
+tp.contains(t3); // true
+time_period tp2(t1, t1);
+tp2.contains(t1); // false</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool contains(time_period)</screen></entry>
+ <entry>True if period is within the period</entry>
+ </row>
+ <row>
+ <entry><screen>time_period tp1(ptime(d,hours(1)),
+ ptime(d,hours(12)));
+time_period tp2(ptime(d,hours(2)),
+ ptime(d,hours(4)));
+tp1.contains(tp2); // --> true
+tp2.contains(tp1); // --> false</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool intersects(time_period)</screen></entry>
+ <entry> True if periods overlap</entry>
+ </row>
+ <row>
+ <entry><screen>time_period tp1(ptime(d,hours(1)),
+ ptime(d,hours(12)));
+time_period tp2(ptime(d,hours(2)),
+ ptime(d,hours(4)));
+tp2.intersects(tp1); // --> true</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_period intersection(time_period)</screen></entry>
+ <entry>Calculate the intersection of 2 periods. Null if no intersection.</entry>
+ </row>
+ <row>
+ <entry></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_period merge(time_period)</screen></entry>
+ <entry>Returns union of two periods. Null if no intersection.</entry>
+ </row>
+ <row>
+ <entry></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_period span(time_period)</screen></entry>
+ <entry>Combines two periods and any gap between them such that begin = min(p1.begin, p2.begin) and end = max(p1.end , p2.end).</entry>
+ </row>
+ <row>
+ <entry></entry>
+ </row>
+
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="time_period_to_string" />
+ <bridgehead renderas="sect3">Conversion To String</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>std::string
+ to_simple_string(time_period dp)</screen></entry>
+ <entry>To <code>[YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff]</code> string where <code>mmm</code> is 3 char month name.</entry>
+ </row>
+ <row>
+ <entry><screen>[2002-Jan-01 01:25:10.000000001/
+ 2002-Jan-31 01:25:10.123456789]
+// string occupies one line</screen></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+
+ <anchor id="time_period_operators" />
+ <bridgehead renderas="sect3">Operators</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;&lt;</screen></entry>
+ <entry>Output streaming operator for time duration. Uses facet to output [date time_of_day/date time_of_day]. The default is format is <code>[YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff]</code> string where <code>mmm</code> is 3 char month name and the fractional seconds are left out when zero.</entry>
+ </row>
+ <row>
+ <entry><screen>[2002-Jan-01 01:25:10.000000001/ \
+ 2002-Jan-31 01:25:10.123456789]</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&gt;&gt;</screen></entry>
+ <entry>Input streaming operator for time duration. Uses facet to read [date time_of_day/date time_of_day]. The default is format is <code>[YYYY-mmm-DD hh:mm:ss.fffffffff/YYYY-mmm-DD hh:mm:ss.fffffffff]</code> string where <code>mmm</code> is 3 char month name and the fractional seconds are left out when zero.</entry>
+ </row>
+ <row>
+ <entry><screen>[2002-Jan-01 01:25:10.000000001/ \
+ 2002-Jan-31 01:25:10.123456789]</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator==, operator!=</screen></entry>
+ <entry>Equality operators. Periods are equal if p1.begin == p2.begin &amp;&amp; p1.last == p2.last</entry>
+ </row>
+ <row>
+ <entry><screen>if (tp1 == tp2) {...</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;</screen></entry>
+ <entry>Ordering with no overlap. True if tp1.end() less than tp2.begin()</entry>
+ </row>
+ <row>
+ <entry><screen>if (tp1 &lt; tp2) {...</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&gt;</screen></entry>
+ <entry>Ordering with no overlap. True if tp1.begin() greater than tp2.end()</entry>
+ </row>
+ <row>
+ <entry><screen>if (tp1 > tp2) {... etc</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>operator&lt;=, operator&gt;=</screen></entry>
+ <entry>Defined in terms of the other operators.</entry>
+ </row>
+ <row>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_zone_base.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/time_zone_base.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.local_time.time_zone_base">
+ <title>Time Zone (abstract)</title>
+
+ <link linkend="time_zone_base_intro">Introduction</link> --
+ <link linkend="time_zone_base_header">Header</link> --
+ <link linkend="time_zone_base_constr">Construction</link> --
+ <link linkend="time_zone_base_accessors">Accessors</link>
+
+ <anchor id="time_zone_base_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ The time_zone_base class is an abstract base class template for representing time zones. Time zones are a set of data and rules that provide information about a time zone. The date_time library handles time_zones by means of a boost::shared_ptr&lt;time_zone_base&gt;. A user's custom time zone class will work in the date_time library by means of this shared_ptr.
+ </para>
+ <para>
+ For convienience, the time_zone_base class is typedef'd as time_zone. All references in the documentation to time_zone, are referring to this typedef.
+ </para>
+
+ <anchor id="time_zone_base_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ The time_zone_base class is defined in the header:
+ <programlisting>#include "boost/date_time/time_zone_base.hpp"
+ </programlisting>
+ </para>
+
+ <anchor id="time_zone_base_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ A default constructor is provided in the time_zone_base class. There are no private data members in this base class to initialize.
+ </para>
+ <para>
+ Template parameters are time_type (typically posix_time::ptime) and CharT (defaults to char).
+ </para>
+
+ <anchor id="time_zone_base_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ All of the accessors listed here are pure virtual functions.
+ </para>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top"><screen>
+string_type dst_zone_abbrev();</screen></entry>
+ <entry>Returns the daylight savings abbreviation for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>
+string_type std_zone_abbrev();</screen></entry>
+ <entry>Returns the standard abbreviation for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>
+string_type dst_zone_name();</screen></entry>
+ <entry>Returns the daylight savings name for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>
+string_type std_zone_name();</screen></entry>
+ <entry>Returns the standard name for the represented time zone.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>bool has_dst();</screen></entry>
+ <entry>Returns true if this time zone does not make a daylight savings shift.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>
+time_type dst_local_start_time(year_type);</screen></entry>
+ <entry>The date and time daylight savings time begins in given year.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>
+time_type dst_local_end_time(year_type);</screen></entry>
+ <entry valign="top">The date and time daylight savings time ends in given year.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>
+time_duration_type base_utc_offset();</screen></entry>
+ <entry>The amount of time offset from UTC (typically in hours).</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>
+time_duration_type dst_offset();</screen></entry>
+ <entry>The amount of time shifted during daylight savings.</entry>
+ </row>
+ <row>
+ <entry valign="top"><screen>
+std::string to_posix_string();</screen></entry>
+ <entry>Returns a posix time zone string representation of this time_zone_base object. For a detailed description of a posix time zone string see <link linkend="date_time.local_time.posix_time_zone">posix_time_zone</link>.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/tradeoffs.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/tradeoffs.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-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)
+-->
+
+<section id="date_time.tradeoffs">
+ <title>Tradeoffs: Stability, Predictability, and Approximations</title>
+ <bridgehead renderas="sect2">
+ Unavoidable Trade-offs
+ </bridgehead>
+ <para>
+ The library does its best to provide everything a user could want, but there are certain inherent constraints that limit what <emphasis>any</emphasis> temporal library can do. Specifically, a user must choose which two of the following three capabilities are desired in any particular application:
+ <itemizedlist mark="bullet">
+ <listitem>exact agreement with wall-clock time</listitem>
+ <listitem>accurate math, e.g. duration calculations</listitem>
+ <listitem>ability to handle timepoints in the future</listitem>
+ </itemizedlist>
+ Some libraries may implicitly promise to deliver all three, but if you actually put them to the test, only two can be true at once. This limitation is not a deficiency in the design or implementation of any particular library; rather it is a consequence of the way different time systems are defined by international standards. Let's look at each of the three cases:
+ </para>
+ <para>
+ If you want exact agreement with wall-clock time, you must use either UTC or local time. If you compute a duration by subtracting one UTC time from another and you want an answer accurate to the second, the two times must not be too far in the future because leap seconds affect the count but are only determined about 6 months in advance. With local times a future duration calculation could be off by an entire hour, since legislatures can and do change DST rules at will.
+ </para>
+ <para>
+ If you want to handle wall-clock times in the future, you won't be able (in the general case) to calculate exact durations, for the same reasons described above.
+ </para>
+ <para>
+ If you want accurate calculations with future times, you will have to use TAI or an equivalent, but the mapping from TAI to UTC or local time depends on leap seconds, so you will not have exact agreement with wall-clock time.
+ </para>
+
+ <bridgehead renderas="sect2">
+ Stability, Predictability, and Approximations
+ </bridgehead>
+ <para>
+ Here is some underlying theory that helps to explain what's going on. Remember that a temporal type, like any abstract data type (ADT), is a set of values together with operations on those values.
+ </para>
+
+ <bridgehead renderas="sect3">
+ Stability
+ </bridgehead>
+ <para>
+ The representation of a type is <emphasis>stable</emphasis> if the bit pattern associated with a given value does not change over time. A type with an unstable representation is unlikely to be of much use to anyone, so we will insist that any temporal library use only stable representations.
+ </para>
+ <para>
+ An operation on a type is stable if the result of applying the operation to a particular operand(s) does not change over time.
+ </para>
+
+ <bridgehead renderas="sect3">
+ Predictability
+ </bridgehead>
+ <para>
+ Sets are most often classified into two categories: well-defined and ill-defined. Since a type is a set, we can extend these definitions to cover types. For any type T, there must be a predicate <emphasis>is_member( x )</emphasis> which determines whether a value x is a member of type T. This predicate must return <emphasis>true, false,</emphasis> or <emphasis>dont_know</emphasis>.
+ </para>
+ <para>
+ If for all x, is_member( x ) returns either true or false, we say the set T is <emphasis>well-defined</emphasis>.
+ </para>
+ <para>
+ If for any x, is_member( x ) returns dont_know, we say the set T is <emphasis>ill-defined</emphasis>.
+ </para>
+ <para>
+ Those are the rules normally used in math. However, because of the special characteristics of temporal types, it is useful to refine this view and create a third category as follows:
+ </para>
+ <para>
+ For any temporal type T, there must be a predicate <emphasis>is_member( x, t )</emphasis> which determines whether a value x is a member of T. The parameter t represents the time when the predicate is evaluated. For each x<subscript>i</subscript>, there must be a time t<subscript>i</subscript> and a value v such that:
+ <itemizedlist mark="bullet">
+ <listitem>v = true or v = false, and</listitem>
+ <listitem>for all t &lt; t<subscript>i</subscript>, is_member( x<subscript>i</subscript>, t ) returns dont_know, and</listitem>
+ <listitem>for all t >= t<subscript>i</subscript>, is_member( x<subscript>i</subscript>, t ) returns v.</listitem>
+ </itemizedlist>
+ t<subscript>i</subscript> is thus the time when we "find out" whether x<subscript>i</subscript> is a member of T. Now we can define three categories of temporal types:
+ </para>
+ <para>
+ If for all x<subscript>i</subscript>, t<subscript>i</subscript> = negative infinity, we say the type T is <emphasis>predictable</emphasis>.
+ </para>
+ <para>
+ If for some x<subscript>i</subscript>, t<subscript>i</subscript> = positive infinity, we say the type T is <emphasis>ill-formed</emphasis>.
+ </para>
+ <para>
+ Otherwise we say the type T is <emphasis>unpredictable</emphasis> (this implies that for some x<subscript>i</subscript>, t<subscript>i</subscript> is finite).
+ </para>
+ <para>
+ Ill-formed sets are not of much practical use, so we will not discuss them further. In plain english the above simply says that all the values of a predictable type are known ahead of time, but some values of an unpredictable type are not known until some particular time.
+ </para>
+
+ <bridgehead renderas="sect3">
+ Stability of Operations
+ </bridgehead>
+ <para>
+ Predictable types have a couple of important properties:
+ <itemizedlist mark="bullet">
+ <listitem>there is an order-preserving mapping from their elements onto a set of consecutive integers, and</listitem>
+ <listitem>duration operations on their values are stable</listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ The practical effect of this is that duration calculations can be implemented with simple integer subtraction. Examples of predictable types are TAI timepoints and Gregorian dates.
+ </para>
+ <para>
+ Unpredictable types have exactly the opposite properties:
+ <itemizedlist mark="bullet">
+ <listitem>there is no order-preserving mapping from their elements onto a set of consecutive integers, and</listitem>
+ <listitem>duration operations on their values are not stable. </listitem>
+ </itemizedlist>
+ </para>
+ <para>
+ Examples of unpredictable types are UTC timepoints and Local Time timepoints.
+ </para>
+ <para>
+ We can refine this a little by saying that a range within an unpredicatable type can be predictable, and operations performed entirely on values within that range will be stable. For example, the range of UTC timepoints from 1970-01-01 through the present is predictable, so calculations of durations within that range will be stable.
+ </para>
+
+ <bridgehead renderas="sect3">
+ Approximations
+ </bridgehead>
+ <para>
+ These limitations are problematical, because important temporal types like UTC and Local Time are in fact unpredictable, and therefore operations on them are sometimes unstable. Yet as a practical matter we often want to perform this kind of operation, such as computing the duration between two timepoints in the future that are specified in Local Time.
+ </para>
+ <para>
+ The best the library can do is to provide an approximation, which is generally possible and for most purposes will be good enough. Of course the documentation must specify when an answer will be approximate (and thus unstable) and how big the error may be. In many respects calculating with unpredictable sets is analogous to the use of floating point numbers, for which results are expected to only be approximately correct. Calculating with predictable sets would then be analogous to the user of integers, where results are expected to be exact.
+ </para>
+ <para>
+ For situations where exact answers are required or instability cannot be tolerated, the user must be able to specify this, and then the library should throw an exception if the user requests a computation for which an exact, stable answer is not possible.
+ </para>
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/tz_database.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/tz_database.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.local_time.tz_database">
+ <title>Time Zone Database</title>
+
+ <link linkend="tz_database_intro">Introduction</link> --
+ <link linkend="tz_database_header">Header</link> --
+ <link linkend="tz_database_constr">Construction</link> --
+ <link linkend="tz_database_accessors">Accessors</link> --
+ <link linkend="tz_database_datafile">Data File Details</link>
+
+ <anchor id="tz_database_intro" />
+ <bridgehead renderas="sect3">Introduction</bridgehead>
+ <para>
+ The local_time system depends on the ability to store time zone information. Our Time Zone Database (tz_database) is a means of permanently storing that data. The specifications for many time zones (377 at this time) are provided. These specifications are based on data found in the <ulink url="http://www.twinsun.com/tz/tz-link.htm">zoneinfo datebase</ulink>. The specifications are stored in the file:<screen>libs/date_time/data/date_time_zonespec.csv</screen>. While this file already contains specifications for many time zones, it's real intent is for the user to modify it by adding (or removing) time zones to fit their application. See <link linkend="tz_database_datafile">Data File Details</link> to learn how this is accomplished.
+ </para>
+
+ <anchor id="tz_database_header" />
+ <bridgehead renderas="sect3">Header</bridgehead>
+ <para>
+ The inclusion of a single header will bring in all boost::local_time types, functions, and IO operators.
+ <programlisting>#include "boost/date_time/local_time/local_time.hpp"
+ </programlisting>
+ </para>
+
+ <anchor id="tz_database_constr" />
+ <bridgehead renderas="sect3">Construction</bridgehead>
+ <para>
+ The only constructor takes no arguments and creates an empty database. It is up to the user to populate the database. This is typically achieved by loading the desired datafile, but can also be accomplished by means of the <code>add_record(...)</code> function (see the <link linkend="tz_database_accessors">Accessors table</link>). A <code>local_time::data_not_accessible</code> exception will be thrown if given zonespec file cannot be found. <code>local_time::bad_field_count</code> exception will be thrown if the number of fields in given zonespec file is incorrect.
+ </para>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>tz_database()</screen></entry>
+ <entry>Constructor creates an empty database.</entry>
+ </row>
+ <row>
+ <entry><screen>tz_database tz_db;</screen></entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>bool load_from_file(std::string)</screen></entry>
+ <entry>Parameter is path to a time zone spec csv file (see <link linkend="tz_database_datafile">Data File Details</link> for details on the contents of this file). This function populates the database with time zone records found in the zone spec file. A <code>local_time::data_not_accessible</code> exception will be thrown if given zonespec file cannot be found. <code>local_time::bad_field_count</code> exception will be thrown if the number of fields in given zonespec file is incorrect.</entry>
+ </row>
+ <row>
+ <entry><screen>tz_database tz_db;
+tz_db.load_from_file("./date_time_zonespec.csv");</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="tz_database_accessors" />
+ <bridgehead renderas="sect3">Accessors</bridgehead>
+ <para>
+ <informaltable frame="all">
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry valign="top" morerows="1">Syntax</entry>
+ <entry>Description</entry>
+ </row>
+ <row>
+ <entry>Example</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry valign="top" morerows="1"><screen>bool tz_db.add_record(std::string id,
+ <link linkend="date_time.local_time.custom_time_zone_ptr">time_zone_ptr</link> tz);</screen></entry>
+ <entry>Adds a time_zone, or a posix_time_zone, to the database. ID is the region name for this zone (Ex: "America/Phoenix").</entry>
+ </row>
+ <row>
+ <entry><screen>time_zone_ptr zone(
+ new posix_time_zone("PST-8PDT,M4.1.0,M10.1.0")
+);
+std::string id("America/West_Coast");
+tz_db.add_record(id, zone);</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>time_zone_ptr
+ tz_db.time_zone_from_region(string id);</screen></entry>
+ <entry>Returns a time_zone, via a time_zone_ptr, that matches the region listed in the data file. A null pointer is returned if no match is found.
+ </entry>
+ </row>
+ <row>
+ <entry><screen>time_zone_ptr nyc =
+ tz_db.time_zone_from_region("America/New_York");</screen>
+ </entry>
+ </row>
+
+ <row>
+ <entry valign="top" morerows="1"><screen>vector&lt;string&gt; tz_db.region_list();</screen></entry>
+ <entry>Returns a vector of strings that holds all the region ID strings from the database.</entry>
+ </row>
+ <row>
+ <entry><screen>std::vector&lt;std::string&gt; regions;
+regions = tz_db.region_list();</screen>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <anchor id="tz_database_datafile" />
+ <bridgehead renderas="sect3">Data File Details</bridgehead>
+ <link linkend="tz_database_fields">Field Description/Details</link>
+ <para>
+ 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.
+ </para>
+ <para>
+ This first line is expected to contain column headings and is therefore
+not processed by the tz_database.
+ </para>
+ <para>
+ 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.
+ <literallayout>
+ Ex:
+ "America/Phoenix" &lt;- string enclosed in quotes
+ "" &lt;- empty field
+ </literallayout>
+ </para>
+ <para>
+ Some fields represent a length of time. The format of these fields must be:
+ <literallayout>
+ "{+|-}hh:mm[:ss]" &lt;- length-of-time format
+ </literallayout>
+ Where the plus or minus is mandatory and the seconds are optional.
+ </para>
+ <para>
+ 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).
+ </para>
+
+ <anchor id="tz_database_fields" />
+ <bridgehead renderas="sect3">Field Description/Details</bridgehead>
+ <para>
+ <itemizedlist>
+ <listitem>
+ ID
+ <para>
+ 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.
+ </para>
+ </listitem>
+ <listitem>
+ STD ABBR
+ </listitem>
+ <listitem>
+ STD NAME
+ </listitem>
+ <listitem>
+ DST ABBR
+ </listitem>
+ <listitem>
+ DST NAME
+ <para>
+ 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.
+ </para>
+ </listitem>
+ <listitem>
+ GMT offset
+ <para>
+ 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, and Africa/Cairo offset +2 hours. The format must follow the length-of-time format described above.
+ </para>
+ </listitem>
+ <listitem>
+ DST adjustment
+ <para>
+ 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.
+ </para>
+ <para>
+ NOTE: more rule capabilities are needed - this portion of the tz_database is incomplete
+ </para>
+ </listitem>
+ <listitem>
+ DST Start Date rule
+ <para>
+ 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.
+ <orderedlist>
+ <listitem>
+ 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).
+ </listitem>
+ <listitem>
+ The second field indicates the day-of-week from 0-6 (Sun=0).
+ </listitem>
+ <listitem>
+ The third field indicates the month from 1-12 (Jan=1).
+ </listitem>
+ </orderedlist>
+ Examples are: "-1;5;9"="Last Friday of September", "2;1;3"="Second Monday of March"
+ </para>
+ </listitem>
+ <listitem>
+ Start time
+ <para>
+ 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.
+ </para>
+ </listitem>
+ <listitem>
+ DST End date rule
+ <para>
+ See DST Start date rule. The difference here is this is the day daylight savings ends (transition to STD).
+ </para>
+ </listitem>
+ <listitem>
+ End time
+ <para>
+ Same as Start time.
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+
+</section>

Added: sandbox/SOC/2008/calendar/libs/date_time/xmldoc/usage_examples.xml
==============================================================================
--- (empty file)
+++ sandbox/SOC/2008/calendar/libs/date_time/xmldoc/usage_examples.xml 2008-05-04 12:55:31 EDT (Sun, 04 May 2008)
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN"
+"../../../tools/boostbook/dtd/boostbook.dtd">
+
+<!-- Copyright (c) 2001-2005 CrystalClear Software, Inc.
+ Subject to the Boost Software License, Version 1.0.
+ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+-->
+
+<section id="date_time.examples.general_usage_examples">
+ <title>General Usage Examples</title>
+
+ <para>
+ The following provides some sample usage of dates.
+ See <link linkend="date_time.gregorian">Date Programming</link>
+ for more details.
+
+ <programlisting><emphasis role="keyword">using namespace</emphasis> boost::gregorian;
+ date weekstart(<emphasis role="number">2002</emphasis>,Feb,<emphasis role="number">1</emphasis>);
+ date weekend = weekstart + week(<emphasis role="number">1</emphasis>);
+ date d2 = d1 + days(<emphasis role="number">5</emphasis>);
+ date today = day_clock::local_day();
+ if (d2 &gt;= today) {} <emphasis role="comment">//date comparison operators</emphasis>
+
+ date_period thisWeek(d1,d2);
+ <emphasis role="keyword">if</emphasis> (thisWeek.contains(today)) {}<emphasis role="comment">//do something
+
+ //iterate and print the week</emphasis>
+ day_iterator itr(weekstart);
+ <emphasis role="keyword">while</emphasis> (itr &lt;= weekend) {
+ std::cout &lt;&lt; (*itr) &lt;&lt; std::endl;
+ ++itr;
+ }
+ <emphasis role="comment">//input streaming</emphasis>
+ std::stringstream ss(<emphasis role="string">"2004-Jan-1"</emphasis>);
+ ss &gt;&gt; d3;
+
+ <emphasis role="comment">//date generator functions</emphasis>
+ date d5 = next_weekday(d4, Sunday); <emphasis role="comment">//calculate Sunday following d4
+
+ //US labor day is first Monday in Sept</emphasis>
+ nth_day_of_the_week_in_month labor_day(nth_dow::first,Monday, Sep);
+ <emphasis role="comment">//calculate a specific date for 2004 from functor</emphasis>
+ date d6 = labor_day.get_date(<emphasis role="number">2004</emphasis>);
+ </programlisting>
+
+ The following provides some example code using times.
+ See <link linkend="date_time.posix_time">Time Programming</link>
+ for more details.
+
+ <programlisting><emphasis role="keyword">using namespace</emphasis> boost::posix_time;
+ date d(<emphasis role="number">2002</emphasis>,Feb,<emphasis role="number">1</emphasis>); <emphasis role="comment">//an arbitrary date</emphasis>
+ ptime t1(d, hours(<emphasis role="number">5</emphasis>)+nanosec(<emphasis role="number">100</emphasis>)); <emphasis role="comment">//date + time of day offset</emphasis>
+ ptime t2 = t1 - minutes(<emphasis role="number">4</emphasis>)+seconds(<emphasis role="number">2</emphasis>);
+ ptime now = second_clock::local_time(); <emphasis role="comment">//use the clock</emphasis>
+ date today = now.date(); <emphasis role="comment">//Get the date part out of the time</emphasis>
+ date tomorrow = today + date_duration(<emphasis role="number">1</emphasis>);
+ ptime tomorrow_start(tomorrow); <emphasis role="comment">//midnight
+
+ //input streaming</emphasis>
+ std::stringstream ss(<emphasis role="string">"2004-Jan-1 05:21:33.20"</emphasis>);
+ ss &gt;&gt; t2;
+
+ <emphasis role="comment">//starting at current time iterator adds by one hour</emphasis>
+ time_iterator titr(now,hours(<emphasis role="number">1</emphasis>));
+ <emphasis role="keyword">for</emphasis> (; titr &lt; tomorrow_start; ++titr) {
+ std::cout &lt;&lt; (*titr) &lt;&lt; std::endl;
+ }
+ </programlisting>
+ </para>
+
+ <para>
+ The following provides some example code using times.
+ See <link linkend="date_time.local_time">Local Time Programming</link>
+ for more details.
+
+ <programlisting>
+ <emphasis role="keyword">using namespace</emphasis> boost::local_time;
+ <emphasis role="comment">//setup some timezones for creating and adjusting times
+ //first time zone uses the time zone file for regional timezone definitions</emphasis>
+ tz_database tz_db;
+ tz_db.load_from_file(<emphasis role="string">"date_time_zonespec.csv"</emphasis>);
+ time_zone_ptr nyc_tz = tz_db.time_zone_from_region(<emphasis role="string">"America/New_York"</emphasis>);
+ <emphasis role="comment">//This timezone uses a posix time zone string definition to create a time zone</emphasis>
+ time_zone_ptr phx_tz(new posix_time_zone(<emphasis role="string">"MST-07:00:00"</emphasis>));
+
+ <emphasis role="comment">//local departure time in phoenix is 11 pm on April 2 2005
+ // Note that New York changes to daylight savings on Apr 3 at 2 am)</emphasis>
+ local_date_time phx_departure(date(<emphasis role="number">2005</emphasis>, Apr, <emphasis role="number">2</emphasis>), hours(<emphasis role="number">23</emphasis>), phx_tz,
+ local_date_time::NOT_DATE_TIME_ON_ERROR);
+
+ time_duration flight_length = hours(<emphasis role="number">4</emphasis>) + minutes(<emphasis role="number">30</emphasis>);
+ local_date_time phx_arrival = phx_departure + flight_length;
+ <emphasis role="comment">//convert the phx time to a nyz time</emphasis>
+ local_date_time nyc_arrival = phx_arrival.local_time_in(nyc_tz);
+
+ <emphasis role="comment">//2005-Apr-03 06:30:00 EDT</emphasis>
+ std::cout &lt;&lt; nyc_arrival &lt;&lt; std::endl;
+ </programlisting>
+ </para>
+
+</section>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk