Compare commits

...

74 Commits

Author SHA1 Message Date
Peter Dimov 6248d64ed9 Merge branch 'develop' 2026-06-01 01:52:20 +03:00
Andrey Semashev 6b387c4969 Remove dependencies on Boost.StaticAssert. (#250)
Boost.StaticAssert has been merged into Boost.Config, so remove
the dependency.
2026-02-06 03:26:58 +02:00
James E. King III 69c45b7a2b Update README 2025-07-07 06:39:45 -04:00
James E. King III 19ffa6232d Implement a reusable GHA workflow with configuration options. 2025-07-06 22:04:23 -04:00
Jeff Garland 363e04d7ec Merge pull request #242 from jeking3/coverity-255065
issue-204: period::intersects incorrect for empty periods
2025-07-06 18:06:39 -07:00
James E. King III 64c1df1e3e issue-204: period::intersects incorrect for empty periods
Originally identified by Coverity Scan.  Zero length periods like
[3, 3) cannot intersect with anything.  Invalid periods like
[5, 4) also cannot intersect with anything.  In both cases the
unit tests are wrong, and fixing them reveals the implementation
is not canonical for half-open sane intervals.
2025-07-06 14:56:23 -04:00
René Ferdinand Rivera Morell 645574e5df Add support for modular build structure. (#239)
* Make the library modular usable.

* Switch to library requirements instead of source. As source puts extra source in install targets.

* Add missing NO_LIB usage requirements.

* Add requires-b2 check to top-level build file.

* Bump B2 require to 5.2

* Update copyright dates.

* Move inter-lib dependencies to a project variable and into the build targets.

* Adjust doc build to avoid boost-root references.

* Update build deps.

* Rework GHA to use containers for the ubuntu that are god or going away.

* Remove obsolete package installs.

* Need another package?

* Some deepndencies are now C++11 only. Hence date_time is now also C++11 only.

* Switch macOS test to use the latest version.

* Remove not-needed software-properties-common package.

* Remove setup gcc toolchain step.

* Install some missing compilers.

* Maybe the gcc builds for the specific ubuntu versions rea broken. Switch to something newer.
2025-06-27 02:30:25 +03:00
Jeff Garland 85e637cb32 minor date-time fixes for 1.81 release (#219)
* fix typo in time_period docs (#212)

Co-authored-by: Quinn O'Connor <qoconnor@fastenal.com>

* Fix constexpr of gregorian::date::date(special_values) to improve perf (#214)

GCC up to at least 10.2 fail to resolve
gregorian::date::date(special_values) as constexpr function due to
assignment to *this within the constructor. Refactoring constructor to
initialize the instance once leads to large performance improvement.

* Avoid using likely function as multiple projects define a likely macro (#216)

* Iso doc fixes (#215)

* to_iso_*string() use "." as fractional separator

The fractional separator for the various to_iso_* methods
is "." not "," (per to_iso_string_type() implementation).
Fix the documentation to match the implementation.

* use "ISO 8601" not "iso" in documentation

The standard is "ISO 8601", so use that instead
of just "iso" or "ISO" in comments and documentation.

* fractional seconds only included if non-zero (#110)

Consistently document that the fractional seconds
are only included if non-zero.

Use "where fffffffff" not "were fff".

* Fix ccache saving on cache hit (#211)

See boostorg/boost-ci#166

* chore: bump macos runner version (#213)

GitHub Action is sunsetting the macOS 10.15 Actions runner. It will stop working intermittently until being completely removed by 2022-8-30: https://github.blog/changelog/2022-07-20-github-actions-the-macos-10-15-actions-runner-image-is-being-deprecated-and-will-be-removed-by-8-30-22

Co-authored-by: Quinnsicle <qtoconnor@gmail.com>
Co-authored-by: Quinn O'Connor <qoconnor@fastenal.com>
Co-authored-by: Povilas Kanapickas <povilas@radix.lt>
Co-authored-by: Antony Polukhin <antoshkka@gmail.com>
Co-authored-by: Luke Mewburn <luke@mewburn.net>
Co-authored-by: Alexander Grund <Flamefire@users.noreply.github.com>
Co-authored-by: Baoshuo Ren <i@baoshuo.ren>
2022-10-31 09:22:31 -07:00
Baoshuo Ren 39714907b7 chore: bump macos runner version (#213)
GitHub Action is sunsetting the macOS 10.15 Actions runner. It will stop working intermittently until being completely removed by 2022-8-30: https://github.blog/changelog/2022-07-20-github-actions-the-macos-10-15-actions-runner-image-is-being-deprecated-and-will-be-removed-by-8-30-22
2022-09-20 15:13:04 -07:00
Alexander Grund abef5a147a Fix ccache saving on cache hit (#211)
See boostorg/boost-ci#166
2022-09-20 15:12:17 -07:00
Luke Mewburn ddcfd00391 Iso doc fixes (#215)
* to_iso_*string() use "." as fractional separator

The fractional separator for the various to_iso_* methods
is "." not "," (per to_iso_string_type() implementation).
Fix the documentation to match the implementation.

* use "ISO 8601" not "iso" in documentation

The standard is "ISO 8601", so use that instead
of just "iso" or "ISO" in comments and documentation.

* fractional seconds only included if non-zero (#110)

Consistently document that the fractional seconds
are only included if non-zero.

Use "where fffffffff" not "were fff".
2022-09-20 15:10:38 -07:00
Antony Polukhin c02d713cef Avoid using likely function as multiple projects define a likely macro (#216) 2022-09-08 04:01:15 -07:00
Povilas Kanapickas b81ed2874f Fix constexpr of gregorian::date::date(special_values) to improve perf (#214)
GCC up to at least 10.2 fail to resolve
gregorian::date::date(special_values) as constexpr function due to
assignment to *this within the constructor. Refactoring constructor to
initialize the instance once leads to large performance improvement.
2022-08-01 03:34:36 -07:00
Quinnsicle 0aed920bfb fix typo in time_period docs (#212)
Co-authored-by: Quinn O'Connor <qoconnor@fastenal.com>
2022-07-02 10:41:51 -07:00
Raphaël Duhen f972dc9656 Fix minor typo (#210)
Thanks!
2022-04-29 09:33:12 -07:00
James E. King III 7677fdce5a Fix appveyor links in readme 2022-04-28 08:08:09 -04:00
James E. King III 8729945096 remove drone config 2022-04-24 21:00:53 -04:00
Owen Rudge cbad9bcec9 Add from_time_t test for 64-bit time_t 2022-03-01 11:15:22 -05:00
Owen Rudge 64fe6586fe Fix from_time_t Y2K38 bug on LLP64 platforms 2022-03-01 11:15:22 -05:00
James E. King III a20a5c8b7c Merge branch 'master' into develop 2022-02-20 06:58:55 -05:00
timmaraju ff77162265 fix signed to unsigned conversion warning (#179)
MSVC 19.28.29336.0 throws the following warning when
boost::date_time::gregorian_date is called.

warning C4365: 'initializing': conversion from 'int' to 'unsigned long', signed/unsigned mismatch
warning C4365: const boost::posix_time::ptime Since1970(boost::gregorian::date(1970U, 1U, 1U));
warning C4365:                                                                                ^
<path>\include\boost\date_time\date.hpp(72,35): message : while evaluating constexpr function 'boost::date_time::gregorian_calendar_base<boost::gregorian::greg_year_month_day,unsigned int>::day_number'
<path>\include\boost\date_time\date.hpp(72,35): message :       : days_(calendar::day_number(ymd_type(y, m, d)))

Co-authored-by: timmaraju <keerthi.timmaraju@teamviewer.com>
2022-02-12 05:53:38 -07:00
James E. King III 0be5d92c90 refresh ci, codecov, readme
- align to current boost-ci practice
- deal with VERY slow test runner in microsec_time_clock test
- disable sanitize tests - too many issues in boost serialization right now
- omit unit tests from coverage
2022-02-11 21:14:28 -05:00
Jeff Garland 33dc6136f1 misc fixes and updates for date-time boost 1.77 (#196)
* Change greg_month and greg_weekday to be not marked as exported/imported (#146)

* Changed greg_month and greg_weekday to be not marked as exported/imported.

Both greg_month and greg_weekday classes are implemented completely in headers,
so they need not be marked with BOOST_DATE_TIME_DECL. For consistency with other
similar classes, they are now marked with BOOST_SYMBOL_VISIBLE.

This should fix linking errors on Windows/MSVC, where all members of greg_month
and greg_weekday classes remain unresolved as they are expected to be
implemented in a shared library.

* Enabled shared and static linking in AppVeyor CI.

* fix new msvc warning in date_parsing with Warn4 - issue #148

* Cast month numbers to the correct type in map init (#152)

Since the map contains unsigned short for month numbers, it is more correct to explicitly cast constants to that type rather than short.

* Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74 (#150)

* Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers.

* Change BOOST_BORLANDC back to __BORLANDC__ for non-posix functionality.

* Include the header file.

* Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.

* Revert "Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero."

This reverts commit 88e45e951b.

* Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.

* Remove separate outside of template class friend functions.

* Define all the friend functions outside the class to conform with the necessity of Embarcadero C++ clang-based compilers that need the friend functions in exported/imported classes to be defined outside the class. This is an Embarcadero C++ clang-based compiler bug which i reported to Embarcadero.

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* tune: add initial cmake configuration (#151)

* tune: add initial cmake configuration

* bugfix: Incorrect library alias

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* Use BOOST_OVERRIDE to fix GCC -Wsuggest-override and Clang-tidy modernize-use-override warnings. (#155)

Also fix Clang -Wextra-semi-stmt and Clang-tidy readability-container-size-empty warnings.
Alphabetical order of STL headers.
Fix some misspellings.

Co-authored-by: Eugene Zelenko <eugene@diakopto.com>

* Break DateTime <-> Serialization circular dependency (#154)

Breaks DateTime -> Serialization -> Spirit -> Thread -> DateTime chain.

The Serialization documentation seems to be explicitly allow this:
https://www.boost.org/doc/libs/1_73_0/libs/serialization/doc/traits.html#version
https://www.boost.org/doc/libs/1_73_0/libs/serialization/doc/serialization.html#splitting

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* Fix clang 10 C++17 warnings about deprecated implicit assignment operators. (#158)

C++17 deprecates implicit generation of assignment operator in presence of
explicitly declared copy constructor. In future standards this behavior may
be removed.

In the affected Boost.DateTime classes, the explicitly defined copy
constructors are functionally equivalent to those would be generated
implicitly, so we can just remove them. The additional benefit is that the
implicitly generated ones will have constexpr and noexcept specifications,
and will also allow implicit move constructors and assignment operators.

* Suppress MSVC CRT deprecations on Clang (#160)

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* Add BOOST_CXX14_CONSTEXPR to CV assign() (#161)

Without this change the BOOST_CXX14_CONSTEXPR on the constructors has no
effect, as they invoke assign()

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* add constexpr tests to date, ptime, constrained_value (#162)

* merge some doc changes for constexpr fix (#163)

* add constexpr tests to date, ptime, constrained_value

* add some docs for 1.74 release

* const-qualify retrieval and comparison methods of time_itr and date_itr_base (#170)

* [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's  compilation level, without having to search the library's documentation to find this out. (#178)

* add drone config [ci skip] (#180)

* Add GitHub Actions config [ci skip] (#182)

* Update README.md

* Update README.md

* Update README.md

fixup comments on readme to match header_only status

* fix #189 for autolink -- driveby change to remove gcc2.95 support (#191)

* ptime from iso error string error with date only (#192)

* fix #189 for autolink -- driveby change to remove gcc2.95 support

* fix #187 date-only case to avoid string exception, beef up error case test

* ci updates (#194)

* fix #189 for autolink -- driveby change to remove gcc2.95 support

* fix #187 date-only case to avoid string exception, beef up error case test

* attempted fix for #193 - ci issues

* attempted fix for #193 - ci issues try 2

* attempted fix for #193 - ci issues try 3

* attempted fix for #193 - ci issues try 4

* attempted fix for #193 - ci issues try 4a

* attempted fix for #193 - ci issues try 5

* attempted fix for #193 - ci issues try 6

* attempted fix for #193 - ci issues try 7 - rm clang 3.8

* Regenerate CMakeLists.txt

* Add stub source file

Co-authored-by: Andrey Semashev <Lastique@users.noreply.github.com>
Co-authored-by: Edward Diener <eldlistmailingz@tropicsoft.com>
Co-authored-by: tapika <tapika@yahoo.com>
Co-authored-by: EugeneZelenko <eugene.zelenko@gmail.com>
Co-authored-by: Eugene Zelenko <eugene@diakopto.com>
Co-authored-by: Nikita Kniazev <nok.raven@gmail.com>
Co-authored-by: Roger Orr <rogero@howzatt.co.uk>
Co-authored-by: klaus triendl <klaus@triendl.eu>
Co-authored-by: Sam Darwin <samuel.d.darwin@gmail.com>
Co-authored-by: Peter Dimov <pdimov@gmail.com>
2021-06-28 08:14:45 -07:00
Jeff Garland 7156392706 Merge branch 'master' into develop 2021-06-28 07:55:17 -07:00
Peter Dimov 561ccb878d Add stub source file 2021-06-08 21:52:12 +03:00
Peter Dimov 3feaece6d2 Regenerate CMakeLists.txt 2021-06-08 21:51:59 +03:00
Peter Dimov 9970590094 Add stub source file 2021-05-28 01:27:21 +03:00
Peter Dimov 4b97311ca7 Regenerate CMakeLists.txt 2021-05-28 01:26:14 +03:00
Jeff Garland a94bcf288d ci updates (#194)
* fix #189 for autolink -- driveby change to remove gcc2.95 support

* fix #187 date-only case to avoid string exception, beef up error case test

* attempted fix for #193 - ci issues

* attempted fix for #193 - ci issues try 2

* attempted fix for #193 - ci issues try 3

* attempted fix for #193 - ci issues try 4

* attempted fix for #193 - ci issues try 4a

* attempted fix for #193 - ci issues try 5

* attempted fix for #193 - ci issues try 6

* attempted fix for #193 - ci issues try 7 - rm clang 3.8
2021-05-02 17:27:18 -07:00
Jeff Garland 8011fdf0bc ptime from iso error string error with date only (#192)
* fix #189 for autolink -- driveby change to remove gcc2.95 support

* fix #187 date-only case to avoid string exception, beef up error case test
2021-05-02 08:57:36 -07:00
Jeff Garland 15be01a02d fix #189 for autolink -- driveby change to remove gcc2.95 support (#191) 2021-04-30 11:51:48 -07:00
Jeff Garland acbee0dc6a Update README.md
fixup comments on readme to match header_only status
2021-03-23 08:28:14 -07:00
Jeff Garland aa9c5dfd48 Update README.md 2021-03-23 08:26:07 -07:00
Jeff Garland 47de78e4fc Update README.md 2021-03-23 08:25:32 -07:00
Jeff Garland 79ca1aa0a7 Merge minor date-time updates for boost 1.76 (#183)
* Change greg_month and greg_weekday to be not marked as exported/imported (#146)

* Changed greg_month and greg_weekday to be not marked as exported/imported.

Both greg_month and greg_weekday classes are implemented completely in headers,
so they need not be marked with BOOST_DATE_TIME_DECL. For consistency with other
similar classes, they are now marked with BOOST_SYMBOL_VISIBLE.

This should fix linking errors on Windows/MSVC, where all members of greg_month
and greg_weekday classes remain unresolved as they are expected to be
implemented in a shared library.

* Enabled shared and static linking in AppVeyor CI.

* fix new msvc warning in date_parsing with Warn4 - issue #148

* Cast month numbers to the correct type in map init (#152)

Since the map contains unsigned short for month numbers, it is more correct to explicitly cast constants to that type rather than short.

* Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74 (#150)

* Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers.

* Change BOOST_BORLANDC back to __BORLANDC__ for non-posix functionality.

* Include the header file.

* Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.

* Revert "Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero."

This reverts commit 88e45e951b.

* Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.

* Remove separate outside of template class friend functions.

* Define all the friend functions outside the class to conform with the necessity of Embarcadero C++ clang-based compilers that need the friend functions in exported/imported classes to be defined outside the class. This is an Embarcadero C++ clang-based compiler bug which i reported to Embarcadero.

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* tune: add initial cmake configuration (#151)

* tune: add initial cmake configuration

* bugfix: Incorrect library alias

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* Use BOOST_OVERRIDE to fix GCC -Wsuggest-override and Clang-tidy modernize-use-override warnings. (#155)

Also fix Clang -Wextra-semi-stmt and Clang-tidy readability-container-size-empty warnings.
Alphabetical order of STL headers.
Fix some misspellings.

Co-authored-by: Eugene Zelenko <eugene@diakopto.com>

* Break DateTime <-> Serialization circular dependency (#154)

Breaks DateTime -> Serialization -> Spirit -> Thread -> DateTime chain.

The Serialization documentation seems to be explicitly allow this:
https://www.boost.org/doc/libs/1_73_0/libs/serialization/doc/traits.html#version
https://www.boost.org/doc/libs/1_73_0/libs/serialization/doc/serialization.html#splitting

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* Fix clang 10 C++17 warnings about deprecated implicit assignment operators. (#158)

C++17 deprecates implicit generation of assignment operator in presence of
explicitly declared copy constructor. In future standards this behavior may
be removed.

In the affected Boost.DateTime classes, the explicitly defined copy
constructors are functionally equivalent to those would be generated
implicitly, so we can just remove them. The additional benefit is that the
implicitly generated ones will have constexpr and noexcept specifications,
and will also allow implicit move constructors and assignment operators.

* Suppress MSVC CRT deprecations on Clang (#160)

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* Add BOOST_CXX14_CONSTEXPR to CV assign() (#161)

Without this change the BOOST_CXX14_CONSTEXPR on the constructors has no
effect, as they invoke assign()

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* add constexpr tests to date, ptime, constrained_value (#162)

* merge some doc changes for constexpr fix (#163)

* add constexpr tests to date, ptime, constrained_value

* add some docs for 1.74 release

* const-qualify retrieval and comparison methods of time_itr and date_itr_base (#170)

* [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's  compilation level, without having to search the library's documentation to find this out. (#178)

* add drone config [ci skip] (#180)

* Add GitHub Actions config [ci skip] (#182)

Co-authored-by: Andrey Semashev <Lastique@users.noreply.github.com>
Co-authored-by: Edward Diener <eldlistmailingz@tropicsoft.com>
Co-authored-by: tapika <tapika@yahoo.com>
Co-authored-by: EugeneZelenko <eugene.zelenko@gmail.com>
Co-authored-by: Eugene Zelenko <eugene@diakopto.com>
Co-authored-by: Nikita Kniazev <nok.raven@gmail.com>
Co-authored-by: Roger Orr <rogero@howzatt.co.uk>
Co-authored-by: klaus triendl <klaus@triendl.eu>
Co-authored-by: Sam Darwin <samuel.d.darwin@gmail.com>
2021-03-05 08:49:04 -07:00
Sam Darwin ccc21804bd Add GitHub Actions config [ci skip] (#182) 2021-03-04 12:59:38 -07:00
Sam Darwin 31c983b256 add drone config [ci skip] (#180) 2021-01-26 16:17:52 -07:00
Edward Diener f92b2b3bfc [skip ci] Add "cxxstd" json field. The "cxxstd" json field is being added to each Boost library's meta json information for libraries in order to specify the minumum C++ standard compilation level. The value of this field matches one of the values for 'cxxstd' in Boost.Build. The purpose of doing this is to provide information for the Boost website documentation for each library which will specify the minimum C++ standard compilation that an end-user must employ in order to use the particular library. This will aid end-users who want to know if they can successfully use a Boost library based on their C++ compiler's compilation level, without having to search the library's documentation to find this out. (#178) 2021-01-19 17:59:35 -07:00
klaus triendl b43d605ad2 const-qualify retrieval and comparison methods of time_itr and date_itr_base (#170) 2020-09-03 16:19:53 -07:00
Jeff Garland fa46e55ca8 final merges for 1.74 (#164)
* Change greg_month and greg_weekday to be not marked as exported/imported (#146)

* Changed greg_month and greg_weekday to be not marked as exported/imported.

Both greg_month and greg_weekday classes are implemented completely in headers,
so they need not be marked with BOOST_DATE_TIME_DECL. For consistency with other
similar classes, they are now marked with BOOST_SYMBOL_VISIBLE.

This should fix linking errors on Windows/MSVC, where all members of greg_month
and greg_weekday classes remain unresolved as they are expected to be
implemented in a shared library.

* Enabled shared and static linking in AppVeyor CI.

* fix new msvc warning in date_parsing with Warn4 - issue #148

* Cast month numbers to the correct type in map init (#152)

Since the map contains unsigned short for month numbers, it is more correct to explicitly cast constants to that type rather than short.

* Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74 (#150)

* Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers.

* Change BOOST_BORLANDC back to __BORLANDC__ for non-posix functionality.

* Include the header file.

* Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.

* Revert "Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero."

This reverts commit 88e45e951b.

* Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.

* Remove separate outside of template class friend functions.

* Define all the friend functions outside the class to conform with the necessity of Embarcadero C++ clang-based compilers that need the friend functions in exported/imported classes to be defined outside the class. This is an Embarcadero C++ clang-based compiler bug which i reported to Embarcadero.

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* tune: add initial cmake configuration (#151)

* tune: add initial cmake configuration

* bugfix: Incorrect library alias

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* Use BOOST_OVERRIDE to fix GCC -Wsuggest-override and Clang-tidy modernize-use-override warnings. (#155)

Also fix Clang -Wextra-semi-stmt and Clang-tidy readability-container-size-empty warnings.
Alphabetical order of STL headers.
Fix some misspellings.

Co-authored-by: Eugene Zelenko <eugene@diakopto.com>

* Break DateTime <-> Serialization circular dependency (#154)

Breaks DateTime -> Serialization -> Spirit -> Thread -> DateTime chain.

The Serialization documentation seems to be explicitly allow this:
https://www.boost.org/doc/libs/1_73_0/libs/serialization/doc/traits.html#version
https://www.boost.org/doc/libs/1_73_0/libs/serialization/doc/serialization.html#splitting

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* Fix clang 10 C++17 warnings about deprecated implicit assignment operators. (#158)

C++17 deprecates implicit generation of assignment operator in presence of
explicitly declared copy constructor. In future standards this behavior may
be removed.

In the affected Boost.DateTime classes, the explicitly defined copy
constructors are functionally equivalent to those would be generated
implicitly, so we can just remove them. The additional benefit is that the
implicitly generated ones will have constexpr and noexcept specifications,
and will also allow implicit move constructors and assignment operators.

* Suppress MSVC CRT deprecations on Clang (#160)

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* Add BOOST_CXX14_CONSTEXPR to CV assign() (#161)

Without this change the BOOST_CXX14_CONSTEXPR on the constructors has no
effect, as they invoke assign()

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* add constexpr tests to date, ptime, constrained_value (#162)

* merge some doc changes for constexpr fix (#163)

* add constexpr tests to date, ptime, constrained_value

* add some docs for 1.74 release

Co-authored-by: Andrey Semashev <Lastique@users.noreply.github.com>
Co-authored-by: Edward Diener <eldlistmailingz@tropicsoft.com>
Co-authored-by: tapika <tapika@yahoo.com>
Co-authored-by: EugeneZelenko <eugene.zelenko@gmail.com>
Co-authored-by: Eugene Zelenko <eugene@diakopto.com>
Co-authored-by: Nikita Kniazev <nok.raven@gmail.com>
Co-authored-by: Roger Orr <rogero@howzatt.co.uk>
2020-07-16 09:01:11 -07:00
Jeff Garland 61677ba228 merge some doc changes for constexpr fix (#163)
* add constexpr tests to date, ptime, constrained_value

* add some docs for 1.74 release
2020-07-13 08:12:09 -07:00
Jeff Garland 30795441e4 add constexpr tests to date, ptime, constrained_value (#162) 2020-07-09 08:06:58 -07:00
Roger Orr 77495803c1 Add BOOST_CXX14_CONSTEXPR to CV assign() (#161)
Without this change the BOOST_CXX14_CONSTEXPR on the constructors has no
effect, as they invoke assign()

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>
2020-07-08 08:41:24 -07:00
Nikita Kniazev 247424d08d Suppress MSVC CRT deprecations on Clang (#160)
Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>
2020-07-08 07:56:10 -07:00
Jeff Garland ab066e3601 merge date_time maintenance changes for boost 1.74 (#159)
* Change greg_month and greg_weekday to be not marked as exported/imported (#146)

* Changed greg_month and greg_weekday to be not marked as exported/imported.

Both greg_month and greg_weekday classes are implemented completely in headers,
so they need not be marked with BOOST_DATE_TIME_DECL. For consistency with other
similar classes, they are now marked with BOOST_SYMBOL_VISIBLE.

This should fix linking errors on Windows/MSVC, where all members of greg_month
and greg_weekday classes remain unresolved as they are expected to be
implemented in a shared library.

* Enabled shared and static linking in AppVeyor CI.

* fix new msvc warning in date_parsing with Warn4 - issue #148

* Cast month numbers to the correct type in map init (#152)

Since the map contains unsigned short for month numbers, it is more correct to explicitly cast constants to that type rather than short.

* Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74 (#150)

* Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers.

* Change BOOST_BORLANDC back to __BORLANDC__ for non-posix functionality.

* Include the header file.

* Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.

* Revert "Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero."

This reverts commit 88e45e951b.

* Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.

* Remove separate outside of template class friend functions.

* Define all the friend functions outside the class to conform with the necessity of Embarcadero C++ clang-based compilers that need the friend functions in exported/imported classes to be defined outside the class. This is an Embarcadero C++ clang-based compiler bug which i reported to Embarcadero.

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* tune: add initial cmake configuration (#151)

* tune: add initial cmake configuration

* bugfix: Incorrect library alias

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* Use BOOST_OVERRIDE to fix GCC -Wsuggest-override and Clang-tidy modernize-use-override warnings. (#155)

Also fix Clang -Wextra-semi-stmt and Clang-tidy readability-container-size-empty warnings.
Alphabetical order of STL headers.
Fix some misspellings.

Co-authored-by: Eugene Zelenko <eugene@diakopto.com>

* Break DateTime <-> Serialization circular dependency (#154)

Breaks DateTime -> Serialization -> Spirit -> Thread -> DateTime chain.

The Serialization documentation seems to be explicitly allow this:
https://www.boost.org/doc/libs/1_73_0/libs/serialization/doc/traits.html#version
https://www.boost.org/doc/libs/1_73_0/libs/serialization/doc/serialization.html#splitting

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>

* Fix clang 10 C++17 warnings about deprecated implicit assignment operators. (#158)

C++17 deprecates implicit generation of assignment operator in presence of
explicitly declared copy constructor. In future standards this behavior may
be removed.

In the affected Boost.DateTime classes, the explicitly defined copy
constructors are functionally equivalent to those would be generated
implicitly, so we can just remove them. The additional benefit is that the
implicitly generated ones will have constexpr and noexcept specifications,
and will also allow implicit move constructors and assignment operators.

Co-authored-by: Andrey Semashev <Lastique@users.noreply.github.com>
Co-authored-by: Edward Diener <eldlistmailingz@tropicsoft.com>
Co-authored-by: tapika <tapika@yahoo.com>
Co-authored-by: EugeneZelenko <eugene.zelenko@gmail.com>
Co-authored-by: Eugene Zelenko <eugene@diakopto.com>
Co-authored-by: Nikita Kniazev <nok.raven@gmail.com>
2020-06-25 16:45:21 -07:00
Andrey Semashev 76852e4aab Fix clang 10 C++17 warnings about deprecated implicit assignment operators. (#158)
C++17 deprecates implicit generation of assignment operator in presence of
explicitly declared copy constructor. In future standards this behavior may
be removed.

In the affected Boost.DateTime classes, the explicitly defined copy
constructors are functionally equivalent to those would be generated
implicitly, so we can just remove them. The additional benefit is that the
implicitly generated ones will have constexpr and noexcept specifications,
and will also allow implicit move constructors and assignment operators.
2020-06-23 13:28:16 -07:00
Nikita Kniazev 356c5c2600 Break DateTime <-> Serialization circular dependency (#154)
Breaks DateTime -> Serialization -> Spirit -> Thread -> DateTime chain.

The Serialization documentation seems to be explicitly allow this:
https://www.boost.org/doc/libs/1_73_0/libs/serialization/doc/traits.html#version
https://www.boost.org/doc/libs/1_73_0/libs/serialization/doc/serialization.html#splitting

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>
2020-05-25 09:39:21 -07:00
EugeneZelenko 3d55c15cbb Use BOOST_OVERRIDE to fix GCC -Wsuggest-override and Clang-tidy modernize-use-override warnings. (#155)
Also fix Clang -Wextra-semi-stmt and Clang-tidy readability-container-size-empty warnings.
Alphabetical order of STL headers.
Fix some misspellings.

Co-authored-by: Eugene Zelenko <eugene@diakopto.com>
2020-05-23 07:19:59 -07:00
tapika d77ee59bc2 tune: add initial cmake configuration (#151)
* tune: add initial cmake configuration

* bugfix: Incorrect library alias

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>
2020-05-18 13:59:29 -07:00
Edward Diener 5093074e0e Changes for Embarcadero C++ clang-based compilers, targeting Boost 1.74 (#150)
* Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers.

* Change BOOST_BORLANDC back to __BORLANDC__ for non-posix functionality.

* Include the header file.

* Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.

* Revert "Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero."

This reverts commit 88e45e951b.

* Inline friend function definitions for exported/imported classes must become declarations and inline definitions outside the class for Embarcadero C++ clang-based compilers. This bug has been reported to Embarcadero.

* Remove separate outside of template class friend functions.

* Define all the friend functions outside the class to conform with the necessity of Embarcadero C++ clang-based compilers that need the friend functions in exported/imported classes to be defined outside the class. This is an Embarcadero C++ clang-based compiler bug which i reported to Embarcadero.

Co-authored-by: Jeff Garland <jeff@crystalclearsoftware.com>
2020-05-04 09:09:57 -07:00
Andrey Semashev ecf042f538 Cast month numbers to the correct type in map init (#152)
Since the map contains unsigned short for month numbers, it is more correct to explicitly cast constants to that type rather than short.
2020-05-03 07:52:25 -07:00
JeffGarland d0b3c1da88 fix new msvc warning in date_parsing with Warn4 - issue #148 2020-04-10 06:27:11 -07:00
Jeff Garland b03272650e Change greg_month and greg_weekday to be not marked as exported/imported (#146) (#147)
* Changed greg_month and greg_weekday to be not marked as exported/imported.

Both greg_month and greg_weekday classes are implemented completely in headers,
so they need not be marked with BOOST_DATE_TIME_DECL. For consistency with other
similar classes, they are now marked with BOOST_SYMBOL_VISIBLE.

This should fix linking errors on Windows/MSVC, where all members of greg_month
and greg_weekday classes remain unresolved as they are expected to be
implemented in a shared library.

* Enabled shared and static linking in AppVeyor CI.

Co-authored-by: Andrey Semashev <Lastique@users.noreply.github.com>
2020-04-06 10:02:51 -07:00
Andrey Semashev e9a9ce3e35 Change greg_month and greg_weekday to be not marked as exported/imported (#146)
* Changed greg_month and greg_weekday to be not marked as exported/imported.

Both greg_month and greg_weekday classes are implemented completely in headers,
so they need not be marked with BOOST_DATE_TIME_DECL. For consistency with other
similar classes, they are now marked with BOOST_SYMBOL_VISIBLE.

This should fix linking errors on Windows/MSVC, where all members of greg_month
and greg_weekday classes remain unresolved as they are expected to be
implemented in a shared library.

* Enabled shared and static linking in AppVeyor CI.
2020-04-06 08:55:36 -07:00
JeffGarland 0c1d8fddd8 fix merge conflicts to master from develop for boost 1.73 2020-04-05 15:27:12 -07:00
Jeff Garland ad3239b722 date_time documentation updates for release 1.73 (#128)
* change gettimeofday to be clearer - issue #127

* clarify date_number docs - github issue #125

* add docs for from_iso_extended_string function - issue #116

* update documentation for 1.73 release - changes.xml
2020-04-05 14:14:40 -07:00
Andrey Semashev d335a54e9f Add missing includes and fix special_value_from_string definition (#144)
* Added a test generator for whether all public headers are self-contained.

The generator creates a compile test for every public header, unless
BOOST_DATE_TIME_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS environment variable
is set to 1.

* Only enable self-contained header tests on a few jobs.

There is no point in performing self-contained header tests on every compiler
configuration, so running them only on some saves CI time.

* Make public headers self-contained.

This commit:

- Adds missing includes.
- Adjusts gregorian namespace qualification in a few places to use use
  equivalent symbols from date_time and not have to include gregorian
  headers.
- Converts tabs to spaces and trims trailing spaces.

This makes the self-contained header tests pass on Linux.

* Move special_value_from_string definition to parsers.hpp.

This resolves different attributes applied to the function definition
in parsers.hpp and greg_month.hpp. The function is now inline and defined
in parsers.hpp.

Also, the commit converts tabs to spaces and trims trailing spaces.

Fixes https://github.com/boostorg/date_time/issues/143.

* Convert tabs to spaces and trim trailing spaces.
2020-04-05 07:27:27 -07:00
Jeff Garland cb3bd50b90 make date-time all inline, additional constexpr fixes, clang 2a fix for boost 1.73 (#142)
* pull request to make date-time all inline (#135)

* remove legacy to_simple_string and prefer streaming in test code

* driveby fix to clean up self-assign compiler warnings in test code

* driveby fix to clean up unused variable compiler warnings in test code

* another update for issue #123 (constexpr) to allow time_duration constexpr to work

* final updates to make date_time free of library - issue #134

* add stub library for backward compatibility (#137)

* remove legacy to_simple_string and prefer streaming in test code

* driveby fix to clean up self-assign compiler warnings in test code

* driveby fix to clean up unused variable compiler warnings in test code

* another update for issue #123 (constexpr) to allow time_duration constexpr to work

* final updates to make date_time free of library - issue #134

* make a stub library for backward compatibility of libs that link date_time library

* suppressed const qualifier on function return type (#138)

* suppressed const qualifier on function return type

As warned in https://www.boost.org/development/tests/develop/output/teeks99-dkr-dg4-6-warn-date_time-gcc-4-6~c++0x~warn-warnings.html#hours_special_value
```../boost/date_time/gregorian/greg_weekday.hpp:52:41: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
../boost/date_time/gregorian/greg_weekday.hpp:61:40: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]```

* trivial commit to trigger CI

* fix c++2a ambiguity on clang10 with operator== issue #132 (#140)

Co-authored-by: joaquintides <joaquin.lopezmunoz@gmail.com>
2020-03-25 05:38:03 -07:00
Jeff Garland 4a46476358 fix c++2a ambiguity on clang10 with operator== issue #132 (#140) 2020-03-22 20:05:09 -07:00
joaquintides 44618f1632 suppressed const qualifier on function return type (#138)
* suppressed const qualifier on function return type

As warned in https://www.boost.org/development/tests/develop/output/teeks99-dkr-dg4-6-warn-date_time-gcc-4-6~c++0x~warn-warnings.html#hours_special_value
```../boost/date_time/gregorian/greg_weekday.hpp:52:41: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
../boost/date_time/gregorian/greg_weekday.hpp:61:40: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]```

* trivial commit to trigger CI
2020-03-19 08:16:47 -07:00
Jeff Garland bbac2178ed add stub library for backward compatibility (#137)
* remove legacy to_simple_string and prefer streaming in test code

* driveby fix to clean up self-assign compiler warnings in test code

* driveby fix to clean up unused variable compiler warnings in test code

* another update for issue #123 (constexpr) to allow time_duration constexpr to work

* final updates to make date_time free of library - issue #134

* make a stub library for backward compatibility of libs that link date_time library
2020-03-15 21:03:59 -07:00
Jeff Garland d8c7a59ed9 pull request to make date-time all inline (#135)
* remove legacy to_simple_string and prefer streaming in test code

* driveby fix to clean up self-assign compiler warnings in test code

* driveby fix to clean up unused variable compiler warnings in test code

* another update for issue #123 (constexpr) to allow time_duration constexpr to work

* final updates to make date_time free of library - issue #134
2020-03-15 04:27:39 -07:00
JeffGarland d8a894c44a fix merge conflicts 2020-03-14 10:28:43 -07:00
Jeff Garland 139f44776d date time misc cleanup (#131)
* remove superflous HAS_MICROSECOND and HAS_MILLISECOND macros

* remove pre 1_33 facet detection for dead compilers
2020-03-12 18:36:13 -07:00
Jeff Garland 6f7b2b5056 fix report of warnings for constexpr updates on gcc9 03 mode (#130) 2020-03-10 16:24:10 -07:00
Jeff Garland 4e1b7cde45 initial set of core changes for constexpr support (issue #123) (#126)
* initial set of core changes for constexpr support (issue #123)

* fixes for constexpr core support based on ci failures (issue #123)

* drive by fix for gcc9.2 warning on polymorphic exception

* fixes for constexpr core support based on for cpp11 and cpp14 build variants (issue #123)

* more fixes for constexpr core support  (issue #123) - also fix for issue #124

* next round of changes for constexpr core support (issue #123)

* fix last msvc regression for constexpr core

* driveby fix to remove detail include

* 3rd round of changes for constexpr

* yet another msvc fix for cpp14

* minor doc fix for issue #127 - tm_isddst -> tm_isdst

* minor doc fix for issue #127 - tm_isddst -> tm_isdst

* push constexpr deep into the library including date, ptime (issue #123)

* push constexpr deep into the library including date, ptime (issue #123)

* fix latests regressions from constexpr changes in older gcc
2020-03-05 06:46:35 -07:00
Jeff Garland e26fd2ed98 pull develop to master for boost 1.72 (#117)
* Synchronize each miscrosec test to the next second (#109)

* Synchronize each miscrosec test to the next second

The aim is to avoid false positives in test_microsec when the seconds,
minutes or hours change during time read between the second_clock and
the microsec_clock.

* Improved readability of the microcec_time_clock test

* Improve performance of adding and subtracting time durations from a ptime. (#99)

Modifying ptime objects by adding and subtracting time durations was
inefficient because it extracted the date and time of day and then
re-constructed a ptime using the date and modified time of day.

This can be avoided by using the existing time_system utilities which
perform the operation by adjusting the number of ticks.

Performance is improved by a factor of 48 on my system.

* Update CI Scripts

* Add time_duration helper functions: (#113)

1. is_positive()
  - Return boolean value to indicate whether or not time duration is
    positive.
2. is_zero()
  - Return boolean value to indicate whether or not time duration is
    zero.
3. abs()
  - Return a time_duration which is the absolute value of time
    duration.

Added documentation for these helper functions and improved existing
documentation to indicate constness, return values or static
functions.

* Cease dependence on MPL (#115)
2019-12-03 17:06:28 -07:00
Nikita Kniazev 061aec856d Cease dependence on MPL (#115) 2019-11-21 07:28:47 -07:00
Gawain Bolton 1a95e81043 Add time_duration helper functions: (#113)
1. is_positive()
  - Return boolean value to indicate whether or not time duration is
    positive.
2. is_zero()
  - Return boolean value to indicate whether or not time duration is
    zero.
3. abs()
  - Return a time_duration which is the absolute value of time
    duration.

Added documentation for these helper functions and improved existing
documentation to indicate constness, return values or static
functions.
2019-11-01 04:08:45 -07:00
James E. King III c0b71da135 Update CI Scripts 2019-10-14 16:42:18 -04:00
Gawain Bolton 2fabfad443 Improve performance of adding and subtracting time durations from a ptime. (#99)
Modifying ptime objects by adding and subtracting time durations was
inefficient because it extracted the date and time of day and then
re-constructed a ptime using the date and modified time of day.

This can be avoided by using the existing time_system utilities which
perform the operation by adjusting the number of ticks.

Performance is improved by a factor of 48 on my system.
2019-10-10 13:07:48 -07:00
cclienti 3cc68a4642 Synchronize each miscrosec test to the next second (#109)
* Synchronize each miscrosec test to the next second

The aim is to avoid false positives in test_microsec when the seconds,
minutes or hours change during time read between the second_clock and
the microsec_clock.

* Improved readability of the microcec_time_clock test
2019-10-08 07:17:01 -07:00
LE GARREC Vincent 29bb209464 Fix unsigned / signed conversion
gregorian_calendar::end_of_month_day returns unsigned short and date constructor uses unsigned short too.
2019-05-10 10:32:15 -04:00
Mana Borwornpadungkitti 345abc6b67 Fix a typo in example of time_duration xmldoc (#100) 2019-03-24 08:32:07 -07:00
114 changed files with 2402 additions and 1951 deletions
+116
View File
@@ -0,0 +1,116 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright 2017 - 2019 James E. King III
# Copyright 2019 - 2021 Alexander Grund
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
# Generic Appveyor build script for boostorg repositories
# See: https://github.com/boostorg/boost-ci/
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want.
# 2. If you have more than include/, src/, test/, example/, examples/,
# benchmark/ or tools/ directories, set the environment variable DEPINST.
# For example if your build uses code in "bench/" and "fog/" directories:
# - DEPINST: --include bench --include fog
# 3. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the script will do everything else for you.
#
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /bugfix\/.*/
- /feature\/.*/
- /fix\/.*/
- /pr\/.*/
matrix:
fast_finish: false
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
allow_failures:
- MAYFAIL: true
environment:
global:
B2_CI_VERSION: 1
GIT_FETCH_JOBS: 4
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# to use the default for a given environment, comment it out; recommend you build debug and release however:
# on Windows it is important to exercise all the possibilities, especially shared vs static, however most
# libraries that care about this exercise it in their Jamfiles...
B2_ADDRESS_MODEL: 32,64
B2_LINK: shared,static
# B2_THREADING: threading=multi,single
B2_VARIANT: release
BOOST_DATE_TIME_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS: 1
matrix:
- FLAVOR: Visual Studio 2017 C++2a Strict
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_CXXFLAGS: -permissive-
B2_CXXSTD: 2a
B2_TOOLSET: msvc-14.1
- FLAVOR: Visual Studio 2017 C++14/17
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_CXXSTD: 14,17
B2_TOOLSET: msvc-14.1
- FLAVOR: clang-cl
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
B2_ADDRESS_MODEL: 64
B2_CXXSTD: 11,14,17
B2_TOOLSET: clang-win
- FLAVOR: Visual Studio 2015, 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-12.0,msvc-14.0
- FLAVOR: Visual Studio 2008, 2010, 2012
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
B2_TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
B2_ADDRESS_MODEL: 32 # No 64bit support
- FLAVOR: cygwin (32-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: 32
B2_CXXSTD: 03,11,14,1z
B2_THREADING: threadapi=pthread
B2_TOOLSET: gcc
- FLAVOR: cygwin (64-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin64\bin;
B2_ADDRESS_MODEL: 64
B2_CXXSTD: 03,11,14,1z
B2_THREADING: threadapi=pthread
B2_TOOLSET: gcc
- FLAVOR: mingw64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
ADDPATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;
B2_ADDRESS_MODEL: 64
B2_CXXSTD: 03,11,14,17,2a
B2_TOOLSET: gcc
install:
- git clone --depth 1 https://github.com/boostorg/boost-ci.git C:\boost-ci-cloned
# Copy ci folder if not testing Boost.CI
- if NOT "%APPVEYOR_PROJECT_NAME%" == "boost-ci" xcopy /s /e /q /i /y C:\boost-ci-cloned\ci .\ci
- rmdir /s /q C:\boost-ci-cloned
- ci\appveyor\install.bat
build: off
test_script: ci\build.bat
+23
View File
@@ -0,0 +1,23 @@
# Copyright 2019 - 2021 Alexander Grund
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
# Sample codecov configuration file. Edit as required
codecov:
max_report_age: off
require_ci_to_pass: yes
notify:
# Increase this if you have multiple coverage collection jobs
after_n_builds: 2
wait_for_ci: yes
# Change how pull request comments look
comment:
layout: "reach,diff,flags,files,footer"
# Ignore specific files or folders. Glob patterns are supported.
# See https://docs.codecov.com/docs/ignoring-paths
ignore:
- libs/date_time/test/
- test
+50
View File
@@ -0,0 +1,50 @@
#
# Copyright 2020-2021 Peter Dimov
# Copyright 2021 Andrey Semashev
# Copyright 2021-2024 Alexander Grund
# Copyright 2022-2025 James E. King III
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
# This workflow uses the Boost.CI reusable workflow which builds a variety of
# configurations of your project, runs tests, and generates code coverage reports.
#
# To use it, copy this file into your repository as `.github/workflows/ci.yml` and
# customize it appropriately.
#
---
name: Boost.CI
on:
pull_request:
push:
branches:
- master
- develop
- bugfix/**
- feature/**
- fix/**
- pr/**
paths-ignore:
- LICENSE
- meta/**
- README.md
jobs:
call-boost-ci:
name: Run Boost.CI
uses: boostorg/boost-ci/.github/workflows/reusable.yml@master
with:
# no endian branches
enable_multiarch: false
# serialization has issues, not enough time to add suppressions
enable_sanitizers: false
# these compilers fail
exclude_compiler: 'gcc-4.7,gcc-4.8,gcc-4.9,gcc-5,clang-3.5,clang-3.6,clang-3.7,clang-3.8'
# the tests take a while; this reduces the load a bit and there isn't any C++20 specific code
exclude_cxxstd: '98,03,0x,2a,20'
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
COVERITY_SCAN_NOTIFICATION_EMAIL: ${{ secrets.COVERITY_SCAN_NOTIFICATION_EMAIL }}
COVERITY_SCAN_TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
-175
View File
@@ -1,175 +0,0 @@
# Copyright 2016 Peter Dimov
# Copyright 2017, 2018 James E. King III
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
# Generic Travis CI build script for boostorg repositories
# See: https://github.com/jeking3/boost-ci
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want in the 'jobs'.
# 2. If you have more than include/, src/, test/, example/, examples/, or
# tools/ directories, modify your Travis CI project and add the environment
# variable DEPINST. For example if your build uses code in "bench/" and
# "fog/" directories, then set DEPINST to the following:
# --include bench --include fog
# 3. If you want to enable Coverity Scan, you need to provide the environment
# variables COVERITY_SCAN_TOKEN and COVERITY_SCAN_NOTIFICATION_EMAIL in
# your github settings.
# 4. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the scripts will do everything else for you.
sudo: false
dist: trusty
language: cpp
env:
global:
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# to use the default for a given environment, comment it out; recommend you build debug and release however..
# - B2_ADDRESS_MODEL=address-model=64,32
# - B2_LINK=link=shared,static
# - B2_THREADING=threading=multi,single
- B2_VARIANT=variant=release,debug
install:
- git clone https://github.com/jeking3/boost-ci.git boost-ci
- cp -pr boost-ci/ci boost-ci/.codecov.yml .
- source ci/travis/install.sh
addons:
apt:
packages:
- binutils-gold
- gdb
- libc6-dbg
branches:
only:
- develop
- master
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/build.sh
#
# Default toolsets in Ubuntu
#
# trusty xenial bionic
# 14.04 16.04 18.04
# ------ ------ ------
# clang 3.4 3.8 6.0
# gcc 4.8.2 5.3.1 7.3.0
#
anchors:
clang-34: &clang-34 { apt: { packages: [ "clang-3.4" ], sources: [ "llvm-toolchain-trusty-3.4" ] } }
clang-38: &clang-38 { apt: { packages: [ "clang-3.8",
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-trusty-3.8",
"ubuntu-toolchain-r-test" ] } }
clang-4: &clang-4 { apt: { packages: [ "clang-4.0",
"libstdc++-6-dev" ], sources: [ "llvm-toolchain-trusty-4.0",
"ubuntu-toolchain-r-test" ] } }
clang-5: &clang-5 { apt: { packages: [ "clang-5.0",
"libstdc++-7-dev" ], sources: [ "llvm-toolchain-trusty-5.0",
"ubuntu-toolchain-r-test" ] } }
clang-6: &clang-6 { apt: { packages: [ "clang-6.0",
"libc++-dev",
"libstdc++-8-dev",
"valgrind" ], sources: [ "llvm-toolchain-trusty-6.0",
"ubuntu-toolchain-r-test" ] } }
gcc-44: &gcc-44 { apt: { packages: [ "g++-4.4" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-46: &gcc-46 { apt: { packages: [ "g++-4.6" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-48: &gcc-48 { apt: { packages: [ "g++-4.8" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-5: &gcc-5 { apt: { packages: [ "g++-5" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-6: &gcc-6 { apt: { packages: [ "g++-6" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-7: &gcc-7 { apt: { packages: [ "g++-7" ], sources: [ "ubuntu-toolchain-r-test" ] } }
gcc-8: &gcc-8 { apt: { packages: [ "g++-8" ], sources: [ "ubuntu-toolchain-r-test" ] } }
jobs:
allow_failures:
- env:
- COPY="all the environment settings from your job"
include:
# libstdc++
- { os: "linux", env: [ "TOOLSET=gcc-4.4", "CXXSTD=98,0x" ], addons: *gcc-44 }
- { os: "linux", env: [ "TOOLSET=gcc-4.6", "CXXSTD=03,0x" ], addons: *gcc-46 }
- { os: "linux", env: [ "TOOLSET=gcc-4.8", "CXXSTD=03,11" ], addons: *gcc-48 }
- { os: "linux", env: [ "TOOLSET=gcc-5", "CXXSTD=03,11" ], addons: *gcc-5 }
- { os: "linux", env: [ "TOOLSET=gcc-6", "CXXSTD=03,11,14" ], addons: *gcc-6 }
- { os: "linux", env: [ "TOOLSET=gcc-7", "CXXSTD=03,11,14,17" ], addons: *gcc-7 }
- { os: "linux", env: [ "TOOLSET=gcc-8", "CXXSTD=03,11,14,17,2a" ], addons: *gcc-8 }
- { os: "linux", env: [ "TOOLSET=clang-3.4", "CXXSTD=03,11" ], addons: *clang-34 }
- { os: "linux", env: [ "TOOLSET=clang-3.8", "CXXSTD=03,11,14" ], addons: *clang-38 }
- { os: "linux", env: [ "TOOLSET=clang-4.0", "CXXSTD=03,11,14" ], addons: *clang-4 }
- { os: "linux", env: [ "TOOLSET=clang-5.0", "CXXSTD=03,11,14,17" ], addons: *clang-5 }
- { os: "linux", env: [ "TOOLSET=clang-6.0", "CXXSTD=03,11,14,17,2a" ], addons: *clang-6 }
# libc++
- { os: "linux", env: [ "TOOLSET=clang-6.0", "CXXSTD=03,11,14,17,2a",
"CXXFLAGS=-stdlib=libc++" ], addons: *clang-6 }
# the rvm environment on osx is taking over basic commands like "cd" and breaking things!
# - { os: "osx" , env: [ "COMMENT=libc++",
# "TOOLSET=clang", "CXXSTD=03,11,14" ] }
- os: linux
env:
- COMMENT=codecov.io
- TOOLSET=gcc-7
- DEFINES="define=BOOST_NO_STRESS_TEST=1"
addons: *gcc-7
script:
- pushd /tmp && git clone https://github.com/linux-test-project/lcov.git && export PATH=/tmp/lcov/bin:$PATH && which lcov && lcov --version && popd
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/codecov.sh
- os: linux
env:
- COMMENT=cppcheck
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/cppcheck.sh
- os: linux
env:
- COMMENT=ubsan
- B2_VARIANT=variant=debug
- TOOLSET=gcc-8
- CXXSTD=03,11,14,17,2a
- DEFINES="define=BOOST_NO_STRESS_TEST=1"
- CXXFLAGS="cxxflags=-fno-omit-frame-pointer cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined"
- LINKFLAGS="linkflags=-fsanitize=undefined linkflags=-fno-sanitize-recover=undefined linkflags=-fuse-ld=gold"
- UBSAN_OPTIONS=print_stacktrace=1
addons: *gcc-8
- os: linux
env:
- COMMENT=valgrind
- TOOLSET=clang-6.0
- CXXSTD=03,11,14,17,2a
- DEFINES="define=BOOST_NO_STRESS_TEST=1"
- B2_VARIANT=variant=debug
- TESTFLAGS=testing.launcher=valgrind
- VALGRIND_OPTS=--error-exitcode=1
addons: *clang-6
#################### Jobs to run on pushes to master, develop ###################
# Coverity Scan
- os: linux
if: (env(COVERITY_SCAN_NOTIFICATION_EMAIL) IS present) AND (branch IN (develop, master)) AND (type IN (cron, push))
env:
- COMMENT="Coverity Scan"
- TOOLSET=gcc-7
addons: *gcc-7
script:
- cd $BOOST_ROOT/libs/$SELF
- ci/travis/coverity.sh
notifications:
email:
false
+4
View File
@@ -0,0 +1,4 @@
# https://github.com/boostorg/serialization/issues/122
vptr:/usr/include/c++/*/bits/ios_base.h
# https://github.com/boostorg/serialization/issues/193
# could not figure out how to suppress it
+52
View File
@@ -0,0 +1,52 @@
# Generated by `boostdep --cmake date_time`
# Copyright 2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_date_time VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_date_time
src/gregorian/greg_month.cpp
)
add_library(Boost::date_time ALIAS boost_date_time)
target_include_directories(boost_date_time PUBLIC include)
target_link_libraries(boost_date_time
PUBLIC
Boost::algorithm
Boost::assert
Boost::config
Boost::core
Boost::io
Boost::lexical_cast
Boost::numeric_conversion
Boost::range
Boost::smart_ptr
Boost::throw_exception
Boost::tokenizer
Boost::type_traits
Boost::utility
Boost::winapi
)
target_compile_definitions(boost_date_time
PUBLIC BOOST_DATE_TIME_NO_LIB
PRIVATE BOOST_DATE_TIME_SOURCE
)
if(BUILD_SHARED_LIBS)
target_compile_definitions(boost_date_time PUBLIC BOOST_DATE_TIME_DYN_LINK)
else()
target_compile_definitions(boost_date_time PUBLIC BOOST_DATE_TIME_STATIC_LINK)
endif()
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()
-11
View File
@@ -1,11 +0,0 @@
# Boost.DateTime Library Jamfile
#
# Copyright (c) 2018 James E. King III
#
# Use, modification, and distribution are subject to the
# Boost Software License, Version 1.0. (See accompanying file
# LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# please order by name to ease maintenance
build-project example ;
build-project test ;
+19 -17
View File
@@ -6,28 +6,31 @@ Distributed under the [Boost Software License, Version 1.0](http://www.boost.org
### Properties
* C++03
* Requires Linking
* C++11
* Header only
### Build Status
Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
:-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
[`master`](https://github.com/boostorg/date_time/tree/master) | [![Build Status](https://travis-ci.org/boostorg/date_time.svg?branch=master)](https://travis-ci.org/boostorg/date_time) | [![Build status](https://ci.appveyor.com/api/projects/status/upf5c528fy09fudk?svg=true)](https://ci.appveyor.com/project/jeking3/date-time-1evbf) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/14908/badge.svg)](https://scan.coverity.com/projects/boostorg-date_time) | [![codecov](https://codecov.io/gh/boostorg/date_time/branch/master/graph/badge.svg)](https://codecov.io/gh/boostorg/date_time/branch/master) | [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/date_time.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/date_time.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/date_time.html)
[`develop`](https://github.com/boostorg/date_time/tree/develop) | [![Build Status](https://travis-ci.org/boostorg/date_time.svg?branch=develop)](https://travis-ci.org/boostorg/date_time) | [![Build status](https://ci.appveyor.com/api/projects/status/upf5c528fy09fudk/branch/develop?svg=true)](https://ci.appveyor.com/project/boostorg/date_time/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/14908/badge.svg)](https://scan.coverity.com/projects/boostorg-date_time) | [![codecov](https://codecov.io/gh/boostorg/date_time/branch/develop/graph/badge.svg)](https://codecov.io/gh/boostorg/date_time/branch/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/date_time.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/date_time.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/date_time.html)
<!-- boost-ci/tools/makebadges.sh --repo date_time --appveyorbadge upf5c528fy09fudk --codecovbadge nDoh7t8f6g --coverity 14908 -->
| Branch | GHA CI | Appveyor | Coverity Scan | codecov.io | Deps | Docs | Tests |
| :-------------: | ------ | -------- | ------------- | ---------- | ---- | ---- | ----- |
| [`master`](https://github.com/boostorg/date_time/tree/master) | [![Build Status](https://github.com/boostorg/date_time/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/date_time/actions?query=branch:master) | [![Build status](https://ci.appveyor.com/api/projects/status/upf5c528fy09fudk/branch/master?svg=true)](https://ci.appveyor.com/project/cppalliance/date-time/branch/master) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/14908/badge.svg)](https://scan.coverity.com/projects/boostorg-date_time) | [![codecov](https://codecov.io/gh/boostorg/date_time/branch/master/graph/badge.svg?token=nDoh7t8f6g)](https://codecov.io/gh/boostorg/date_time/tree/master) | [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/date_time.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](https://www.boost.org/doc/libs/master/libs/date_time) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](https://www.boost.org/development/tests/master/developer/date_time.html) |
| [`develop`](https://github.com/boostorg/date_time/tree/develop) | [![Build Status](https://github.com/boostorg/date_time/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/date_time/actions?query=branch:develop) | [![Build status](https://ci.appveyor.com/api/projects/status/upf5c528fy09fudk/branch/develop?svg=true)](https://ci.appveyor.com/project/cppalliance/date-time/branch/develop) | [![Coverity Scan Build Status](https://scan.coverity.com/projects/14908/badge.svg)](https://scan.coverity.com/projects/boostorg-date_time) | [![codecov](https://codecov.io/gh/boostorg/date_time/branch/develop/graph/badge.svg?token=nDoh7t8f6g)](https://codecov.io/gh/boostorg/date_time/tree/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/date_time.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](https://www.boost.org/doc/libs/develop/libs/date_time) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](https://www.boost.org/development/tests/develop/developer/date_time.html) |
### Directories
| Name | Purpose |
| --------- | ------------------------------ |
| `build` | build script for link library |
| `data` | timezone database |
| `doc` | documentation |
| `example` | use case examples |
| `include` | headers |
| `src` | source code for link library |
| `test` | unit tests |
| `xmldoc` | additional documentation |
Note that the built library is only for build backward compatibility and contains no symbols. date_time is now header only.
| Name | Purpose |
| --------- | --------------------------------------- |
| `build` | build script for optional lib build |
| `data` | timezone database |
| `doc` | documentation |
| `example` | use case examples |
| `include` | headers |
| `src` | source code for optional link library |
| `test` | unit tests |
| `xmldoc` | documentation source |
### More information
@@ -35,4 +38,3 @@ Branch | Travis | Appveyor | Coverity Scan | codecov.io | Deps | Docs |
* [Report bugs](https://github.com/boostorg/date_time/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* [Submit Pull Requests](https://github.com/boostorg/date_time/pulls) against the **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). Be sure to include tests proving your changes work properly.
* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[date_time]` tag at the beginning of the subject line.
-129
View File
@@ -1,129 +0,0 @@
# Copyright 2016, 2017 Peter Dimov
# Copyright (C) 2017, 2018 James E. King III
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
#
# Generic Appveyor build script for boostorg repositories
# See: https://github.com/jeking3/boost-ci/
#
# Instructions for customizing this script for your library:
#
# 1. Customize the compilers and language levels you want.
# 2. If you have move than include/, src/, test/, example/, examples/,
# benchmark/ or tools/ directories, set the environment variable DEPINST.
# For example if your build uses code in "bench/" and "fog/" directories:
# - DEPINST: --include bench --include fog
# 3. Enable pull request builds in your boostorg/<library> account.
#
# That's it - the script will do everything else for you.
#
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- develop
- master
matrix:
# Adding MAYFAIL to any matrix job allows it to fail but the build stays green:
allow_failures:
- MAYFAIL: true
environment:
global:
# see: http://www.boost.org/build/doc/html/bbv2/overview/invocation.html#bbv2.overview.invocation.properties
# to use the default for a given environment, comment it out; recommend you build debug and release however:
# on Windows it is important to exercise all the possibilities, especially shared vs static, however most
# libraries that care about this exercise it in their Jamfiles...
# B2_ADDRESS_MODEL: address-model=64,32
# B2_LINK: link=shared,static
# B2_THREADING: threading=multi,single
B2_VARIANT: variant=release,debug
matrix:
- FLAVOR: Visual Studio 2017 C++2a Strict
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
B2_ADDRESS_MODEL: address-model=64
CXXFLAGS: cxxflags=-permissive-
CXXSTD: latest # 2a
- FLAVOR: Visual Studio 2017 C++17
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
B2_ADDRESS_MODEL: address-model=64
CXXSTD: 17
- FLAVOR: Visual Studio 2017 C++14 (Default)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
B2_ADDRESS_MODEL: address-model=64,32
- FLAVOR: Visual Studio 2015 C++14 (Default)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-14.0
B2_ADDRESS_MODEL: address-model=64,32
- FLAVOR: Visual Studio 2010, 2012, 2013
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013
TOOLSET: msvc-10.0,msvc-11.0,msvc-12.0
- FLAVOR: cygwin (32-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin\bin;
B2_ADDRESS_MODEL: address-model=32
CXXSTD: 03,11
# https://github.com/boostorg/test/issues/144
DEFINES: define=_POSIX_C_SOURCE=200112L define=_GLIBCXX_USE_CXX11_ABI=1
THREADING: threadapi=pthread
CYGWIN_UPDATE: true
TOOLSET: gcc
- FLAVOR: cygwin (64-bit)
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ADDPATH: C:\cygwin64\bin;
B2_ADDRESS_MODEL: address-model=64
CXXSTD: 11,17
# https://github.com/boostorg/test/issues/144
DEFINES: define=_POSIX_C_SOURCE=200112L define=__USE_ISOC99 define=_GLIBCXX_USE_CXX11_ABI=1
THREADING: threadapi=pthread
CYGWIN_UPDATE: true
TOOLSET: gcc
- FLAVOR: mingw32
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARCH: i686
B2_ADDRESS_MODEL: address-model=32
CXXSTD: 03,11
SCRIPT: ci\appveyor\mingw.bat
- FLAVOR: mingw64
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
ARCH: x86_64
B2_ADDRESS_MODEL: address-model=64
CXXSTD: 11,17
DEFINES: define=__USE_ISOC99
SCRIPT: ci\appveyor\mingw.bat
install:
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
- git clone https://github.com/jeking3/boost-ci.git C:\boost-ci
- xcopy /s /e /q /i C:\boost-ci\ci .\ci
- ci\appveyor\install.bat
build: off
test_script:
- set SELF=%APPVEYOR_PROJECT_NAME:-=_%
- PATH=%ADDPATH%%PATH%
- IF DEFINED CYGWIN_UPDATE (call libs\%SELF%\ci\appveyor\cygwin-update.bat)
# The definition of TOOLCXX omits CXXSTD= if it was not defined above
- IF NOT DEFINED CXXSTD (SET TOOLCXX=toolset=%TOOLSET%) ELSE (SET TOOLCXX=toolset=%TOOLSET% cxxstd=%CXXSTD%)
# Echo the complete build command to the build log
- IF NOT DEFINED SCRIPT (ECHO b2 libs/%SELF:\=/% %TOOLCXX% %CXXFLAGS% %DEFINES% %THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
# Now go build...
- IF DEFINED SCRIPT (call libs\%SELF%\%SCRIPT%) ELSE (b2 libs/%SELF:\=/% %TOOLCXX% %CXXFLAGS% %DEFINES% %THREADING% %B2_ADDRESS_MODEL% %B2_LINK% %B2_THREADING% %B2_VARIANT% -j3)
+37
View File
@@ -0,0 +1,37 @@
# Copyright René Ferdinand Rivera Morell 2023-2024
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
require-b2 5.2 ;
constant boost_dependencies :
/boost/algorithm//boost_algorithm
/boost/assert//boost_assert
/boost/config//boost_config
/boost/core//boost_core
/boost/io//boost_io
/boost/lexical_cast//boost_lexical_cast
/boost/numeric_conversion//boost_numeric_conversion
/boost/range//boost_range
/boost/smart_ptr//boost_smart_ptr
/boost/throw_exception//boost_throw_exception
/boost/tokenizer//boost_tokenizer
/boost/type_traits//boost_type_traits
/boost/utility//boost_utility
/boost/winapi//boost_winapi ;
project /boost/date_time
: common-requirements
<include>include
;
explicit
[ alias boost_date_time : build//boost_date_time ]
[ alias all : boost_date_time example test ]
;
call-if : boost-library date_time
: install boost_date_time
;
+10 -19
View File
@@ -1,33 +1,24 @@
# Copyright (c) 2002-2005 CrystalClear Software, Inc.
# Use, modification and distribution is subject to the
# 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
# date_time is now header only -- this file provides a stub for backward compatibility
#
project boost/date_time
project
: common-requirements <library>$(boost_dependencies)
: requirements
<define>DATE_TIME_INLINE
<link>shared:<define>BOOST_ALL_DYN_LINK=1
: usage-requirements
<link>shared:<define>BOOST_ALL_DYN_LINK=1
: usage-requirements
<define>DATE_TIME_INLINE
<link>shared:<define>BOOST_DATE_TIME_DYN_LINK=1
<define>BOOST_DATE_TIME_NO_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 ;
# greg_month.cpp is now just a stub so that there is
# still a boost_date_time library to link for backward compatibility
lib boost_date_time : gregorian/greg_month.cpp ;
+2
View File
@@ -4,6 +4,8 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
require-b2 5.2 ;
###############################################################################
alias boostdoc
: ../xmldoc/date_time.xml
+8 -10
View File
@@ -1,7 +1,4 @@
project libs/date_time/example
: requirements
<library>../build//boost_date_time/<link>static
;
project : requirements <library>/boost/date_time//boost_date_time ;
exe dates_as_strings : gregorian/dates_as_strings.cpp ;
exe days_alive : gregorian/days_alive.cpp ;
@@ -19,20 +16,21 @@ exe period_calc : gregorian/period_calc.cpp ;
exe days_since_year_start : gregorian/days_since_year_start.cpp ;
exe local_utc_conversion : posix_time/local_utc_conversion.cpp
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
;
exe print_hours : posix_time/print_hours.cpp
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
;
exe time_math : posix_time/time_math.cpp
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
;
exe time_periods : posix_time/time_periods.cpp
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
;
exe simple_time_zone : local_time/simple_time_zone.cpp ;
@@ -43,7 +41,7 @@ exe io_tutorial : tutorial/io_tutorial.cpp ;
# Copyright (c) 2002-2005
# CrystalClear Software, Inc.
# Subject to the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or
# Subject to the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or
# http://www.boost.org/LICENSE_1_0.txt)
+1 -1
View File
@@ -25,7 +25,7 @@ main()
date d(from_simple_string(s));
std::cout << to_simple_string(d) << std::endl;
//Read ISO Standard(CCYYMMDD) and output ISO Extended
//Read ISO 8601 Standard(CCYYMMDD) and output ISO 8601 Extended
std::string ud("20011009"); //2001-Oct-09
date d1(from_undelimited_string(ud));
std::cout << to_iso_extended_string(d1) << std::endl;
@@ -24,11 +24,11 @@ main()
std::cin >> m;
month = greg_month(m);
}
catch(bad_year by) {
catch(const bad_year& by) {
std::cout << "Invalid Year Entered: " << by.what() << '\n'
<< "Using minimum values for month and year." << std::endl;
}
catch(bad_month bm) {
catch(const bad_month& bm) {
std::cout << "Invalid Month Entered" << bm.what() << '\n'
<< "Using minimum value for month. " << std::endl;
}
+1 -1
View File
@@ -83,7 +83,7 @@ int main()
us_facet->format("%m/%d/%Y");
std::cout << d1 << std::endl; // 10/01/2002
// English names, iso order (year-month-day), '-' separator
// English names, ISO 8601 order (year-month-day), '-' separator
us_facet->format("%Y-%b-%d");
std::cout << d1 << std::endl; // 2002-Oct-01
+2 -2
View File
@@ -22,10 +22,10 @@ int main()
tz_database tz_db;
try {
tz_db.load_from_file("../../data/date_time_zonespec.csv");
}catch(data_not_accessible dna) {
}catch(const data_not_accessible& dna) {
std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
exit(EXIT_FAILURE);
}catch(bad_field_count bfc) {
}catch(const bad_field_count& bfc) {
std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
exit(EXIT_FAILURE);
}
+2 -2
View File
@@ -24,10 +24,10 @@ int main()
tz_database tz_db;
try {
tz_db.load_from_file("../data/date_time_zonespec.csv");
}catch(data_not_accessible dna) {
}catch(const data_not_accessible& dna) {
std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
exit(EXIT_FAILURE);
}catch(bad_field_count bfc) {
}catch(const bad_field_count& bfc) {
std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
exit(EXIT_FAILURE);
}
+9 -4
View File
@@ -90,10 +90,13 @@ namespace date_time {
}
#else // BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS
#if (defined(_MSC_VER) && (_MSC_VER >= 1400))
#if defined(__clang__) // Clang has to be checked before MSVC
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif (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
#endif
//! requires a pointer to a user created std::tm struct
inline
static std::tm* localtime(const std::time_t* t, std::tm* result)
@@ -112,9 +115,11 @@ namespace date_time {
boost::throw_exception(std::runtime_error("could not convert calendar time to UTC time"));
return result;
}
#if (defined(_MSC_VER) && (_MSC_VER >= 1400))
#if defined(__clang__) // Clang has to be checked before MSVC
#pragma clang diagnostic pop
#elif (defined(_MSC_VER) && (_MSC_VER >= 1400))
#pragma warning(pop) // restore warnings to previous state
#endif // _MSC_VER >= 1400
#endif
#endif // BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS
};
+4 -41
View File
@@ -12,19 +12,6 @@
#include <boost/config.hpp>
#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
@@ -41,12 +28,8 @@
// 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) ) )
#if (defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) || BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x581) ) )
#define BOOST_DATE_TIME_NO_MEMBER_INIT
#endif
@@ -60,13 +43,13 @@
/* 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)
#if defined(BOOST_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)
#if defined(BOOST_BORLANDC) && defined(BOOST_BCB_WITH_STLPORT)
#include <locale>
namespace std {
using stlport::tolower;
@@ -83,7 +66,7 @@ namespace std {
#if (((defined(__GNUC__) && (__GNUC__ < 3)) || \
(defined(_MSC_VER) && (_MSC_VER < 1300)) ) && \
!defined(_STLP_OWN_IOSTREAMS) ) || \
BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x581) )
#define BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS
#endif
@@ -136,26 +119,6 @@ namespace std {
# 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__)
+19 -11
View File
@@ -13,7 +13,7 @@
#include <stdexcept>
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>
#include <boost/mpl/if.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_base_of.hpp>
namespace boost {
@@ -43,25 +43,29 @@ namespace CV {
public:
typedef typename value_policies::value_type value_type;
// typedef except_type exception_type;
constrained_value(value_type value) : value_((min)())
BOOST_CXX14_CONSTEXPR constrained_value(value_type value) : value_((min)())
{
assign(value);
}
constrained_value& operator=(value_type v)
BOOST_CXX14_CONSTEXPR 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)();}
static BOOST_CONSTEXPR 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)();}
static BOOST_CONSTEXPR value_type
min BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::min)();}
//! Coerce into the representation type
operator value_type() const {return value_;}
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
protected:
value_type value_;
private:
void assign(value_type value)
BOOST_CXX14_CONSTEXPR 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....
@@ -95,16 +99,20 @@ namespace CV {
}
};
typedef typename mpl::if_<
is_base_of< std::exception, exception_type >,
typedef typename conditional<
is_base_of< std::exception, exception_type >::value,
exception_type,
exception_wrapper
>::type actual_exception_type;
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 BOOST_CONSTEXPR rep_type
min BOOST_PREVENT_MACRO_SUBSTITUTION () { return min_value; }
static BOOST_CONSTEXPR rep_type
max BOOST_PREVENT_MACRO_SUBSTITUTION () { return max_value; }
static void on_error(rep_type, rep_type, violation_enum)
{
boost::throw_exception(actual_exception_type());
+24 -24
View File
@@ -21,7 +21,7 @@ namespace date_time {
/*!
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
or ISO 8601 systems. It provides basic operations to enable calculation
and comparisons.
<b>Theory</b>
@@ -68,76 +68,76 @@ namespace date_time {
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)
BOOST_CXX14_CONSTEXPR date(year_type y, month_type m, day_type d)
: days_(calendar::day_number(ymd_type(y, m, d)))
{}
date(const ymd_type& ymd)
BOOST_CXX14_CONSTEXPR date(const ymd_type& ymd)
: days_(calendar::day_number(ymd))
{}
//let the compiler write copy, assignment, and destructor
year_type year() const
BOOST_CXX14_CONSTEXPR year_type year() const
{
ymd_type ymd = calendar::from_day_number(days_);
return ymd.year;
}
month_type month() const
BOOST_CXX14_CONSTEXPR month_type month() const
{
ymd_type ymd = calendar::from_day_number(days_);
return ymd.month;
}
day_type day() const
BOOST_CXX14_CONSTEXPR day_type day() const
{
ymd_type ymd = calendar::from_day_number(days_);
return ymd.day;
}
day_of_week_type day_of_week() const
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR ymd_type year_month_day() const
{
return calendar::from_day_number(days_);
}
bool operator<(const date_type& rhs) const
BOOST_CONSTEXPR bool operator<(const date_type& rhs) const
{
return days_ < rhs.days_;
}
bool operator==(const date_type& rhs) const
BOOST_CONSTEXPR bool operator==(const date_type& rhs) const
{
return days_ == rhs.days_;
}
//! check to see if date is a special value
bool is_special()const
BOOST_CONSTEXPR 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
BOOST_CONSTEXPR 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
BOOST_CONSTEXPR 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
BOOST_CONSTEXPR 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
BOOST_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR special_values as_special() const
{
return traits_type::to_special(days_);
}
duration_type operator-(const date_type& d) const
BOOST_CXX14_CONSTEXPR duration_type operator-(const date_type& d) const
{
if (!this->is_special() && !d.is_special())
{
@@ -154,7 +154,7 @@ namespace date_time {
}
}
date_type operator-(const duration_type& dd) const
BOOST_CXX14_CONSTEXPR date_type operator-(const duration_type& dd) const
{
if(dd.is_special())
{
@@ -162,17 +162,17 @@ namespace date_time {
}
return date_type(date_rep_type(days_) - static_cast<date_int_type>(dd.days()));
}
date_type operator-=(const duration_type& dd)
BOOST_CXX14_CONSTEXPR date_type operator-=(const duration_type& dd)
{
*this = *this - dd;
return date_type(days_);
}
date_rep_type day_count() const
BOOST_CONSTEXPR date_rep_type day_count() const
{
return days_;
}
//allow internal access from operators
date_type operator+(const duration_type& dd) const
BOOST_CXX14_CONSTEXPR date_type operator+(const duration_type& dd) const
{
if(dd.is_special())
{
@@ -180,7 +180,7 @@ namespace date_time {
}
return date_type(date_rep_type(days_) + static_cast<date_int_type>(dd.days()));
}
date_type operator+=(const duration_type& dd)
BOOST_CXX14_CONSTEXPR date_type operator+=(const duration_type& dd)
{
*this = *this + dd;
return date_type(days_);
@@ -192,8 +192,8 @@ namespace date_time {
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()) {}
BOOST_CONSTEXPR explicit date(date_int_type days) : days_(days) {}
BOOST_CXX14_CONSTEXPR explicit date(date_rep_type days) : days_(days.as_number()) {}
date_int_type days_;
};
+17 -22
View File
@@ -13,6 +13,7 @@
#include <boost/operators.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/int_adapter.hpp>
namespace boost {
namespace date_time {
@@ -33,50 +34,44 @@ namespace date_time {
typedef typename duration_rep_traits::impl_type duration_rep;
//! Construct from a day count
explicit date_duration(duration_rep day_count) : days_(day_count) {}
BOOST_CXX14_CONSTEXPR 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) :
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR duration_rep get_rep()const
{
return days_;
}
special_values as_special() const
BOOST_CXX14_CONSTEXPR special_values as_special() const
{
return days_.as_special();
}
bool is_special()const
BOOST_CXX14_CONSTEXPR bool is_special()const
{
return days_.is_special();
}
//! returns days as value, not object.
duration_rep_type days() const
BOOST_CXX14_CONSTEXPR 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()
static BOOST_CXX14_CONSTEXPR date_duration unit()
{
return date_duration<duration_rep_traits>(1);
}
//! Equality
bool operator==(const date_duration& rhs) const
BOOST_CXX14_CONSTEXPR bool operator==(const date_duration& rhs) const
{
return days_ == rhs.days_;
}
//! Less
bool operator<(const date_duration& rhs) const
BOOST_CXX14_CONSTEXPR bool operator<(const date_duration& rhs) const
{
return days_ < rhs.days_;
}
@@ -87,33 +82,33 @@ namespace date_time {
* so this will not compile */
//! Subtract another duration -- result is signed
date_duration& operator-=(const date_duration& rhs)
BOOST_CXX14_CONSTEXPR 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)
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR date_duration operator-() const
{
return date_duration<duration_rep_traits>(get_rep() * (-1));
}
//! Division operations on a duration with an integer.
date_duration& operator/=(int divisor)
BOOST_CXX14_CONSTEXPR date_duration& operator/=(int divisor)
{
days_ = days_ / divisor;
return *this;
}
//! return sign information
bool is_negative() const
BOOST_CXX14_CONSTEXPR bool is_negative() const
{
return days_ < 0;
}
@@ -130,7 +125,7 @@ namespace date_time {
{
typedef long int_type;
typedef long impl_type;
static int_type as_number(impl_type i) { return i; }
static BOOST_CXX14_CONSTEXPR int_type as_number(impl_type i) { return i; }
};
/*! Struct for instantiating date_duration <b>WITH</b> special values
@@ -140,7 +135,7 @@ namespace date_time {
{
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(); }
static BOOST_CXX14_CONSTEXPR int_type as_number(impl_type i) { return i.as_number(); }
};
+44 -49
View File
@@ -22,9 +22,9 @@ namespace date_time {
template <class duration_config>
class BOOST_SYMBOL_VISIBLE weeks_duration : public date_duration<duration_config> {
public:
weeks_duration(typename duration_config::impl_type w)
BOOST_CXX14_CONSTEXPR weeks_duration(typename duration_config::impl_type w)
: date_duration<duration_config>(w * 7) {}
weeks_duration(special_values sv)
BOOST_CXX14_CONSTEXPR weeks_duration(special_values sv)
: date_duration<duration_config>(sv) {}
};
@@ -49,106 +49,104 @@ namespace date_time {
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)
BOOST_CXX14_CONSTEXPR months_duration(int_rep num) : _m(num) {}
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR 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
BOOST_CONSTEXPR bool operator==(const months_type& rhs) const
{
return(_m == rhs._m);
}
bool operator!=(const months_type& rhs) const
BOOST_CONSTEXPR bool operator!=(const months_type& rhs) const
{
return(_m != rhs._m);
}
months_type operator+(const months_type& rhs)const
BOOST_CXX14_CONSTEXPR months_type operator+(const months_type& rhs)const
{
return months_type(_m + rhs._m);
}
months_type& operator+=(const months_type& rhs)
BOOST_CXX14_CONSTEXPR months_type& operator+=(const months_type& rhs)
{
_m = _m + rhs._m;
return *this;
}
months_type operator-(const months_type& rhs)const
BOOST_CXX14_CONSTEXPR months_type operator-(const months_type& rhs)const
{
return months_type(_m - rhs._m);
}
months_type& operator-=(const months_type& rhs)
BOOST_CXX14_CONSTEXPR months_type& operator-=(const months_type& rhs)
{
_m = _m - rhs._m;
return *this;
}
months_type operator*(const int_type rhs)const
BOOST_CXX14_CONSTEXPR months_type operator*(const int_type rhs)const
{
return months_type(_m * rhs);
}
months_type& operator*=(const int_type rhs)
BOOST_CXX14_CONSTEXPR months_type& operator*=(const int_type rhs)
{
_m = _m * rhs;
return *this;
}
months_type operator/(const int_type rhs)const
BOOST_CXX14_CONSTEXPR months_type operator/(const int_type rhs)const
{
return months_type(_m / rhs);
}
months_type& operator/=(const int_type rhs)
BOOST_CXX14_CONSTEXPR months_type& operator/=(const int_type rhs)
{
_m = _m / rhs;
return *this;
}
months_type operator+(const years_type& y)const
BOOST_CXX14_CONSTEXPR months_type operator+(const years_type& y)const
{
return months_type(y.number_of_years() * 12 + _m);
}
months_type& operator+=(const years_type& y)
BOOST_CXX14_CONSTEXPR months_type& operator+=(const years_type& y)
{
_m = y.number_of_years() * 12 + _m;
return *this;
}
months_type operator-(const years_type& y) const
BOOST_CXX14_CONSTEXPR months_type operator-(const years_type& y) const
{
return months_type(_m - y.number_of_years() * 12);
}
months_type& operator-=(const years_type& y)
BOOST_CXX14_CONSTEXPR 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)
BOOST_CXX14_CONSTEXPR 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)
BOOST_CXX14_CONSTEXPR 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)
BOOST_CXX14_CONSTEXPR 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)
BOOST_CXX14_CONSTEXPR 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;
};
@@ -171,24 +169,24 @@ namespace date_time {
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)
BOOST_CXX14_CONSTEXPR years_duration(int_rep num) : _y(num) {}
BOOST_CXX14_CONSTEXPR years_duration(special_values sv) : _y(sv)
{
_y = int_rep::from_special(sv);
}
int_rep number_of_years() const { return _y; }
BOOST_CXX14_CONSTEXPR int_rep number_of_years() const { return _y; }
//! returns a negative duration
duration_type get_neg_offset(const date_type& d) const
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR bool operator==(const years_type& rhs) const
{
return(_y == rhs._y);
}
@@ -196,75 +194,72 @@ namespace date_time {
{
return(_y != rhs._y);
}
years_type operator+(const years_type& rhs)const
BOOST_CXX14_CONSTEXPR years_type operator+(const years_type& rhs)const
{
return years_type(_y + rhs._y);
}
years_type& operator+=(const years_type& rhs)
BOOST_CXX14_CONSTEXPR years_type& operator+=(const years_type& rhs)
{
_y = _y + rhs._y;
return *this;
}
years_type operator-(const years_type& rhs)const
BOOST_CXX14_CONSTEXPR years_type operator-(const years_type& rhs)const
{
return years_type(_y - rhs._y);
}
years_type& operator-=(const years_type& rhs)
BOOST_CXX14_CONSTEXPR years_type& operator-=(const years_type& rhs)
{
_y = _y - rhs._y;
return *this;
}
years_type operator*(const int_type rhs)const
BOOST_CXX14_CONSTEXPR years_type operator*(const int_type rhs)const
{
return years_type(_y * rhs);
}
years_type& operator*=(const int_type rhs)
BOOST_CXX14_CONSTEXPR years_type& operator*=(const int_type rhs)
{
_y = _y * rhs;
return *this;
}
years_type operator/(const int_type rhs)const
BOOST_CXX14_CONSTEXPR years_type operator/(const int_type rhs)const
{
return years_type(_y / rhs);
}
years_type& operator/=(const int_type rhs)
BOOST_CXX14_CONSTEXPR years_type& operator/=(const int_type rhs)
{
_y = _y / rhs;
return *this;
}
months_type operator+(const months_type& m) const
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR 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)
BOOST_CXX14_CONSTEXPR 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)
BOOST_CXX14_CONSTEXPR 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)
BOOST_CXX14_CONSTEXPR 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)
BOOST_CXX14_CONSTEXPR 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___
+5 -6
View File
@@ -9,10 +9,10 @@
* $Date$
*/
#include <iterator> // ostreambuf_iterator
#include <locale>
#include <string>
#include <vector>
#include <iterator> // ostreambuf_iterator
#include <boost/throw_exception.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/date_time/compiler_config.hpp>
@@ -316,23 +316,23 @@ namespace boost { namespace date_time {
string_type a_format) const
{
// update format string with custom names
if (m_weekday_long_names.size()) {
if (!m_weekday_long_names.empty()) {
boost::algorithm::replace_all(a_format,
long_weekday_format,
m_weekday_long_names[tm_value.tm_wday]);
}
if (m_weekday_short_names.size()) {
if (!m_weekday_short_names.empty()) {
boost::algorithm::replace_all(a_format,
short_weekday_format,
m_weekday_short_names[tm_value.tm_wday]);
}
if (m_month_long_names.size()) {
if (!m_month_long_names.empty()) {
boost::algorithm::replace_all(a_format,
long_month_format,
m_month_long_names[tm_value.tm_mon]);
}
if (m_month_short_names.size()) {
if (!m_month_short_names.empty()) {
boost::algorithm::replace_all(a_format,
short_month_format,
m_month_short_names[tm_value.tm_mon]);
@@ -763,5 +763,4 @@ namespace boost { namespace date_time {
} } // namespaces
#endif
+22 -17
View File
@@ -13,8 +13,8 @@
Definition and implementation of date algorithm templates
*/
#include <stdexcept>
#include <sstream>
#include <stdexcept>
#include <boost/throw_exception.hpp>
#include <boost/date_time/date.hpp>
#include <boost/date_time/compiler_config.hpp>
@@ -38,7 +38,7 @@ namespace date_time {
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;
virtual std::string to_string() const = 0;
};
//! Generates a date by applying the year to the given month and day.
@@ -98,7 +98,7 @@ namespace date_time {
* pg.get_date(2000); // returns 2000-2-29
* @endcode
*/
date_type get_date(year_type y) const
date_type get_date(year_type y) const BOOST_OVERRIDE
{
if((day_ == 29) && (month_ == 2) && !(calendar_type::is_leap_year(y))) {
std::ostringstream ss;
@@ -139,7 +139,7 @@ namespace date_time {
* Jan-01 == "0"
* Feb-29 == "58"
* Dec-31 == "365" */
virtual std::string to_string() const
std::string to_string() const BOOST_OVERRIDE
{
std::ostringstream ss;
date_type d(2004, month_, day_);
@@ -153,9 +153,18 @@ namespace date_time {
month_type month_;
};
//! Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5.
BOOST_DATE_TIME_DECL const char* nth_as_str(int n);
inline const char* nth_as_str(int ele)
{
static const char* const _nth_as_str[] = {"out of range", "first", "second",
"third", "fourth", "fifth"};
if(ele >= 1 && ele <= 5) {
return _nth_as_str[ele];
}
else {
return _nth_as_str[0];
}
}
//! Useful generator functor for finding holidays
/*! Based on the idea in Cal. Calc. for finding holidays that are
@@ -167,7 +176,7 @@ namespace date_time {
* 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 it needs Wednesday 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
@@ -192,7 +201,7 @@ namespace date_time {
dow_(dow)
{}
//! Return a concrete date when provided with a year specific year.
date_type get_date(year_type y) const
date_type get_date(year_type y) const BOOST_OVERRIDE
{
date_type d(y, month_, 1); //first day of month
duration_type one_day(1);
@@ -230,7 +239,7 @@ namespace date_time {
}
//! 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::string to_string() const BOOST_OVERRIDE
{
std::ostringstream ss;
ss << 'M'
@@ -267,7 +276,7 @@ namespace date_time {
dow_(dow)
{}
//! Return a concrete date when provided with a year specific year.
date_type get_date(year_type year) const
date_type get_date(year_type year) const BOOST_OVERRIDE
{
date_type d(year, month_,1);
duration_type one_day(1);
@@ -287,7 +296,7 @@ namespace date_time {
}
//! 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::string to_string() const BOOST_OVERRIDE
{
std::ostringstream ss;
ss << 'M'
@@ -328,7 +337,7 @@ namespace date_time {
dow_(dow)
{}
//! Return a concrete date when provided with a year specific year.
date_type get_date(year_type year) const
date_type get_date(year_type year) const BOOST_OVERRIDE
{
date_type d(year, month_, calendar_type::end_of_month_day(year,month_));
duration_type one_day(1);
@@ -348,7 +357,7 @@ namespace date_time {
}
//! 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::string to_string() const BOOST_OVERRIDE
{
std::ostringstream ss;
ss << 'M'
@@ -502,8 +511,4 @@ namespace date_time {
} } //namespace date_time
#endif
+8 -8
View File
@@ -53,14 +53,14 @@ namespace date_time {
}
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;}
const date_type& operator*() const {return current_;}
const date_type* operator->() const {return &current_;}
bool operator< (const date_type& d) const {return current_ < d;}
bool operator<= (const date_type& d) const {return current_ <= d;}
bool operator> (const date_type& d) const {return current_ > d;}
bool operator>= (const date_type& d) const {return current_ >= d;}
bool operator== (const date_type& d) const {return current_ == d;}
bool operator!= (const date_type& d) const {return current_ != d;}
private:
date_type current_;
};
+51 -25
View File
@@ -9,13 +9,16 @@
* $Date$
*/
#include <map>
#include <string>
#include <sstream>
#include <iterator>
#include <algorithm>
#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 <boost/date_time/period.hpp>
#if defined(BOOST_DATE_TIME_NO_LOCALE)
#include <cctype> // ::tolower(int)
@@ -54,8 +57,6 @@ namespace date_time {
}
//! 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>
inline unsigned short
month_str_to_ushort(std::string const& s) {
@@ -64,34 +65,59 @@ namespace date_time {
}
else {
std::string str = 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(str);
if(iter != ptr->end()) { // required for STLport
return iter->second;
//c++98 support
#if defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
static std::map<std::string, unsigned short> month_map;
typedef std::map<std::string, unsigned short>::value_type vtype;
if( month_map.empty() ) {
month_map.insert( vtype("jan", static_cast<unsigned short>(1)) );
month_map.insert( vtype("january", static_cast<unsigned short>(1)) );
month_map.insert( vtype("feb", static_cast<unsigned short>(2)) );
month_map.insert( vtype("february", static_cast<unsigned short>(2)) );
month_map.insert( vtype("mar", static_cast<unsigned short>(3)) );
month_map.insert( vtype("march", static_cast<unsigned short>(3)) );
month_map.insert( vtype("apr", static_cast<unsigned short>(4)) );
month_map.insert( vtype("april", static_cast<unsigned short>(4)) );
month_map.insert( vtype("may", static_cast<unsigned short>(5)) );
month_map.insert( vtype("jun", static_cast<unsigned short>(6)) );
month_map.insert( vtype("june", static_cast<unsigned short>(6)) );
month_map.insert( vtype("jul", static_cast<unsigned short>(7)) );
month_map.insert( vtype("july", static_cast<unsigned short>(7)) );
month_map.insert( vtype("aug", static_cast<unsigned short>(8)) );
month_map.insert( vtype("august", static_cast<unsigned short>(8)) );
month_map.insert( vtype("sep", static_cast<unsigned short>(9)) );
month_map.insert( vtype("september", static_cast<unsigned short>(9)) );
month_map.insert( vtype("oct", static_cast<unsigned short>(10)) );
month_map.insert( vtype("october", static_cast<unsigned short>(10)) );
month_map.insert( vtype("nov", static_cast<unsigned short>(11)) );
month_map.insert( vtype("november", static_cast<unsigned short>(11)) );
month_map.insert( vtype("dec", static_cast<unsigned short>(12)) );
month_map.insert( vtype("december", static_cast<unsigned short>(12)) );
}
#else //c+11 and beyond
static std::map<std::string, unsigned short> month_map =
{ { "jan", static_cast<unsigned short>(1) }, { "january", static_cast<unsigned short>(1) },
{ "feb", static_cast<unsigned short>(2) }, { "february", static_cast<unsigned short>(2) },
{ "mar", static_cast<unsigned short>(3) }, { "march", static_cast<unsigned short>(3) },
{ "apr", static_cast<unsigned short>(4) }, { "april", static_cast<unsigned short>(4) },
{ "may", static_cast<unsigned short>(5) },
{ "jun", static_cast<unsigned short>(6) }, { "june", static_cast<unsigned short>(6) },
{ "jul", static_cast<unsigned short>(7) }, { "july", static_cast<unsigned short>(7) },
{ "aug", static_cast<unsigned short>(8) }, { "august", static_cast<unsigned short>(8) },
{ "sep", static_cast<unsigned short>(9) }, { "september", static_cast<unsigned short>(9) },
{ "oct", static_cast<unsigned short>(10) }, { "october", static_cast<unsigned short>(10)},
{ "nov", static_cast<unsigned short>(11) }, { "november", static_cast<unsigned short>(11)},
{ "dec", static_cast<unsigned short>(12) }, { "december", static_cast<unsigned short>(12)}
};
#endif
std::map<std::string, unsigned short>::const_iterator mitr = month_map.find( str );
if ( mitr != month_map.end() ) {
return mitr->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'. Both arrays
* must contain 'size' elements. The index of the match is returned.
* If no match is found, 'size' is returned.
* Ex. "Jan" returns 0, "Dec" returns 11, "Tue" returns 2.
* 'size' can be sent in with: (greg_month::max)() (which 12),
* (greg_weekday::max)() + 1 (which is 7) or date_time::NumSpecialValues */
template<class charT>
short find_match(const charT* const* short_names,
const charT* const* long_names,
short size,
const std::basic_string<charT>& s) {
for(short i = 0; i < size; ++i){
if(short_names[i] == s || long_names[i] == s){
return i;
}
}
return size; // 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
+53 -53
View File
@@ -2,7 +2,7 @@
#define DATE_TIME_DST_RULES_HPP__
/* Copyright (c) 2002,2003, 2007 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* 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
@@ -21,12 +21,12 @@
namespace boost {
namespace date_time {
enum time_is_dst_result {is_not_in_dst, is_in_dst,
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_,
template<class date_type_,
class time_duration_type_>
class dst_calculator
{
@@ -37,14 +37,14 @@ namespace boost {
//! 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.
* 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
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)
@@ -57,19 +57,19 @@ namespace boost {
if (time_of_day >= time_duration_type(0,offset,0)) {
return is_in_dst;
}
return invalid_time_label;
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
* 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
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)
@@ -86,10 +86,10 @@ namespace boost {
}
//! Calculates if the given local time is dst or not
/*! Determines if the time is really in DST or not. Also checks for
/*! 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 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
@@ -97,7 +97,7 @@ namespace boost {
* @param dst_length_minutes length of dst adjusment
* @retval The time is either ambiguous, invalid, in dst, or not in dst
*/
static time_is_dst_result
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,
@@ -120,20 +120,20 @@ namespace boost {
}
//! Calculates if the given local time is dst or not
/*! Determines if the time is really in DST or not. Also checks for
/*! 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 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
* @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
* @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
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,
@@ -165,7 +165,7 @@ namespace boost {
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,
@@ -183,29 +183,29 @@ namespace boost {
* 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
* 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
* 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
* @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_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
* 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_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,
template<class date_type,
class time_duration_type,
class dst_traits>
class dst_calc_engine
@@ -216,12 +216,12 @@ namespace boost {
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
/*! 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)
const time_duration_type& td)
{
year_type y = d.year();
@@ -230,10 +230,10 @@ namespace boost {
return dstcalc::local_is_dst(d,td,
dst_start,
dst_traits::dst_start_offset_minutes(),
dst_end,
dst_traits::dst_end_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)
@@ -244,14 +244,14 @@ namespace boost {
}
//! The time of day for the dst transition (eg: typically 01:00:00 or 02:00:00)
static time_duration_type dst_offset()
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);
return dst_traits::local_dst_start_day(year);
}
static date_type local_dst_end_day(year_type year)
@@ -267,11 +267,11 @@ namespace boost {
* 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_,
template<class date_type_,
class time_duration_type_,
unsigned int dst_start_offset_minutes=120, //from start of day
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
class us_dst_rules
{
public:
typedef time_duration_type_ time_duration_type;
@@ -284,12 +284,12 @@ namespace boost {
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
/*! 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)
const time_duration_type& td)
{
year_type y = d.year();
@@ -297,9 +297,9 @@ namespace boost {
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_end, dst_start_offset_minutes,
dst_length_minutes);
}
@@ -314,12 +314,12 @@ namespace boost {
{
if (year >= year_type(2007)) {
//second sunday in march
nkday ssim(nkday::second, Sunday, gregorian::Mar);
return ssim.get_date(year);
nkday ssim(nkday::second, Sunday, date_time::Mar);
return ssim.get_date(year);
} else {
//first sunday in april
fkday fsia(Sunday, gregorian::Apr);
return fsia.get_date(year);
fkday fsia(Sunday, date_time::Apr);
return fsia.get_date(year);
}
}
@@ -327,11 +327,11 @@ namespace boost {
{
if (year >= year_type(2007)) {
//first sunday in november
fkday fsin(Sunday, gregorian::Nov);
return fsin.get_date(year);
fkday fsin(Sunday, date_time::Nov);
return fsin.get_date(year);
} else {
//last sunday in october
lkday lsio(Sunday, gregorian::Oct);
lkday lsio(Sunday, date_time::Oct);
return lsio.get_date(year);
}
}
@@ -358,15 +358,15 @@ namespace boost {
//! 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&)
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&)
static time_is_dst_result utc_is_dst(const date_type&,
const time_duration_type&)
{
return is_not_in_dst;
}
@@ -376,7 +376,7 @@ namespace boost {
return false;
}
static time_duration_type dst_offset()
static time_duration_type dst_offset()
{
return time_duration_type(0,0,0);
}
@@ -7,7 +7,7 @@
#ifndef DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__
#define DATE_TIME_DATE_DST_TRANSITION_DAY_GEN_HPP__
#include <string>
namespace boost {
namespace date_time {
+42
View File
@@ -0,0 +1,42 @@
#ifndef _BOOST_DATE_TIME_FIND_MATCH_HPP___
#define _BOOST_DATE_TIME_FIND_MATCH_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$
*/
#include <string>
namespace boost {
namespace date_time {
//! Find index of a string in either of 2 arrays
/*! find_match searches both arrays for a match to 's'. Both arrays
* must contain 'size' elements. The index of the match is returned.
* If no match is found, 'size' is returned.
* Ex. "Jan" returns 0, "Dec" returns 11, "Tue" returns 2.
* 'size' can be sent in with: (greg_month::max)() (which 12),
* (greg_weekday::max)() + 1 (which is 7) or date_time::NumSpecialValues */
template<class charT>
short find_match(const charT* const* short_names,
const charT* const* long_names,
short size,
const std::basic_string<charT>& s) {
for(short i = 0; i < size; ++i){
if(short_names[i] == s || long_names[i] == s){
return i;
}
}
return size; // not-found, return a value out of range
}
} } //namespace date_time
#endif
+99 -99
View File
@@ -3,7 +3,7 @@
#define DATE_TIME_FORMAT_DATE_PARSER_HPP__
/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* 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
@@ -32,11 +32,11 @@ namespace std {
}
#endif
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
/*! 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
@@ -50,12 +50,12 @@ fixed_string_to_int(std::istreambuf_iterator<charT>& itr,
//typedef std::basic_string<charT> string_type;
unsigned int j = 0;
//string_type s;
while (j < length && itr != stream_end &&
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.
/* 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');
mr.cache += ('0');
}
else {
mr.cache += (*itr);
@@ -77,9 +77,9 @@ fixed_string_to_int(std::istreambuf_iterator<charT>& itr,
}
//! 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
/*! 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
@@ -93,8 +93,8 @@ fixed_string_to_int(std::istreambuf_iterator<charT>& itr,
}
//! 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 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
@@ -133,7 +133,7 @@ var_string_to_int(std::istreambuf_iterator<charT>& itr,
- %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
- %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
@@ -142,7 +142,7 @@ var_string_to_int(std::istreambuf_iterator<charT>& itr,
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.
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...
@@ -166,7 +166,7 @@ class format_date_parser
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,
@@ -178,7 +178,7 @@ class format_date_parser
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),
@@ -196,7 +196,7 @@ class format_date_parser
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;
@@ -225,7 +225,7 @@ class format_date_parser
}
date_type
parse_date(const string_type& value,
parse_date(const string_type& value,
const string_type& format_str,
const special_values_parser<date_type,charT>& sv_parser) const
{
@@ -236,49 +236,49 @@ class format_date_parser
}
date_type
parse_date(std::istreambuf_iterator<charT>& sitr,
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
/*! 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,
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; }
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.
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++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 == '%') {
if ( ++itr == format_str.end())
break;
break;
if (*itr != '%') {
switch(*itr) {
case 'a':
case 'a':
{
//this value is just throw away. It could be used for
//error checking potentially, but it isn't helpful in
//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);
@@ -294,10 +294,10 @@ class format_date_parser
}
break;
}
case 'A':
case 'A':
{
//this value is just throw away. It could be used for
//error checking potentially, but it isn't helpful in
//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);
@@ -313,7 +313,7 @@ class format_date_parser
}
break;
}
case 'b':
case 'b':
{
match_results mr = m_month_short_names.match(sitr, stream_end);
if(mr.current_match == match_results::PARSE_ERROR) {
@@ -328,7 +328,7 @@ class format_date_parser
}
break;
}
case 'B':
case 'B':
{
match_results mr = m_month_long_names.match(sitr, stream_end);
if(mr.current_match == match_results::PARSE_ERROR) {
@@ -343,7 +343,7 @@ class format_date_parser
}
break;
}
case 'd':
case 'd':
{
match_results mr;
day = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2);
@@ -355,7 +355,7 @@ class format_date_parser
t_day = day_type(day);
break;
}
case 'e':
case 'e':
{
match_results mr;
day = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2, ' ');
@@ -367,7 +367,7 @@ class format_date_parser
t_day = day_type(day);
break;
}
case 'j':
case 'j':
{
match_results mr;
day_of_year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 3);
@@ -381,7 +381,7 @@ class format_date_parser
t_day_of_year = day_of_year_type(day_of_year);
break;
}
case 'm':
case 'm':
{
match_results mr;
month = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2);
@@ -393,7 +393,7 @@ class format_date_parser
t_month = month_type(month);
break;
}
case 'Y':
case 'Y':
{
match_results mr;
year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 4);
@@ -405,7 +405,7 @@ class format_date_parser
t_year = year_type(year);
break;
}
case 'y':
case 'y':
{
match_results mr;
year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2);
@@ -420,14 +420,14 @@ class format_date_parser
}
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
@@ -440,48 +440,48 @@ class format_date_parser
}
}
}
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
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,
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,
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; }
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
short month(0);
const_itr itr(format_str.begin());
while (itr != format_str.end() && (sitr != stream_end)) {
if (*itr == '%') {
if ( ++itr == format_str.end())
break;
break;
if (*itr != '%') {
switch(*itr) {
case 'b':
case 'b':
{
mr = m_month_short_names.match(sitr, stream_end);
month = mr.current_match;
@@ -490,7 +490,7 @@ class format_date_parser
}
break;
}
case 'B':
case 'B':
{
mr = m_month_long_names.match(sitr, stream_end);
month = mr.current_match;
@@ -499,23 +499,23 @@ class format_date_parser
}
break;
}
case 'm':
case 'm':
{
month = var_string_to_int<short, charT>(sitr, stream_end, 2);
// var_string_to_int returns -1 if parse failed. That will
// 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
@@ -528,27 +528,27 @@ class format_date_parser
}
}
}
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,
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; }
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,
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; }
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
//return day_type(var_string_to_int<short, charT>(sitr, stream_end, 2));
match_results mr;
@@ -556,7 +556,7 @@ class format_date_parser
}
day_of_week_type
parse_weekday(std::istreambuf_iterator<charT>& sitr,
parse_weekday(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end,
string_type format_str) const
{
@@ -564,29 +564,29 @@ class format_date_parser
return parse_weekday(sitr, stream_end, format_str, mr);
}
day_of_week_type
parse_weekday(std::istreambuf_iterator<charT>& sitr,
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; }
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
short wkday(0);
const_itr itr(format_str.begin());
while (itr != format_str.end() && (sitr != stream_end)) {
if (*itr == '%') {
if ( ++itr == format_str.end())
break;
break;
if (*itr != '%') {
switch(*itr) {
case 'a':
case 'a':
{
//this value is just throw away. It could be used for
//error checking potentially, but it isn't helpful in
//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);
@@ -596,10 +596,10 @@ class format_date_parser
}
break;
}
case 'A':
case 'A':
{
//this value is just throw away. It could be used for
//error checking potentially, but it isn't helpful in
//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);
@@ -617,14 +617,14 @@ class format_date_parser
}
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
@@ -637,14 +637,14 @@ class format_date_parser
}
}
}
return day_of_week_type(wkday); // throws bad_day_of_month exception
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,
parse_year(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end,
string_type format_str) const
{
@@ -654,21 +654,21 @@ class format_date_parser
//! throws bad_year if unable to parse
year_type
parse_year(std::istreambuf_iterator<charT>& sitr,
parse_year(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end,
string_type format_str,
match_results& mr) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
unsigned short year(0);
const_itr itr(format_str.begin());
while (itr != format_str.end() && (sitr != stream_end)) {
if (*itr == '%') {
if ( ++itr == format_str.end())
break;
break;
if (*itr != '%') {
//match_results mr;
switch(*itr) {
@@ -687,14 +687,14 @@ class format_date_parser
}
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
@@ -702,11 +702,11 @@ class format_date_parser
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;
@@ -65,7 +65,7 @@ namespace gregorian {
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
//! Date period to ISO 8601 standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date_period& d) {
@@ -78,7 +78,7 @@ namespace gregorian {
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
//! Convert to ISO 8601 extended format string CCYY-MM-DD. Example 2002-12-31
/*!\ingroup date_format
*/
inline std::string to_iso_extended_string(const date& d) {
@@ -90,7 +90,7 @@ namespace gregorian {
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
//! Convert to ISO 8601 standard string YYYYMMDD. Example: 20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date& d) {
@@ -35,7 +35,7 @@ namespace gregorian {
return std::string("[" + d1 + "/" + d2 + "]");
}
//! Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
//! Date period to ISO 8601 standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date_period& d) {
@@ -44,14 +44,14 @@ namespace gregorian {
}
//! Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31
//! Convert to ISO 8601 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
//! Convert to ISO 8601 standard string YYYYMMDD. Example: 20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date& d) {
+34 -27
View File
@@ -1,7 +1,7 @@
#ifndef GREG_DATE_HPP___
#define GREG_DATE_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@@ -48,12 +48,12 @@ namespace gregorian {
typedef date_duration duration_type;
#if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
//! Default constructor constructs with not_a_date_time
date():
BOOST_CXX14_CONSTEXPR 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)
BOOST_CXX14_CONSTEXPR 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) {
@@ -61,73 +61,80 @@ namespace gregorian {
}
}
//! Constructor from a ymd_type structure
explicit date(const ymd_type& ymd)
BOOST_CXX14_CONSTEXPR 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):
BOOST_CXX14_CONSTEXPR 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):
BOOST_CXX14_CONSTEXPR 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);
}
}
BOOST_CXX14_CONSTEXPR explicit date(special_values sv):
date_time::date<date, gregorian_calendar, date_duration>(from_special_adjusted(sv))
{}
//!Return the Julian Day number for the date.
date_int_type julian_day() const
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR 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.
date_int_type modjulian_day() const
BOOST_CXX14_CONSTEXPR date_int_type 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
//!Return the ISO 8601 week number 1..53
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR date_int_type day_number() const
{
return days_;
}
//! Return the last day of the current month
date end_of_month() const
BOOST_CXX14_CONSTEXPR date end_of_month() const
{
ymd_type ymd = year_month_day();
short eom_day = gregorian_calendar::end_of_month_day(ymd.year, ymd.month);
unsigned short eom_day = gregorian_calendar::end_of_month_day(ymd.year, ymd.month);
return date(ymd.year, ymd.month, eom_day);
}
friend BOOST_CXX14_CONSTEXPR
bool operator==(const date& lhs, const date& rhs);
private:
BOOST_CXX14_CONSTEXPR date_rep_type from_special_adjusted(special_values sv)
{
switch (sv)
{
case min_date_time: return gregorian_calendar::day_number(ymd_type(1400, 1, 1));
case max_date_time: return gregorian_calendar::day_number(ymd_type(9999, 12, 31));
default: return date_rep_type::from_special(sv);
}
}
};
inline BOOST_CXX14_CONSTEXPR
bool operator==(const date& lhs, const date& rhs)
{
return lhs.days_ == rhs.days_;
}
} } //namespace gregorian
@@ -1,7 +1,7 @@
#ifndef GREG_DAY_HPP___
#define GREG_DAY_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003,2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@@ -42,9 +42,9 @@ namespace gregorian {
*/
class BOOST_SYMBOL_VISIBLE greg_day : public greg_day_rep {
public:
greg_day(value_type day_of_month) : greg_day_rep(day_of_month) {}
value_type as_number() const {return value_;}
operator value_type() const {return value_;}
BOOST_CXX14_CONSTEXPR greg_day(value_type day_of_month) : greg_day_rep(day_of_month) {}
BOOST_CXX14_CONSTEXPR value_type as_number() const {return value_;}
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
private:
};
@@ -1,7 +1,7 @@
#ifndef GREG_DURATION_HPP___
#define GREG_DURATION_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@@ -32,16 +32,15 @@ namespace gregorian {
typedef base_type::duration_rep duration_rep;
//! Construct from a day count
explicit date_duration(duration_rep day_count = 0) : base_type(day_count) {}
BOOST_CXX14_CONSTEXPR explicit
date_duration(duration_rep day_count = 0) : base_type(day_count) {}
//! construct from special_values
BOOST_CXX14_CONSTEXPR
date_duration(date_time::special_values sv) : base_type(sv) {}
//! Copy constructor
date_duration(const date_duration& other) : base_type(static_cast< base_type const& >(other))
{}
//! Construct from another date_duration
BOOST_CXX14_CONSTEXPR
date_duration(const base_type& other) : base_type(other)
{}
@@ -49,80 +48,93 @@ namespace gregorian {
// NOTE: Because of date_time::date_duration< T > design choice we don't use Boost.Operators here,
// because we need the class to be a direct base. Either lose EBO, or define operators by hand.
// The latter is more effecient.
bool operator== (const date_duration& rhs) const
BOOST_CXX14_CONSTEXPR bool operator== (const date_duration& rhs) const
{
return base_type::operator== (rhs);
}
bool operator!= (const date_duration& rhs) const
BOOST_CXX14_CONSTEXPR bool operator!= (const date_duration& rhs) const
{
return !operator== (rhs);
}
bool operator< (const date_duration& rhs) const
BOOST_CXX14_CONSTEXPR bool operator< (const date_duration& rhs) const
{
return base_type::operator< (rhs);
}
bool operator> (const date_duration& rhs) const
BOOST_CXX14_CONSTEXPR bool operator> (const date_duration& rhs) const
{
return !(base_type::operator< (rhs) || base_type::operator== (rhs));
}
bool operator<= (const date_duration& rhs) const
BOOST_CXX14_CONSTEXPR bool operator<= (const date_duration& rhs) const
{
return (base_type::operator< (rhs) || base_type::operator== (rhs));
}
bool operator>= (const date_duration& rhs) const
BOOST_CXX14_CONSTEXPR bool operator>= (const date_duration& rhs) const
{
return !base_type::operator< (rhs);
}
//! Subtract another duration -- result is signed
date_duration& operator-= (const date_duration& rhs)
BOOST_CXX14_CONSTEXPR date_duration& operator-= (const date_duration& rhs)
{
base_type::operator-= (rhs);
return *this;
}
friend date_duration operator- (date_duration rhs, date_duration const& lhs)
{
rhs -= lhs;
return rhs;
}
BOOST_CXX14_CONSTEXPR friend
date_duration operator- (date_duration rhs, date_duration const& lhs);
//! Add a duration -- result is signed
date_duration& operator+= (const date_duration& rhs)
BOOST_CXX14_CONSTEXPR date_duration& operator+= (const date_duration& rhs)
{
base_type::operator+= (rhs);
return *this;
}
friend date_duration operator+ (date_duration rhs, date_duration const& lhs)
{
rhs += lhs;
return rhs;
}
BOOST_CXX14_CONSTEXPR friend
date_duration operator+ (date_duration rhs, date_duration const& lhs);
//! unary- Allows for dd = -date_duration(2); -> dd == -2
date_duration operator- ()const
BOOST_CXX14_CONSTEXPR date_duration operator- ()const
{
return date_duration(get_rep() * (-1));
}
//! Division operations on a duration with an integer.
date_duration& operator/= (int divisor)
BOOST_CXX14_CONSTEXPR date_duration& operator/= (int divisor)
{
base_type::operator/= (divisor);
return *this;
}
friend date_duration operator/ (date_duration rhs, int lhs)
{
rhs /= lhs;
return rhs;
}
BOOST_CXX14_CONSTEXPR friend date_duration operator/ (date_duration rhs, int lhs);
//! Returns the smallest duration -- used by to calculate 'end'
static date_duration unit()
static BOOST_CXX14_CONSTEXPR date_duration unit()
{
return date_duration(base_type::unit().get_rep());
}
};
inline BOOST_CXX14_CONSTEXPR
date_duration operator- (date_duration rhs, date_duration const& lhs)
{
rhs -= lhs;
return rhs;
}
inline BOOST_CXX14_CONSTEXPR
date_duration operator+ (date_duration rhs, date_duration const& lhs)
{
rhs += lhs;
return rhs;
}
inline BOOST_CXX14_CONSTEXPR date_duration operator/ (date_duration rhs, int lhs)
{
rhs /= lhs;
return rhs;
}
//! Shorthand for date_duration
typedef date_duration days;
@@ -31,9 +31,9 @@ namespace gregorian {
class BOOST_SYMBOL_VISIBLE weeks_duration : public date_duration {
public:
weeks_duration(duration_rep w)
BOOST_CXX14_CONSTEXPR weeks_duration(duration_rep w)
: date_duration(w * 7) {}
weeks_duration(date_time::special_values sv)
BOOST_CXX14_CONSTEXPR weeks_duration(date_time::special_values sv)
: date_duration(sv) {}
};
@@ -1,7 +1,7 @@
#ifndef GREG_MONTH_HPP___
#define GREG_MONTH_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@@ -11,13 +11,9 @@
#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 {
@@ -39,7 +35,7 @@ namespace gregorian {
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 BOOST_SYMBOL_VISIBLE bad_month : public std::out_of_range
{
@@ -50,31 +46,65 @@ namespace gregorian {
//! 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 {
class BOOST_SYMBOL_VISIBLE 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) :
BOOST_CXX14_CONSTEXPR greg_month(month_enum theMonth) :
greg_month_rep(static_cast<greg_month_rep::value_type>(theMonth)) {}
//! Construct from a short value
greg_month(value_type theMonth) : greg_month_rep(theMonth) {}
BOOST_CXX14_CONSTEXPR greg_month(value_type theMonth) : greg_month_rep(theMonth) {}
//! Convert the value back to a short
operator value_type() const {return value_;}
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
//! Returns month as number from 1 to 12
value_type 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;
BOOST_CXX14_CONSTEXPR value_type as_number() const {return value_;}
BOOST_CXX14_CONSTEXPR month_enum as_enum() const {return static_cast<month_enum>(value_);}
//! Returns 3 char english string for the month ex: Jan, Feb, Mar, Apr
const char*
as_short_string() const
{
static const char* const short_month_names[NumMonths]
= {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec", "NAM"};
return short_month_names[value_-1];
}
//! Returns full name of month as string in english ex: January, February
const char*
as_long_string() const
{
static const char* const long_month_names[NumMonths]
= {"January","February","March","April","May","June","July","August",
"September","October","November","December","NotAMonth"};
return long_month_names[value_-1];
}
#ifndef BOOST_NO_STD_WSTRING
const wchar_t* as_short_wstring() const;
const wchar_t* as_long_wstring() const;
//! Returns 3 wchar_t english string for the month ex: Jan, Feb, Mar, Apr
const wchar_t*
as_short_wstring() const
{
static 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"};
return w_short_month_names[value_-1];
}
//! Returns full name of month as wchar_t string in english ex: January, February
const wchar_t*
as_long_wstring() const
{
static 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"};
return w_long_month_names[value_-1];
}
#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');" */
@@ -100,6 +130,4 @@ namespace gregorian {
} } //namespace gregorian
#endif
@@ -11,27 +11,8 @@
#include "boost/date_time/gregorian/gregorian_types.hpp"
#include "boost/date_time/gregorian/parsers.hpp"
#include "boost/serialization/split_free.hpp"
#include "boost/serialization/nvp.hpp"
#include "boost/core/nvp.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_year)
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 {
@@ -41,15 +22,36 @@ namespace boost {
namespace serialization {
// A macro to split serialize functions into save & load functions.
// It is here to avoid dependency on Boost.Serialization just for the
// BOOST_SERIALIZATION_SPLIT_FREE macro
#define BOOST_DATE_TIME_SPLIT_FREE(T) \
template<class Archive> \
inline void serialize(Archive & ar, \
T & t, \
const unsigned int file_version) \
{ \
split_free(ar, t, file_version); \
}
/*! 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);
}
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::date)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::date_duration)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::date_duration::duration_rep)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::date_period)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::greg_year)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::greg_month)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::greg_day)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::greg_weekday)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::partial_date)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::nth_kday_of_month)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::first_kday_of_month)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::last_kday_of_month)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::first_kday_before)
BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::first_kday_after)
#undef BOOST_DATE_TIME_SPLIT_FREE
//! Function to save gregorian::date objects using serialization lib
/*! Dates are serialized into a string for transport and storage.
@@ -1,7 +1,7 @@
#ifndef GREG_WEEKDAY_HPP___
#define GREG_WEEKDAY_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003,2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@@ -38,21 +38,55 @@ namespace gregorian {
//! Represent a day within a week (range 0==Sun to 6==Sat)
class BOOST_DATE_TIME_DECL greg_weekday : public greg_weekday_rep {
class BOOST_SYMBOL_VISIBLE greg_weekday : public greg_weekday_rep {
public:
typedef boost::date_time::weekdays weekday_enum;
greg_weekday(value_type day_of_week_num) :
BOOST_CXX14_CONSTEXPR greg_weekday(value_type day_of_week_num) :
greg_weekday_rep(day_of_week_num)
{}
value_type as_number() const {return value_;}
const char* as_short_string() const;
const char* as_long_string() const;
BOOST_CXX14_CONSTEXPR value_type as_number() const {return value_;}
BOOST_CXX14_CONSTEXPR weekday_enum as_enum() const {return static_cast<weekday_enum>(value_);}
//! Return a 3 digit english string of the day of week (eg: Sun)
const char* as_short_string() const
{
static const char* const short_weekday_names[]
= {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
return short_weekday_names[value_];
}
//! Return a point to a long english string representing day of week
const char* as_long_string() const
{
static const char* const long_weekday_names[]
= {"Sunday","Monday","Tuesday","Wednesday", "Thursday", "Friday", "Saturday"};
return long_weekday_names[value_];
}
#ifndef BOOST_NO_STD_WSTRING
const wchar_t* as_short_wstring() const;
const wchar_t* as_long_wstring() const;
//! Return a 3 digit english wchar_t string of the day of week (eg: Sun)
const wchar_t* as_short_wstring() const
{
static const wchar_t* const w_short_weekday_names[]={L"Sun", L"Mon", L"Tue",
L"Wed", L"Thu", L"Fri", L"Sat"};
return w_short_weekday_names[value_];
}
//! Return a point to a long english wchar_t string representing day of week
const wchar_t* as_long_wstring() const
{
static const wchar_t* const w_long_weekday_names[]= {L"Sunday",L"Monday",L"Tuesday",
L"Wednesday", L"Thursday",
L"Friday", L"Saturday"};
return w_long_weekday_names[value_];
}
#endif // BOOST_NO_STD_WSTRING
weekday_enum as_enum() const {return static_cast<weekday_enum>(value_);}
};
@@ -1,7 +1,7 @@
#ifndef GREG_YEAR_HPP___
#define GREG_YEAR_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@@ -39,8 +39,8 @@ namespace gregorian {
*/
class BOOST_SYMBOL_VISIBLE greg_year : public greg_year_rep {
public:
greg_year(value_type year) : greg_year_rep(year) {}
operator value_type() const {return value_;}
BOOST_CXX14_CONSTEXPR greg_year(value_type year) : greg_year_rep(year) {}
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
};
+34 -15
View File
@@ -9,48 +9,67 @@
* $Date$
*/
#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 <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 <boost/date_time/special_defs.hpp>
#include <boost/date_time/find_match.hpp>
#include <string>
#include <sstream>
#include <iterator>
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 special_value from string argument. If argument is
* not one of the special value names (defined in names.hpp),
* return 'not_special' */
BOOST_DATE_TIME_DECL special_values special_value_from_string(const std::string& s);
inline
date_time::special_values
special_value_from_string(const std::string& s) {
static const char* const special_value_names[date_time::NumSpecialValues]
= {"not-a-date-time","-infinity","+infinity","min_date_time",
"max_date_time","not_special"};
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 date_time::not_special;
}
else {
return static_cast<date_time::special_values>(i);
}
}
//! Deprecated: Use from_simple_string
inline date from_string(std::string s) {
inline date from_string(const 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) {
inline date from_simple_string(const 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) {
inline date from_us_string(const 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) {
inline date from_uk_string(const 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) {
//! From ISO 8601 type date string where with order year-month-day eg: 20020125
inline date from_undelimited_string(const std::string& s) {
return date_time::parse_undelimited_date<date>(s);
}
//! From iso type date string where with order year-month-day eg: 20020125
//! From ISO 8601 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);
}
+13 -15
View File
@@ -40,19 +40,18 @@ namespace date_time {
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 date_int_type 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(date_int_type);
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();
static BOOST_CXX14_CONSTEXPR unsigned short day_of_week(const ymd_type& ymd);
static BOOST_CXX14_CONSTEXPR int week_number(const ymd_type&ymd);
static BOOST_CXX14_CONSTEXPR date_int_type day_number(const ymd_type& ymd);
static BOOST_CXX14_CONSTEXPR date_int_type julian_day_number(const ymd_type& ymd);
static BOOST_CXX14_CONSTEXPR date_int_type modjulian_day_number(const ymd_type& ymd);
static BOOST_CXX14_CONSTEXPR ymd_type from_day_number(date_int_type);
static BOOST_CXX14_CONSTEXPR ymd_type from_julian_day_number(date_int_type);
static BOOST_CXX14_CONSTEXPR ymd_type from_modjulian_day_number(date_int_type);
static BOOST_CXX14_CONSTEXPR bool is_leap_year(year_type);
static BOOST_CXX14_CONSTEXPR unsigned short end_of_month_day(year_type y, month_type m);
static BOOST_CXX14_CONSTEXPR ymd_type epoch();
static BOOST_CXX14_CONSTEXPR unsigned short days_in_week();
};
@@ -60,9 +59,8 @@ namespace date_time {
} } //namespace
#ifndef NO_BOOST_DATE_TIME_INLINE
#include "boost/date_time/gregorian_calendar.ipp"
#endif
+30 -25
View File
@@ -6,10 +6,6 @@
* $Date$
*/
#ifndef NO_BOOST_DATE_TIME_INLINE
#undef BOOST_DATE_TIME_INLINE
#define BOOST_DATE_TIME_INLINE inline
#endif
namespace boost {
namespace date_time {
@@ -17,7 +13,8 @@ namespace date_time {
/*! Converts a year-month-day into a day of the week number
*/
template<typename ymd_type_, typename date_int_type_>
BOOST_DATE_TIME_INLINE
BOOST_CXX14_CONSTEXPR
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);
@@ -28,14 +25,15 @@ namespace date_time {
return d;
}
//!Return the iso week number for the date
/*!Implements the rules associated with the iso 8601 week number.
//!Return the ISO 8601 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
BOOST_CXX14_CONSTEXPR
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));
@@ -71,14 +69,15 @@ namespace date_time {
/*! 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
BOOST_CXX14_CONSTEXPR
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;
unsigned long d = static_cast<unsigned long>(ymd.day) + ((153*m + 2)/5) + 365*y + (y/4) - (y/100) + (y/400) - 32045;
return static_cast<date_int_type>(d);
}
@@ -86,7 +85,8 @@ namespace date_time {
/*! 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
BOOST_CXX14_CONSTEXPR
inline
date_int_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::julian_day_number(const ymd_type& ymd)
{
@@ -98,7 +98,8 @@ namespace date_time {
* 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
BOOST_CXX14_CONSTEXPR
inline
date_int_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::modjulian_day_number(const ymd_type& ymd)
{
@@ -107,7 +108,8 @@ namespace date_time {
//! Change a day number into a year-month-day
template<typename ymd_type_, typename date_int_type_>
BOOST_DATE_TIME_INLINE
BOOST_CXX14_CONSTEXPR
inline
ymd_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::from_day_number(date_int_type dayNumber)
{
@@ -127,7 +129,8 @@ namespace date_time {
//! Change a day number into a year-month-day
template<typename ymd_type_, typename date_int_type_>
BOOST_DATE_TIME_INLINE
BOOST_CXX14_CONSTEXPR
inline
ymd_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::from_julian_day_number(date_int_type dayNumber)
{
@@ -147,7 +150,8 @@ namespace date_time {
//! Change a modified julian day number into a year-month-day
template<typename ymd_type_, typename date_int_type_>
BOOST_DATE_TIME_INLINE
BOOST_CXX14_CONSTEXPR
inline
ymd_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::from_modjulian_day_number(date_int_type dayNumber) {
date_int_type jd = dayNumber + 2400001; //is 2400000.5 prerounded
@@ -159,7 +163,8 @@ namespace date_time {
*@return true if year is a leap year, false otherwise
*/
template<typename ymd_type_, typename date_int_type_>
BOOST_DATE_TIME_INLINE
BOOST_CXX14_CONSTEXPR
inline
bool
gregorian_calendar_base<ymd_type_,date_int_type_>::is_leap_year(year_type year)
{
@@ -172,7 +177,8 @@ namespace date_time {
* No error checking is performed.
*/
template<typename ymd_type_, typename date_int_type_>
BOOST_DATE_TIME_INLINE
BOOST_CXX14_CONSTEXPR
inline
unsigned short
gregorian_calendar_base<ymd_type_,date_int_type_>::end_of_month_day(year_type year,
month_type month)
@@ -183,7 +189,7 @@ namespace date_time {
return 29;
} else {
return 28;
};
}
case 4:
case 6:
case 9:
@@ -191,13 +197,13 @@ namespace date_time {
return 30;
default:
return 31;
};
}
}
//! Provide the ymd_type specification for the calandar start
//! Provide the ymd_type specification for the calendar start
template<typename ymd_type_, typename date_int_type_>
BOOST_DATE_TIME_INLINE
BOOST_CXX14_CONSTEXPR
inline
ymd_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::epoch()
{
@@ -206,7 +212,8 @@ namespace date_time {
//! Defines length of a week for week calculations
template<typename ymd_type_, typename date_int_type_>
BOOST_DATE_TIME_INLINE
BOOST_CXX14_CONSTEXPR
inline
unsigned short
gregorian_calendar_base<ymd_type_,date_int_type_>::days_in_week()
{
@@ -215,5 +222,3 @@ namespace date_time {
} } //namespace gregorian
+57 -37
View File
@@ -46,34 +46,34 @@ template<typename int_type_>
class int_adapter {
public:
typedef int_type_ int_type;
int_adapter(int_type v) :
BOOST_CXX14_CONSTEXPR int_adapter(int_type v) :
value_(v)
{}
static bool has_infinity()
static BOOST_CONSTEXPR bool has_infinity()
{
return true;
}
static const int_adapter pos_infinity()
static BOOST_CONSTEXPR int_adapter pos_infinity()
{
return (::std::numeric_limits<int_type>::max)();
}
static const int_adapter neg_infinity()
static BOOST_CONSTEXPR int_adapter neg_infinity()
{
return (::std::numeric_limits<int_type>::min)();
}
static const int_adapter not_a_number()
static BOOST_CONSTEXPR int_adapter not_a_number()
{
return (::std::numeric_limits<int_type>::max)()-1;
}
static int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION ()
static BOOST_CONSTEXPR int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION ()
{
return (::std::numeric_limits<int_type>::max)()-2;
}
static int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION ()
static BOOST_CONSTEXPR int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION ()
{
return (::std::numeric_limits<int_type>::min)()+1;
}
static int_adapter from_special(special_values sv)
static BOOST_CXX14_CONSTEXPR int_adapter from_special(special_values sv)
{
switch (sv) {
case not_a_date_time: return not_a_number();
@@ -84,25 +84,25 @@ public:
default: return not_a_number();
}
}
static bool is_inf(int_type v)
static BOOST_CONSTEXPR 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)
static BOOST_CXX14_CONSTEXPR bool is_neg_inf(int_type v)
{
return (v == neg_infinity().as_number());
}
static bool is_pos_inf(int_type v)
static BOOST_CXX14_CONSTEXPR bool is_pos_inf(int_type v)
{
return (v == pos_infinity().as_number());
}
static bool is_not_a_number(int_type v)
static BOOST_CXX14_CONSTEXPR 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)
static BOOST_CXX14_CONSTEXPR 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;
@@ -111,36 +111,36 @@ public:
}
//-3 leaves room for representations of infinity and not a date
static int_type maxcount()
static BOOST_CONSTEXPR int_type maxcount()
{
return (::std::numeric_limits<int_type>::max)()-3;
}
bool is_infinity() const
BOOST_CONSTEXPR bool is_infinity() const
{
return (value_ == neg_infinity().as_number() ||
value_ == pos_infinity().as_number());
}
bool is_pos_infinity()const
BOOST_CONSTEXPR bool is_pos_infinity()const
{
return(value_ == pos_infinity().as_number());
}
bool is_neg_infinity()const
BOOST_CONSTEXPR bool is_neg_infinity()const
{
return(value_ == neg_infinity().as_number());
}
bool is_nan() const
BOOST_CONSTEXPR bool is_nan() const
{
return (value_ == not_a_number().as_number());
}
bool is_special() const
BOOST_CONSTEXPR bool is_special() const
{
return(is_infinity() || is_nan());
}
bool operator==(const int_adapter& rhs) const
BOOST_CONSTEXPR bool operator==(const int_adapter& rhs) const
{
return (compare(rhs) == 0);
}
bool operator==(const int& rhs) const
BOOST_CXX14_CONSTEXPR bool operator==(const int& rhs) const
{
if(!std::numeric_limits<int_type>::is_signed)
{
@@ -151,11 +151,11 @@ public:
}
return (compare(rhs) == 0);
}
bool operator!=(const int_adapter& rhs) const
BOOST_CONSTEXPR bool operator!=(const int_adapter& rhs) const
{
return (compare(rhs) != 0);
}
bool operator!=(const int& rhs) const
BOOST_CXX14_CONSTEXPR bool operator!=(const int& rhs) const
{
if(!std::numeric_limits<int_type>::is_signed)
{
@@ -166,11 +166,11 @@ public:
}
return (compare(rhs) != 0);
}
bool operator<(const int_adapter& rhs) const
BOOST_CONSTEXPR bool operator<(const int_adapter& rhs) const
{
return (compare(rhs) == -1);
}
bool operator<(const int& rhs) const
BOOST_CXX14_CONSTEXPR bool operator<(const int& rhs) const
{
// quiets compiler warnings
if(!std::numeric_limits<int_type>::is_signed)
@@ -182,16 +182,16 @@ public:
}
return (compare(rhs) == -1);
}
bool operator>(const int_adapter& rhs) const
BOOST_CONSTEXPR bool operator>(const int_adapter& rhs) const
{
return (compare(rhs) == 1);
}
int_type as_number() const
BOOST_CONSTEXPR int_type as_number() const
{
return value_;
}
//! Returns either special value type or is_not_special
special_values as_special() const
BOOST_CONSTEXPR special_values as_special() const
{
return int_adapter::to_special(value_);
}
@@ -204,7 +204,7 @@ public:
/*! 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
BOOST_CXX14_CONSTEXPR
int_adapter operator+(const int_adapter<rhs_type>& rhs) const
{
if(is_special() || rhs.is_special())
@@ -234,6 +234,7 @@ public:
return int_adapter<int_type>(value_ + static_cast<int_type>(rhs.as_number()));
}
BOOST_CXX14_CONSTEXPR
int_adapter operator+(const int_type rhs) const
{
if(is_special())
@@ -253,7 +254,7 @@ public:
/*! 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
BOOST_CXX14_CONSTEXPR
int_adapter operator-(const int_adapter<rhs_type>& rhs)const
{
if(is_special() || rhs.is_special())
@@ -282,6 +283,8 @@ public:
}
return int_adapter<int_type>(value_ - static_cast<int_type>(rhs.as_number()));
}
BOOST_CXX14_CONSTEXPR
int_adapter operator-(const int_type rhs) const
{
if(is_special())
@@ -299,6 +302,7 @@ public:
}
// should templatize this to be consistant with op +-
BOOST_CXX14_CONSTEXPR
int_adapter operator*(const int_adapter& rhs)const
{
if(this->is_special() || rhs.is_special())
@@ -307,8 +311,10 @@ public:
}
return int_adapter<int_type>(value_ * rhs.value_);
}
/*! Provided for cases when automatic conversion from
* 'int' to 'int_adapter' causes incorrect results. */
BOOST_CXX14_CONSTEXPR
int_adapter operator*(const int rhs) const
{
if(is_special())
@@ -319,6 +325,7 @@ public:
}
// should templatize this to be consistant with op +-
BOOST_CXX14_CONSTEXPR
int_adapter operator/(const int_adapter& rhs)const
{
if(this->is_special() || rhs.is_special())
@@ -332,23 +339,27 @@ public:
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_); //NOLINT
}
}
return int_adapter<int_type>(value_ / rhs.value_);
}
/*! Provided for cases when automatic conversion from
* 'int' to 'int_adapter' causes incorrect results. */
BOOST_CXX14_CONSTEXPR
int_adapter operator/(const int rhs) const
{
if(is_special() && rhs != 0)
{
return mult_div_specials(rhs);
}
return int_adapter<int_type>(value_ / rhs);
// let divide by zero blow itself up like int
return int_adapter<int_type>(value_ / rhs); //NOLINT
}
// should templatize this to be consistant with op +-
BOOST_CXX14_CONSTEXPR
int_adapter operator%(const int_adapter& rhs)const
{
if(this->is_special() || rhs.is_special())
@@ -362,26 +373,31 @@ public:
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_); //NOLINT
}
}
return int_adapter<int_type>(value_ % rhs.value_);
}
/*! Provided for cases when automatic conversion from
* 'int' to 'int_adapter' causes incorrect results. */
BOOST_CXX14_CONSTEXPR
int_adapter operator%(const int rhs) const
{
if(is_special() && rhs != 0)
{
return mult_div_specials(rhs);
}
return int_adapter<int_type>(value_ % rhs);
// let divide by zero blow itself up
return int_adapter<int_type>(value_ % rhs); //NOLINT
}
private:
int_type value_;
//! returns -1, 0, 1, or 2 if 'this' is <, ==, >, or 'nan comparison' rhs
int compare(const int_adapter& rhs)const
BOOST_CXX14_CONSTEXPR
int compare( const int_adapter& rhs ) const
{
if(this->is_special() || rhs.is_special())
{
@@ -408,12 +424,14 @@ private:
// 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
BOOST_CXX14_CONSTEXPR
int_adapter mult_div_specials(const int_adapter& rhs) const
{
if(this->is_nan() || rhs.is_nan()) {
return int_adapter<int_type>(not_a_number());
@@ -428,12 +446,14 @@ private:
//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
BOOST_CXX14_CONSTEXPR
int_adapter mult_div_specials(const int& rhs) const
{
if(this->is_nan()) {
@@ -449,7 +469,7 @@ private:
//implied -> if(this->value_ == 0 || rhs.value_ == 0)
return int_adapter<int_type>(not_a_number());
}
};
#ifndef BOOST_DATE_TIME_NO_LOCALE
+13 -13
View File
@@ -14,11 +14,11 @@
namespace boost {
namespace date_time {
//! Class to provide common iso formatting spec
//! Class to provide common ISO 8601 formatting spec
template<class charT>
class iso_format_base {
public:
//! Describe month format -- its an integer in iso format
//! Describe month format -- its an integer in ISO 8601 format
static month_format_spec month_format()
{
return month_as_integer;
@@ -40,17 +40,17 @@ public:
return "-infinity";
}
//! ISO char for a year -- used in durations
//! ISO 8601 char for a year -- used in durations
static charT year_sep_char()
{
return 'Y';
}
//! ISO char for a month
//! ISO 8601 char for a month
static charT month_sep_char()
{
return '-';
}
//! ISO char for a day
//! ISO 8601 char for a day
static charT day_sep_char()
{
return '-';
@@ -70,7 +70,7 @@ public:
{
return ':';
}
//! ISO char for a period
//! ISO 8601 char for a period
static charT period_start_char()
{
return 'P';
@@ -143,11 +143,11 @@ public:
#ifndef BOOST_NO_STD_WSTRING
//! Class to provide common iso formatting spec
//! Class to provide common ISO 8601 formatting spec
template<>
class iso_format_base<wchar_t> {
public:
//! Describe month format -- its an integer in iso format
//! Describe month format -- its an integer in ISO 8601 format
static month_format_spec month_format()
{
return month_as_integer;
@@ -169,17 +169,17 @@ public:
return L"-infinity";
}
//! ISO char for a year -- used in durations
//! ISO 8601 char for a year -- used in durations
static wchar_t year_sep_char()
{
return 'Y';
}
//! ISO char for a month
//! ISO 8601 char for a month
static wchar_t month_sep_char()
{
return '-';
}
//! ISO char for a day
//! ISO 8601 char for a day
static wchar_t day_sep_char()
{
return '-';
@@ -199,7 +199,7 @@ public:
{
return ':';
}
//! ISO char for a period
//! ISO 8601 char for a period
static wchar_t period_start_char()
{
return 'P';
@@ -272,7 +272,7 @@ public:
#endif // BOOST_NO_STD_WSTRING
//! Format description for iso normal YYYYMMDD
//! Format description for ISO 8601 normal YYYYMMDD
template<class charT>
class iso_format : public iso_format_base<charT> {
public:
@@ -315,7 +315,7 @@ namespace local_time {
//! 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
* (ie "+07:00" extended ISO 8601 format). Empty string is returned for
* classes that do not use a time_zone */
std::string zone_name(bool as_offset=false) const
{
@@ -349,7 +349,7 @@ namespace local_time {
}
//! 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
* (ie "+0700" ISO 8601 format). Empty string is returned for classes
* that do not use a time_zone */
std::string zone_abbrev(bool as_offset=false) const
{
@@ -8,12 +8,15 @@
* $Date$
*/
#include <string>
#include <locale>
#include <iostream>
#include <iterator> // i/ostreambuf_iterator
#include <boost/io/ios_state.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/time_facet.hpp>
#include <boost/date_time/string_convert.hpp>
#include <boost/date_time/local_time/local_time_types.hpp>
#include <boost/date_time/local_time/local_date_time.hpp>
#include <boost/date_time/local_time/posix_time_zone.hpp>
#include <boost/date_time/local_time/conversion.hpp> // to_tm will be needed in the facets
+3 -3
View File
@@ -1,7 +1,7 @@
#ifndef DATE_TIME_LOCALE_CONFIG_HPP___
#define DATE_TIME_LOCALE_CONFIG_HPP___
/* Copyright (c) 2002-2006 CrystalClear Software, Inc.
/* Copyright (c) 2002-2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@@ -17,12 +17,12 @@
// defines BOOST_NO_STD_LOCALE (gcc 2.95.x)
#include "boost/config.hpp" //sets BOOST_NO_STD_LOCALE
#include "boost/detail/workaround.hpp"
#include "boost/config/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 )) ) \
|| (BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT( 0x581 )) ) \
|| (BOOST_WORKAROUND( BOOST_XLCPP_ZOS, BOOST_TESTED_AT( 0x42010000 )) ) /* <cctype> "shadows" the locale enabled overloads from <locale> */ \
)
#define BOOST_DATE_TIME_NO_LOCALE
+45 -50
View File
@@ -58,26 +58,26 @@ namespace date_time {
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;
BOOST_CXX14_CONSTEXPR period(point_rep first_point, point_rep end_point);
BOOST_CXX14_CONSTEXPR period(point_rep first_point, duration_rep len);
BOOST_CXX14_CONSTEXPR point_rep begin() const;
BOOST_CXX14_CONSTEXPR point_rep end() const;
BOOST_CXX14_CONSTEXPR point_rep last() const;
BOOST_CXX14_CONSTEXPR duration_rep length() const;
BOOST_CXX14_CONSTEXPR bool is_null() const;
BOOST_CXX14_CONSTEXPR bool operator==(const period& rhs) const;
BOOST_CXX14_CONSTEXPR bool operator<(const period& rhs) const;
BOOST_CXX14_CONSTEXPR void shift(const duration_rep& d);
BOOST_CXX14_CONSTEXPR void expand(const duration_rep& d);
BOOST_CXX14_CONSTEXPR bool contains(const point_rep& point) const;
BOOST_CXX14_CONSTEXPR bool contains(const period& other) const;
BOOST_CXX14_CONSTEXPR bool intersects(const period& other) const;
BOOST_CXX14_CONSTEXPR bool is_adjacent(const period& other) const;
BOOST_CXX14_CONSTEXPR bool is_before(const point_rep& point) const;
BOOST_CXX14_CONSTEXPR bool is_after(const point_rep& point) const;
BOOST_CXX14_CONSTEXPR period intersection(const period& other) const;
BOOST_CXX14_CONSTEXPR period merge(const period& other) const;
BOOST_CXX14_CONSTEXPR period span(const period& other) const;
private:
point_rep begin_;
point_rep last_;
@@ -87,7 +87,7 @@ namespace date_time {
/*! If end <= begin then the period will be invalid
*/
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
period<point_rep,duration_rep>::period(point_rep first_point,
point_rep end_point) :
begin_(first_point),
@@ -98,7 +98,7 @@ namespace date_time {
/*! If len is <= 0 then the period will be invalid
*/
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
period<point_rep,duration_rep>::period(point_rep first_point, duration_rep len) :
begin_(first_point),
last_(first_point + len-duration_rep::unit())
@@ -107,7 +107,7 @@ namespace date_time {
//! Return the first element in the period
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
point_rep period<point_rep,duration_rep>::begin() const
{
return begin_;
@@ -115,7 +115,7 @@ namespace date_time {
//! Return one past the last element
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
point_rep period<point_rep,duration_rep>::end() const
{
return last_ + duration_rep::unit();
@@ -123,7 +123,7 @@ namespace date_time {
//! Return the last item in the period
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
point_rep period<point_rep,duration_rep>::last() const
{
return last_;
@@ -131,7 +131,7 @@ namespace date_time {
//! True if period is ill formed (length is zero or less)
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
bool period<point_rep,duration_rep>::is_null() const
{
return end() <= begin_;
@@ -139,7 +139,7 @@ namespace date_time {
//! Return the length of the period
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
duration_rep period<point_rep,duration_rep>::length() const
{
if(last_ < begin_){ // invalid period
@@ -152,7 +152,7 @@ namespace date_time {
//! Equality operator
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
bool period<point_rep,duration_rep>::operator==(const period& rhs) const
{
return ((begin_ == rhs.begin_) &&
@@ -161,7 +161,7 @@ namespace date_time {
//! Strict as defined by rhs.last <= lhs.last
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
bool period<point_rep,duration_rep>::operator<(const period& rhs) const
{
return (last_ < rhs.begin_);
@@ -170,7 +170,7 @@ namespace date_time {
//! Shift the start and end by the specified amount
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
void period<point_rep,duration_rep>::shift(const duration_rep& d)
{
begin_ = begin_ + d;
@@ -197,7 +197,7 @@ namespace date_time {
*@endcode
*/
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
void period<point_rep,duration_rep>::expand(const duration_rep& d)
{
begin_ = begin_ - d;
@@ -206,7 +206,7 @@ namespace date_time {
//! True if the point is inside the period, zero length periods contain no points
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
bool period<point_rep,duration_rep>::contains(const point_rep& point) const
{
return ((point >= begin_) &&
@@ -216,7 +216,7 @@ namespace date_time {
//! True if this period fully contains (or equals) the other period
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
bool period<point_rep,duration_rep>::contains(const period<point_rep,duration_rep>& other) const
{
return ((begin_ <= other.begin_) && (last_ >= other.last_));
@@ -233,9 +233,8 @@ namespace date_time {
*@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
inline BOOST_CXX14_CONSTEXPR
bool period<point_rep,duration_rep>::is_adjacent(const period<point_rep,duration_rep>& other) const
{
return (other.begin() == end() ||
begin_ == other.end());
@@ -252,9 +251,8 @@ namespace date_time {
*@endcode
*/
template<class point_rep, class duration_rep>
inline
bool
period<point_rep,duration_rep>::is_after(const point_rep& t) const
inline BOOST_CXX14_CONSTEXPR
bool period<point_rep,duration_rep>::is_after(const point_rep& t) const
{
if (is_null())
{
@@ -274,9 +272,8 @@ namespace date_time {
*@endcode
*/
template<class point_rep, class duration_rep>
inline
bool
period<point_rep,duration_rep>::is_before(const point_rep& t) const
inline BOOST_CXX14_CONSTEXPR
bool period<point_rep,duration_rep>::is_before(const point_rep& t) const
{
if (is_null())
{
@@ -299,17 +296,15 @@ namespace date_time {
*@endcode
*/
template<class point_rep, class duration_rep>
inline
bool period<point_rep,duration_rep>::intersects(const period<point_rep,duration_rep>& other) const
inline BOOST_CXX14_CONSTEXPR
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_)));
return !is_null() && !other.is_null() && (begin_ < other.end()) && (other.begin_ < end());
}
//! Returns the period of intersection or invalid range no intersection
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
period<point_rep,duration_rep>
period<point_rep,duration_rep>::intersection(const period<point_rep,duration_rep>& other) const
{
@@ -334,7 +329,7 @@ namespace date_time {
/*!
*/
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
period<point_rep,duration_rep>
period<point_rep,duration_rep>::merge(const period<point_rep,duration_rep>& other) const
{
@@ -361,7 +356,7 @@ namespace date_time {
*@endcode
*/
template<class point_rep, class duration_rep>
inline
inline BOOST_CXX14_CONSTEXPR
period<point_rep,duration_rep>
period<point_rep,duration_rep>::span(const period<point_rep,duration_rep>& other) const
{
+34 -31
View File
@@ -3,14 +3,17 @@
#define DATETIME_PERIOD_FORMATTER_HPP___
/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* 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 <iosfwd>
#include <string>
#include <vector>
#include <iterator>
namespace boost { namespace date_time {
@@ -19,14 +22,14 @@ namespace boost { namespace date_time {
/*! 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 ']'
* - 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
*@endcode
* So for a typical date_period this would be
*@code
* [2004-Jan-04/2004-Feb-01]
@@ -34,13 +37,13 @@ namespace boost { namespace date_time {
* 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 {
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];
@@ -49,8 +52,8 @@ namespace boost { namespace date_time {
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,
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) :
@@ -62,7 +65,7 @@ namespace boost { namespace date_time {
{}
//! Puts the characters between period elements into stream -- default is /
OutItrT put_period_separator(OutItrT& oitr) const
OutItrT put_period_separator(OutItrT& oitr) const
{
const_itr_type ci = m_period_separator.begin();
while (ci != m_period_separator.end()) {
@@ -73,7 +76,7 @@ namespace boost { namespace date_time {
}
//! Puts the period start characters into stream -- default is [
OutItrT put_period_start_delimeter(OutItrT& oitr) const
OutItrT put_period_start_delimeter(OutItrT& oitr) const
{
const_itr_type ci = m_period_start_delimeter.begin();
while (ci != m_period_start_delimeter.end()) {
@@ -84,9 +87,9 @@ namespace boost { namespace date_time {
}
//! Puts the period end characters into stream as controled by open/closed range setting.
OutItrT put_period_end_delimeter(OutItrT& oitr) const
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();
@@ -102,14 +105,14 @@ namespace boost { namespace date_time {
}
return oitr;
}
range_display_options range_option() const
{
return m_range_option;
}
//! Reset the range_option control
void
void
range_option(range_display_options option) const
{
m_range_option = option;
@@ -130,13 +133,13 @@ namespace boost { namespace date_time {
//! 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
* 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 the separator
* - put either last or end element depending on range settings
* - put end delimeter depending on range settings
*
@@ -149,9 +152,9 @@ namespace boost { namespace date_time {
*@endcode
*/
template<class period_type, class facet_type>
OutItrT put_period(OutItrT next,
std::ios_base& a_ios,
char_type a_fill,
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);
@@ -167,29 +170,29 @@ namespace boost { namespace date_time {
return next;
}
private:
range_display_options m_range_option;
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
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
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
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
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
+27 -28
View File
@@ -3,14 +3,19 @@
#define DATETIME_PERIOD_PARSER_HPP___
/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* 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 <ios>
#include <string>
#include <vector>
#include <iterator>
#include <boost/throw_exception.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/string_parse_tree.hpp>
#include <boost/date_time/string_convert.hpp>
@@ -18,12 +23,12 @@
namespace boost { namespace date_time {
//! Not a facet, but a class used to specify and control period parsing
//! 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 ']'
* - 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
@@ -64,12 +69,6 @@ namespace boost { namespace date_time {
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;
@@ -99,11 +98,11 @@ namespace boost { namespace date_time {
* 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
* - consume the separator
* - get either last or end element depending on range settings
* - consume the end delimeter depending on range settings
*
@@ -117,15 +116,15 @@ namespace boost { namespace date_time {
*@endcode
*/
template<class period_type, class duration_type, class facet_type>
period_type get_period(stream_itr_type& sitr,
period_type get_period(stream_itr_type& sitr,
stream_itr_type& stream_end,
std::ios_base& a_ios,
std::ios_base& a_ios,
const period_type& /* p */,
const duration_type& dur_unit,
const facet_type& facet) const
const facet_type& facet) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
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);
@@ -150,7 +149,7 @@ namespace boost { namespace date_time {
}
private:
collection_type delimiters;
collection_type delimiters;
period_range_option m_range_option;
enum delim_ids { SEPARATOR, START, OPEN_END, CLOSED_END };
@@ -160,10 +159,10 @@ namespace boost { namespace date_time {
stream_itr_type& stream_end,
const string_type& delim) const
{
/* string_parse_tree will not parse a string of punctuation characters
/* 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
* 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) {
@@ -177,20 +176,20 @@ namespace boost { namespace date_time {
}
};
template <class date_type, class char_type>
const typename period_parser<date_type, char_type>::char_type
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
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
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
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
@@ -26,7 +26,7 @@ namespace posix_time {
inline
ptime from_time_t(std::time_t t)
{
return ptime(gregorian::date(1970,1,1)) + seconds(static_cast<long>(t));
return ptime(gregorian::date(1970,1,1)) + seconds(t);
}
//! Function that converts a ptime into a time_t
@@ -26,7 +26,7 @@ namespace posix_time {
/*! 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
inline BOOST_CXX14_CONSTEXPR
ptime
operator+(const ptime& t, const boost::gregorian::months& m)
{
@@ -36,7 +36,7 @@ namespace posix_time {
/*! 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
inline BOOST_CXX14_CONSTEXPR
ptime
operator+=(ptime& t, const boost::gregorian::months& m)
{
@@ -47,7 +47,7 @@ namespace posix_time {
/*! 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
inline BOOST_CXX14_CONSTEXPR
ptime
operator-(const ptime& t, const boost::gregorian::months& m)
{
@@ -58,7 +58,7 @@ namespace posix_time {
/*! 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
inline BOOST_CXX14_CONSTEXPR
ptime
operator-=(ptime& t, const boost::gregorian::months& m)
{
@@ -70,7 +70,7 @@ namespace posix_time {
/*! 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
inline BOOST_CXX14_CONSTEXPR
ptime
operator+(const ptime& t, const boost::gregorian::years& y)
{
@@ -80,7 +80,7 @@ namespace posix_time {
/*! 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
inline BOOST_CXX14_CONSTEXPR
ptime
operator+=(ptime& t, const boost::gregorian::years& y)
{
@@ -90,7 +90,7 @@ namespace posix_time {
/*! 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
inline BOOST_CXX14_CONSTEXPR
ptime
operator-(const ptime& t, const boost::gregorian::years& y)
{
@@ -101,7 +101,7 @@ namespace posix_time {
/*! 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
inline BOOST_CXX14_CONSTEXPR
ptime
operator-=(ptime& t, const boost::gregorian::years& y)
{
@@ -1,7 +1,7 @@
#ifndef POSIX_TIME_CONFIG_HPP___
#define POSIX_TIME_CONFIG_HPP___
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003,2005,2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@@ -22,32 +22,19 @@
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
@@ -66,23 +53,23 @@ namespace posix_time {
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) :
BOOST_CXX14_CONSTEXPR 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() :
BOOST_CXX14_CONSTEXPR 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) :
BOOST_CXX14_CONSTEXPR 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>;
protected:
explicit time_duration(impl_type tick_count) :
BOOST_CXX14_CONSTEXPR explicit time_duration(impl_type tick_count) :
date_time::time_duration<time_duration, time_res_traits>(tick_count)
{}
};
@@ -94,7 +81,7 @@ namespace posix_time {
{
typedef gregorian::date date_type;
typedef time_duration time_duration_type;
simple_time_rep(date_type d, time_duration_type tod) :
BOOST_CXX14_CONSTEXPR simple_time_rep(date_type d, time_duration_type tod) :
day(d),
time_of_day(tod)
{
@@ -116,19 +103,19 @@ namespace posix_time {
}
date_type day;
time_duration_type time_of_day;
bool is_special()const
BOOST_CXX14_CONSTEXPR bool is_special()const
{
return(is_pos_infinity() || is_neg_infinity() || is_not_a_date_time());
}
bool is_pos_infinity()const
BOOST_CXX14_CONSTEXPR bool is_pos_infinity()const
{
return(day.is_pos_infinity() || time_of_day.is_pos_infinity());
}
bool is_neg_infinity()const
BOOST_CXX14_CONSTEXPR bool is_neg_infinity()const
{
return(day.is_neg_infinity() || time_of_day.is_neg_infinity());
}
bool is_not_a_date_time()const
BOOST_CXX14_CONSTEXPR bool is_not_a_date_time()const
{
return(day.is_not_a_date() || time_of_day.is_not_a_date_time());
}
@@ -1,7 +1,7 @@
#ifndef POSIX_TIME_DURATION_HPP___
#define POSIX_TIME_DURATION_HPP___
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@@ -26,7 +26,7 @@ namespace posix_time {
{
public:
template <typename T>
explicit hours(T const& h,
BOOST_CXX14_CONSTEXPR explicit hours(T const& h,
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
time_duration(numeric_cast<hour_type>(h), 0, 0)
{}
@@ -40,7 +40,7 @@ namespace posix_time {
{
public:
template <typename T>
explicit minutes(T const& m,
BOOST_CXX14_CONSTEXPR explicit minutes(T const& m,
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
time_duration(0, numeric_cast<min_type>(m),0)
{}
@@ -54,7 +54,7 @@ namespace posix_time {
{
public:
template <typename T>
explicit seconds(T const& s,
BOOST_CXX14_CONSTEXPR explicit seconds(T const& s,
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
time_duration(0,0, numeric_cast<sec_type>(s))
{}
@@ -97,7 +97,7 @@ namespace posix_time {
throw; // rethrow original exception
}
else {
// if the user want's to fail quietly, we simply set the failbit
// if the user wants to fail quietly, we simply set the failbit
is.setstate(std::ios_base::failbit);
}
}
+22 -4
View File
@@ -37,26 +37,44 @@ namespace posix_time {
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)
BOOST_CXX14_CONSTEXPR
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))
BOOST_CXX14_CONSTEXPR
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
BOOST_CXX14_CONSTEXPR
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)
BOOST_CXX14_CONSTEXPR
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))
BOOST_CXX14_CONSTEXPR
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
friend BOOST_CXX14_CONSTEXPR
bool operator==(const ptime& lhs, const ptime& rhs);
};
inline BOOST_CXX14_CONSTEXPR
bool operator==(const ptime& lhs, const ptime& rhs)
{
return ptime::time_system_type::is_equal(lhs.time_,rhs.time_);
}
} }//namespace posix_time
@@ -157,7 +157,7 @@ namespace posix_time {
}// else
return ss.str();
}
//! Time duration in iso format -hhmmss,fffffff Example: 10:09:03,0123456
//! Time duration in ISO 8601 format -hhmmss.fffffff. Example: 10:09:03.0123456
/*!\ingroup time_format
*/
inline std::string to_iso_string(time_duration td){
@@ -215,7 +215,7 @@ namespace posix_time {
return ts;
}
}
//! Convert iso short form YYYYMMDDTHHMMSS where T is the date-time separator
//! Convert ISO 8601 short form YYYYMMDDTHHMMSS where T is the date-time separator
/*!\ingroup time_format
*/
inline std::string to_iso_string(ptime t){
@@ -251,7 +251,7 @@ namespace posix_time {
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
//! Time duration in ISO 8601 format -hhmmss.fffffff. Example: 10:09:03.0123456
/*!\ingroup time_format
*/
inline std::wstring to_iso_wstring(time_duration td){
@@ -266,7 +266,7 @@ namespace posix_time {
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
//! Convert ISO 8601 short form YYYYMMDDTHHMMSS where T is the date-time separator
/*!\ingroup time_format
*/
inline std::wstring to_iso_wstring(ptime t){
@@ -82,7 +82,7 @@ namespace posix_time {
return ss.str();
}
//! Time duration in iso format -hhmmss,fffffff Example: 10:09:03,0123456
//! Time duration in ISO 8601 format -hhmmss.fffffff. Example: 10:09:03.0123456
/*!\ingroup time_format
*/
inline
@@ -173,7 +173,7 @@ namespace posix_time {
return std::string("[" + d1 + "/" + d2 +"]");
}
//! Convert iso short form YYYYMMDDTHHMMSS where T is the date-time separator
//! Convert ISO 8601 short form YYYYMMDDTHHMMSS where T is the date-time separator
/*!\ingroup time_format
*/
inline
@@ -36,6 +36,10 @@ namespace posix_time {
}
inline ptime from_iso_extended_string(const std::string& s) {
if (s.size() == 10) { //assume we just have a date which is 10 chars
gregorian::date d = gregorian::from_simple_string(s);
return ptime( d );
}
return date_time::parse_delimited_time<ptime>(s, 'T');
}
@@ -11,17 +11,9 @@
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/gregorian/greg_serialize.hpp"
#include "boost/core/nvp.hpp"
#include "boost/numeric/conversion/cast.hpp"
#include "boost/serialization/split_free.hpp"
#include "boost/serialization/nvp.hpp"
#include "boost/serialization/version.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)
#include "boost/type_traits/integral_constant.hpp"
// Define versions for serialization compatibility
// alows the unit tests to make an older version to check compatibility
@@ -29,11 +21,35 @@ BOOST_SERIALIZATION_SPLIT_FREE(boost::posix_time::time_period)
#define BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION 1
#endif
BOOST_CLASS_VERSION(boost::posix_time::time_duration, BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION)
namespace boost {
namespace serialization {
template<typename T>
struct version;
template<>
struct version<boost::posix_time::time_duration>
: integral_constant<int, BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION>
{
};
// A macro to split serialize functions into save & load functions.
// It is here to avoid dependency on Boost.Serialization just for the
// BOOST_SERIALIZATION_SPLIT_FREE macro
#define BOOST_DATE_TIME_SPLIT_FREE(T) \
template<class Archive> \
inline void serialize(Archive & ar, \
T & t, \
const unsigned int file_version) \
{ \
split_free(ar, t, file_version); \
}
BOOST_DATE_TIME_SPLIT_FREE(boost::posix_time::ptime)
BOOST_DATE_TIME_SPLIT_FREE(boost::posix_time::time_duration)
BOOST_DATE_TIME_SPLIT_FREE(boost::posix_time::time_period)
#undef BOOST_DATE_TIME_SPLIT_FREE
/*** time_duration ***/
@@ -12,6 +12,7 @@
#include <vector>
#include <string>
#include <iterator>
#include "boost/date_time/special_defs.hpp"
namespace boost { namespace date_time {
@@ -75,11 +75,6 @@ namespace boost { namespace date_time {
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,
@@ -102,7 +97,7 @@ namespace boost { namespace date_time {
//! match() should be called and return value checked.
//! \param[in] str the string to check
//! \returns false if it is definitely not a special value
static bool likely(const string_type& str)
static bool should_call_match(const string_type& str)
{
if (!str.empty()) {
switch (str[0]) {
@@ -10,11 +10,13 @@
*/
#include "boost/lexical_cast.hpp" //error without?
#include "boost/algorithm/string/case_conv.hpp"
#include <boost/algorithm/string/case_conv.hpp>
#include <cctype>
#include <map>
#include <string>
#include <vector>
#include <ostream>
#include <iterator>
#include <algorithm>
namespace boost { namespace date_time {
@@ -82,7 +84,7 @@ operator<<(std::basic_ostream<charT>& os, parse_match_result<charT>& mr)
template<typename charT>
struct string_parse_tree
{
#if BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x581) )
#if BOOST_WORKAROUND( BOOST_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;
@@ -9,10 +9,12 @@
* $Date$
*/
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <locale>
#include <iterator>
namespace boost { namespace date_time {
@@ -50,7 +52,7 @@ gather_month_strings(const std::locale& locale, bool short_strings=true)
//output each month
const charT* p_outfmt = outfmt.c_str(), *p_outfmt_end = p_outfmt + outfmt.size();
tm tm_value;
memset(&tm_value, 0, sizeof(tm_value));
std::memset(&tm_value, 0, sizeof(tm_value));
for (int m=0; m < 12; m++) {
tm_value.tm_mon = m;
stringstream_type ss;
@@ -103,7 +105,7 @@ gather_weekday_strings(const std::locale& locale, bool short_strings=true)
//output each month / weekday
const charT* p_outfmt = outfmt.c_str(), *p_outfmt_end = p_outfmt + outfmt.size();
tm tm_value;
memset(&tm_value, 0, sizeof(tm_value));
std::memset(&tm_value, 0, sizeof(tm_value));
for (int i=0; i < 7; i++) {
tm_value.tm_wday = i;
stringstream_type ss;
+24 -3
View File
@@ -1,7 +1,7 @@
#ifndef DATE_TIME_TIME_HPP___
#define DATE_TIME_TIME_HPP___
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003,2005,2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@@ -58,21 +58,26 @@ namespace date_time {
typedef typename time_system::time_duration_type time_duration_type;
//typedef typename time_system::hms_type hms_type;
BOOST_CXX14_CONSTEXPR
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))
{}
BOOST_CXX14_CONSTEXPR
base_time(special_values sv) :
time_(time_system::get_time_rep(sv))
{}
BOOST_CXX14_CONSTEXPR
base_time(const time_rep_type& rhs) :
time_(rhs)
{}
BOOST_CXX14_CONSTEXPR
date_type date() const
{
return time_system::get_date(time_);
}
BOOST_CXX14_CONSTEXPR
time_duration_type time_of_day() const
{
return time_system::get_time_of_day(time_);
@@ -98,83 +103,99 @@ namespace date_time {
}
//! check to see if date is not a value
BOOST_CXX14_CONSTEXPR
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
BOOST_CXX14_CONSTEXPR
bool is_infinity() const
{
return (is_pos_infinity() || is_neg_infinity());
}
//! check to see if date is greater than all possible dates
BOOST_CXX14_CONSTEXPR
bool is_pos_infinity() const
{
return time_.is_pos_infinity();
}
//! check to see if date is greater than all possible dates
BOOST_CXX14_CONSTEXPR
bool is_neg_infinity() const
{
return time_.is_neg_infinity();
}
//! check to see if time is a special value
BOOST_CXX14_CONSTEXPR
bool is_special() const
{
return(is_not_a_date_time() || is_infinity());
}
//!Equality operator -- others generated by boost::equality_comparable
BOOST_CXX14_CONSTEXPR
bool operator==(const time_type& rhs) const
{
return time_system::is_equal(time_,rhs.time_);
}
//!Equality operator -- others generated by boost::less_than_comparable
BOOST_CXX14_CONSTEXPR
bool operator<(const time_type& rhs) const
{
return time_system::is_less(time_,rhs.time_);
}
//! difference between two times
BOOST_CXX14_CONSTEXPR
time_duration_type operator-(const time_type& rhs) const
{
return time_system::subtract_times(time_, rhs.time_);
}
//! add date durations
BOOST_CXX14_CONSTEXPR
time_type operator+(const date_duration_type& dd) const
{
return time_system::add_days(time_, dd);
}
BOOST_CXX14_CONSTEXPR
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
BOOST_CXX14_CONSTEXPR
time_type operator-(const date_duration_type& dd) const
{
return time_system::subtract_days(time_, dd);
}
BOOST_CXX14_CONSTEXPR
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
BOOST_CXX14_CONSTEXPR
time_type operator+(const time_duration_type& td) const
{
return time_type(time_system::add_time_duration(time_, td));
}
BOOST_CXX14_CONSTEXPR
time_type operator+=(const time_duration_type& td)
{
time_ = (time_system::get_time_rep(date(), time_of_day() + td));
time_ = time_system::add_time_duration(time_,td);
return time_type(time_);
}
//! subtract time durations
BOOST_CXX14_CONSTEXPR
time_type operator-(const time_duration_type& rhs) const
{
return time_system::subtract_time_duration(time_, rhs);
}
BOOST_CXX14_CONSTEXPR
time_type operator-=(const time_duration_type& td)
{
time_ = (time_system::get_time_rep(date(), time_of_day() - td));
time_ = time_system::subtract_time_duration(time_, td);
return time_type(time_);
}
+54 -42
View File
@@ -56,58 +56,53 @@ namespace date_time {
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,
BOOST_CXX14_CONSTEXPR time_duration() : ticks_(0) {}
BOOST_CXX14_CONSTEXPR 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))
BOOST_CXX14_CONSTEXPR time_duration(special_values sv) : ticks_(impl_type::from_special(sv))
{}
//! Returns smallest representable duration
static duration_type unit()
static BOOST_CXX14_CONSTEXPR duration_type unit()
{
return duration_type(0,0,0,1);
}
//! Return the number of ticks in a second
static tick_type ticks_per_second()
static BOOST_CXX14_CONSTEXPR tick_type ticks_per_second()
{
return rep_type::res_adjust();
}
//! Provide the resolution of this duration type
static time_resolutions resolution()
static BOOST_CXX14_CONSTEXPR time_resolutions resolution()
{
return rep_type::resolution();
}
//! Returns number of hours in the duration
hour_type hours() const
BOOST_CXX14_CONSTEXPR hour_type hours() const
{
return static_cast<hour_type>(ticks() / (3600*ticks_per_second()));
}
//! Returns normalized number of minutes
min_type minutes() const
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR tick_type total_milliseconds() const
{
if (ticks_per_second() < 1000) {
return ticks() * (static_cast<tick_type>(1000) / ticks_per_second());
@@ -115,7 +110,7 @@ namespace date_time {
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
BOOST_CXX14_CONSTEXPR tick_type total_nanoseconds() const
{
if (ticks_per_second() < 1000000000) {
return ticks() * (static_cast<tick_type>(1000000000) / ticks_per_second());
@@ -123,7 +118,7 @@ namespace date_time {
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
BOOST_CXX14_CONSTEXPR tick_type total_microseconds() const
{
if (ticks_per_second() < 1000000) {
return ticks() * (static_cast<tick_type>(1000000) / ticks_per_second());
@@ -131,81 +126,97 @@ namespace date_time {
return ticks() / (ticks_per_second() / static_cast<tick_type>(1000000)) ;
}
//! Returns count of fractional seconds at given resolution
fractional_seconds_type fractional_seconds() const
BOOST_CXX14_CONSTEXPR 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()
static BOOST_CXX14_CONSTEXPR unsigned short num_fractional_digits()
{
return rep_type::num_fractional_digits();
}
duration_type invert_sign() const
BOOST_CXX14_CONSTEXPR duration_type invert_sign() const
{
return duration_type(ticks_ * (-1));
}
bool is_negative() const
BOOST_CXX14_CONSTEXPR duration_type abs() const
{
if ( is_negative() )
{
return invert_sign();
}
return duration_type(ticks_);
}
BOOST_CONSTEXPR bool is_negative() const
{
return ticks_ < 0;
}
bool operator<(const time_duration& rhs) const
BOOST_CONSTEXPR bool is_zero() const
{
return ticks_ == 0;
}
BOOST_CONSTEXPR bool is_positive() const
{
return ticks_ > 0;
}
BOOST_CONSTEXPR bool operator<(const time_duration& rhs) const
{
return ticks_ < rhs.ticks_;
}
bool operator==(const time_duration& rhs) const
BOOST_CONSTEXPR bool operator==(const time_duration& rhs) const
{
return ticks_ == rhs.ticks_;
}
//! unary- Allows for time_duration td = -td1
duration_type operator-()const
BOOST_CONSTEXPR duration_type operator-()const
{
return duration_type(ticks_ * (-1));
}
duration_type operator-(const duration_type& d) const
BOOST_CONSTEXPR duration_type operator-(const duration_type& d) const
{
return duration_type(ticks_ - d.ticks_);
}
duration_type operator+(const duration_type& d) const
BOOST_CONSTEXPR duration_type operator+(const duration_type& d) const
{
return duration_type(ticks_ + d.ticks_);
}
duration_type operator/(int divisor) const
BOOST_CONSTEXPR duration_type operator/(int divisor) const
{
return duration_type(ticks_ / divisor);
}
duration_type operator-=(const duration_type& d)
BOOST_CXX14_CONSTEXPR duration_type operator-=(const duration_type& d)
{
ticks_ = ticks_ - d.ticks_;
return duration_type(ticks_);
}
duration_type operator+=(const duration_type& d)
BOOST_CXX14_CONSTEXPR 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)
BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR duration_type operator*(int rhs) const
{
return duration_type(ticks_ * rhs);
}
duration_type operator*=(int divisor)
BOOST_CXX14_CONSTEXPR duration_type operator*=(int divisor)
{
ticks_ = ticks_ * divisor;
return duration_type(ticks_);
}
tick_type ticks() const
BOOST_CXX14_CONSTEXPR tick_type ticks() const
{
return traits_type::as_number(ticks_);
}
//! Is ticks_ a special value?
bool is_special()const
BOOST_CXX14_CONSTEXPR bool is_special()const
{
if(traits_type::is_adapted())
{
@@ -216,7 +227,7 @@ namespace date_time {
}
}
//! Is duration pos-infinity
bool is_pos_infinity()const
BOOST_CXX14_CONSTEXPR bool is_pos_infinity()const
{
if(traits_type::is_adapted())
{
@@ -227,7 +238,7 @@ namespace date_time {
}
}
//! Is duration neg-infinity
bool is_neg_infinity()const
BOOST_CXX14_CONSTEXPR bool is_neg_infinity()const
{
if(traits_type::is_adapted())
{
@@ -238,7 +249,7 @@ namespace date_time {
}
}
//! Is duration not-a-date-time
bool is_not_a_date_time()const
BOOST_CXX14_CONSTEXPR bool is_not_a_date_time()const
{
if(traits_type::is_adapted())
{
@@ -250,13 +261,13 @@ namespace date_time {
}
//! Used for special_values output
impl_type get_rep()const
BOOST_CONSTEXPR impl_type get_rep()const
{
return ticks_;
}
protected:
explicit time_duration(impl_type in) : ticks_(in) {}
BOOST_CXX14_CONSTEXPR explicit time_duration(impl_type in) : ticks_(in) {}
impl_type ticks_;
};
@@ -282,8 +293,9 @@ namespace date_time {
public:
// The argument (ss) must be an integral type
template <typename T>
explicit subsecond_duration(T const& ss,
typename boost::enable_if<boost::is_integral<T>, void>::type* = BOOST_DATE_TIME_NULLPTR) :
BOOST_CXX14_CONSTEXPR explicit subsecond_duration(T const& ss,
typename boost::enable_if<boost::is_integral<T>,
void>::type* = BOOST_DATE_TIME_NULLPTR) :
base_duration(impl_type(traits_type::ticks_per_second >= frac_of_second ? ss * adjustment_ratio : ss / adjustment_ratio))
{
}
+10 -13
View File
@@ -11,13 +11,13 @@
*/
#include <cctype>
#include <locale>
#include <limits>
#include <string>
#include <sstream>
#include <exception>
#include <iomanip>
#include <iterator> // i/ostreambuf_iterator
#include <exception>
#include <locale>
#include <limits>
#include <sstream>
#include <string>
#include <boost/assert.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/throw_exception.hpp>
@@ -269,11 +269,11 @@ namespace date_time {
m_time_duration_format = format;
}
virtual void set_iso_format()
void set_iso_format() BOOST_OVERRIDE
{
this->m_format = iso_time_format_specifier;
}
virtual void set_iso_extended_format()
void set_iso_extended_format() BOOST_OVERRIDE
{
this->m_format = iso_time_format_extended_specifier;
}
@@ -409,7 +409,7 @@ namespace date_time {
// replace %F with nnnnnnn or nothing if fs == 0
frac_str =
fractional_seconds_as_string(time_arg.time_of_day(), true);
if (frac_str.size()) {
if (!frac_str.empty()) {
char_type sep = std::use_facet<std::numpunct<char_type> >(ios_arg.getloc()).decimal_point();
string_type replace_string;
replace_string += sep;
@@ -481,7 +481,7 @@ namespace date_time {
boost::algorithm::replace_all(format, unrestricted_hours_format, hours_str);
}
// We still have to process restricted hours format specifier. In order to
// support parseability of durations in ISO format (%H%M%S), we'll have to
// support parseability of durations in ISO 8601 format (%H%M%S), we'll have to
// restrict the stringified hours length to 2 characters.
if (format.find(hours_format) != string_type::npos) {
if (hours_str.empty())
@@ -958,7 +958,7 @@ namespace date_time {
while((sitr != stream_end) && std::isspace(*sitr)) { ++sitr; }
bool use_current_char = false;
bool use_current_format_char = false; // used whith two character flags
bool use_current_format_char = false; // used with two character flags
// num_get will consume the +/-, we may need a copy if special_value
char_type c = '\0';
@@ -1365,9 +1365,6 @@ 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
+8 -8
View File
@@ -30,14 +30,14 @@ namespace date_time {
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;}
const time_type& operator*() const {return current_;}
const time_type* operator->() const {return &current_;}
bool operator< (const time_type& t) const {return current_ < t;}
bool operator<= (const time_type& t) const {return current_ <= t;}
bool operator!= (const time_type& t) const {return current_ != t;}
bool operator== (const time_type& t) const {return current_ == t;}
bool operator> (const time_type& t) const {return current_ > t;}
bool operator>= (const time_type& t) const {return current_ >= t;}
private:
time_type current_;
+5 -10
View File
@@ -21,7 +21,7 @@ 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
//everywhere. Hasn't been tested with negatives and zeros
template<class int_type>
inline
int_type power(int_type base, int_type exponent)
@@ -79,7 +79,7 @@ namespace date_time {
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
@@ -183,7 +183,7 @@ namespace date_time {
}
//! Parse time duration part of an iso time of form: [-]hhmmss[.fff...] (eg: 120259.123 is 12 hours, 2 min, 59 seconds, 123000 microseconds)
//! Parse time duration part of an ISO 8601 time of form: [-]hhmmss[.fff...] (eg: 120259.123 is 12 hours, 2 min, 59 seconds, 123000 microseconds)
template<class time_duration>
inline
time_duration
@@ -284,7 +284,7 @@ namespace date_time {
break;
}
default: break;
};
}
pos++;
}
if(sign) {
@@ -309,7 +309,7 @@ namespace date_time {
// then from_iso_string should be able to read a special value string
// the special_values_parser is expensive to set up and not thread-safe
// so it cannot be static, so we need to be careful about when we use it
if (svp_type::likely(s)) {
if (svp_type::should_call_match(s)) {
typedef typename svp_type::stringstream_type ss_type;
typedef typename svp_type::stream_itr_type itr_type;
typedef typename svp_type::match_results mr_type;
@@ -334,11 +334,6 @@ namespace date_time {
return time_type(d, td);
}
} }//namespace date_time
#endif
@@ -22,7 +22,7 @@ namespace date_time {
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)
inline BOOST_CXX14_CONSTEXPR T absolute_value(T x)
{
return x < 0 ? -x : x;
}
@@ -31,33 +31,33 @@ namespace date_time {
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;}
static BOOST_CXX14_CONSTEXPR 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;}
static BOOST_CXX14_CONSTEXPR 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();}
static BOOST_CXX14_CONSTEXPR 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;}
static BOOST_CXX14_CONSTEXPR 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;}
static BOOST_CXX14_CONSTEXPR 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;}
static BOOST_CXX14_CONSTEXPR 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();}
static BOOST_CXX14_CONSTEXPR 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;}
static BOOST_CXX14_CONSTEXPR bool is_adapted() { return true;}
};
//
@@ -103,11 +103,11 @@ namespace date_time {
typedef var_type sec_type;
// bring in function from frac_sec_type traits structs
static fractional_seconds_type as_number(impl_type i)
static BOOST_CXX14_CONSTEXPR fractional_seconds_type as_number(impl_type i)
{
return frac_sec_type::as_number(i);
}
static bool is_adapted()
static BOOST_CXX14_CONSTEXPR bool is_adapted()
{
return frac_sec_type::is_adapted();
}
@@ -119,23 +119,23 @@ namespace date_time {
BOOST_STATIC_CONSTANT(fractional_seconds_type, ticks_per_second = resolution_adjust);
#endif
static time_resolutions resolution()
static BOOST_CXX14_CONSTEXPR time_resolutions resolution()
{
return res;
}
static unsigned short num_fractional_digits()
static BOOST_CXX14_CONSTEXPR unsigned short num_fractional_digits()
{
return frac_digits;
}
static fractional_seconds_type res_adjust()
static BOOST_CXX14_CONSTEXPR 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)
static BOOST_CXX14_CONSTEXPR 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)
{
+65 -50
View File
@@ -2,7 +2,7 @@
#define DATE_TIME_TIME_SYSTEM_COUNTED_HPP
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* 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
@@ -10,8 +10,9 @@
*/
#include "boost/date_time/time_defs.hpp"
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/time_defs.hpp>
#include <boost/date_time/special_defs.hpp>
#include <string>
@@ -30,24 +31,28 @@ namespace date_time {
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)
BOOST_CXX14_CONSTEXPR
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 {
else {
time_count_ = (d.day_number() * frac_sec_per_day()) + time_of_day.ticks();
}
}
BOOST_CXX14_CONSTEXPR
explicit counted_time_rep(int_type count) :
time_count_(count)
{}
BOOST_CXX14_CONSTEXPR
explicit counted_time_rep(impl_type count) :
time_count_(count)
{}
BOOST_CXX14_CONSTEXPR
date_type date() const
{
if(time_count_.is_special()) {
@@ -61,53 +66,54 @@ namespace date_time {
}
}
//int_type day_count() const
BOOST_CXX14_CONSTEXPR
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.
/* 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
BOOST_CXX14_CONSTEXPR int_type time_count() const
{
return resolution_traits::as_number(time_count_);
}
int_type tod() const
BOOST_CXX14_CONSTEXPR int_type tod() const
{
return resolution_traits::as_number(time_count_) % frac_sec_per_day();
}
static int_type frac_sec_per_day()
static BOOST_CXX14_CONSTEXPR 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
BOOST_CXX14_CONSTEXPR bool is_pos_infinity()const
{
return impl_type::is_pos_inf(time_count_.as_number());
}
bool is_neg_infinity()const
BOOST_CXX14_CONSTEXPR bool is_neg_infinity()const
{
return impl_type::is_neg_inf(time_count_.as_number());
}
bool is_not_a_date_time()const
BOOST_CXX14_CONSTEXPR bool is_not_a_date_time()const
{
return impl_type::is_not_a_number(time_count_.as_number());
}
bool is_special()const
BOOST_CXX14_CONSTEXPR bool is_special()const
{
return time_count_.is_special();
}
impl_type get_rep()const
BOOST_CXX14_CONSTEXPR impl_type get_rep()const
{
return time_count_;
}
@@ -128,27 +134,28 @@ namespace date_time {
typedef typename time_rep_type::date_duration_type date_duration_type;
template<class T> static void unused_var(const T&) {}
template<class T> static BOOST_CXX14_CONSTEXPR 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)
static BOOST_CXX14_CONSTEXPR
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)
static BOOST_CXX14_CONSTEXPR 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),
return time_rep_type(date_type(pos_infin),
time_duration_type(pos_infin));
case neg_infin:
return time_rep_type(date_type(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);
@@ -160,38 +167,42 @@ namespace date_time {
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)
static BOOST_CXX14_CONSTEXPR 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)
static BOOST_CXX14_CONSTEXPR
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());
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)
static BOOST_CXX14_CONSTEXPR 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)
static BOOST_CXX14_CONSTEXPR
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)
static BOOST_CXX14_CONSTEXPR
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()));
@@ -200,8 +211,9 @@ namespace date_time {
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)
static BOOST_CXX14_CONSTEXPR
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()));
@@ -210,8 +222,9 @@ namespace date_time {
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)
static BOOST_CXX14_CONSTEXPR
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()));
@@ -220,8 +233,9 @@ namespace date_time {
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)
static BOOST_CXX14_CONSTEXPR
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()));
@@ -230,8 +244,9 @@ namespace date_time {
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)
static BOOST_CXX14_CONSTEXPR
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(
@@ -239,10 +254,10 @@ namespace date_time {
}
else {
fractional_seconds_type fs = lhs.time_count() - rhs.time_count();
return time_duration_type(0,0,0,fs);
return time_duration_type(0,0,0,fs);
}
}
};
+43 -30
View File
@@ -2,7 +2,7 @@
#define DATE_TIME_TIME_SYSTEM_SPLIT_HPP
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* 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
@@ -11,15 +11,17 @@
#include <string>
#include <boost/config.hpp>
#include "boost/date_time/compiler_config.hpp"
#include "boost/date_time/special_defs.hpp"
#include <boost/cstdint.hpp>
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/time_defs.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/wrapping_int.hpp>
namespace boost {
namespace date_time {
//! An unadjusted time system implementation.
#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT))
#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT))
template<typename config, boost::int32_t ticks_per_second>
#else
template<typename config>
@@ -35,30 +37,32 @@ namespace date_time {
typedef typename config::resolution_traits resolution_traits;
//86400 is number of seconds in a day...
#if (defined(BOOST_DATE_TIME_NO_MEMBER_INIT))
#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) )
# if BOOST_WORKAROUND( BOOST_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)
static
BOOST_CXX14_CONSTEXPR
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),
return time_rep_type(date_type(pos_infin),
time_duration_type(pos_infin));
case neg_infin:
return time_rep_type(date_type(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);
@@ -70,14 +74,16 @@ namespace date_time {
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)
static
BOOST_CXX14_CONSTEXPR
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()) {
@@ -123,11 +129,11 @@ namespace date_time {
}
return time_rep_type(day, tod);
}
static date_type get_date(const time_rep_type& val)
static BOOST_CONSTEXPR 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)
static BOOST_CONSTEXPR time_duration_type get_time_of_day(const time_rep_type& val)
{
return time_duration_type(val.time_of_day);
}
@@ -135,28 +141,33 @@ namespace date_time {
{
return std::string();
}
static bool is_equal(const time_rep_type& lhs, const time_rep_type& rhs)
static BOOST_CONSTEXPR
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)
static BOOST_CXX14_CONSTEXPR
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)
static BOOST_CXX14_CONSTEXPR
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)
static BOOST_CXX14_CONSTEXPR
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)
static BOOST_CXX14_CONSTEXPR
time_rep_type subtract_time_duration(const time_rep_type& base,
const time_duration_type& td)
{
if(base.day.is_special() || td.is_special())
{
@@ -173,8 +184,9 @@ namespace date_time {
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)
static BOOST_CXX14_CONSTEXPR
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);
@@ -184,14 +196,15 @@ namespace date_time {
return subtract_time_duration(base,td1);
}
wrap_int_type day_offset(base.time_of_day.ticks());
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.add(td.ticks())));
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)
static BOOST_CXX14_CONSTEXPR
time_duration_type subtract_times(const time_rep_type& lhs,
const time_rep_type& rhs)
{
date_duration_type dd = lhs.day - rhs.day;
if (BOOST_LIKELY(!dd.is_special())) {
@@ -204,7 +217,7 @@ namespace date_time {
return td+td2;
}
}
};
} } //namespace date_time
-1
View File
@@ -245,7 +245,6 @@ namespace boost {
//! 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;
+16 -15
View File
@@ -9,6 +9,7 @@
* $Date$
*/
#include "boost/config.hpp"
namespace boost {
namespace date_time {
@@ -32,19 +33,19 @@ class wrapping_int {
public:
typedef int_type_ int_type;
//typedef overflow_type_ overflow_type;
static int_type wrap_value() {return wrap_val;}
static BOOST_CONSTEXPR int_type wrap_value() {return wrap_val;}
//!Add, return true if wrapped
wrapping_int(int_type v) : value_(v) {}
BOOST_CXX14_CONSTEXPR wrapping_int(int_type v) : value_(v) {}
//! Explicit converion method
int_type as_int() const {return value_;}
operator int_type() const {return value_;}
BOOST_CONSTEXPR int_type as_int() const {return value_;}
BOOST_CONSTEXPR 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 */
template< typename IntT >
IntT add(IntT v)
BOOST_CXX14_CONSTEXPR IntT add(IntT v)
{
int_type remainder = static_cast<int_type>(v % (wrap_val));
IntT overflow = static_cast<IntT>(v / (wrap_val));
@@ -58,7 +59,7 @@ public:
* occur, this would be indicated by a negative return value. If
* wrapping under took place, a positive value would be returned. */
template< typename IntT >
IntT subtract(IntT v)
BOOST_CXX14_CONSTEXPR IntT subtract(IntT v)
{
int_type remainder = static_cast<int_type>(v % (wrap_val));
IntT underflow = static_cast<IntT>(-(v / (wrap_val)));
@@ -69,7 +70,7 @@ private:
int_type value_;
template< typename IntT >
IntT calculate_wrap(IntT wrap)
BOOST_CXX14_CONSTEXPR IntT calculate_wrap(IntT wrap)
{
if ((value_) >= wrap_val)
{
@@ -95,11 +96,11 @@ 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;}
static BOOST_CONSTEXPR int_type wrap_value() {return wrap_max;}
static BOOST_CONSTEXPR 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) {
BOOST_CXX14_CONSTEXPR wrapping_int2(int_type v) : value_(v) {
if(value_ < wrap_min)
{
value_ = wrap_min;
@@ -110,15 +111,15 @@ public:
}
}
//! Explicit converion method
int_type as_int() const {return value_;}
operator int_type() const {return value_;}
BOOST_CONSTEXPR int_type as_int() const {return value_;}
BOOST_CONSTEXPR 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 */
template< typename IntT >
IntT add(IntT v)
BOOST_CXX14_CONSTEXPR IntT add(IntT v)
{
int_type remainder = static_cast<int_type>(v % (wrap_max - wrap_min + 1));
IntT overflow = static_cast<IntT>(v / (wrap_max - wrap_min + 1));
@@ -131,7 +132,7 @@ public:
* occur, this would be indicated by a positive return value. If
* wrapping under took place, a negative value would be returned */
template< typename IntT >
IntT subtract(IntT v)
BOOST_CXX14_CONSTEXPR IntT subtract(IntT v)
{
int_type remainder = static_cast<int_type>(v % (wrap_max - wrap_min + 1));
IntT underflow = static_cast<IntT>(-(v / (wrap_max - wrap_min + 1)));
@@ -143,7 +144,7 @@ private:
int_type value_;
template< typename IntT >
IntT calculate_wrap(IntT wrap)
BOOST_CXX14_CONSTEXPR IntT calculate_wrap(IntT wrap)
{
if ((value_) > wrap_max)
{
+7 -5
View File
@@ -17,9 +17,11 @@ namespace date_time {
//! Allow rapid creation of ymd triples of different types
template<typename YearType, typename MonthType, typename DayType>
struct BOOST_SYMBOL_VISIBLE year_month_day_base {
year_month_day_base(YearType year,
BOOST_CXX14_CONSTEXPR
year_month_day_base(YearType year,
MonthType month,
DayType day);
YearType year;
MonthType month;
DayType day;
@@ -27,11 +29,11 @@ namespace date_time {
typedef MonthType month_type;
typedef DayType day_type;
};
//! A basic constructor
template<typename YearType, typename MonthType, typename DayType>
inline
inline BOOST_CXX14_CONSTEXPR
year_month_day_base<YearType,MonthType,DayType>::year_month_day_base(YearType y,
MonthType m,
DayType d) :
@@ -39,7 +41,7 @@ namespace date_time {
month(m),
day(d)
{}
} }//namespace date_time
+2 -1
View File
@@ -12,5 +12,6 @@
"maintainers": [
"Jeff Garland <jeff -at- crystalclearsoftware.com>",
"James E. King III <jking -at- apache.org>"
]
],
"cxxstd": "11"
}
+8 -150
View File
@@ -1,4 +1,4 @@
/* Copyright (c) 2002-2005 CrystalClear Software, Inc.
/* Copyright (c) 2002-2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@@ -7,164 +7,22 @@
*/
// define BOOST_DATE_TIME_SOURCE so that <boost/date_time/config.hpp> knows
// the library is being built (possibly exporting rather than importing code)
#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"
#include <boost/date_time/compiler_config.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;
}
BOOST_DATE_TIME_DECL void date_time_dummy_exported_function()
{}
//! 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
} } //namespace boost::gregorian
+142 -226
View File
@@ -1,251 +1,167 @@
import os ;
import path ;
import regex ;
import testing ;
project : requirements <library>/boost/date_time//boost_date_time ;
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
# FIXME
#std::locale-support
# FIXME
#std::locale-support
<define>BOOST_ALL_NO_LIB ;
# core stuff
run testint_adapter.cpp ;
run testtime_resolution_traits.cpp ;
run testwrapping_int.cpp ;
run testconstrained_value.cpp ;
run testgregorian_calendar.cpp ;
run testgeneric_period.cpp ;
# the library dependence below is just to test that the
# stub library will build, it's completely uneeded not that
# date-time is all inline
run testmisc.cpp
../build//boost_date_time/<link>static
: : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
: testmisc_std_cfg ;
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 ]
;
### gregorian
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 ]
;
run gregorian/testdate.cpp ;
run gregorian/testdate_duration.cpp ;
run gregorian/testdate_facet_new.cpp ;
run gregorian/testdate_input_facet.cpp ;
run gregorian/testdate_iterator.cpp ;
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) ]
[ compile-fail posix_time/compile_fail/hours_special_value.cpp ]
[ compile-fail posix_time/compile_fail/minutes_special_value.cpp ]
[ compile-fail posix_time/compile_fail/seconds_special_value.cpp ]
[ compile-fail posix_time/compile_fail/millisec_special_value.cpp ]
[ run 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) ]
###
run gregorian/testgenerators.cpp ;
run gregorian/testgreg_cal.cpp ;
run gregorian/testgreg_day.cpp ;
run gregorian/testgreg_durations.cpp ;
run gregorian/testgreg_month.cpp ;
run gregorian/testgreg_year.cpp ;
run gregorian/testformatters.cpp ;
run gregorian/testparse_date.cpp ;
run gregorian/testperiod.cpp ;
;
run gregorian/testgreg_serialize.cpp
/boost/serialization//boost_serialization
: : : <define>DATE_TIME_XML_SERIALIZE
: testgreg_serialize_xml ;
run gregorian/testgreg_serialize.cpp
/boost/serialization//boost_serialization
: : :
: testgreg_serialize ;
run posix_time/testfiletime_functions.cpp ;
run posix_time/testlocal_adjustor.cpp ;
run posix_time/testc_local_adjustor.cpp ;
run posix_time/testclock.cpp ;
run posix_time/testdst_rules.cpp ;
run posix_time/testduration.cpp ;
run posix_time/testiterator.cpp ;
run posix_time/testparse_time.cpp ;
run posix_time/testtime_period.cpp ;
run posix_time/testtime.cpp ;
run posix_time/testmicrosec_time_clock.cpp ;
run posix_time/testgreg_duration_operators.cpp ;
run posix_time/testtime_facet.cpp ;
run posix_time/testtime_input_facet.cpp
: : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
: testtime_input_facet ;
run posix_time/testtime_formatters.cpp
: : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
: testtime_formatters ;
# text archive tests
run posix_time/testtime_serialize.cpp
/boost/serialization//boost_serialization
: : :
: testtime_serialize ;
run posix_time/testtime_serialize.cpp
/boost/serialization//boost_serialization
: : : <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
: testtime_serialize_std_config ;
# xml archive tests
run posix_time/testtime_serialize.cpp
/boost/serialization//boost_serialization
: : : <define>DATE_TIME_XML_SERIALIZE <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
: testtime_serialize_xml_std_config ;
run posix_time/testtime_serialize.cpp
/boost/serialization//boost_serialization
: : : <define>DATE_TIME_XML_SERIALIZE
: testtime_serialize_xml ;
# versioning tests
run posix_time/testtime_serialize_versioning.cpp
/boost/serialization//boost_serialization
: : testtime_serialize_versioning_prev
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
: testtime_serialize_versioning_curr ;
run posix_time/testtime_serialize_versioning.cpp
/boost/serialization//boost_serialization
: : : <define>BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION=0
: testtime_serialize_versioning_prev ;
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 ]
;
compile-fail posix_time/compile_fail/hours_special_value.cpp ;
compile-fail posix_time/compile_fail/minutes_special_value.cpp ;
compile-fail posix_time/compile_fail/seconds_special_value.cpp ;
compile-fail posix_time/compile_fail/millisec_special_value.cpp ;
local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
# FIXME
#std::locale-support
<define>BOOST_ALL_NO_LIB ;
run local_time/testdst_transition_day_rule.cpp ;
run local_time/testcustom_time_zone.cpp ;
run local_time/testposix_time_zone.cpp ;
run local_time/testwcustom_time_zone.cpp ;
run local_time/testwposix_time_zone.cpp ;
run local_time/testlocal_time.cpp ;
run local_time/testlocal_time_iterator.cpp ;
run local_time/testlocal_time_period.cpp ;
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
: : ../data/date_time_zonespec.csv local_time/poorly_formed_zonespec.csv : $(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
: : ../data/date_time_zonespec.csv : $(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) ]
;
run local_time/testtz_database.cpp
: : ../data/date_time_zonespec.csv local_time/poorly_formed_zonespec.csv
: ;
run local_time/testlocal_time_facet.cpp
: : ../data/date_time_zonespec.csv : ;
run local_time/testclocks.cpp ;
if ! [ os.environ UBSAN_OPTIONS ]
#todo
#if ! [ os.environ UBSAN_OPTIONS ]
#{
# local DATE_TIME_PROPERTIES = <define>BOOST_ALL_NO_LIB <define>USE_DATE_TIME_PRE_1_33_FACET_IO
# # FIXME
# # std::locale-support toolset::require-boost-spirit-support
# ;
# Iterate over all public headers and generate a self-contained header test to check for any missing includes
# and basic syntax errors.
if ! [ os.environ BOOST_DATE_TIME_TEST_WITHOUT_SELF_CONTAINED_HEADER_TESTS ]
{
local DATE_TIME_PROPERTIES = <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 ]
[ run posix_time/testtime_serialize_versioning.cpp
../build//boost_date_time/<link>static
../../serialization/build//boost_serialization
: : : $(DATE_TIME_PROPERTIES) <define>BOOST_DATE_TIME_POSIX_TIME_DURATION_VERSION=0
: testtime_serialize_versioning_prev ]
[ run posix_time/testtime_serialize_versioning.cpp
../build//boost_date_time/<link>static
../../serialization/build//boost_serialization
: : testtime_serialize_versioning_prev
: $(DATE_TIME_PROPERTIES)
: testtime_serialize_versioning_curr ]
# 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 ]
;
for file in [ glob-tree-ex ../include/boost : *.hpp ]
{
local rel_file = [ path.relative-to ../include/boost $(file) ] ;
# Note: The test name starts with '~' in order to group these tests in the test report table, preferably at the end.
# All '/' are replaced with '-' because apparently test scripts have a problem with test names containing slashes.
local test_name = [ regex.replace ~hdr/$(rel_file) "/" "-" ] ;
#ECHO $(rel_file) ;
compile self_contained_header.cpp : <define>"BOOST_DATE_TIME_TEST_HEADER=$(rel_file)" <dependency>$(file) : $(test_name) ;
}
}
# Copyright (c) 2000-2005
# Copyright (c) 2000-2020
# CrystalClear Software, Inc.
# Subject to the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or
# Subject to the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or
# http://www.boost.org/LICENSE_1_0.txt)
+22
View File
@@ -0,0 +1,22 @@
# Copyright 2021-2024 Alexander Grund
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_subdir_test LANGUAGES CXX)
# Those 2 should work the same
# while using find_package for the installed Boost avoids the need to manually specify dependencies
if(BOOST_CI_INSTALL_TEST)
find_package(boost_date_time REQUIRED)
else()
set(BOOST_INCLUDE_LIBRARIES date_time)
add_subdirectory(../../../.. deps/boost EXCLUDE_FROM_ALL)
endif()
add_executable(main main.cpp)
target_link_libraries(main Boost::date_time)
enable_testing()
add_test(NAME main COMMAND main)
+86
View File
@@ -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)
*/
+19
View File
@@ -34,6 +34,25 @@ main()
date def;
check("Default constructor", def == date(not_a_date_time));
#endif
#ifdef BOOST_NO_CXX14_CONSTEXPR
check("constexpr not configured", true);
#else
//check constexpr case
{
constexpr date d1(1900,1,1);
static_assert(d1.day() == 1, "constexpr construction day()");
static_assert(d1.month() == 1, "constexpr construction month()");
static_assert(d1.year() == 1900, "constexpr construction year()");
constexpr date d2 = date(2000,12,31);
constexpr date d3(d2);
static_assert(d3.day() == 31, "constexpr construct and copy day()");
static_assert(d3.month() == 12, "constexpr construct and copy month()");
static_assert(d3.year() == 2000, "constexpr construct and copy year()");
check("constexpr tests compiled", true);
}
#endif
date d1(1900,1,1);
date d2 = date(2000,1,1);
+2 -2
View File
@@ -77,8 +77,8 @@ int main(){
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);
date_input_facet f;
f.get(sitr, str_end, ss, m);
check("No extra characters consumed", m == greg_month(Mar) && *sitr == '.');
}
+4 -5
View File
@@ -36,7 +36,7 @@ main()
//Find last Sunday in Feb
lastkday lsif(Sunday, Feb);
std::cout << to_simple_string(lsif.get_date(2002)) << std::endl; //24th
std::cout << lsif.get_date(2002) << std::endl; //24th
check("Last kday", date(2002,Feb,24) == lsif.get_date(2002));
check("Last kday to_string()", lsif.to_string() == std::string("M2.5.0"));
lastkday ltif(Thursday, Feb);
@@ -49,7 +49,7 @@ main()
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
std::cout << fsif.get_date(2002) << std::endl; //24th
check("First kday", date(2002,Feb,3) == fsif.get_date(2002));
check("First kday to_string()", fsif.to_string() == std::string("M2.1.0"));
firstkday ftif(Thursday, Feb);
@@ -61,8 +61,7 @@ main()
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
std::cout << fkaf.get_date(date(2002,Feb,1)) << std::endl; //feb 4
check("kday after",date(2002,Feb,4) == fkaf.get_date(date(2002,Feb,1)));
firstkdayafter fkaf2(Thursday);
check("kday after",date(2002,Feb,7) == fkaf2.get_date(date(2002,Feb,1)));
@@ -70,7 +69,7 @@ main()
typedef first_day_of_the_week_before firstkdaybefore;
firstkdaybefore fkbf(Monday);
std::cout << to_simple_string(fkaf.get_date(date(2002,Feb,10)))
std::cout << fkaf.get_date(date(2002,Feb,10))
<< std::endl; //feb 4
check("kday before",date(2002,Feb,4) == fkbf.get_date(date(2002,Feb,10)));
firstkdaybefore fkbf2(Thursday);
+2 -2
View File
@@ -61,7 +61,7 @@ int main(){
d4 - months(-14) == date(2007,Jan,1));
}
{
months m1x(5), m2x(3), m3x(10);
months m1x(5), m3x(10);
check("months & int multipliable", months(15) == m1x * 3);
m1x *= 3;
check("months & int multipliable", months(15) == m1x);
@@ -116,7 +116,7 @@ int main(){
y3 -= y2;
check("years & years subtractable", years(-1) == y3);
{
years y1x(5), y2x(3), y3x(10);
years y1x(5), y3x(10);
check("years & int multipliable", years(15) == y1x * 3);
y1x *= 3;
check("years & int multipliable", years(15) == y1x);
+1 -1
View File
@@ -61,7 +61,7 @@ int main()
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;
std::cout << i1.intersection(i2) << std::endl;
check("intersect case1", i1.intersection(i2) == r1);
check("intersect case1", i2.intersection(i1) == r1);
//case 2 [5 -10) intersect [1-15) -> [5-10)
+2 -2
View File
@@ -23,14 +23,14 @@ main()
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;
std::cout << tl << std::endl;
local_date_time ldt1 = local_sec_clock::local_time(az_tz);
std::cout << ldt1.to_string() << std::endl;
local_date_time ldt2 = local_sec_clock::local_time(ny_tz);
std::cout << ldt2.to_string() << std::endl;
tl = microsec_clock::local_time();
std::cout << to_simple_string(tl) << std::endl;
std::cout << tl << std::endl;
local_date_time ldt3 = local_microsec_clock::local_time(az_tz);
std::cout << ldt3.to_string() << std::endl;
local_date_time ldt4 = local_microsec_clock::local_time(ny_tz);
+2 -2
View File
@@ -288,8 +288,8 @@ main()
local_date_time ldt(not_a_date_time);
tm ldt_tm = to_tm(ldt);
check("Exception not thrown (special_value to_tm)", false);
//does nothing useful but stops compiler from complaining about unused ldt_tm
std::cout << ldt_tm.tm_sec << std::endl;
//does nothing useful but stops compiler from complaining about unused ldt_tm
std::cout << ldt_tm.tm_sec << std::endl;
}catch(std::out_of_range&){
check("Caught expected exception (special_value to_tm)", true);
}catch(...){
+9 -9
View File
@@ -33,11 +33,11 @@ main()
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::cout << t2 << " LOCAL is "
<< t1 << " UTC time "
<< std::endl;
td1 = t2 - t1;
std::cout << "A difference of: " << to_simple_string(td1)
std::cout << "A difference of: " << td1
<< std::endl;
}
catch (std::runtime_error & re)
@@ -51,11 +51,11 @@ main()
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::cout << t4 << " LOCAL is "
<< t3 << " UTC time "
<< std::endl;
td2 = t4 - t3;
std::cout << "A difference of: " << to_simple_string(td2)
std::cout << "A difference of: " << td2
<< std::endl;
}
catch (std::runtime_error & re)
@@ -69,11 +69,11 @@ main()
ptime t5(date(2040,May,1), hours(5)+millisec(5));
std::cout << "UTC <--> TZ Setting of Machine -- In DST" << std::endl;
ptime t6 = local_adj::utc_to_local(t5);
std::cout << to_simple_string(t6) << " LOCAL is "
<< to_simple_string(t5) << " UTC time "
std::cout << t6 << " LOCAL is "
<< t5 << " UTC time "
<< std::endl;
td3 = t6 - t5;
std::cout << "a difference of: " << to_simple_string(td3)
std::cout << "a difference of: " << td3
<< std::endl;
}
catch (std::runtime_error & re)
+4 -4
View File
@@ -15,15 +15,15 @@ main()
using namespace boost::posix_time;
ptime tl = second_clock::local_time();
std::cout << to_simple_string(tl) << std::endl;
std::cout << tl << std::endl;
ptime tu = second_clock::universal_time();
std::cout << to_simple_string(tu) << std::endl;
std::cout << tu << std::endl;
#if !defined(BOOST_WINDOWS) && defined(_POSIX_TIMERS)
for (int i=0; i < 3; ++i) {
ptime t2 = second_clock::local_time();
std::cout << to_simple_string(t2) << std::endl;
std::cout << t2 << std::endl;
sleep(1);
}
#endif
@@ -32,7 +32,7 @@ main()
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;
std::cout << t2 << std::endl;
}
#endif // BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK
+11 -1
View File
@@ -35,8 +35,18 @@ main()
time_duration td3(td1.hours(),td1.minutes(),td1.seconds());
check("total up elements", td1 == td3);
td1 = -td1; // td1 == "-1:25:00"
check("invert_sign",td3 == td1.invert_sign());
check("invert_sign",td1 == td3.invert_sign());
check("abs",td3 == td1.abs());
check("abs",td3 == td3.abs());
check("is_positive",td3.is_positive());
check("is_positive",!td1.is_positive());
check("is_negative",td1.is_negative());
check("is_negative",!td3.is_negative());
check("is_zero",!td1.is_zero());
check("is_zero",(td1 - td1).is_zero());
td3 = time_duration(td1.hours(),td1.minutes(),td1.seconds());
check("total up elements-invered sign", td1 == td3);
check("total up elements-inverted sign", td1 == td3);
time_duration t_1(0,1,40);
+6 -6
View File
@@ -27,7 +27,7 @@ void iterate_backward(const boost::posix_time::ptime *answers, int ary_len,
std::cout << "counting down by previous duration..." << std::endl;
for (; titr >= answers[0]; --titr) {
std::cout << to_simple_string(*titr) << std::endl;
std::cout << *titr << std::endl;
check("iterating backward", answers[i] == *titr);
--i;
}
@@ -48,7 +48,7 @@ main()
int i=0;
time_iterator titr(start,seconds(1));
for (; titr < ptime(d,seconds(4)); ++titr) {
std::cout << to_simple_string(*titr) << std::endl;
std::cout << *titr << std::endl;
check("iterator -- 1 sec", answer1[i] == *titr);
i++;
}
@@ -62,7 +62,7 @@ main()
i=0;
time_iterator titr2(start,hours(1));
for (; titr2 < ptime(d,hours(4)); ++titr2) {
std::cout << to_simple_string(*titr2) << std::endl;
std::cout << *titr2 << std::endl;
check("iterator -- 1 hour", answer2[i] == *titr2);
i++;
}
@@ -78,7 +78,7 @@ main()
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;
std::cout << *titr3 << std::endl;
check("iterator -- 15 min", answer3[i] == *titr3);
i++;
}
@@ -93,7 +93,7 @@ main()
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;
std::cout << *titr4 << std::endl;
check("iterator -- tenth sec", answer4[i] == *titr4);
i++;
}
@@ -109,7 +109,7 @@ main()
i=0;
time_iterator titr5(start,crzyd);
for (; titr5 < ptime(d,crzyd * 4); ++titr5) {
std::cout << to_simple_string(*titr5) << std::endl;
std::cout << *titr5 << std::endl;
check("iterator -- crazy duration", answer5[i] == *titr5);
i++;
}
+3 -6
View File
@@ -32,8 +32,7 @@ main()
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;
std::cout << t10_local << std::endl;
check("check local calculation", t10_local == t10_check);
check("check utc is dst",
us_eastern::utc_to_local_offset(t10) == hours(-5));
@@ -43,12 +42,10 @@ main()
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;
std::cout << us_eastern::local_to_utc_offset(t11) << std::endl;
ptime t11_check(d4, hours(7));//now utc offset is only 4 hours
ptime t11_local = t11 + us_eastern::local_to_utc_offset(t11);
std::cout << to_simple_string(t11_local) << " "
<< to_simple_string(t11_check)
<< std::endl;
std::cout << t11_local << " " << t11_check << std::endl;
check("check local calculation", t11_local == t11_check);
//should get same offset with DST flag set
check("check local offset-dst flag on",
+117 -68
View File
@@ -1,5 +1,5 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* 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)
@@ -12,95 +12,145 @@
#include <windows.h>
#endif
void
sync_to_next_second()
{
using namespace boost::posix_time;
ptime t_prev;
ptime t_now = second_clock::local_time();
// Wait the next seconds
do
{
t_prev = t_now;
t_now = second_clock::local_time();
} while (t_now.time_of_day().seconds() == t_prev.time_of_day().seconds());
// Wait 300ms in order to avoid seconds of second_clock > microsec_clock.
t_now = microsec_clock::local_time();
t_prev = t_now;
do
{
t_now = microsec_clock::local_time();
} while (t_now - t_prev < milliseconds(300));
}
int
main()
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();
std::cout << "Check local time of microsec_clock against second_clock" << std::endl;
int max = 30;
int i = 0;
for (i = 0; i<max; i++)
ptime last = microsec_clock::local_time();
int max = 5;
for (int 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
}
// 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. Moreover, we must wait the next
// second to avoid a change in hour, minute or second field
// between acquisition of t1 and t2.
sync_to_next_second();
ptime t1 = second_clock::local_time();
std::cout << to_simple_string(t1) << std::endl;
std::cout << 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 << t2 << std::endl;
// sometimes on very slow systems (github actions) a long time
// can pass between syncing to the next second + 300ms (see previous
// function) and asking for t2; therefore if the fractional seconds
// of t2 are less than 300ms we skip that test loop assuming it
// took too long
time_duration t2_tod = t2.time_of_day();
if (t2_tod.fractional_seconds() < (t2_tod.ticks_per_second() * 3) / 10) {
std::cout << "SKIP :: we had a significant host processing delay" << std::endl;
continue;
}
check("check equality of hours "
"between second_clock and microsec_clock timestamps",
t1.time_of_day().hours() == t2.time_of_day().hours());
check("check equality of minutes "
"between second_clock and microsec_clock timestamps",
t1.time_of_day().minutes() == t2.time_of_day().minutes());
check("check equality of seconds "
"between second_clock and microsec_clock timestamps",
t1.time_of_day().seconds() == t2.time_of_day().seconds());
check("check equality of date"
"between second_clock and microsec_clock timestamps",
t1.date() == t2.date());
if( !check("check that previous microsec_clock timestamp "
"is less than the current", last < t2) ) {
std::cout << last << " < " << t2 << std::endl;
}
last = t2;
}
std::cout << "Now do the same test for universal time -- a few less iterations" << std::endl;
max = 10;
std::cout << "Check universal time of microsec_clock against second_clock" << std::endl;
max = 5;
last = microsec_clock::universal_time();
for (i = 0; i<max; i++)
for (int 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
}
// 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. Moreover, we must wait the next
// second to avoid a change in hour, minute or second field
// between acquisition of t1 and t2.
sync_to_next_second();
ptime t1 = second_clock::universal_time();
std::cout << to_simple_string(t1) << std::endl;
std::cout << 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;
std::cout << t2 << std::endl;
// sometimes on very slow systems (github actions) a long time
// can pass between syncing to the next second + 300ms (see previous
// function) and asking for t2; therefore if the fractional seconds
// of t2 are less than 300ms we skip that test loop assuming it
// took too long
time_duration t2_tod = t2.time_of_day();
if (t2_tod.fractional_seconds() < (t2_tod.ticks_per_second() * 3) / 10) {
std::cout << "SKIP :: we had a significant host processing delay" << std::endl;
continue;
}
check("check equality of hours "
"between second_clock and microsec_clock timestamps",
t1.time_of_day().hours() == t2.time_of_day().hours());
check("check equality of minutes "
"between second_clock and microsec_clock timestamps",
t1.time_of_day().minutes() == t2.time_of_day().minutes());
check("check equality of seconds "
"between second_clock and microsec_clock timestamps",
t1.time_of_day().seconds() == t2.time_of_day().seconds());
check("check equality of date"
"between second_clock and microsec_clock timestamps",
t1.date() == t2.date());
if( !check("check that previous microsec_clock timestamp "
"is less than the current", last < t2) ) {
std::cout << last << " < " << t2 << std::endl;
}
last = t2;
}
#else
@@ -109,4 +159,3 @@ main()
return printTestStats();
}
+57 -20
View File
@@ -16,7 +16,7 @@ main()
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,
@@ -56,18 +56,9 @@ main()
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,
@@ -94,15 +85,8 @@ main()
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");
@@ -118,6 +102,28 @@ main()
}
#endif
if (time_duration::resolution() != boost::date_time::nano)
{
std::string s1("12:11:10.123456");
time_duration td1= duration_from_string(s1);
check("parse time duration: " + s1,
td1 == time_duration(12,11,10,123456));
std::cout << "td1: " << td1 << std::endl;
std::string s2("12:11:10,123456");
time_duration td2= boost::date_time::parse_delimited_time_duration<time_duration>(s2);
check("parse time duration: " + s2,
td2 == time_duration(12,11,10,123456));
std::cout << "td2: " << td2 << std::endl;
//truncate for non-nanosecond case
std::string s8b("1:22:33.123456321"); // too many digits
time_duration td8b= boost::date_time::parse_delimited_time_duration<time_duration>(s8b);
check("parse time duration: " + s8b,
td8b == time_duration(1,22,33,123456)); // excess digits should be dropped
}
std::string date_1, tod_1;
std::string ts1("2002-01-20 23:59:59.000");
@@ -214,6 +220,8 @@ main()
ptime t27 = from_iso_extended_string(ts10);
check("parse iso extended time w/ frac sec (dec only): " + ts10,
t27 == ptime(date(1900,12,31),time_duration(23,0,0,0)));
#else
std::string ts3("20020120T235859.123456");
ptime t20 = from_iso_string(ts3);
@@ -254,6 +262,35 @@ main()
ptime t27 = from_iso_extended_string(ts10);
check("parse iso extended time w/ frac sec (dec only): " + ts10,
t27 == ptime(date(1900,12,31),time_duration(23,0,0,0)));
//the following test cases are for this issue:
//https://github.com/boostorg/date_time/issues/187
try {
std::string ts11("1900-12-31"); //date only string
ptime t28 = from_iso_extended_string(ts11);
check("parse iso extended time date only): " + ts11,
t28 == ptime(date(1900,12,31),time_duration(0,0,0,0)));
}
catch( std::exception& e )
{
std::cout << e.what() << std::endl;
check("parse iso extended time date only): 1900-12-32", false);
}
try {
//expect a date-time exception here
std::string ts12("1900-1"); //completely bogus string
ptime t29 = from_iso_extended_string(ts12);
check("parse iso extended time bad string: " + ts12, false);
(void) t29; //supress unused compiler warning, this is never reached
}
catch( std::exception& e )
{
//Day of month value is out of range 1..31
// std::cout << e.what() << std::endl;
check("parse iso extended time date only): 1900-1", true);
}
#endif // BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
}
+34
View File
@@ -29,6 +29,28 @@ void special_values_tests()
}
#endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR
#ifdef BOOST_NO_CXX14_CONSTEXPR
check("constexpr not configured", true);
#else
//check constexpr case
{
constexpr date d1(1970,1,1);
constexpr ptime t1(d1);
static_assert(t1.date().day() == 1, "constexpr construction day()");
static_assert(t1.date().month() == 1, "constexpr construction month()");
static_assert(t1.date().year() == 1970, "constexpr construction year()");
static_assert(t1.time_of_day().hours() == 0, "constexpr construction hour()");
static_assert(t1.time_of_day().minutes() == 0, "constexpr construction minute()");
static_assert(t1.time_of_day().seconds() == 0, "constexpr construction second()");
constexpr ptime t2(d1, time_duration(1,2,3));
static_assert(t2.time_of_day().hours() == 1, "constexpr contruct with duration hour()");
static_assert(t2.time_of_day().minutes() == 2, "constexpr contruct with duration minute()");
static_assert(t2.time_of_day().seconds() == 3, "constexpr contruct with duration second()");
check("constexpr tests compiled", true);
}
#endif
{ // special values construction tests
ptime p_sv1(pos_infin);
std::string s("+infinity");
@@ -284,6 +306,18 @@ main()
t18 == ptime(date(2032,2,15), time_duration(18,47,14)));
check("time_t conversion from 1960483634", to_time_t(t18) == tt3);
#if !defined(BOOST_NO_INT64_T)
// 64-bit time_t test (if running with a 64-bit time_t)
if (sizeof(std::time_t) >= 8)
{
std::time_t tt4(INT64_C(11864480887));
t18 = from_time_t(tt4); //2345-12-21 09:08:07
check("time_t conversion of 11864480887",
t18 == ptime(date(2345,12,21), time_duration(9,8,7)));
check("time_t conversion from 11864480887", to_time_t(t18) == tt4);
}
#endif
special_values_tests();
//min and max constructors
+2 -8
View File
@@ -30,8 +30,6 @@ main()
CHECK_ROUNDTRIP(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);
@@ -40,9 +38,6 @@ main()
CHECK_ROUNDTRIP(t4);
}
#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));
@@ -66,9 +61,8 @@ main()
CHECK_ROUNDTRIP(t3);
}
#endif
#ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
if (time_duration::resolution() == boost::date_time::nano) {
ptime t2(d1,hours(12) + minutes(5) + seconds(1));
@@ -102,7 +96,7 @@ main()
CHECK_ROUNDTRIP(t3);
}
#endif
// Boost Trac 1078 (https://svn.boost.org/trac10/ticket/1078)
// from_iso_string should be able to parse output of to_iso_string
+11 -11
View File
@@ -24,15 +24,15 @@ int main()
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;
std::cout << t1 << std::endl;
std::cout << p4 << std::endl;
std::cout << p1 << std::endl;
check("construction and ==", p1 == p4);
check("begin", p1.begin() == t1);
check("last", p1.end() == t2);
check("end", p1.last() == t2-time_duration::unit());
std::cout << to_simple_string(p1) << std::endl;
std::cout << p1 << std::endl;
// check("last", p1.() == t2);
check("contains begin", p1.contains(t1));
check("contains end-not", !p1.contains(t2));
@@ -51,21 +51,21 @@ int main()
time_period p6(p5);
p6.shift(minutes(30));
std::cout << to_simple_string(p5) << std::endl;
std::cout << to_simple_string(p6) << std::endl;
std::cout << p5 << std::endl;
std::cout << p6 << std::endl;
check("shifted intersects", p5.intersects(p6));
check("shifted intersects", p6.intersects(p5));
check("contains begin", p5.contains(p6.begin()));
p6.shift(minutes(30));
std::cout << to_simple_string(p5) << std::endl;
std::cout << to_simple_string(p6) << std::endl;
std::cout << p5 << std::endl;
std::cout << p6 << std::endl;
check("shifted !intersects", !p5.intersects(p6));
check("shifted !intersects", !p6.intersects(p5));
p6.shift(minutes(-30));
std::cout << to_simple_string(p5) << std::endl;
std::cout << to_simple_string(p6) << std::endl;
std::cout << p5 << std::endl;
std::cout << p6 << std::endl;
time_period p7 = p5.intersection(p6);
std::cout << to_simple_string(p7) << std::endl;
std::cout << p7 << std::endl;
check("shifted intersection",
p7 == time_period(ptime(d1,time_duration(3,30,0)),
ptime(d1,time_duration(4,0,0))));

Some files were not shown because too many files have changed in this diff Show More