Compare commits

..

10 Commits

Author SHA1 Message Date
nobody c101e80f77 This commit was manufactured by cvs2svn to create tag
'Version_1_32_0'.

[SVN r26264]
2004-11-19 19:19:18 +00:00
Jeff Garland 3a8dde364a remove local_time_base reference
[SVN r26071]
2004-11-01 22:28:39 +00:00
Jeff Garland c711ff3d66 fix linking problem
[SVN r26070]
2004-11-01 22:10:01 +00:00
nobody f37779f725 This commit was manufactured by cvs2svn to create branch 'RC_1_32_0'.
[SVN r26066]
2004-11-01 21:18:55 +00:00
Aleksey Gurtovoy 55ecb500f6 fix broken links
[SVN r25994]
2004-10-31 06:17:30 +00:00
Aleksey Gurtovoy 9bc5d61365 fix tabs
[SVN r25993]
2004-10-31 06:08:02 +00:00
Aleksey Gurtovoy bc3653a9d2 fix BoostBook/broken links/invalid filenames/etc.
[SVN r25933]
2004-10-29 10:23:48 +00:00
Aleksey Gurtovoy a51548825e fix BoostBook/broken links/invalid filenames/etc.
[SVN r25931]
2004-10-29 09:40:12 +00:00
Victor A. Wagner Jr. 97d7e6fcc0 fix to the VC8.0 regrssion test. Comments in the source, this was a bug just
waiting to happen as soon as some new string implementation came along.


[SVN r25927]
2004-10-29 06:27:24 +00:00
nobody 872f61bebb This commit was manufactured by cvs2svn to create branch 'RC_1_32_0'.
[SVN r25797]
2004-10-20 08:26:43 +00:00
308 changed files with 14912 additions and 25098 deletions
-116
View File
@@ -1,116 +0,0 @@
# 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
@@ -1,23 +0,0 @@
# 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
@@ -1,50 +0,0 @@
#
# 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 }}
-2
View File
@@ -1,2 +0,0 @@
**/test_facet_file.out
**/time_duration_serialization.*
-4
View File
@@ -1,4 +0,0 @@
# 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
@@ -1,52 +0,0 @@
# 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()
-23
View File
@@ -1,23 +0,0 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
-40
View File
@@ -1,40 +0,0 @@
DateTime, part of the collection of [Boost C++ Libraries](http://github.com/boostorg), makes programming with dates and times as simple and natural as programming with strings and integers.
### License
Distributed under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt).
### Properties
* C++11
* Header only
### Build Status
<!-- 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
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
* [Ask questions](http://stackoverflow.com/questions/ask?tags=c%2B%2B,boost,boost-date_time): Be sure to read the documentation first to see if it answers your question.
* [Report bugs](https://github.com/boostorg/date_time/issues): Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well.
* [Submit Pull Requests](https://github.com/boostorg/date_time/pulls) against the **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](http://www.boost.org/LICENSE_1_0.txt). Be sure to include tests proving your changes work properly.
* Discussions about the library are held on the [Boost developers mailing list](http://www.boost.org/community/groups.html#main). Be sure to read the [discussion policy](http://www.boost.org/community/policy.html) before posting and add the `[date_time]` tag at the beginning of the subject line.
-37
View File
@@ -1,37 +0,0 @@
# 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
;
+42
View File
@@ -0,0 +1,42 @@
# (C) Copyright 2002. Permission to copy, use, modify, sell and
# distribute this software is granted provided this copyright notice appears
# in all copies. This software is provided "as is" without express or implied# warranty, and with no claim as to its suitability for any purpose.### Boost.date_time build ## To run all tests quietly: jam test## Declares the following targets:# 1. libboost_date_time, a library to be linked with all# Boost.date_time modules#
# declare the location of this subproject relative to the root
subproject libs/date_time/build ;
# Base names of the source files for libboost_date_time
CPP_SOURCES =
greg_month greg_weekday date_generators ;
dll boost_date_time
: ../src/gregorian/$(CPP_SOURCES).cpp
:
<sysinclude>$(BOOST_ROOT)
<runtime-link>dynamic
<define>BOOST_ALL_DYN_LINK=1
# the common names rule ensures that the library will
# be named according to the rules used by the install
# and auto-link features:
common-variant-tag
: debug release ;
lib boost_date_time : ../src/gregorian/$(CPP_SOURCES).cpp
:
<sysinclude>$(BOOST_ROOT)
<define>BOOST_DATE_TIME_STATIC_LINK
# the common names rule ensures that the library will
# be named according to the rules used by the install
# and auto-link features:
common-variant-tag
:
debug
release
<runtime-link>static
;
install date_time lib
: <dll>boost_date_time <lib>boost_date_time
;
+23 -14
View File
@@ -1,24 +1,33 @@
# Copyright (c) 2002-2005 CrystalClear Software, Inc.
# Use, modification and distribution is subject to the
# Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# (C) Copyright 2002. Permission to copy, use, modify, sell and
# distribute this software is granted provided this copyright notice appears
# in all copies. This software is provided "as is" without express or implied
# warranty, and with no claim as to its suitability for any purpose.
#
# date_time is now header only -- this file provides a stub for backward compatibility
#
# Boost.date_time build and test Jamfile
#
# Based on boost.python Jamfile
#
# To run all tests quietly: jam test
#
# Declares the following targets:
# 1. libboost_date_time, a static link library to be linked with all
# Boost.date_time modules
#
project
: common-requirements <library>$(boost_dependencies)
project boost/date_time
: requirements
<define>DATE_TIME_INLINE
<link>shared:<define>BOOST_ALL_DYN_LINK=1
: usage-requirements
<link>shared:<define>BOOST_ALL_DYN_LINK=1
<link>static:<define>BOOST_DATE_TIME_STATIC_LINK
: usage-requirements
<define>DATE_TIME_INLINE
<link>shared:<define>BOOST_DATE_TIME_DYN_LINK=1
<define>BOOST_DATE_TIME_NO_LINK=1
: source-location ../src
;
# greg_month.cpp is now just a stub so that there is
# still a boost_date_time library to link for backward compatibility
lib boost_date_time : gregorian/greg_month.cpp ;
# 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 ;
+137 -279
View File
@@ -3,7 +3,6 @@
"Africa/Accra","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Africa/Addis_Ababa","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Africa/Algiers","CET","CET","","","+01:00:00","+00:00:00","","","","+00:00:00"
"Africa/Asmara","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Africa/Asmera","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Africa/Bamako","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Africa/Bangui","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
@@ -12,20 +11,19 @@
"Africa/Blantyre","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
"Africa/Brazzaville","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
"Africa/Bujumbura","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
"Africa/Cairo","EET","EET","","","+02:00:00","+00:00:00","","","","+00:00:00"
"Africa/Casablanca","WET","WET","WEST","WEST","+00:00:00","+01:00:00","2;0;7","+02:00:00","-1;0;10","+03:00:00"
"Africa/Cairo","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;5;4","+00:00:00","-1;5;9","+00:00:00"
"Africa/Casablanca","WET","WET","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Africa/Ceuta","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Africa/Conakry","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Africa/Dakar","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Africa/Dar_es_Salaam","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Africa/Djibouti","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Africa/Douala","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
"Africa/El_Aaiun","WET","WET","WEST","WEST","+00:00:00","+01:00:00","2;0;7","+02:00:00","-1;0;10","+03:00:00"
"Africa/El_Aaiun","WET","WET","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Africa/Freetown","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Africa/Gaborone","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
"Africa/Harare","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
"Africa/Johannesburg","SAST","SAST","","","+02:00:00","+00:00:00","","","","+00:00:00"
"Africa/Juba","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Africa/Kampala","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Africa/Khartoum","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Africa/Kigali","CAT","CAT","","","+02:00:00","+00:00:00","","","","+00:00:00"
@@ -48,361 +46,235 @@
"Africa/Nouakchott","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Africa/Ouagadougou","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Africa/Porto-Novo","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
"Africa/Porto_Novo","WAT","WAT","","","+01:00:00","+00:00:00","","","","+00:00:00"
"Africa/Sao_Tome","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Africa/Timbuktu","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Africa/Tripoli","EET","EET","","","+02:00:00","+00:00:00","","","","+00:00:00"
"Africa/Tunis","CET","CET","","","+01:00:00","+00:00:00","","","","+00:00:00"
"Africa/Windhoek","WAT","WAT","WAST","WAST","+01:00:00","+01:00:00","1;0;9","+02:00:00","1;0;4","+02:00:00"
"America/Adak","HST","HST","HDT","HDT","-10:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Anchorage","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Adak","HAST","HAST","HADT","HADT","-10:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Anchorage","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Anguilla","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Antigua","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Araguaina","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/Buenos_Aires","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/Catamarca","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/ComodRivadavia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/Cordoba","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/Jujuy","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/La_Rioja","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/Mendoza","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/Rio_Gallegos","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/Salta","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/San_Juan","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/San_Luis","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/Tucuman","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Argentina/Ushuaia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Araguaina","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","2;0;10","+00:00:00","3;0;2","+00:00:00"
"America/Aruba","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Asuncion","PYT","PYT","PYST","PYST","-04:00:00","+01:00:00","1;0;10","+00:00:00","-1;0;3","+00:00:00"
"America/Atikokan","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Atka","HST","HST","HDT","HDT","-10:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Bahia","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Bahia_Banderas","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Asuncion","PYT","PYT","PYST","PYST","-04:00:00","+01:00:00","1;0;10","+00:00:00","1;0;3","+00:00:00"
"America/Barbados","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Belem","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Belize","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"America/Beulah","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Blanc-Sablon","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Blanc_Sablon","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Boa_Vista","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Bogota","COT","COT","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Boise","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Boise","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Buenos_Aires","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Cambridge_Bay","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Campo_Grande","AMT","AMT","AMST","AMST","-04:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00"
"America/Cancun","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Caracas","VET","VET","","","-04:30:00","+00:00:00","","","","+00:00:00"
"America/Cambridge_Bay","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Cancun","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;5","+02:00:00","-1;0;9","+02:00:00"
"America/Caracas","VET","VET","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Catamarca","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Cayenne","GFT","GFT","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Cayman","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Center","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Chicago","CST","Central Standard Time","CDT","Central Daylight Time","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Chihuahua","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/ComodRivadavia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Coral_Harbour","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Chicago","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Chihuahua","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;5","+02:00:00","-1;0;9","+02:00:00"
"America/Cordoba","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Costa_Rica","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"America/Creston","MST","MST","","","-07:00:00","+00:00:00","","","","+00:00:00"
"America/Cuiaba","AMT","AMT","AMST","AMST","-04:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00"
"America/Cuiaba","AMT","AMT","AMST","AMST","-04:00:00","+01:00:00","2;0;10","+00:00:00","3;0;2","+00:00:00"
"America/Curacao","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Danmarkshavn","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"America/Dawson","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Dawson","PST","PST","PDT","PDT","-08:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Dawson_Creek","MST","MST","","","-07:00:00","+00:00:00","","","","+00:00:00"
"America/Denver","MST","Mountain Standard Time","MDT","Mountain Daylight Time","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Detroit","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Denver","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Detroit","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Dominica","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Edmonton","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Edmonton","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Eirunepe","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/El_Salvador","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"America/Ensenada","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Fortaleza","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Fort_Wayne","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Glace_Bay","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Fortaleza","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","2;0;10","+00:00:00","3;0;2","+00:00:00"
"America/Glace_Bay","AST","AST","ADT","ADT","-04:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Godthab","WGT","WGT","WGST","WGST","-03:00:00","+01:00:00","-1;6;3","+22:00:00","-1;6;10","+23:00:00"
"America/Goose_Bay","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Grand_Turk","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Goose_Bay","AST","AST","ADT","ADT","-04:00:00","+01:00:00","1;0;4","+00:01:00","-1;0;10","+00:01:00"
"America/Grand_Turk","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+00:00:00","-1;0;10","+00:00:00"
"America/Grenada","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Guadeloupe","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Guatemala","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"America/Guayaquil","ECT","ECT","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Guyana","GYT","GYT","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Halifax","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Havana","CST","CST","CDT","CDT","-05:00:00","+01:00:00","2;0;3","+00:00:00","1;0;11","+01:00:00"
"America/Halifax","AST","AST","ADT","ADT","-04:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Havana","CST","CST","CDT","CDT","-05:00:00","+01:00:00","1;0;4","+00:00:00","-1;0;10","+01:00:00"
"America/Hermosillo","MST","MST","","","-07:00:00","+00:00:00","","","","+00:00:00"
"America/Indiana/Indianapolis","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Indiana/Knox","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Indiana/Marengo","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Indiana/Petersburg","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Indiana/Tell_City","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Indiana/Vevay","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Indiana/Vincennes","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Indiana/Winamac","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Indianapolis","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Inuvik","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Iqaluit","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Indiana/Indianapolis","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Indiana/Knox","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Indiana/Marengo","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Indiana/Vevay","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Indianapolis","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Inuvik","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Iqaluit","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Jamaica","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Jujuy","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Juneau","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Kentucky/Louisville","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Kentucky/Monticello","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Knox","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Knox_IN","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Kralendijk","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Juneau","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Kentucky/Louisville","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Kentucky/Monticello","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/La_Paz","BOT","BOT","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/La_Rioja","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Lima","PET","PET","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Los_Angeles","PST","Pacific Standard Time","PDT","Pacific Daylight Time","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Louisville","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Lower_Princes","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Maceio","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Los_Angeles","PST","PST","PDT","PDT","-08:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Louisville","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Maceio","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","2;0;10","+00:00:00","3;0;2","+00:00:00"
"America/Managua","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"America/Manaus","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Marengo","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Marigot","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Martinique","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Matamoros","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Mazatlan","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Mazatlan","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;5","+02:00:00","-1;0;9","+02:00:00"
"America/Mendoza","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Menominee","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Merida","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Metlakatla","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Mexico_City","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Miquelon","PMST","PMST","PMDT","PMDT","-03:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Moncton","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Monterrey","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Menominee","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Merida","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;5","+02:00:00","-1;0;9","+02:00:00"
"America/Mexico_City","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"America/Miquelon","PMST","PMST","PMDT","PMDT","-03:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Monterrey","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;5","+02:00:00","-1;0;9","+02:00:00"
"America/Montevideo","UYT","UYT","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Monticello","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Montreal","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Montreal","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Montserrat","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Nassau","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/New_Salem","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/New_York","EST","Eastern Standard Time","EDT","Eastern Daylight Time","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Nipigon","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Nome","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Nassau","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/New_York","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Nipigon","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Nome","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Noronha","FNT","FNT","","","-02:00:00","+00:00:00","","","","+00:00:00"
"America/North_Dakota/Beulah","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/North_Dakota/Center","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/North_Dakota/New_Salem","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Ojinaga","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/North_Dakota/Center","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Panama","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Pangnirtung","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Pangnirtung","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Paramaribo","SRT","SRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Petersburg","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Phoenix","MST","Mountain Standard Time","","","-07:00:00","+00:00:00","","","","+00:00:00"
"America/Phoenix","MST","MST","","","-07:00:00","+00:00:00","","","","+00:00:00"
"America/Port-au-Prince","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Porto_Acre","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Porto_Velho","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Port_au_Prince","EST","EST","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Port_of_Spain","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Porto_Velho","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Puerto_Rico","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Rainy_River","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Rankin_Inlet","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Recife","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Rainy_River","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Rankin_Inlet","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Recife","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","2;0;10","+00:00:00","3;0;2","+00:00:00"
"America/Regina","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"America/Resolute","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Rio_Branco","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00"
"America/Rio_Gallegos","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Rosario","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Salta","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Santarem","BRT","BRT","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Santa_Isabel","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Santiago","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;8","+00:00:00","3;0;5","+00:00:00"
"America/Santiago","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;10","+00:00:00","2;0;3","+00:00:00"
"America/Santo_Domingo","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/San_Juan","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/San_Luis","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Sao_Paulo","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00"
"America/Sao_Paulo","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","2;0;10","+00:00:00","3;0;2","+00:00:00"
"America/Scoresbysund","EGT","EGT","EGST","EGST","-01:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+01:00:00"
"America/Shiprock","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Sitka","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/St_Barthelemy","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/St_Johns","NST","NST","NDT","NDT","-03:30:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Shiprock","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/St_Johns","NST","NST","NDT","NDT","-03:30:00","+01:00:00","1;0;4","+00:01:00","-1;0;10","+00:01:00"
"America/St_Kitts","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/St_Lucia","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/St_Thomas","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/St_Vincent","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Swift_Current","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"America/Tegucigalpa","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"America/Tell_City","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Thule","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Thunder_Bay","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Tijuana","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Toronto","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Thule","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Thunder_Bay","EST","EST","EDT","EDT","-05:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Tijuana","PST","PST","PDT","PDT","-08:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Tortola","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Tucuman","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Ushuaia","ART","ART","","","-03:00:00","+00:00:00","","","","+00:00:00"
"America/Vancouver","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Vevay","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Vincennes","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Virgin","AST","AST","","","-04:00:00","+00:00:00","","","","+00:00:00"
"America/Whitehorse","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Winamac","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Winnipeg","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Yakutat","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"America/Yellowknife","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"Antarctica/Casey","AWST","AWST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"America/Vancouver","PST","PST","PDT","PDT","-08:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Whitehorse","PST","PST","PDT","PDT","-08:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Winnipeg","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+03:00:00"
"America/Yakutat","AKST","AKST","AKDT","AKDT","-09:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"America/Yellowknife","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"Antarctica/Casey","WST","WST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Antarctica/Davis","DAVT","DAVT","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Antarctica/DumontDUrville","DDUT","DDUT","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Antarctica/Macquarie","MIST","MIST","","","+11:00:00","+00:00:00","","","","+00:00:00"
"Antarctica/Mawson","MAWT","MAWT","","","+05:00:00","+00:00:00","","","","+00:00:00"
"Antarctica/McMurdo","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00"
"Antarctica/Palmer","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;8","+00:00:00","3;0;5","+00:00:00"
"Antarctica/Rothera","ROTT","ROTT","","","-03:00:00","+00:00:00","","","","+00:00:00"
"Antarctica/South_Pole","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00"
"Antarctica/Mawson","MAWT","MAWT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Antarctica/McMurdo","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","1;0;10","+02:00:00","3;0;3","+03:00:00"
"Antarctica/Palmer","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;10","+00:00:00","2;0;3","+00:00:00"
"Antarctica/South_Pole","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","1;0;10","+02:00:00","3;0;3","+03:00:00"
"Antarctica/Syowa","SYOT","SYOT","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Antarctica/Troll","UTC","UTC","CEST","CEST","+00:00:00","+02:00:00","-1;0;3","+01:00:00","-1;0;10","+03:00:00"
"Antarctica/Vostok","VOST","VOST","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Arctic/Longyearbyen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Aden","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Asia/Almaty","ALMT","ALMT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Amman","EET","EET","EEST","EEST","+02:00:00","+01:00:00","1;5;4","+00:00:00","-1;5;10","+01:00:00"
"Asia/Anadyr","ANAT","ANAT","","","+12:00:00","+00:00:00","","","","+00:00:00"
"Asia/Aqtau","AQTT","AQTT","","","+05:00:00","+00:00:00","","","","+00:00:00"
"Asia/Aqtobe","AQTT","AQTT","","","+05:00:00","+00:00:00","","","","+00:00:00"
"Asia/Almaty","ALMT","ALMT","ALMST","ALMST","+06:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+00:00:00"
"Asia/Amman","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;4;3","+00:00:00","-1;4;9","+01:00:00"
"Asia/Anadyr","ANAT","ANAT","ANAST","ANAST","+12:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Aqtau","AQTT","AQTT","AQTST","AQTST","+04:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+00:00:00"
"Asia/Aqtobe","AQTT","AQTT","AQTST","AQTST","+05:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+00:00:00"
"Asia/Ashgabat","TMT","TMT","","","+05:00:00","+00:00:00","","","","+00:00:00"
"Asia/Ashkhabad","TMT","TMT","","","+05:00:00","+00:00:00","","","","+00:00:00"
"Asia/Baghdad","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Asia/Baghdad","AST","AST","ADT","ADT","+03:00:00","+01:00:00","1;0;4","+03:00:00","1;0;10","+04:00:00"
"Asia/Bahrain","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Asia/Baku","AZT","AZT","","","+04:00:00","+00:00:00","","","","+00:00:00"
"Asia/Baku","AZT","AZT","AZST","AZST","+04:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+01:00:00"
"Asia/Bangkok","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Beirut","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+00:00:00"
"Asia/Bishkek","KGT","KGT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Bishkek","KGT","KGT","KGST","KGST","+05:00:00","+01:00:00","-1;0;3","+02:30:00","-1;0;10","+02:30:00"
"Asia/Brunei","BNT","BNT","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Calcutta","IST","IST","","","+05:30:00","+00:00:00","","","","+00:00:00"
"Asia/Chita","YAKT","YAKT","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Asia/Choibalsan","CHOT","CHOT","CHOST","CHOST","+08:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00"
"Asia/Choibalsan","CHOT","CHOT","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Asia/Chongqing","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Chungking","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Colombo","IST","IST","","","+05:30:00","+00:00:00","","","","+00:00:00"
"Asia/Dacca","BDT","BDT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Damascus","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;5;3","+00:00:00","-1;5;10","+00:00:00"
"Asia/Colombo","LKT","LKT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Damascus","EET","EET","EEST","EEST","+02:00:00","+01:00:00","1;0;4","+00:00:00","1;0;10","+00:00:00"
"Asia/Dhaka","BDT","BDT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Dili","TLT","TLT","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Asia/Dili","TPT","TPT","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Asia/Dubai","GST","GST","","","+04:00:00","+00:00:00","","","","+00:00:00"
"Asia/Dushanbe","TJT","TJT","","","+05:00:00","+00:00:00","","","","+00:00:00"
"Asia/Gaza","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;6;3","+01:00:00","3;5;10","+00:00:00"
"Asia/Gaza","EET","EET","EEST","EEST","+02:00:00","+01:00:00","3;5;4","+00:00:00","3;5;10","+00:00:00"
"Asia/Harbin","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Hebron","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;6;3","+01:00:00","3;5;10","+00:00:00"
"Asia/Hong_Kong","HKT","HKT","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Hovd","HOVT","HOVT","HOVST","HOVST","+07:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00"
"Asia/Ho_Chi_Minh","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Irkutsk","IRKT","IRKT","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Hovd","HOVT","HOVT","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Irkutsk","IRKT","IRKT","IRKST","IRKST","+08:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Istanbul","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Asia/Jakarta","WIB","WIB","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Jayapura","WIT","WIT","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Asia/Jerusalem","IST","IST","IDT","IDT","+02:00:00","+01:00:00","-1;5;3","+02:00:00","-1;0;10","+02:00:00"
"Asia/Jakarta","WIT","WIT","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Jayapura","EIT","EIT","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Asia/Jerusalem","IST","IST","IDT","IDT","+02:00:00","+01:00:00","1;0;4","+01:00:00","1;0;10","+01:00:00"
"Asia/Kabul","AFT","AFT","","","+04:30:00","+00:00:00","","","","+00:00:00"
"Asia/Kamchatka","PETT","PETT","","","+12:00:00","+00:00:00","","","","+00:00:00"
"Asia/Kamchatka","PETT","PETT","PETST","PETST","+12:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Karachi","PKT","PKT","","","+05:00:00","+00:00:00","","","","+00:00:00"
"Asia/Kashgar","XJT","XJT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Kathmandu","NPT","NPT","","","+05:45:00","+00:00:00","","","","+00:00:00"
"Asia/Kashgar","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Katmandu","NPT","NPT","","","+05:45:00","+00:00:00","","","","+00:00:00"
"Asia/Khandyga","YAKT","YAKT","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Asia/Kolkata","IST","IST","","","+05:30:00","+00:00:00","","","","+00:00:00"
"Asia/Krasnoyarsk","KRAT","KRAT","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Krasnoyarsk","KRAT","KRAT","KRAST","KRAST","+07:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Kuala_Lumpur","MYT","MYT","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Kuching","MYT","MYT","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Kuwait","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Asia/Macao","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Macau","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Magadan","MAGT","MAGT","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Asia/Makassar","WITA","WITA","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Magadan","MAGT","MAGT","MAGST","MAGST","+11:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Manila","PHT","PHT","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Muscat","GST","GST","","","+04:00:00","+00:00:00","","","","+00:00:00"
"Asia/Nicosia","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Asia/Novokuznetsk","KRAT","KRAT","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Novosibirsk","NOVT","NOVT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Omsk","OMST","OMST","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Oral","ORAT","ORAT","","","+05:00:00","+00:00:00","","","","+00:00:00"
"Asia/Novosibirsk","NOVT","NOVT","NOVST","NOVST","+06:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Omsk","OMST","OMST","OMSST","OMSST","+06:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Phnom_Penh","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Pontianak","WIB","WIB","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Pyongyang","KST","KST","","","+08:30:00","+00:00:00","","","","+00:00:00"
"Asia/Pontianak","WIT","WIT","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Pyongyang","KST","KST","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Asia/Qatar","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Asia/Qyzylorda","QYZT","QYZT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Rangoon","MMT","MMT","","","+06:30:00","+00:00:00","","","","+00:00:00"
"Asia/Riyadh","AST","AST","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Asia/Saigon","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Sakhalin","SAKT","SAKT","","","+11:00:00","+00:00:00","","","","+00:00:00"
"Asia/Sakhalin","SAKT","SAKT","SAKST","SAKST","+10:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Samarkand","UZT","UZT","","","+05:00:00","+00:00:00","","","","+00:00:00"
"Asia/Seoul","KST","KST","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Asia/Shanghai","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Singapore","SGT","SGT","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Srednekolymsk","SRET","SRET","","","+11:00:00","+00:00:00","","","","+00:00:00"
"Asia/Taipei","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Tashkent","UZT","UZT","","","+05:00:00","+00:00:00","","","","+00:00:00"
"Asia/Tbilisi","GET","GET","","","+04:00:00","+00:00:00","","","","+00:00:00"
"Asia/Tehran","IRST","IRST","IRDT","IRDT","+03:30:00","+01:00:00","3;1;3","+00:00:00","3;3;9","+00:00:00"
"Asia/Tel_Aviv","IST","IST","IDT","IDT","+02:00:00","+01:00:00","-1;5;3","+02:00:00","-1;0;10","+02:00:00"
"Asia/Thimbu","BTT","BTT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Tbilisi","GET","GET","GEST","GEST","+04:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+00:00:00"
"Asia/Tehran","IRT","IRT","","","+03:30:00","+00:00:00","","","","+00:00:00"
"Asia/Thimphu","BTT","BTT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Tokyo","JST","JST","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Asia/Ujung_Pandang","WITA","WITA","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Ulaanbaatar","ULAT","ULAT","ULAST","ULAST","+08:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00"
"Asia/Ulan_Bator","ULAT","ULAT","ULAST","ULAST","+08:00:00","+01:00:00","-1;6;3","+02:00:00","-1;6;9","+00:00:00"
"Asia/Urumqi","XJT","XJT","","","+06:00:00","+00:00:00","","","","+00:00:00"
"Asia/Ust-Nera","VLAT","VLAT","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Asia/Ust_Nera","VLAT","VLAT","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Asia/Ujung_Pandang","CIT","CIT","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Ulaanbaatar","ULAT","ULAT","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Urumqi","CST","CST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Asia/Vientiane","ICT","ICT","","","+07:00:00","+00:00:00","","","","+00:00:00"
"Asia/Vladivostok","VLAT","VLAT","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Asia/Yakutsk","YAKT","YAKT","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Asia/Yekaterinburg","YEKT","YEKT","","","+05:00:00","+00:00:00","","","","+00:00:00"
"Asia/Yerevan","AMT","AMT","","","+04:00:00","+00:00:00","","","","+00:00:00"
"Asia/Vladivostok","VLAT","VLAT","VLAST","VLAST","+10:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Yakutsk","YAKT","YAKT","YAKST","YAKST","+09:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Yekaterinburg","YEKT","YEKT","YEKST","YEKST","+05:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Asia/Yerevan","AMT","AMT","AMST","AMST","+04:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Atlantic/Azores","AZOT","AZOT","AZOST","AZOST","-01:00:00","+01:00:00","-1;0;3","+00:00:00","-1;0;10","+01:00:00"
"Atlantic/Bermuda","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"Atlantic/Bermuda","AST","AST","ADT","ADT","-04:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"Atlantic/Canary","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
"Atlantic/Cape_Verde","CVT","CVT","","","-01:00:00","+00:00:00","","","","+00:00:00"
"Atlantic/Faeroe","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
"Atlantic/Faroe","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
"Atlantic/Jan_Mayen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Atlantic/Madeira","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
"Atlantic/Reykjavik","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Atlantic/South_Georgia","GST","GST","","","-02:00:00","+00:00:00","","","","+00:00:00"
"Atlantic/Stanley","FKST","FKST","","","-03:00:00","+00:00:00","","","","+00:00:00"
"Atlantic/St_Helena","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Australia/ACT","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/Adelaide","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/Brisbane","AEST","AEST","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Australia/Broken_Hill","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/Canberra","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/Currie","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/Darwin","ACST","ACST","","","+09:30:00","+00:00:00","","","","+00:00:00"
"Australia/Eucla","ACWST","ACWST","","","+08:45:00","+00:00:00","","","","+00:00:00"
"Australia/Hobart","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/LHI","LHST","LHST","LHDT","LHDT","+10:30:00","+00:30:00","1;0;10","+02:00:00","1;0;4","+02:00:00"
"Australia/Lindeman","AEST","AEST","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Australia/Lord_Howe","LHST","LHST","LHDT","LHDT","+10:30:00","+00:30:00","1;0;10","+02:00:00","1;0;4","+02:00:00"
"Australia/Melbourne","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/North","ACST","ACST","","","+09:30:00","+00:00:00","","","","+00:00:00"
"Australia/NSW","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/Perth","AWST","AWST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Australia/Queensland","AEST","AEST","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Australia/South","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/Sydney","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/Tasmania","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/Victoria","AEST","AEST","AEDT","AEDT","+10:00:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Australia/West","AWST","AWST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Australia/Yancowinna","ACST","ACST","ACDT","ACDT","+09:30:00","+01:00:00","1;0;10","+02:00:00","1;0;4","+03:00:00"
"Brazil/Acre","ACT","ACT","","","-05:00:00","+00:00:00","","","","+00:00:00"
"Brazil/DeNoronha","FNT","FNT","","","-02:00:00","+00:00:00","","","","+00:00:00"
"Brazil/East","BRT","BRT","BRST","BRST","-03:00:00","+01:00:00","3;0;10","+00:00:00","3;0;2","+00:00:00"
"Brazil/West","AMT","AMT","","","-04:00:00","+00:00:00","","","","+00:00:00"
"Canada/Atlantic","AST","AST","ADT","ADT","-04:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"Canada/Central","CST","CST","CDT","CDT","-06:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"Canada/East-Saskatchewan","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"Canada/Eastern","EST","EST","EDT","EDT","-05:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"Canada/East_Saskatchewan","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"Canada/Mountain","MST","MST","MDT","MDT","-07:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"Canada/Newfoundland","NST","NST","NDT","NDT","-03:30:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"Canada/Pacific","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"Canada/Saskatchewan","CST","CST","","","-06:00:00","+00:00:00","","","","+00:00:00"
"Canada/Yukon","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"Chile/Continental","CLT","CLT","CLST","CLST","-04:00:00","+01:00:00","2;0;8","+00:00:00","3;0;5","+00:00:00"
"Chile/EasterIsland","EAST","EAST","EASST","EASST","-06:00:00","+01:00:00","2;6;8","+22:00:00","2;6;5","+22:00:00"
"Etc/GMT","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Etc/Greenwich","GMT","GMT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Etc/UCT","UCT","UCT","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Etc/Universal","UTC","UTC","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Etc/UTC","UTC","UTC","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Etc/Zulu","UTC","UTC","","","+00:00:00","+00:00:00","","","","+00:00:00"
"Atlantic/Stanley","FKT","FKT","FKST","FKST","-04:00:00","+01:00:00","1;0;9","+02:00:00","3;0;4","+02:00:00"
"Australia/Adelaide","CST","CST","CST","CST","+09:30:00","+01:00:00","-1;0;10","+02:00:00","-1;0;3","+03:00:00"
"Australia/Brisbane","EST","EST","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Australia/Broken_Hill","CST","CST","CST","CST","+09:30:00","+01:00:00","-1;0;10","+02:00:00","-1;0;3","+03:00:00"
"Australia/Darwin","CST","CST","","","+09:30:00","+00:00:00","","","","+00:00:00"
"Australia/Hobart","EST","EST","EST","EST","+10:00:00","+01:00:00","1;0;10","+02:00:00","-1;0;3","+03:00:00"
"Australia/Lindeman","EST","EST","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Australia/Lord_Howe","LHST","LHST","LHST","LHST","+10:30:00","+00:30:00","-1;0;10","+02:00:00","-1;0;3","+02:00:00"
"Australia/Melbourne","EST","EST","EST","EST","+10:00:00","+01:00:00","-1;0;10","+02:00:00","-1;0;3","+03:00:00"
"Australia/Perth","WST","WST","","","+08:00:00","+00:00:00","","","","+00:00:00"
"Australia/Sydney","EST","EST","EST","EST","+10:00:00","+01:00:00","-1;0;10","+02:00:00","-1;0;3","+03:00:00"
"Europe/Amsterdam","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Andorra","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Athens","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
@@ -413,17 +285,13 @@
"Europe/Brussels","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Bucharest","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Budapest","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Busingen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Chisinau","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Chisinau","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Copenhagen","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Dublin","GMT","GMT","IST","IST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
"Europe/Gibraltar","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Guernsey","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
"Europe/Helsinki","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Isle_of_Man","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
"Europe/Istanbul","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Jersey","GMT","GMT","BST","BST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
"Europe/Kaliningrad","EET","EET","","","+02:00:00","+00:00:00","","","","+00:00:00"
"Europe/Kaliningrad","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Kiev","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Lisbon","WET","WET","WEST","WEST","+00:00:00","+01:00:00","-1;0;3","+01:00:00","-1;0;10","+02:00:00"
"Europe/Ljubljana","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
@@ -431,33 +299,29 @@
"Europe/Luxembourg","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Madrid","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Malta","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Mariehamn","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Minsk","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Europe/Minsk","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Monaco","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Moscow","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Europe/Moscow","MSK","MSK","MSD","MSD","+03:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Nicosia","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Oslo","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Paris","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Podgorica","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Prague","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Riga","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Rome","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Samara","SAMT","SAMT","","","+04:00:00","+00:00:00","","","","+00:00:00"
"Europe/Samara","SAMT","SAMT","SAMST","SAMST","+04:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/San_Marino","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Sarajevo","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Simferopol","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Europe/Simferopol","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Skopje","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Sofia","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Stockholm","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Tallinn","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Tallinn","EET","EET","","","+02:00:00","+00:00:00","","","","+00:00:00"
"Europe/Tirane","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Tiraspol","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Uzhgorod","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Vaduz","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Vatican","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Vienna","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Vilnius","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
"Europe/Volgograd","MSK","MSK","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Europe/Vilnius","EET","EET","","","+02:00:00","+00:00:00","","","","+00:00:00"
"Europe/Warsaw","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Zagreb","CET","CET","CEST","CEST","+01:00:00","+01:00:00","-1;0;3","+02:00:00","-1;0;10","+03:00:00"
"Europe/Zaporozhye","EET","EET","EEST","EEST","+02:00:00","+01:00:00","-1;0;3","+03:00:00","-1;0;10","+04:00:00"
@@ -473,18 +337,14 @@
"Indian/Mauritius","MUT","MUT","","","+04:00:00","+00:00:00","","","","+00:00:00"
"Indian/Mayotte","EAT","EAT","","","+03:00:00","+00:00:00","","","","+00:00:00"
"Indian/Reunion","RET","RET","","","+04:00:00","+00:00:00","","","","+00:00:00"
"Mexico/BajaNorte","PST","PST","PDT","PDT","-08:00:00","+01:00:00","2;0;3","+02:00:00","1;0;11","+02:00:00"
"Mexico/BajaSur","MST","MST","MDT","MDT","-07:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"Mexico/General","CST","CST","CDT","CDT","-06:00:00","+01:00:00","1;0;4","+02:00:00","-1;0;10","+02:00:00"
"Pacific/Apia","WSST","WSST","WSDT","WSDT","+13:00:00","+01:00:00","-1;0;9","+03:00:00","1;0;4","+04:00:00"
"Pacific/Auckland","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00"
"Pacific/Chatham","CHAST","CHAST","CHADT","CHADT","+12:45:00","+01:00:00","-1;0;9","+02:00:00","1;0;4","+03:00:00"
"Pacific/Chuuk","CHUT","CHUT","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Easter","EAST","EAST","EASST","EASST","-06:00:00","+01:00:00","2;6;8","+22:00:00","2;6;5","+22:00:00"
"Pacific/Apia","WST","WST","","","-11:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Auckland","NZST","NZST","NZDT","NZDT","+12:00:00","+01:00:00","1;0;10","+02:00:00","3;0;3","+03:00:00"
"Pacific/Chatham","CHAST","CHAST","CHADT","CHADT","+12:45:00","+01:00:00","1;0;10","+02:45:00","3;0;3","+03:45:00"
"Pacific/Easter","EAST","EAST","EASST","EASST","-06:00:00","+01:00:00","2;6;10","+22:00:00","2;6;3","+22:00:00"
"Pacific/Efate","VUT","VUT","","","+11:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Enderbury","PHOT","PHOT","","","+13:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Fakaofo","TKT","TKT","","","+13:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Fiji","FJT","FJT","FJST","FJST","+12:00:00","+01:00:00","1;0;11","+02:00:00","3;0;1","+03:00:00"
"Pacific/Fakaofo","TKT","TKT","","","-10:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Fiji","FJT","FJT","","","+12:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Funafuti","TVT","TVT","","","+12:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Galapagos","GALT","GALT","","","-06:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Gambier","GAMT","GAMT","","","-09:00:00","+00:00:00","","","","+00:00:00"
@@ -500,21 +360,19 @@
"Pacific/Midway","SST","SST","","","-11:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Nauru","NRT","NRT","","","+12:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Niue","NUT","NUT","","","-11:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Norfolk","NFT","NFT","","","+11:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Norfolk","NFT","NFT","","","+11:30:00","+00:00:00","","","","+00:00:00"
"Pacific/Noumea","NCT","NCT","","","+11:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Pago_Pago","SST","SST","","","-11:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Palau","PWT","PWT","","","+09:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Pitcairn","PST","PST","","","-08:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Pohnpei","PONT","PONT","","","+11:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Ponape","PONT","PONT","","","+11:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Port_Moresby","PGT","PGT","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Rarotonga","CKT","CKT","","","-10:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Saipan","ChST","ChST","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Samoa","SST","SST","","","-11:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Tahiti","TAHT","TAHT","","","-10:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Tarawa","GILT","GILT","","","+12:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Tongatapu","TOT","TOT","","","+13:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Truk","CHUT","CHUT","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Truk","TRUT","TRUT","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Wake","WAKT","WAKT","","","+12:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Wallis","WFT","WFT","","","+12:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Yap","CHUT","CHUT","","","+10:00:00","+00:00:00","","","","+00:00:00"
"Pacific/Yap","YAPT","YAPT","","","+10:00:00","+00:00:00","","","","+00:00:00"
1 ID STD ABBR STD NAME DST ABBR DST NAME GMT offset DST adjustment DST Start Date rule Start time DST End date rule End time
3 Africa/Accra GMT GMT +00:00:00 +00:00:00 +00:00:00
4 Africa/Addis_Ababa EAT EAT +03:00:00 +00:00:00 +00:00:00
5 Africa/Algiers CET CET +01:00:00 +00:00:00 +00:00:00
Africa/Asmara EAT EAT +03:00:00 +00:00:00 +00:00:00
6 Africa/Asmera EAT EAT +03:00:00 +00:00:00 +00:00:00
7 Africa/Bamako GMT GMT +00:00:00 +00:00:00 +00:00:00
8 Africa/Bangui WAT WAT +01:00:00 +00:00:00 +00:00:00
11 Africa/Blantyre CAT CAT +02:00:00 +00:00:00 +00:00:00
12 Africa/Brazzaville WAT WAT +01:00:00 +00:00:00 +00:00:00
13 Africa/Bujumbura CAT CAT +02:00:00 +00:00:00 +00:00:00
14 Africa/Cairo EET EET EEST EEST +02:00:00 +00:00:00 +01:00:00 -1;5;4 +00:00:00 -1;5;9 +00:00:00
15 Africa/Casablanca WET WET WEST WEST +00:00:00 +01:00:00 +00:00:00 2;0;7 +02:00:00 -1;0;10 +03:00:00 +00:00:00
16 Africa/Ceuta CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
17 Africa/Conakry GMT GMT +00:00:00 +00:00:00 +00:00:00
18 Africa/Dakar GMT GMT +00:00:00 +00:00:00 +00:00:00
19 Africa/Dar_es_Salaam EAT EAT +03:00:00 +00:00:00 +00:00:00
20 Africa/Djibouti EAT EAT +03:00:00 +00:00:00 +00:00:00
21 Africa/Douala WAT WAT +01:00:00 +00:00:00 +00:00:00
22 Africa/El_Aaiun WET WET WEST WEST +00:00:00 +01:00:00 +00:00:00 2;0;7 +02:00:00 -1;0;10 +03:00:00 +00:00:00
23 Africa/Freetown GMT GMT +00:00:00 +00:00:00 +00:00:00
24 Africa/Gaborone CAT CAT +02:00:00 +00:00:00 +00:00:00
25 Africa/Harare CAT CAT +02:00:00 +00:00:00 +00:00:00
26 Africa/Johannesburg SAST SAST +02:00:00 +00:00:00 +00:00:00
Africa/Juba EAT EAT +03:00:00 +00:00:00 +00:00:00
27 Africa/Kampala EAT EAT +03:00:00 +00:00:00 +00:00:00
28 Africa/Khartoum EAT EAT +03:00:00 +00:00:00 +00:00:00
29 Africa/Kigali CAT CAT +02:00:00 +00:00:00 +00:00:00
46 Africa/Nouakchott GMT GMT +00:00:00 +00:00:00 +00:00:00
47 Africa/Ouagadougou GMT GMT +00:00:00 +00:00:00 +00:00:00
48 Africa/Porto-Novo WAT WAT +01:00:00 +00:00:00 +00:00:00
Africa/Porto_Novo WAT WAT +01:00:00 +00:00:00 +00:00:00
49 Africa/Sao_Tome GMT GMT +00:00:00 +00:00:00 +00:00:00
50 Africa/Timbuktu GMT GMT +00:00:00 +00:00:00 +00:00:00
51 Africa/Tripoli EET EET +02:00:00 +00:00:00 +00:00:00
52 Africa/Tunis CET CET +01:00:00 +00:00:00 +00:00:00
53 Africa/Windhoek WAT WAT WAST WAST +01:00:00 +01:00:00 1;0;9 +02:00:00 1;0;4 +02:00:00
54 America/Adak HST HAST HST HAST HDT HADT HDT HADT -10:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
55 America/Anchorage AKST AKST AKDT AKDT -09:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
56 America/Anguilla AST AST -04:00:00 +00:00:00 +00:00:00
57 America/Antigua AST AST -04:00:00 +00:00:00 +00:00:00
58 America/Araguaina BRT BRT BRST BRST -03:00:00 +00:00:00 +01:00:00 2;0;10 +00:00:00 3;0;2 +00:00:00
America/Argentina/Buenos_Aires ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/Catamarca ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/ComodRivadavia ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/Cordoba ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/Jujuy ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/La_Rioja ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/Mendoza ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/Rio_Gallegos ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/Salta ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/San_Juan ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/San_Luis ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/Tucuman ART ART -03:00:00 +00:00:00 +00:00:00
America/Argentina/Ushuaia ART ART -03:00:00 +00:00:00 +00:00:00
59 America/Aruba AST AST -04:00:00 +00:00:00 +00:00:00
60 America/Asuncion PYT PYT PYST PYST -04:00:00 +01:00:00 1;0;10 +00:00:00 -1;0;3 1;0;3 +00:00:00
America/Atikokan EST EST -05:00:00 +00:00:00 +00:00:00
America/Atka HST HST HDT HDT -10:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Bahia BRT BRT -03:00:00 +00:00:00 +00:00:00
America/Bahia_Banderas CST CST CDT CDT -06:00:00 +01:00:00 1;0;4 +02:00:00 -1;0;10 +02:00:00
61 America/Barbados AST AST -04:00:00 +00:00:00 +00:00:00
62 America/Belem BRT BRT -03:00:00 +00:00:00 +00:00:00
63 America/Belize CST CST -06:00:00 +00:00:00 +00:00:00
America/Beulah CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Blanc-Sablon AST AST -04:00:00 +00:00:00 +00:00:00
America/Blanc_Sablon AST AST -04:00:00 +00:00:00 +00:00:00
64 America/Boa_Vista AMT AMT -04:00:00 +00:00:00 +00:00:00
65 America/Bogota COT COT -05:00:00 +00:00:00 +00:00:00
66 America/Boise MST MST MDT MDT -07:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
67 America/Buenos_Aires ART ART -03:00:00 +00:00:00 +00:00:00
68 America/Cambridge_Bay MST MST MDT MDT -07:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
69 America/Campo_Grande America/Cancun AMT CST AMT CST AMST CDT AMST CDT -04:00:00 -06:00:00 +01:00:00 3;0;10 1;0;5 +00:00:00 +02:00:00 3;0;2 -1;0;9 +00:00:00 +02:00:00
70 America/Cancun America/Caracas EST VET EST VET -05:00:00 -04:00:00 +00:00:00 +00:00:00
America/Caracas VET VET -04:30:00 +00:00:00 +00:00:00
71 America/Catamarca ART ART -03:00:00 +00:00:00 +00:00:00
72 America/Cayenne GFT GFT -03:00:00 +00:00:00 +00:00:00
73 America/Cayman EST EST -05:00:00 +00:00:00 +00:00:00
74 America/Center America/Chicago CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
75 America/Chicago America/Chihuahua CST MST Central Standard Time MST CDT MDT Central Daylight Time MDT -06:00:00 -07:00:00 +01:00:00 2;0;3 1;0;5 +02:00:00 1;0;11 -1;0;9 +02:00:00
America/Chihuahua MST MST MDT MDT -07:00:00 +01:00:00 1;0;4 +02:00:00 -1;0;10 +02:00:00
America/ComodRivadavia ART ART -03:00:00 +00:00:00 +00:00:00
America/Coral_Harbour EST EST -05:00:00 +00:00:00 +00:00:00
76 America/Cordoba ART ART -03:00:00 +00:00:00 +00:00:00
77 America/Costa_Rica CST CST -06:00:00 +00:00:00 +00:00:00
78 America/Creston America/Cuiaba MST AMT MST AMT AMST AMST -07:00:00 -04:00:00 +00:00:00 +01:00:00 2;0;10 +00:00:00 3;0;2 +00:00:00
America/Cuiaba AMT AMT AMST AMST -04:00:00 +01:00:00 3;0;10 +00:00:00 3;0;2 +00:00:00
79 America/Curacao AST AST -04:00:00 +00:00:00 +00:00:00
80 America/Danmarkshavn GMT GMT +00:00:00 +00:00:00 +00:00:00
81 America/Dawson PST PST PDT PDT -08:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
82 America/Dawson_Creek MST MST -07:00:00 +00:00:00 +00:00:00
83 America/Denver MST Mountain Standard Time MST MDT Mountain Daylight Time MDT -07:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
84 America/Detroit EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
85 America/Dominica AST AST -04:00:00 +00:00:00 +00:00:00
86 America/Edmonton MST MST MDT MDT -07:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
87 America/Eirunepe ACT ACT -05:00:00 +00:00:00 +00:00:00
88 America/El_Salvador CST CST -06:00:00 +00:00:00 +00:00:00
89 America/Ensenada America/Fortaleza PST BRT PST BRT PDT BRST PDT BRST -08:00:00 -03:00:00 +01:00:00 2;0;3 2;0;10 +02:00:00 +00:00:00 1;0;11 3;0;2 +02:00:00 +00:00:00
90 America/Fortaleza America/Glace_Bay BRT AST BRT AST ADT ADT -03:00:00 -04:00:00 +00:00:00 +01:00:00 1;0;4 +02:00:00 -1;0;10 +00:00:00 +02:00:00
America/Fort_Wayne EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Glace_Bay AST AST ADT ADT -04:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
91 America/Godthab WGT WGT WGST WGST -03:00:00 +01:00:00 -1;6;3 +22:00:00 -1;6;10 +23:00:00
92 America/Goose_Bay AST AST ADT ADT -04:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 +00:01:00 1;0;11 -1;0;10 +02:00:00 +00:01:00
93 America/Grand_Turk AST EST AST EST EDT EDT -04:00:00 -05:00:00 +00:00:00 +01:00:00 1;0;4 +00:00:00 -1;0;10 +00:00:00
94 America/Grenada AST AST -04:00:00 +00:00:00 +00:00:00
95 America/Guadeloupe AST AST -04:00:00 +00:00:00 +00:00:00
96 America/Guatemala CST CST -06:00:00 +00:00:00 +00:00:00
97 America/Guayaquil ECT ECT -05:00:00 +00:00:00 +00:00:00
98 America/Guyana GYT GYT -04:00:00 +00:00:00 +00:00:00
99 America/Halifax AST AST ADT ADT -04:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
100 America/Havana CST CST CDT CDT -05:00:00 +01:00:00 2;0;3 1;0;4 +00:00:00 1;0;11 -1;0;10 +01:00:00
101 America/Hermosillo MST MST -07:00:00 +00:00:00 +00:00:00
102 America/Indiana/Indianapolis EST EST EDT EDT -05:00:00 +01:00:00 +00:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00 +00:00:00
103 America/Indiana/Knox CST EST CST EST CDT CDT -06:00:00 -05:00:00 +01:00:00 +00:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00 +00:00:00
104 America/Indiana/Marengo EST EST EDT EDT -05:00:00 +01:00:00 +00:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00 +00:00:00
105 America/Indiana/Petersburg America/Indiana/Vevay EST EST EDT EDT -05:00:00 +01:00:00 +00:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00 +00:00:00
106 America/Indiana/Tell_City America/Indianapolis CST EST CST EST CDT CDT -06:00:00 -05:00:00 +01:00:00 +00:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00 +00:00:00
107 America/Indiana/Vevay America/Inuvik EST MST EST MST EDT MDT EDT MDT -05:00:00 -07:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
108 America/Indiana/Vincennes America/Iqaluit EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
America/Indiana/Winamac EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Indianapolis EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Inuvik MST MST MDT MDT -07:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Iqaluit EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
109 America/Jamaica EST EST -05:00:00 +00:00:00 +00:00:00
110 America/Jujuy ART ART -03:00:00 +00:00:00 +00:00:00
111 America/Juneau AKST AKST AKDT AKDT -09:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
112 America/Kentucky/Louisville EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
113 America/Kentucky/Monticello EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
America/Knox CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Knox_IN CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Kralendijk AST AST -04:00:00 +00:00:00 +00:00:00
114 America/La_Paz BOT BOT -04:00:00 +00:00:00 +00:00:00
America/La_Rioja ART ART -03:00:00 +00:00:00 +00:00:00
115 America/Lima PET PET -05:00:00 +00:00:00 +00:00:00
116 America/Los_Angeles PST Pacific Standard Time PST PDT Pacific Daylight Time PDT -08:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
117 America/Louisville EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
118 America/Lower_Princes America/Maceio AST BRT AST BRT BRST BRST -04:00:00 -03:00:00 +00:00:00 +01:00:00 2;0;10 +00:00:00 3;0;2 +00:00:00
America/Maceio BRT BRT -03:00:00 +00:00:00 +00:00:00
119 America/Managua CST CST -06:00:00 +00:00:00 +00:00:00
120 America/Manaus AMT AMT -04:00:00 +00:00:00 +00:00:00
America/Marengo EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Marigot AST AST -04:00:00 +00:00:00 +00:00:00
121 America/Martinique AST AST -04:00:00 +00:00:00 +00:00:00
122 America/Matamoros America/Mazatlan CST MST CST MST CDT MDT CDT MDT -06:00:00 -07:00:00 +01:00:00 2;0;3 1;0;5 +02:00:00 1;0;11 -1;0;9 +02:00:00
America/Mazatlan MST MST MDT MDT -07:00:00 +01:00:00 1;0;4 +02:00:00 -1;0;10 +02:00:00
123 America/Mendoza ART ART -03:00:00 +00:00:00 +00:00:00
124 America/Menominee CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
125 America/Merida CST CST CDT CDT -06:00:00 +01:00:00 1;0;4 1;0;5 +02:00:00 -1;0;10 -1;0;9 +02:00:00
126 America/Metlakatla America/Mexico_City AKST CST AKST CST AKDT AKDT -09:00:00 -06:00:00 +01:00:00 +00:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00 +00:00:00
127 America/Mexico_City America/Miquelon CST PMST CST PMST CDT PMDT CDT PMDT -06:00:00 -03:00:00 +01:00:00 1;0;4 +02:00:00 -1;0;10 +02:00:00
128 America/Miquelon America/Monterrey PMST CST PMST CST PMDT CDT PMDT CDT -03:00:00 -06:00:00 +01:00:00 2;0;3 1;0;5 +02:00:00 1;0;11 -1;0;9 +02:00:00
America/Moncton AST AST ADT ADT -04:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Monterrey CST CST CDT CDT -06:00:00 +01:00:00 1;0;4 +02:00:00 -1;0;10 +02:00:00
129 America/Montevideo UYT UYT -03:00:00 +00:00:00 +00:00:00
130 America/Monticello America/Montreal EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
America/Montreal EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
131 America/Montserrat AST AST -04:00:00 +00:00:00 +00:00:00
132 America/Nassau EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
133 America/New_Salem America/New_York CST EST CST EST CDT EDT CDT EDT -06:00:00 -05:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
134 America/New_York America/Nipigon EST Eastern Standard Time EST EDT Eastern Daylight Time EDT -05:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
135 America/Nipigon America/Nome EST AKST EST AKST EDT AKDT EDT AKDT -05:00:00 -09:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
America/Nome AKST AKST AKDT AKDT -09:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
136 America/Noronha FNT FNT -02:00:00 +00:00:00 +00:00:00
137 America/North_Dakota/Beulah America/North_Dakota/Center CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
America/North_Dakota/Center CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/North_Dakota/New_Salem CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Ojinaga MST MST MDT MDT -07:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
138 America/Panama EST EST -05:00:00 +00:00:00 +00:00:00
139 America/Pangnirtung EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
140 America/Paramaribo SRT SRT -03:00:00 +00:00:00 +00:00:00
141 America/Petersburg America/Phoenix EST MST EST MST EDT EDT -05:00:00 -07:00:00 +01:00:00 +00:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00 +00:00:00
America/Phoenix MST Mountain Standard Time -07:00:00 +00:00:00 +00:00:00
142 America/Port-au-Prince EST EST -05:00:00 +00:00:00 +00:00:00
America/Porto_Acre ACT ACT -05:00:00 +00:00:00 +00:00:00
America/Porto_Velho AMT AMT -04:00:00 +00:00:00 +00:00:00
America/Port_au_Prince EST EST -05:00:00 +00:00:00 +00:00:00
143 America/Port_of_Spain AST AST -04:00:00 +00:00:00 +00:00:00
144 America/Porto_Velho AMT AMT -04:00:00 +00:00:00 +00:00:00
145 America/Puerto_Rico AST AST -04:00:00 +00:00:00 +00:00:00
146 America/Rainy_River CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
147 America/Rankin_Inlet CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
148 America/Recife BRT BRT BRST BRST -03:00:00 +00:00:00 +01:00:00 2;0;10 +00:00:00 3;0;2 +00:00:00
149 America/Regina CST CST -06:00:00 +00:00:00 +00:00:00
America/Resolute CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
150 America/Rio_Branco ACT ACT -05:00:00 +00:00:00 +00:00:00
America/Rio_Gallegos ART ART -03:00:00 +00:00:00 +00:00:00
151 America/Rosario ART ART -03:00:00 +00:00:00 +00:00:00
152 America/Salta America/Santiago ART CLT ART CLT CLST CLST -03:00:00 -04:00:00 +00:00:00 +01:00:00 2;0;10 +00:00:00 2;0;3 +00:00:00
America/Santarem BRT BRT -03:00:00 +00:00:00 +00:00:00
America/Santa_Isabel PST PST PDT PDT -08:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Santiago CLT CLT CLST CLST -04:00:00 +01:00:00 2;0;8 +00:00:00 3;0;5 +00:00:00
153 America/Santo_Domingo AST AST -04:00:00 +00:00:00 +00:00:00
154 America/San_Juan America/Sao_Paulo ART BRT ART BRT BRST BRST -03:00:00 +00:00:00 +01:00:00 2;0;10 +00:00:00 3;0;2 +00:00:00
America/San_Luis ART ART -03:00:00 +00:00:00 +00:00:00
America/Sao_Paulo BRT BRT BRST BRST -03:00:00 +01:00:00 3;0;10 +00:00:00 3;0;2 +00:00:00
155 America/Scoresbysund EGT EGT EGST EGST -01:00:00 +01:00:00 -1;0;3 +00:00:00 -1;0;10 +01:00:00
156 America/Shiprock MST MST MDT MDT -07:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
157 America/Sitka America/St_Johns AKST NST AKST NST AKDT NDT AKDT NDT -09:00:00 -03:30:00 +01:00:00 2;0;3 1;0;4 +02:00:00 +00:01:00 1;0;11 -1;0;10 +02:00:00 +00:01:00
America/St_Barthelemy AST AST -04:00:00 +00:00:00 +00:00:00
America/St_Johns NST NST NDT NDT -03:30:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
158 America/St_Kitts AST AST -04:00:00 +00:00:00 +00:00:00
159 America/St_Lucia AST AST -04:00:00 +00:00:00 +00:00:00
160 America/St_Thomas AST AST -04:00:00 +00:00:00 +00:00:00
161 America/St_Vincent AST AST -04:00:00 +00:00:00 +00:00:00
162 America/Swift_Current CST CST -06:00:00 +00:00:00 +00:00:00
163 America/Tegucigalpa CST CST -06:00:00 +00:00:00 +00:00:00
164 America/Tell_City America/Thule CST AST CST AST CDT CDT -06:00:00 -04:00:00 +01:00:00 +00:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00 +00:00:00
165 America/Thule America/Thunder_Bay AST EST AST EST ADT EDT ADT EDT -04:00:00 -05:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
166 America/Thunder_Bay America/Tijuana EST PST EST PST EDT PDT EDT PDT -05:00:00 -08:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
America/Tijuana PST PST PDT PDT -08:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Toronto EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
167 America/Tortola AST AST -04:00:00 +00:00:00 +00:00:00
168 America/Tucuman America/Vancouver ART PST ART PST PDT PDT -03:00:00 -08:00:00 +00:00:00 +01:00:00 1;0;4 +02:00:00 -1;0;10 +00:00:00 +02:00:00
169 America/Ushuaia America/Whitehorse ART PST ART PST PDT PDT -03:00:00 -08:00:00 +00:00:00 +01:00:00 1;0;4 +02:00:00 -1;0;10 +00:00:00 +02:00:00
170 America/Vancouver America/Winnipeg PST CST PST CST PDT CDT PDT CDT -08:00:00 -06:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00 +03:00:00
171 America/Vevay America/Yakutat EST AKST EST AKST EDT AKDT EDT AKDT -05:00:00 -09:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
172 America/Vincennes America/Yellowknife EST MST EST MST EDT MDT EDT MDT -05:00:00 -07:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
173 America/Virgin Antarctica/Casey AST WST AST WST -04:00:00 +08:00:00 +00:00:00 +00:00:00
America/Whitehorse PST PST PDT PDT -08:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Winamac EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Winnipeg CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Yakutat AKST AKST AKDT AKDT -09:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
America/Yellowknife MST MST MDT MDT -07:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
Antarctica/Casey AWST AWST +08:00:00 +00:00:00 +00:00:00
174 Antarctica/Davis DAVT DAVT +07:00:00 +00:00:00 +00:00:00
175 Antarctica/DumontDUrville DDUT DDUT +10:00:00 +00:00:00 +00:00:00
176 Antarctica/Macquarie Antarctica/Mawson MIST MAWT MIST MAWT +11:00:00 +06:00:00 +00:00:00 +00:00:00
177 Antarctica/Mawson Antarctica/McMurdo MAWT NZST MAWT NZST NZDT NZDT +05:00:00 +12:00:00 +00:00:00 +01:00:00 1;0;10 +02:00:00 3;0;3 +00:00:00 +03:00:00
178 Antarctica/McMurdo Antarctica/Palmer NZST CLT NZST CLT NZDT CLST NZDT CLST +12:00:00 -04:00:00 +01:00:00 -1;0;9 2;0;10 +02:00:00 +00:00:00 1;0;4 2;0;3 +03:00:00 +00:00:00
179 Antarctica/Palmer Antarctica/South_Pole CLT NZST CLT NZST CLST NZDT CLST NZDT -04:00:00 +12:00:00 +01:00:00 2;0;8 1;0;10 +00:00:00 +02:00:00 3;0;5 3;0;3 +00:00:00 +03:00:00
Antarctica/Rothera ROTT ROTT -03:00:00 +00:00:00 +00:00:00
Antarctica/South_Pole NZST NZST NZDT NZDT +12:00:00 +01:00:00 -1;0;9 +02:00:00 1;0;4 +03:00:00
180 Antarctica/Syowa SYOT SYOT +03:00:00 +00:00:00 +00:00:00
Antarctica/Troll UTC UTC CEST CEST +00:00:00 +02:00:00 -1;0;3 +01:00:00 -1;0;10 +03:00:00
181 Antarctica/Vostok VOST VOST +06:00:00 +00:00:00 +00:00:00
182 Arctic/Longyearbyen CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
183 Asia/Aden AST AST +03:00:00 +00:00:00 +00:00:00
184 Asia/Almaty ALMT ALMT ALMST ALMST +06:00:00 +00:00:00 +01:00:00 -1;0;3 +00:00:00 -1;0;10 +00:00:00
185 Asia/Amman EET EET EEST EEST +02:00:00 +01:00:00 1;5;4 -1;4;3 +00:00:00 -1;5;10 -1;4;9 +01:00:00
186 Asia/Anadyr ANAT ANAT ANAST ANAST +12:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
187 Asia/Aqtau AQTT AQTT AQTST AQTST +05:00:00 +04:00:00 +00:00:00 +01:00:00 -1;0;3 +00:00:00 -1;0;10 +00:00:00
188 Asia/Aqtobe AQTT AQTT AQTST AQTST +05:00:00 +00:00:00 +01:00:00 -1;0;3 +00:00:00 -1;0;10 +00:00:00
189 Asia/Ashgabat TMT TMT +05:00:00 +00:00:00 +00:00:00
190 Asia/Ashkhabad Asia/Baghdad TMT AST TMT AST ADT ADT +05:00:00 +03:00:00 +00:00:00 +01:00:00 1;0;4 +03:00:00 1;0;10 +00:00:00 +04:00:00
Asia/Baghdad AST AST +03:00:00 +00:00:00 +00:00:00
191 Asia/Bahrain AST AST +03:00:00 +00:00:00 +00:00:00
192 Asia/Baku AZT AZT AZST AZST +04:00:00 +00:00:00 +01:00:00 -1;0;3 +01:00:00 -1;0;10 +00:00:00 +01:00:00
193 Asia/Bangkok ICT ICT +07:00:00 +00:00:00 +00:00:00
194 Asia/Beirut EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +00:00:00 -1;0;10 +00:00:00
195 Asia/Bishkek KGT KGT KGST KGST +06:00:00 +05:00:00 +00:00:00 +01:00:00 -1;0;3 +02:30:00 -1;0;10 +00:00:00 +02:30:00
196 Asia/Brunei BNT BNT +08:00:00 +00:00:00 +00:00:00
197 Asia/Calcutta IST IST +05:30:00 +00:00:00 +00:00:00
198 Asia/Chita Asia/Choibalsan YAKT CHOT YAKT CHOT +09:00:00 +00:00:00 +00:00:00
Asia/Choibalsan CHOT CHOT CHOST CHOST +08:00:00 +01:00:00 -1;6;3 +02:00:00 -1;6;9 +00:00:00
199 Asia/Chongqing CST CST +08:00:00 +00:00:00 +00:00:00
200 Asia/Chungking Asia/Colombo CST LKT CST LKT +08:00:00 +06:00:00 +00:00:00 +00:00:00
201 Asia/Colombo Asia/Damascus IST EET IST EET EEST EEST +05:30:00 +02:00:00 +00:00:00 +01:00:00 1;0;4 +00:00:00 1;0;10 +00:00:00
Asia/Dacca BDT BDT +06:00:00 +00:00:00 +00:00:00
Asia/Damascus EET EET EEST EEST +02:00:00 +01:00:00 -1;5;3 +00:00:00 -1;5;10 +00:00:00
202 Asia/Dhaka BDT BDT +06:00:00 +00:00:00 +00:00:00
203 Asia/Dili TLT TPT TLT TPT +09:00:00 +00:00:00 +00:00:00
204 Asia/Dubai GST GST +04:00:00 +00:00:00 +00:00:00
205 Asia/Dushanbe TJT TJT +05:00:00 +00:00:00 +00:00:00
206 Asia/Gaza EET EET EEST EEST +02:00:00 +01:00:00 -1;6;3 3;5;4 +01:00:00 +00:00:00 3;5;10 +00:00:00
207 Asia/Harbin CST CST +08:00:00 +00:00:00 +00:00:00
Asia/Hebron EET EET EEST EEST +02:00:00 +01:00:00 -1;6;3 +01:00:00 3;5;10 +00:00:00
208 Asia/Hong_Kong HKT HKT +08:00:00 +00:00:00 +00:00:00
209 Asia/Hovd HOVT HOVT HOVST HOVST +07:00:00 +01:00:00 +00:00:00 -1;6;3 +02:00:00 -1;6;9 +00:00:00
210 Asia/Ho_Chi_Minh Asia/Irkutsk ICT IRKT ICT IRKT IRKST IRKST +07:00:00 +08:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
Asia/Irkutsk IRKT IRKT +08:00:00 +00:00:00 +00:00:00
211 Asia/Istanbul EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
212 Asia/Jakarta WIB WIT WIB WIT +07:00:00 +00:00:00 +00:00:00
213 Asia/Jayapura WIT EIT WIT EIT +09:00:00 +00:00:00 +00:00:00
214 Asia/Jerusalem IST IST IDT IDT +02:00:00 +01:00:00 -1;5;3 1;0;4 +02:00:00 +01:00:00 -1;0;10 1;0;10 +02:00:00 +01:00:00
215 Asia/Kabul AFT AFT +04:30:00 +00:00:00 +00:00:00
216 Asia/Kamchatka PETT PETT PETST PETST +12:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
217 Asia/Karachi PKT PKT +05:00:00 +00:00:00 +00:00:00
218 Asia/Kashgar XJT CST XJT CST +06:00:00 +08:00:00 +00:00:00 +00:00:00
Asia/Kathmandu NPT NPT +05:45:00 +00:00:00 +00:00:00
219 Asia/Katmandu NPT NPT +05:45:00 +00:00:00 +00:00:00
220 Asia/Khandyga Asia/Krasnoyarsk YAKT KRAT YAKT KRAT KRAST KRAST +09:00:00 +07:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
Asia/Kolkata IST IST +05:30:00 +00:00:00 +00:00:00
Asia/Krasnoyarsk KRAT KRAT +07:00:00 +00:00:00 +00:00:00
221 Asia/Kuala_Lumpur MYT MYT +08:00:00 +00:00:00 +00:00:00
222 Asia/Kuching MYT MYT +08:00:00 +00:00:00 +00:00:00
223 Asia/Kuwait AST AST +03:00:00 +00:00:00 +00:00:00
224 Asia/Macao CST CST +08:00:00 +00:00:00 +00:00:00
225 Asia/Macau Asia/Magadan CST MAGT CST MAGT MAGST MAGST +08:00:00 +11:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
Asia/Magadan MAGT MAGT +10:00:00 +00:00:00 +00:00:00
Asia/Makassar WITA WITA +08:00:00 +00:00:00 +00:00:00
226 Asia/Manila PHT PHT +08:00:00 +00:00:00 +00:00:00
227 Asia/Muscat GST GST +04:00:00 +00:00:00 +00:00:00
228 Asia/Nicosia EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
229 Asia/Novokuznetsk Asia/Novosibirsk KRAT NOVT KRAT NOVT NOVST NOVST +07:00:00 +06:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
230 Asia/Novosibirsk Asia/Omsk NOVT OMST NOVT OMST OMSST OMSST +06:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
Asia/Omsk OMST OMST +06:00:00 +00:00:00 +00:00:00
Asia/Oral ORAT ORAT +05:00:00 +00:00:00 +00:00:00
231 Asia/Phnom_Penh ICT ICT +07:00:00 +00:00:00 +00:00:00
232 Asia/Pontianak WIB WIT WIB WIT +07:00:00 +00:00:00 +00:00:00
233 Asia/Pyongyang KST KST +08:30:00 +09:00:00 +00:00:00 +00:00:00
234 Asia/Qatar AST AST +03:00:00 +00:00:00 +00:00:00
Asia/Qyzylorda QYZT QYZT +06:00:00 +00:00:00 +00:00:00
235 Asia/Rangoon MMT MMT +06:30:00 +00:00:00 +00:00:00
236 Asia/Riyadh AST AST +03:00:00 +00:00:00 +00:00:00
237 Asia/Saigon ICT ICT +07:00:00 +00:00:00 +00:00:00
238 Asia/Sakhalin SAKT SAKT SAKST SAKST +11:00:00 +10:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
239 Asia/Samarkand UZT UZT +05:00:00 +00:00:00 +00:00:00
240 Asia/Seoul KST KST +09:00:00 +00:00:00 +00:00:00
241 Asia/Shanghai CST CST +08:00:00 +00:00:00 +00:00:00
242 Asia/Singapore SGT SGT +08:00:00 +00:00:00 +00:00:00
Asia/Srednekolymsk SRET SRET +11:00:00 +00:00:00 +00:00:00
243 Asia/Taipei CST CST +08:00:00 +00:00:00 +00:00:00
244 Asia/Tashkent UZT UZT +05:00:00 +00:00:00 +00:00:00
245 Asia/Tbilisi GET GET GEST GEST +04:00:00 +00:00:00 +01:00:00 -1;0;3 +00:00:00 -1;0;10 +00:00:00
246 Asia/Tehran IRST IRT IRST IRT IRDT IRDT +03:30:00 +01:00:00 +00:00:00 3;1;3 +00:00:00 3;3;9 +00:00:00
Asia/Tel_Aviv IST IST IDT IDT +02:00:00 +01:00:00 -1;5;3 +02:00:00 -1;0;10 +02:00:00
Asia/Thimbu BTT BTT +06:00:00 +00:00:00 +00:00:00
247 Asia/Thimphu BTT BTT +06:00:00 +00:00:00 +00:00:00
248 Asia/Tokyo JST JST +09:00:00 +00:00:00 +00:00:00
249 Asia/Ujung_Pandang WITA CIT WITA CIT +08:00:00 +00:00:00 +00:00:00
250 Asia/Ulaanbaatar ULAT ULAT ULAST ULAST +08:00:00 +01:00:00 +00:00:00 -1;6;3 +02:00:00 -1;6;9 +00:00:00
251 Asia/Ulan_Bator Asia/Urumqi ULAT CST ULAT CST ULAST ULAST +08:00:00 +01:00:00 +00:00:00 -1;6;3 +02:00:00 -1;6;9 +00:00:00
Asia/Urumqi XJT XJT +06:00:00 +00:00:00 +00:00:00
Asia/Ust-Nera VLAT VLAT +10:00:00 +00:00:00 +00:00:00
Asia/Ust_Nera VLAT VLAT +10:00:00 +00:00:00 +00:00:00
252 Asia/Vientiane ICT ICT +07:00:00 +00:00:00 +00:00:00
253 Asia/Vladivostok VLAT VLAT VLAST VLAST +10:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
254 Asia/Yakutsk YAKT YAKT YAKST YAKST +09:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
255 Asia/Yekaterinburg YEKT YEKT YEKST YEKST +05:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
256 Asia/Yerevan AMT AMT AMST AMST +04:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
257 Atlantic/Azores AZOT AZOT AZOST AZOST -01:00:00 +01:00:00 -1;0;3 +00:00:00 -1;0;10 +01:00:00
258 Atlantic/Bermuda AST AST ADT ADT -04:00:00 +01:00:00 2;0;3 1;0;4 +02:00:00 1;0;11 -1;0;10 +02:00:00
259 Atlantic/Canary WET WET WEST WEST +00:00:00 +01:00:00 -1;0;3 +01:00:00 -1;0;10 +02:00:00
260 Atlantic/Cape_Verde CVT CVT -01:00:00 +00:00:00 +00:00:00
261 Atlantic/Faeroe WET WET WEST WEST +00:00:00 +01:00:00 -1;0;3 +01:00:00 -1;0;10 +02:00:00
Atlantic/Faroe WET WET WEST WEST +00:00:00 +01:00:00 -1;0;3 +01:00:00 -1;0;10 +02:00:00
262 Atlantic/Jan_Mayen CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
263 Atlantic/Madeira WET WET WEST WEST +00:00:00 +01:00:00 -1;0;3 +01:00:00 -1;0;10 +02:00:00
264 Atlantic/Reykjavik GMT GMT +00:00:00 +00:00:00 +00:00:00
265 Atlantic/South_Georgia GST GST -02:00:00 +00:00:00 +00:00:00
Atlantic/Stanley FKST FKST -03:00:00 +00:00:00 +00:00:00
266 Atlantic/St_Helena GMT GMT +00:00:00 +00:00:00 +00:00:00
267 Australia/ACT Atlantic/Stanley AEST FKT AEST FKT AEDT FKST AEDT FKST +10:00:00 -04:00:00 +01:00:00 1;0;10 1;0;9 +02:00:00 1;0;4 3;0;4 +03:00:00 +02:00:00
268 Australia/Adelaide ACST CST ACST CST ACDT CST ACDT CST +09:30:00 +01:00:00 1;0;10 -1;0;10 +02:00:00 1;0;4 -1;0;3 +03:00:00
269 Australia/Brisbane AEST EST AEST EST +10:00:00 +00:00:00 +00:00:00
270 Australia/Broken_Hill ACST CST ACST CST ACDT CST ACDT CST +09:30:00 +01:00:00 1;0;10 -1;0;10 +02:00:00 1;0;4 -1;0;3 +03:00:00
271 Australia/Canberra Australia/Darwin AEST CST AEST CST AEDT AEDT +10:00:00 +09:30:00 +01:00:00 +00:00:00 1;0;10 +02:00:00 1;0;4 +03:00:00 +00:00:00
272 Australia/Currie Australia/Hobart AEST EST AEST EST AEDT EST AEDT EST +10:00:00 +01:00:00 1;0;10 +02:00:00 1;0;4 -1;0;3 +03:00:00
273 Australia/Darwin Australia/Lindeman ACST EST ACST EST +09:30:00 +10:00:00 +00:00:00 +00:00:00
274 Australia/Eucla Australia/Lord_Howe ACWST LHST ACWST LHST LHST LHST +08:45:00 +10:30:00 +00:00:00 +00:30:00 -1;0;10 +02:00:00 -1;0;3 +00:00:00 +02:00:00
275 Australia/Hobart Australia/Melbourne AEST EST AEST EST AEDT EST AEDT EST +10:00:00 +01:00:00 1;0;10 -1;0;10 +02:00:00 1;0;4 -1;0;3 +03:00:00
276 Australia/LHI Australia/Perth LHST WST LHST WST LHDT LHDT +10:30:00 +08:00:00 +00:30:00 +00:00:00 1;0;10 +02:00:00 1;0;4 +02:00:00 +00:00:00
277 Australia/Lindeman Australia/Sydney AEST EST AEST EST EST EST +10:00:00 +00:00:00 +01:00:00 -1;0;10 +02:00:00 -1;0;3 +00:00:00 +03:00:00
Australia/Lord_Howe LHST LHST LHDT LHDT +10:30:00 +00:30:00 1;0;10 +02:00:00 1;0;4 +02:00:00
Australia/Melbourne AEST AEST AEDT AEDT +10:00:00 +01:00:00 1;0;10 +02:00:00 1;0;4 +03:00:00
Australia/North ACST ACST +09:30:00 +00:00:00 +00:00:00
Australia/NSW AEST AEST AEDT AEDT +10:00:00 +01:00:00 1;0;10 +02:00:00 1;0;4 +03:00:00
Australia/Perth AWST AWST +08:00:00 +00:00:00 +00:00:00
Australia/Queensland AEST AEST +10:00:00 +00:00:00 +00:00:00
Australia/South ACST ACST ACDT ACDT +09:30:00 +01:00:00 1;0;10 +02:00:00 1;0;4 +03:00:00
Australia/Sydney AEST AEST AEDT AEDT +10:00:00 +01:00:00 1;0;10 +02:00:00 1;0;4 +03:00:00
Australia/Tasmania AEST AEST AEDT AEDT +10:00:00 +01:00:00 1;0;10 +02:00:00 1;0;4 +03:00:00
Australia/Victoria AEST AEST AEDT AEDT +10:00:00 +01:00:00 1;0;10 +02:00:00 1;0;4 +03:00:00
Australia/West AWST AWST +08:00:00 +00:00:00 +00:00:00
Australia/Yancowinna ACST ACST ACDT ACDT +09:30:00 +01:00:00 1;0;10 +02:00:00 1;0;4 +03:00:00
Brazil/Acre ACT ACT -05:00:00 +00:00:00 +00:00:00
Brazil/DeNoronha FNT FNT -02:00:00 +00:00:00 +00:00:00
Brazil/East BRT BRT BRST BRST -03:00:00 +01:00:00 3;0;10 +00:00:00 3;0;2 +00:00:00
Brazil/West AMT AMT -04:00:00 +00:00:00 +00:00:00
Canada/Atlantic AST AST ADT ADT -04:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
Canada/Central CST CST CDT CDT -06:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
Canada/East-Saskatchewan CST CST -06:00:00 +00:00:00 +00:00:00
Canada/Eastern EST EST EDT EDT -05:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
Canada/East_Saskatchewan CST CST -06:00:00 +00:00:00 +00:00:00
Canada/Mountain MST MST MDT MDT -07:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
Canada/Newfoundland NST NST NDT NDT -03:30:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
Canada/Pacific PST PST PDT PDT -08:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
Canada/Saskatchewan CST CST -06:00:00 +00:00:00 +00:00:00
Canada/Yukon PST PST PDT PDT -08:00:00 +01:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00
Chile/Continental CLT CLT CLST CLST -04:00:00 +01:00:00 2;0;8 +00:00:00 3;0;5 +00:00:00
Chile/EasterIsland EAST EAST EASST EASST -06:00:00 +01:00:00 2;6;8 +22:00:00 2;6;5 +22:00:00
Etc/GMT GMT GMT +00:00:00 +00:00:00 +00:00:00
Etc/Greenwich GMT GMT +00:00:00 +00:00:00 +00:00:00
Etc/UCT UCT UCT +00:00:00 +00:00:00 +00:00:00
Etc/Universal UTC UTC +00:00:00 +00:00:00 +00:00:00
Etc/UTC UTC UTC +00:00:00 +00:00:00 +00:00:00
Etc/Zulu UTC UTC +00:00:00 +00:00:00 +00:00:00
278 Europe/Amsterdam CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
279 Europe/Andorra CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
280 Europe/Athens EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
285 Europe/Brussels CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
286 Europe/Bucharest EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
287 Europe/Budapest CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
288 Europe/Busingen Europe/Chisinau CET EET CET EET CEST EEST CEST EEST +01:00:00 +02:00:00 +01:00:00 -1;0;3 +02:00:00 +03:00:00 -1;0;10 +03:00:00 +04:00:00
Europe/Chisinau EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
289 Europe/Copenhagen CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
290 Europe/Dublin GMT GMT IST IST +00:00:00 +01:00:00 -1;0;3 +01:00:00 -1;0;10 +02:00:00
291 Europe/Gibraltar CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
Europe/Guernsey GMT GMT BST BST +00:00:00 +01:00:00 -1;0;3 +01:00:00 -1;0;10 +02:00:00
292 Europe/Helsinki EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
Europe/Isle_of_Man GMT GMT BST BST +00:00:00 +01:00:00 -1;0;3 +01:00:00 -1;0;10 +02:00:00
293 Europe/Istanbul EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
294 Europe/Jersey Europe/Kaliningrad GMT EET GMT EET BST EEST BST EEST +00:00:00 +02:00:00 +01:00:00 -1;0;3 +01:00:00 +02:00:00 -1;0;10 +02:00:00 +03:00:00
Europe/Kaliningrad EET EET +02:00:00 +00:00:00 +00:00:00
295 Europe/Kiev EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
296 Europe/Lisbon WET WET WEST WEST +00:00:00 +01:00:00 -1;0;3 +01:00:00 -1;0;10 +02:00:00
297 Europe/Ljubljana CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
299 Europe/Luxembourg CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
300 Europe/Madrid CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
301 Europe/Malta CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
302 Europe/Mariehamn Europe/Minsk EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 +02:00:00 -1;0;10 +04:00:00 +03:00:00
Europe/Minsk MSK MSK +03:00:00 +00:00:00 +00:00:00
303 Europe/Monaco CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
304 Europe/Moscow MSK MSK MSD MSD +03:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
305 Europe/Nicosia EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
306 Europe/Oslo CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
307 Europe/Paris CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
Europe/Podgorica CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
308 Europe/Prague CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
309 Europe/Riga EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
310 Europe/Rome CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
311 Europe/Samara SAMT SAMT SAMST SAMST +04:00:00 +00:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +00:00:00 +03:00:00
312 Europe/San_Marino CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
313 Europe/Sarajevo CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
314 Europe/Simferopol MSK EET MSK EET EEST EEST +03:00:00 +02:00:00 +00:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +00:00:00 +04:00:00
315 Europe/Skopje CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
316 Europe/Sofia EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
317 Europe/Stockholm CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
318 Europe/Tallinn EET EET EEST EEST +02:00:00 +01:00:00 +00:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00 +00:00:00
319 Europe/Tirane CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
Europe/Tiraspol EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
320 Europe/Uzhgorod EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
321 Europe/Vaduz CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
322 Europe/Vatican CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
323 Europe/Vienna CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
324 Europe/Vilnius EET EET EEST EEST +02:00:00 +01:00:00 +00:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00 +00:00:00
Europe/Volgograd MSK MSK +03:00:00 +00:00:00 +00:00:00
325 Europe/Warsaw CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
326 Europe/Zagreb CET CET CEST CEST +01:00:00 +01:00:00 -1;0;3 +02:00:00 -1;0;10 +03:00:00
327 Europe/Zaporozhye EET EET EEST EEST +02:00:00 +01:00:00 -1;0;3 +03:00:00 -1;0;10 +04:00:00
337 Indian/Mauritius MUT MUT +04:00:00 +00:00:00 +00:00:00
338 Indian/Mayotte EAT EAT +03:00:00 +00:00:00 +00:00:00
339 Indian/Reunion RET RET +04:00:00 +00:00:00 +00:00:00
340 Mexico/BajaNorte Pacific/Apia PST WST PST WST PDT PDT -08:00:00 -11:00:00 +01:00:00 +00:00:00 2;0;3 +02:00:00 1;0;11 +02:00:00 +00:00:00
341 Mexico/BajaSur Pacific/Auckland MST NZST MST NZST MDT NZDT MDT NZDT -07:00:00 +12:00:00 +01:00:00 1;0;4 1;0;10 +02:00:00 -1;0;10 3;0;3 +02:00:00 +03:00:00
342 Mexico/General Pacific/Chatham CST CHAST CST CHAST CDT CHADT CDT CHADT -06:00:00 +12:45:00 +01:00:00 1;0;4 1;0;10 +02:00:00 +02:45:00 -1;0;10 3;0;3 +02:00:00 +03:45:00
343 Pacific/Apia Pacific/Easter WSST EAST WSST EAST WSDT EASST WSDT EASST +13:00:00 -06:00:00 +01:00:00 -1;0;9 2;6;10 +03:00:00 +22:00:00 1;0;4 2;6;3 +04:00:00 +22:00:00
Pacific/Auckland NZST NZST NZDT NZDT +12:00:00 +01:00:00 -1;0;9 +02:00:00 1;0;4 +03:00:00
Pacific/Chatham CHAST CHAST CHADT CHADT +12:45:00 +01:00:00 -1;0;9 +02:00:00 1;0;4 +03:00:00
Pacific/Chuuk CHUT CHUT +10:00:00 +00:00:00 +00:00:00
Pacific/Easter EAST EAST EASST EASST -06:00:00 +01:00:00 2;6;8 +22:00:00 2;6;5 +22:00:00
344 Pacific/Efate VUT VUT +11:00:00 +00:00:00 +00:00:00
345 Pacific/Enderbury PHOT PHOT +13:00:00 +00:00:00 +00:00:00
346 Pacific/Fakaofo TKT TKT +13:00:00 -10:00:00 +00:00:00 +00:00:00
347 Pacific/Fiji FJT FJT FJST FJST +12:00:00 +01:00:00 +00:00:00 1;0;11 +02:00:00 3;0;1 +03:00:00 +00:00:00
348 Pacific/Funafuti TVT TVT +12:00:00 +00:00:00 +00:00:00
349 Pacific/Galapagos GALT GALT -06:00:00 +00:00:00 +00:00:00
350 Pacific/Gambier GAMT GAMT -09:00:00 +00:00:00 +00:00:00
360 Pacific/Midway SST SST -11:00:00 +00:00:00 +00:00:00
361 Pacific/Nauru NRT NRT +12:00:00 +00:00:00 +00:00:00
362 Pacific/Niue NUT NUT -11:00:00 +00:00:00 +00:00:00
363 Pacific/Norfolk NFT NFT +11:00:00 +11:30:00 +00:00:00 +00:00:00
364 Pacific/Noumea NCT NCT +11:00:00 +00:00:00 +00:00:00
365 Pacific/Pago_Pago SST SST -11:00:00 +00:00:00 +00:00:00
366 Pacific/Palau PWT PWT +09:00:00 +00:00:00 +00:00:00
367 Pacific/Pitcairn PST PST -08:00:00 +00:00:00 +00:00:00
Pacific/Pohnpei PONT PONT +11:00:00 +00:00:00 +00:00:00
368 Pacific/Ponape PONT PONT +11:00:00 +00:00:00 +00:00:00
369 Pacific/Port_Moresby PGT PGT +10:00:00 +00:00:00 +00:00:00
370 Pacific/Rarotonga CKT CKT -10:00:00 +00:00:00 +00:00:00
371 Pacific/Saipan ChST ChST +10:00:00 +00:00:00 +00:00:00
Pacific/Samoa SST SST -11:00:00 +00:00:00 +00:00:00
372 Pacific/Tahiti TAHT TAHT -10:00:00 +00:00:00 +00:00:00
373 Pacific/Tarawa GILT GILT +12:00:00 +00:00:00 +00:00:00
374 Pacific/Tongatapu TOT TOT +13:00:00 +00:00:00 +00:00:00
375 Pacific/Truk CHUT TRUT CHUT TRUT +10:00:00 +00:00:00 +00:00:00
376 Pacific/Wake WAKT WAKT +12:00:00 +00:00:00 +00:00:00
377 Pacific/Wallis WFT WFT +12:00:00 +00:00:00 +00:00:00
378 Pacific/Yap CHUT YAPT CHUT YAPT +10:00:00 +00:00:00 +00:00:00
-18
View File
@@ -1,18 +0,0 @@
# Copyright (c) 2016 Rene Rivera
#
# 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 ;
###############################################################################
alias boostdoc
: ../xmldoc/date_time.xml
:
: <dependency>../xmldoc//date_time_autodoc <dependency>../xmldoc//gregorian_autodoc
<dependency>../xmldoc//posix_time_autodoc <dependency>../xmldoc//local_time_autodoc
: ;
explicit boostdoc ;
alias boostrelease ;
explicit boostrelease ;
-4
View File
@@ -5,9 +5,5 @@
<body>
Automatic redirection failed, please go to
<a href="../../../doc/html/date_time.html">../../../doc/html/date_time.html</a>
<p>© Copyright CrystalClear Software, Inc 2003-2006</p>
<p> Use, modification, and distribution are subject to the Boost Software
License, Version 1.0. (See accompanying file <a href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt">
www.boost.org/LICENSE_1_0.txt</a>)</p>
</body>
</html>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

+73 -34
View File
@@ -1,47 +1,86 @@
project : requirements <library>/boost/date_time//boost_date_time ;
subproject libs/date_time/example ;
exe dates_as_strings : gregorian/dates_as_strings.cpp ;
exe days_alive : gregorian/days_alive.cpp ;
exe days_till_new_year : gregorian/days_till_new_year.cpp ;
exe days_between_new_years : gregorian/days_between_new_years.cpp ;
exe find_last_day_of_months : gregorian/find_last_day_of_months.cpp ;
exe month_add : gregorian/month_add.cpp ;
exe localization : gregorian/localization.cpp ;
exe print_holidays : gregorian/print_holidays.cpp ;
exe print_month : gregorian/print_month.cpp ;
exe period_calc : gregorian/period_calc.cpp ;
exe days_since_year_start : gregorian/days_since_year_start.cpp ;
local DATE_TIME_PROPERTIES = <define>BOOST_DATE_TIME_STATIC_LINK ;
exe local_utc_conversion : posix_time/local_utc_conversion.cpp
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
exe dates_as_strings : <lib>../build/boost_date_time
gregorian/dates_as_strings.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
;
exe days_alive : <lib>../build/boost_date_time
gregorian/days_alive.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
;
exe print_hours : posix_time/print_hours.cpp
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
exe days_till_new_year : <lib>../build/boost_date_time
gregorian/days_till_new_year.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
;
exe time_math : posix_time/time_math.cpp
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
exe days_between_new_years : <lib>../build/boost_date_time
gregorian/days_between_new_years.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
;
exe time_periods : posix_time/time_periods.cpp
: <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
;
exe end_of_month_day : <lib>../build/boost_date_time
gregorian/end_of_month_day.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
;
exe simple_time_zone : local_time/simple_time_zone.cpp ;
exe calc_rules : local_time/calc_rules.cpp ;
exe seconds_since_epoch : local_time/seconds_since_epoch.cpp ;
exe flight : local_time/flight.cpp ;
exe io_tutorial : tutorial/io_tutorial.cpp ;
exe month_add : <lib>../build/boost_date_time
gregorian/month_add.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
;
# Copyright (c) 2002-2005
exe localization : <lib>../build/boost_date_time
gregorian/localization.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
;
exe print_holidays : <lib>../build/boost_date_time
gregorian/print_holidays.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
;
exe print_month : <lib>../build/boost_date_time
gregorian/print_month.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
;
exe period_calc : <lib>../build/boost_date_time
gregorian/period_calc.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
;
exe days_since_year_start : <lib>../build/boost_date_time
gregorian/days_since_year_start.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES)
;
exe local_utc_conversion : <lib>../build/boost_date_time
posix_time/local_utc_conversion.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
;
exe print_hours : <lib>../build/boost_date_time
posix_time/print_hours.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
;
exe time_math : <lib>../build/boost_date_time
posix_time/time_math.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
;
exe time_periods : <lib>../build/boost_date_time
posix_time/time_periods.cpp
: <include>$(BOOST_ROOT) $(DATE_TIME_PROPERTIES) <define>BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG
;
# Copyright (c) 2002-2004
# CrystalClear Software, Inc.
# Subject to the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or
# http://www.boost.org/LICENSE_1_0.txt)
# Subject to the Boost Software License, Version 1.0.
# (See accompanying file LICENSE-1.0 or
# http://www.boost.org/LICENSE-1.0)
-5
View File
@@ -1,8 +1,3 @@
# Copyright (c) 2002-2006 CrystalClear Software, Inc.
# Use, modification and distribution is subject to the
# Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
#
project
: requirements <library>../../build/boost_date_time
@@ -122,6 +122,6 @@ main()
* 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)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+2 -2
View File
@@ -25,7 +25,7 @@ main()
date d(from_simple_string(s));
std::cout << to_simple_string(d) << std::endl;
//Read ISO 8601 Standard(CCYYMMDD) and output ISO 8601 Extended
//Read ISO Standard(CCYYMMDD) and output ISO Extended
std::string ud("20011009"); //2001-Oct-09
date d1(from_undelimited_string(ud));
std::cout << to_iso_extended_string(d1) << std::endl;
@@ -58,6 +58,6 @@ main()
* 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)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+1 -1
View File
@@ -42,6 +42,6 @@ main()
* 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)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+4 -5
View File
@@ -3,11 +3,10 @@
* New Years day of this year, and days until next New Years day.
*
* Expected results:
* Adding together both durations will produce 365 (366 in a leap year).
* Adding together both durations will produce 366 (365 in a leap year).
*/
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
#include "boost/date_time/gregorian/gregorian.hpp"
int
main()
@@ -26,13 +25,13 @@ main()
std::cout << "Days until next Jan 1: " << days_until_year_start.days()
<< std::endl;
return 0;
}
};
/* Copyright 2001-2004: CrystalClear Software, Inc
* http://www.crystalclearsoftware.com
*
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+3 -3
View File
@@ -1,6 +1,6 @@
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
#include "boost/date_time/gregorian/gregorian.hpp"
int
main()
@@ -14,12 +14,12 @@ main()
std::cout << "Days since Jan 1: " << days_since_year_start.days()
<< std::endl;
return 0;
}
};
/* Copyright 2001-2004: CrystalClear Software, Inc
* http://www.crystalclearsoftware.com
*
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+2 -2
View File
@@ -15,12 +15,12 @@ main()
std::cout << "Days till new year: " << dd.days() << std::endl;
return 0;
}
};
/* Copyright 2001-2004: CrystalClear Software, Inc
* http://www.crystalclearsoftware.com
*
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+1 -1
View File
@@ -41,6 +41,6 @@ main()
* 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)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
@@ -1,54 +0,0 @@
/* Simple program that finds the last day of the given month,
* then displays the last day of every month left in the given year.
*/
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
int
main()
{
using namespace boost::gregorian;
greg_year year(1400);
greg_month month(1);
// get a month and a year from the user
try {
greg_year::value_type y;
greg_month::value_type m;
std::cout << " Enter Year(ex: 2002): ";
std::cin >> y;
year = greg_year(y);
std::cout << " Enter Month(1..12): ";
std::cin >> m;
month = greg_month(m);
}
catch(const bad_year& by) {
std::cout << "Invalid Year Entered: " << by.what() << '\n'
<< "Using minimum values for month and year." << std::endl;
}
catch(const bad_month& bm) {
std::cout << "Invalid Month Entered" << bm.what() << '\n'
<< "Using minimum value for month. " << std::endl;
}
date start_of_next_year(year+1, Jan, 1);
date d(year, month, 1);
// add another month to d until we enter the next year.
while (d < start_of_next_year){
std::cout << to_simple_string(d.end_of_month()) << std::endl;
d += months(1);
}
return 0;
}
/* Copyright 2001-2005: CrystalClear Software, Inc
* http://www.crystalclearsoftware.com
*
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
*/
+96 -48
View File
@@ -5,11 +5,9 @@
#include "boost/date_time/gregorian/gregorian.hpp"
#include <iostream>
#include <algorithm>
/* Define a series of char arrays for short and long name strings
* to be associated with German date output (US names will be
* retrieved from the locale). */
/* Define a series of char arrays for short and long name strings to be
* associated with date output. */
const char* const de_short_month_names[] =
{
"Jan", "Feb", "Mar", "Apr", "Mai", "Jun",
@@ -21,6 +19,10 @@ const char* const de_long_month_names[] =
"Juni", "Juli", "August", "September", "Oktober",
"November", "Dezember", "NichtDerMonat"
};
const char* const de_special_value_names[] =
{
"NichtDatumzeit", "-unbegrenztheit", "+unbegrenztheit"
};
const char* const de_long_weekday_names[] =
{
"Sonntag", "Montag", "Dienstag", "Mittwoch",
@@ -31,70 +33,116 @@ const char* const de_short_weekday_names[] =
"Son", "Mon", "Die","Mit", "Don", "Fre", "Sam"
};
int main()
const char* const us_short_month_names[] =
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "NAD"
};
const char* const us_long_month_names[] =
{
"January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December", "Not-A-Date"
};
const char* const us_special_value_names[] =
{
"Not-A-Date", "-infinity", "+infinity"
};
const char* const us_long_weekday_names[] =
{
"Sunday", "Monday", "Tuesday", "Wenesday",
"Thursday", "Friday", "Saturday"
};
const char* const us_short_weekday_names[] =
{
"Sun", "Mon", "Tue","Wed", "Thu", "Fri", "Sat"
};
int
main()
{
#ifndef BOOST_DATE_TIME_NO_LOCALE
using namespace boost::gregorian;
// create some gregorian objects to output
typedef boost::date_time::all_date_names_put<greg_facet_config> date_facet;
//create a new local
std::locale default_locale;
std::locale german_dates1(default_locale,
new date_facet(de_short_month_names,
de_long_month_names,
de_special_value_names,
de_short_weekday_names,
de_long_weekday_names,
'.',
boost::date_time::ymd_order_dmy,
boost::date_time::month_as_integer));
date d1(2002, Oct, 1);
greg_month m = d1.month();
greg_weekday wd = d1.day_of_week();
// create a facet and a locale for German dates
date_facet* german_facet = new date_facet();
std::cout.imbue(std::locale(std::locale::classic(), german_facet));
// create the German name collections
date_facet::input_collection_type short_months, long_months,
short_weekdays, long_weekdays;
std::copy(&de_short_month_names[0], &de_short_month_names[11],
std::back_inserter(short_months));
std::copy(&de_long_month_names[0], &de_long_month_names[11],
std::back_inserter(long_months));
std::copy(&de_short_weekday_names[0], &de_short_weekday_names[6],
std::back_inserter(short_weekdays));
std::copy(&de_long_weekday_names[0], &de_long_weekday_names[6],
std::back_inserter(long_weekdays));
// replace the default names with ours
// NOTE: date_generators and special_values were not replaced as
// they are not used in this example
german_facet->short_month_names(short_months);
german_facet->long_month_names(long_months);
german_facet->short_weekday_names(short_weekdays);
german_facet->long_weekday_names(long_weekdays);
std::cout.imbue(german_dates1);
// output the date in German using short month names
german_facet->format("%d.%m.%Y");
std::cout << d1 << std::endl; //01.10.2002
german_facet->month_format("%B");
std::locale german_dates2(default_locale,
new date_facet(de_short_month_names,
de_long_month_names,
de_special_value_names,
de_short_weekday_names,
de_long_weekday_names,
'.',
boost::date_time::ymd_order_dmy,
boost::date_time::month_as_long_string));
std::cout.imbue(german_dates2);
greg_month m = d1.month();
std::cout << m << std::endl; //Oktober
german_facet->weekday_format("%A");
greg_weekday wd = d1.day_of_week();
std::cout << wd << std::endl; //Dienstag
// Output the same gregorian objects using US names
date_facet* us_facet = new date_facet();
std::cout.imbue(std::locale(std::locale::classic(), us_facet));
us_facet->format("%m/%d/%Y");
std::cout << d1 << std::endl; // 10/01/2002
//Numeric date format with US month/day/year ordering
std::locale usa_dates1(default_locale,
new date_facet(us_short_month_names,
us_long_month_names,
us_special_value_names,
us_short_weekday_names,
us_long_weekday_names,
'/',
boost::date_time::ymd_order_us,
boost::date_time::month_as_integer));
// English names, ISO 8601 order (year-month-day), '-' separator
us_facet->format("%Y-%b-%d");
std::cout.imbue(usa_dates1);
std::cout << d1 << std::endl; // 10/01/2002
//English names, iso order (year-month-day), '-' separator
std::locale usa_dates2(default_locale,
new date_facet(us_short_month_names,
us_long_month_names,
us_special_value_names,
us_short_weekday_names,
us_long_weekday_names,
'-',
boost::date_time::ymd_order_iso,
boost::date_time::month_as_short_string));
std::cout.imbue(usa_dates2);
std::cout << d1 << std::endl; // 2002-Oct-01
#else
std::cout << "Sorry, localization is not supported by this compiler/library"
<< std::endl;
#endif
return 0;
}
/* Copyright 2001-2005: CrystalClear Software, Inc
/* Copyright 2001-2004: CrystalClear Software, Inc
* http://www.crystalclearsoftware.com
*
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+8 -13
View File
@@ -12,12 +12,13 @@ main()
{
using namespace boost::gregorian;
typedef boost::date_time::month_functor<date> add_month;
date d = day_clock::local_day();
date d2 = d + months(1);
date d3 = d - months(1);
std::cout << "Today is: " << to_simple_string(d) << ".\n"
<< "One month from today will be: " << to_simple_string(d2) << ".\n"
<< "One month from today will be: " << to_simple_string(d2)
<< "One month ago was: " << to_simple_string(d3)
<< std::endl;
std::cout << "******** Warning read this ***********************\n";
@@ -31,28 +32,22 @@ main()
<< std::endl;
std::cout << "\nSo what does this mean? It means the result of adding months is order\n"
<< "dependent, non-commutative, and may create problems for applications.\n"
<< "dependent, non-communitive, and may create problems for applications.\n"
<< "Consider: \n"
<< "Jan 30, 2004 + (1 month) + (1 month) != Jan 30, 2004 + (2 months)\n"
<< "Why not? Because Jan 30, 2004 + 1 month is Feb 29 + 1 month is Mar 31st.\n"
<< "while Jan 30, 2004 + 2 months is Mar 30th.\n"
<< "Jan 30, 2004 + (1 month) + (1 month) != Jan 29, 2004 + (2 months)\n"
<< "Why not? Because Jan 30, 2004 + 1 month is Feb 29 + 1 month is Mar 29th.\n"
<< "while Jan 30, 2004 + 2 months is Mar 29th.\n"
<< "All of this clears up as long as all the starting dates before the 28th of\n"
<< "the month -- then all the behavior follows classical mathematical rules.\n";
date d6(2004, Jan, 30);
date d7 = d6 + months(1) + months(1);
date d8 = d6 + months(2);
std::cout << "2004-01-30 + (1 month) + (1 month) is: " << to_simple_string(d7) << ".\n"
<< "2004-01-30 + (2 months) is: " << to_simple_string(d8)
<< std::endl;
return 0;
}
/* Copyright 2001-2005: CrystalClear Software, Inc
/* Copyright 2001-2004: CrystalClear Software, Inc
* http://www.crystalclearsoftware.com
*
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+1 -1
View File
@@ -81,6 +81,6 @@ int main()
* 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)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+4 -4
View File
@@ -33,12 +33,12 @@ print_date(boost::gregorian::date d)
int
main() {
using namespace boost::gregorian;
std::cout << "Enter Year: ";
greg_year::value_type year;
int year;
std::cin >> year;
using namespace boost::gregorian;
//define a collection of holidays fixed by month and day
std::vector<year_based_generator*> holidays;
holidays.push_back(new partial_date(1,Jan)); //Western New Year
@@ -78,6 +78,6 @@ main() {
* 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)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+4 -6
View File
@@ -19,18 +19,16 @@
int
main()
{
using namespace boost::gregorian;
std::cout << "Enter Year: ";
greg_year::value_type year;
greg_month::value_type month;
int year, month;
std::cin >> year;
std::cout << "Enter Month(1..12): ";
std::cin >> month;
using namespace boost::gregorian;
try {
//Use the calendar to get the last day of the month
greg_day::value_type eom_day = gregorian_calendar::end_of_month_day(year,month);
int eom_day = gregorian_calendar::end_of_month_day(year,month);
date endOfMonth(year,month,eom_day);
//construct an iterator starting with firt day of the month
@@ -59,6 +57,6 @@ main()
* 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)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
-47
View File
@@ -1,47 +0,0 @@
/* A simple example for creating various dst_calc_rule instances
*/
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/local_time/local_time.hpp"
#include <iostream>
int
main()
{
using namespace boost;
using namespace local_time;
using namespace gregorian;
/***** create the necessary date_generator objects *****/
// starting generators
first_day_of_the_week_in_month fd_start(Sunday, May);
last_day_of_the_week_in_month ld_start(Sunday, May);
nth_day_of_the_week_in_month nkd_start(nth_day_of_the_week_in_month::third,
Sunday, May);
partial_date pd_start(1, May);
// ending generators
first_day_of_the_week_in_month fd_end(Sunday, Oct);
last_day_of_the_week_in_month ld_end(Sunday, Oct);
nth_day_of_the_week_in_month nkd_end(nth_day_of_the_week_in_month::third,
Sunday, Oct);
partial_date pd_end(31, Oct);
/***** create the various dst_calc_rule objects *****/
dst_calc_rule_ptr pdr(new partial_date_dst_rule(pd_start, pd_end));
dst_calc_rule_ptr flr(new first_last_dst_rule(fd_start, ld_end));
dst_calc_rule_ptr llr(new last_last_dst_rule(ld_start, ld_end));
dst_calc_rule_ptr nlr(new nth_last_dst_rule(nkd_start, ld_end));
dst_calc_rule_ptr ndr(new nth_day_of_the_week_in_month_dst_rule(nkd_start, nkd_end));
std::cout << "Program run successfully" << std::endl;
return 0;
}
/* Copyright 2001-2005: CrystalClear Software, Inc
* http://www.crystalclearsoftware.com
*
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
*/
-60
View File
@@ -1,60 +0,0 @@
#include "boost/date_time/local_time/local_time.hpp"
#include <iostream>
/* This example shows a program that calculates the arrival time of a plane
* that flys from Phoenix to New York. During the flight New York shifts
* into daylight savings time (Phoenix doesn't because Arizona doesn't use
* DST).
*
*
*/
int main()
{
using namespace boost::gregorian;
using namespace boost::local_time;
using namespace boost::posix_time;
//setup some timezones for creating and adjusting local times
//This user editable file can be found in libs/date_time/data.
tz_database tz_db;
try {
tz_db.load_from_file("../../data/date_time_zonespec.csv");
}catch(const data_not_accessible& dna) {
std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
exit(EXIT_FAILURE);
}catch(const bad_field_count& bfc) {
std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
exit(EXIT_FAILURE);
}
time_zone_ptr nyc_tz = tz_db.time_zone_from_region("America/New_York");
//Use a newly created time zone rule
time_zone_ptr phx_tz(new posix_time_zone("MST-07:00:00"));
//local departure time in Phoenix is 11 pm on March 13 2010
// (NY changes to DST on March 14 at 2 am)
local_date_time phx_departure(date(2010, Mar, 13), hours(23),
phx_tz,
local_date_time::NOT_DATE_TIME_ON_ERROR);
local_date_time nyc_departure = phx_departure.local_time_in(nyc_tz);
time_duration flight_length = hours(4) + minutes(30);
local_date_time phx_arrival = phx_departure + flight_length;
local_date_time nyc_arrival = phx_arrival.local_time_in(nyc_tz);
std::cout << "departure PHX time: " << phx_departure << std::endl;
std::cout << "departure NYC time: " << nyc_departure << std::endl;
std::cout << "arrival PHX time: " << phx_arrival << std::endl;
std::cout << "arrival NYC time: " << nyc_arrival << std::endl;
}
/* Copyright 2005: CrystalClear Software, Inc
* http://www.crystalclearsoftware.com
*
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
*/
-45
View File
@@ -1,45 +0,0 @@
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/local_time/local_time.hpp"
#include <iostream>
#include <locale>
int main() {
using namespace boost::gregorian;
using namespace boost::posix_time;
using namespace boost::local_time;
tz_database tz_db;
try {
tz_db.load_from_file("../../data/date_time_zonespec.csv");
}catch(data_not_accessible dna) {
std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
exit(EXIT_FAILURE);
}catch(bad_field_count bfc) {
std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
exit(EXIT_FAILURE);
}
time_zone_ptr nyc = tz_db.time_zone_from_region("America/New_York");
local_date_time ny_time(date(2004, Aug, 30), hours(10), nyc, true);
typedef boost::date_time::time_facet<local_date_time, char> ldt_facet;
ldt_facet* timefacet = new ldt_facet("%Y-%b-%d %H:%M:%S""%F %Z");
std::locale loc(std::locale::classic(), timefacet);
std::cout << ny_time << std::endl;
// 2004-Aug-30 10:00:00 EDT
std::cout.imbue(loc);
std::cout << ny_time << std::endl;
// 2004-Aug-30 10:00:00 Eastern Daylight Time
return 0;
}
/* Copyright 2004-2005: CrystalClear Software, Inc
* http://www.crystalclearsoftware.com
*
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
*/
@@ -1,65 +0,0 @@
/* This example demonstrates the use of the time zone database and
* local time to calculate the number of seconds since the UTC
* time_t epoch 1970-01-01 00:00:00. Note that the selected timezone
* could be any timezone supported in the time zone database file which
* can be modified and updated as needed by the user.
*
* To solve this problem the following steps are required:
* 1) Get a timezone from the tz database for the local time
* 2) Construct a local time using the timezone
* 3) Construct a posix_time::ptime for the time_t epoch time
* 4) Convert the local_time to utc and subtract the epoch time
*
*/
#include "boost/date_time/local_time/local_time.hpp"
#include <iostream>
int main()
{
using namespace boost::gregorian;
using namespace boost::local_time;
using namespace boost::posix_time;
tz_database tz_db;
try {
tz_db.load_from_file("../data/date_time_zonespec.csv");
}catch(const data_not_accessible& dna) {
std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
exit(EXIT_FAILURE);
}catch(const bad_field_count& bfc) {
std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
exit(EXIT_FAILURE);
}
time_zone_ptr nyc_tz = tz_db.time_zone_from_region("America/New_York");
date in_date(2004,10,04);
time_duration td(12,14,32);
// construct with local time value
// create not-a-date-time if invalid (eg: in dst transition)
local_date_time nyc_time(in_date,
td,
nyc_tz,
local_date_time::NOT_DATE_TIME_ON_ERROR);
std::cout << nyc_time << std::endl;
ptime time_t_epoch(date(1970,1,1));
std::cout << time_t_epoch << std::endl;
// first convert nyc_time to utc via the utc_time()
// call and subtract the ptime.
time_duration diff = nyc_time.utc_time() - time_t_epoch;
//Expected 1096906472
std::cout << "Seconds diff: " << diff.total_seconds() << std::endl;
}
/* Copyright 2005: CrystalClear Software, Inc
* http://www.crystalclearsoftware.com
*
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
*/
-86
View File
@@ -1,86 +0,0 @@
/* 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)
*/
-4
View File
@@ -1,7 +1,3 @@
# Copyright (c) 2002-2005 CrystalClear Software, Inc.
# Use, modification and distribution is subject to the
# Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
project
: requirements <library>../../build/boost_date_time
+1 -1
View File
@@ -85,6 +85,6 @@ main()
* 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)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+5 -5
View File
@@ -29,16 +29,16 @@ main()
ptime now = second_clock::local_time();
//Get the date part out of the time
date today = now.date();
date tomorrow = today + days(1);
ptime tomorrow_start(tomorrow); //midnight
date tommorrow = today + days(1);
ptime tommorrow_start(tommorrow); //midnight
//iterator adds by one hour
time_iterator titr(now,hours(1));
for (; titr < tomorrow_start; ++titr) {
for (; titr < tommorrow_start; ++titr) {
std::cout << to_simple_string(*titr) << std::endl;
}
time_duration remaining = tomorrow_start - now;
time_duration remaining = tommorrow_start - now;
std::cout << "Time left till midnight: "
<< to_simple_string(remaining) << std::endl;
return 0;
@@ -48,6 +48,6 @@ main()
* 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)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+2 -2
View File
@@ -13,7 +13,7 @@ main()
using namespace boost::gregorian;
date d(2002,Feb,1); //an arbitrary date
//construct a time by adding up some durations
//construct a time by adding up some durations durations
ptime t1(d, hours(5)+minutes(4)+seconds(2)+milliseconds(1));
//construct a new time by subtracting some times
ptime t2 = t1 - hours(5)- minutes(4)- seconds(2)- milliseconds(1);
@@ -31,6 +31,6 @@ main()
* 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)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
+1 -1
View File
@@ -53,6 +53,6 @@ main()
* 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)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
*/
-194
View File
@@ -1,194 +0,0 @@
#include <iostream>
#include <boost/date_time/local_time/local_time.hpp>
int main(){
using namespace boost::gregorian;
using namespace boost::posix_time;
using namespace boost::local_time;
using namespace std;
/****** basic use ******/
date d(2004, Feb, 29);
time_duration td(12,34,56,789);
stringstream ss;
ss << d << ' ' << td;
ptime pt(not_a_date_time);
cout << pt << endl; // "not-a-date-time"
ss >> pt;
cout << pt << endl; // "2004-Feb-29 12:34:56.000789"
ss.str("");
ss << pt << " EDT-05EDT,M4.1.0,M10.5.0";
local_date_time ldt(not_a_date_time);
ss >> ldt;
cout << ldt << endl; // " 2004-Feb-29 12:34:56.000789 EDT"
/****** format strings ******/
local_time_facet* output_facet = new local_time_facet();
local_time_input_facet* input_facet = new local_time_input_facet();
ss.imbue(locale(locale::classic(), output_facet));
ss.imbue(locale(ss.getloc(), input_facet));
output_facet->format("%a %b %d, %H:%M %z");
ss.str("");
ss << ldt;
cout << ss.str() << endl; // "Sun Feb 29, 12:34 EDT"
output_facet->format(local_time_facet::iso_time_format_specifier);
ss.str("");
ss << ldt;
cout << ss.str() << endl; // "20040229T123456.000789-0500"
output_facet->format(local_time_facet::iso_time_format_extended_specifier);
ss.str("");
ss << ldt;
cout << ss.str() << endl; // "2004-02-29 12:34:56.000789-05:00"
// extra words in format
string my_format("The extended ordinal time %Y-%jT%H:%M can also be represented as %A %B %d, %Y");
output_facet->format(my_format.c_str());
input_facet->format(my_format.c_str());
ss.str("");
ss << ldt;
cout << ss.str() << endl;
// matching extra words in input
ss.str("The extended ordinal time 2005-128T12:15 can also be represented as Sunday May 08, 2005");
ss >> ldt;
cout << ldt << endl; // cout is using default format "2005-May-08 12:15:00 UTC"
/****** content strings ******/
// set up the collections of custom strings.
// only the full names are altered for the sake of brevity
string month_names[12] = { "january", "february", "march",
"april", "may", "june",
"july", "august", "september",
"october", "november", "december" };
vector<string> long_months(&month_names[0], &month_names[12]);
string day_names[7] = { "sunday", "monday", "tuesday", "wednesday",
"thursday", "friday", "saturday" };
vector<string> long_days(&day_names[0], &day_names[7]);
// create date_facet and date_input_facet using all defaults
date_facet* date_output = new date_facet();
date_input_facet* date_input = new date_input_facet();
ss.imbue(locale(ss.getloc(), date_output));
ss.imbue(locale(ss.getloc(), date_input));
// replace names in the output facet
date_output->long_month_names(long_months);
date_output->long_weekday_names(long_days);
// replace names in the input facet
date_input->long_month_names(long_months);
date_input->long_weekday_names(long_days);
// customize month, weekday and date formats
date_output->format("%Y-%B-%d");
date_input->format("%Y-%B-%d");
date_output->month_format("%B"); // full name
date_input->month_format("%B"); // full name
date_output->weekday_format("%A"); // full name
date_input->weekday_format("%A"); // full name
ss.str("");
ss << greg_month(3);
cout << ss.str() << endl; // "march"
ss.str("");
ss << greg_weekday(3);
cout << ss.str() << endl; // "tuesday"
ss.str("");
ss << date(2005,Jul,4);
cout << ss.str() << endl; // "2005-july-04"
/****** special values ******/
// reset the formats to defaults
output_facet->format(local_time_facet::default_time_format);
input_facet->format(local_time_input_facet::default_time_input_format);
// create custom special_values parser and formatter objects
// and add them to the facets
string sv[5] = {"nadt","neg_inf", "pos_inf", "min_dt", "max_dt" };
vector<string> sv_names(&sv[0], &sv[5]);
special_values_parser sv_parser(sv_names.begin(), sv_names.end());
special_values_formatter sv_formatter(sv_names.begin(), sv_names.end());
output_facet->special_values_formatter(sv_formatter);
input_facet->special_values_parser(sv_parser);
ss.str("");
ldt = local_date_time(not_a_date_time);
ss << ldt;
cout << ss.str() << endl; // "nadt"
ss.str("min_dt");
ss >> ldt;
ss.str("");
ss << ldt;
cout << ss.str() << endl; // "1400-Jan-01 00:00:00 UTC"
/****** date/time periods ******/
// reset all formats to defaults
date_output->format(date_facet::default_date_format);
date_input->format(date_facet::default_date_format);
date_output->month_format("%b"); // abbrev
date_input->month_format("%b"); // abbrev
date_output->weekday_format("%a"); // abbrev
date_input->weekday_format("%a"); // abbrev
// create our date_period
date_period dp(date(2005,Mar,1), days(31)); // month of march
// custom period formatter and parser
period_formatter per_formatter(period_formatter::AS_OPEN_RANGE,
" to ", "from ", " exclusive", " inclusive" );
period_parser per_parser(period_parser::AS_OPEN_RANGE,
" to ", "from ", " exclusive" , " inclusive" );
// default output
ss.str("");
ss << dp;
cout << ss.str() << endl; // "[2005-Mar-01/2005-Mar-31]"
// add out custom parser and formatter to the facets
date_output->period_formatter(per_formatter);
date_input->period_parser(per_parser);
// custom output
ss.str("");
ss << dp;
cout << ss.str() << endl; // "from 2005-Feb-01 to 2005-Apr-01 exclusive"
/****** date generators ******/
// custom date_generator phrases
string dg_phrases[9] = { "1st", "2nd", "3rd", "4th", "5th",
"final", "prior to", "following", "in" };
vector<string> phrases(&dg_phrases[0], &dg_phrases[9]);
// create our date_generator
first_day_of_the_week_before d_gen(Monday);
// default output
ss.str("");
ss << d_gen;
cout << ss.str() << endl; // "Mon before"
// add our custom strings to the date facets
date_output->date_gen_phrase_strings(phrases);
date_input->date_gen_element_strings(phrases);
// custom output
ss.str("");
ss << d_gen;
cout << ss.str() << endl; // "Mon prior to"
return 0;
}
/* Copyright 2005: CrystalClear Software, Inc
* http://www.crystalclearsoftware.com
*
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
*/
-17
View File
@@ -1,17 +0,0 @@
#ifndef BOOST_DATE_TIME_ALL_HPP___
#define BOOST_DATE_TIME_ALL_HPP___
/* Copyright (c) 2006 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland
* $Date$
*/
// See www.boost.org/libs/date_time for documentation.
//gregorian and posix time included by indirectly
#include "boost/date_time/local_time/local_time.hpp"
#endif // BOOST_DATE_TIME_ALL_HPP___
+35 -21
View File
@@ -2,9 +2,9 @@
#define _DATE_TIME_ADJUST_FUNCTORS_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)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -14,21 +14,26 @@
namespace boost {
namespace date_time {
//! Functor to iterate a fixed number of days
template<class date_type>
class day_functor
class day_functor
{
public:
typedef typename date_type::duration_type duration_type;
day_functor(int f) : f_(f) {}
duration_type get_offset(const date_type&) const
duration_type get_offset(const date_type& d) const
{
// why is 'd' a parameter???
// fix compiler warnings
d.year();
return duration_type(f_);
}
duration_type get_neg_offset(const date_type&) const
duration_type get_neg_offset(const date_type& d) const
{
// fix compiler warnings
d.year();
return duration_type(-f_);
}
private:
@@ -38,7 +43,7 @@ namespace date_time {
//! Provides calculation to find next nth month given a date
/*! This adjustment function provides the logic for 'month-based'
* advancement on a ymd based calendar. The policy it uses
* advancement on a ymd based calendar. The policy it uses
* to handle the non existant end of month days is to back
* up to the last day of the month. Also, if the starting
* date is the last day of a month, this functor will attempt
@@ -46,7 +51,7 @@ namespace date_time {
*/
template<class date_type>
class month_functor
class month_functor
{
public:
typedef typename date_type::duration_type duration_type;
@@ -55,7 +60,7 @@ namespace date_time {
typedef typename cal_type::day_type day_type;
month_functor(int f) : f_(f), origDayOfMonth_(0) {}
duration_type get_offset(const date_type& d) const
duration_type get_offset(const date_type& d) const
{
ymd_type ymd(d.year_month_day());
if (origDayOfMonth_ == 0) {
@@ -66,9 +71,11 @@ namespace date_time {
}
}
typedef date_time::wrapping_int2<short,1,12> wrap_int2;
typedef typename wrap_int2::int_type int_type;
wrap_int2 wi(ymd.month);
//calc the year wrap around, add() returns 0 or 1 if wrapped
const typename ymd_type::year_type year(static_cast<typename ymd_type::year_type::value_type>(ymd.year + wi.add(f_)));
int_type year = wi.add(static_cast<int_type>(f_));
year = static_cast<int_type>(year + ymd.year); //calculate resulting year
// std::cout << "trace wi: " << wi.as_int() << std::endl;
// std::cout << "trace year: " << year << std::endl;
//find the last day for the new month
@@ -84,7 +91,7 @@ namespace date_time {
return date_type(year, wi.as_int(), dayOfMonth) - d;
}
//! Returns a negative duration_type
duration_type get_neg_offset(const date_type& d) const
duration_type get_neg_offset(const date_type& d) const
{
ymd_type ymd(d.year_month_day());
if (origDayOfMonth_ == 0) {
@@ -95,9 +102,11 @@ namespace date_time {
}
}
typedef date_time::wrapping_int2<short,1,12> wrap_int2;
typedef typename wrap_int2::int_type int_type;
wrap_int2 wi(ymd.month);
//calc the year wrap around, add() returns 0 or 1 if wrapped
const typename ymd_type::year_type year(static_cast<typename ymd_type::year_type::value_type>(ymd.year + wi.subtract(f_)));
int_type year = wi.subtract(static_cast<int_type>(f_));
year = static_cast<int_type>(year + ymd.year); //calculate resulting year
//find the last day for the new month
day_type resultingEndOfMonthDay(cal_type::end_of_month_day(year, wi.as_int()));
//original was the end of month -- force to last day of month
@@ -118,19 +127,24 @@ namespace date_time {
//! Functor to iterate a over weeks
template<class date_type>
class week_functor
class week_functor
{
public:
typedef typename date_type::duration_type duration_type;
typedef typename date_type::calendar_type calendar_type;
week_functor(int f) : f_(f) {}
duration_type get_offset(const date_type&) const
duration_type get_offset(const date_type& d) const
{
return duration_type(f_*static_cast<int>(calendar_type::days_in_week()));
// why is 'd' a parameter???
// fix compiler warnings
d.year();
return duration_type(f_*calendar_type::days_in_week());
}
duration_type get_neg_offset(const date_type&) const
duration_type get_neg_offset(const date_type& d) const
{
return duration_type(-f_*static_cast<int>(calendar_type::days_in_week()));
// fix compiler warnings
d.year();
return duration_type(-f_*calendar_type::days_in_week());
}
private:
int f_;
@@ -138,17 +152,17 @@ namespace date_time {
//! Functor to iterate by a year adjusting for leap years
template<class date_type>
class year_functor
class year_functor
{
public:
//typedef typename date_type::year_type year_type;
typedef typename date_type::duration_type duration_type;
year_functor(int f) : _mf(f * 12) {}
duration_type get_offset(const date_type& d) const
duration_type get_offset(const date_type& d) const
{
return _mf.get_offset(d);
}
duration_type get_neg_offset(const date_type& d) const
duration_type get_neg_offset(const date_type& d) const
{
return _mf.get_neg_offset(d);
}
@@ -156,7 +170,7 @@ namespace date_time {
month_functor<date_type> _mf;
};
} }//namespace date_time
@@ -1,10 +1,10 @@
#ifndef DATE_TIME_C_LOCAL_TIME_ADJUSTOR_HPP__
#define DATE_TIME_C_LOCAL_TIME_ADJUSTOR_HPP__
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -14,10 +14,7 @@
*/
#include <stdexcept>
#include <boost/throw_exception.hpp>
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/c_time.hpp>
#include <boost/numeric/conversion/cast.hpp>
#include "boost/date_time/c_time.hpp"
namespace boost {
namespace date_time {
@@ -38,25 +35,18 @@ namespace date_time {
date_type time_t_start_day(1970,1,1);
time_type time_t_start_time(time_t_start_day,time_duration_type(0,0,0));
if (t < time_t_start_time) {
boost::throw_exception(std::out_of_range("Cannot convert dates prior to Jan 1, 1970"));
BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return time_t_start_time); // should never reach
throw std::out_of_range("Cannot convert dates prior to Jan 1, 1970");
}
date_duration_type dd = t.date() - time_t_start_day;
time_duration_type td = t.time_of_day();
uint64_t t2 = static_cast<uint64_t>(dd.days())*86400 +
static_cast<uint64_t>(td.hours())*3600 +
static_cast<uint64_t>(td.minutes())*60 +
td.seconds();
// detect y2038 issue and throw instead of proceed with bad time
std::time_t tv = boost::numeric_cast<std::time_t>(t2);
std::tm tms, *tms_ptr;
tms_ptr = c_time::localtime(&tv, &tms);
date_type d(static_cast<unsigned short>(tms_ptr->tm_year + 1900),
static_cast<unsigned short>(tms_ptr->tm_mon + 1),
static_cast<unsigned short>(tms_ptr->tm_mday));
time_duration_type td2(tms_ptr->tm_hour,
tms_ptr->tm_min,
tms_ptr->tm_sec,
std::time_t t2 = dd.days()*86400 + td.hours()*3600 + td.minutes()*60 + td.seconds();
std::tm* tms = std::localtime(&t2);
date_type d(static_cast<unsigned short>(tms->tm_year + 1900),
static_cast<unsigned short>(tms->tm_mon + 1),
static_cast<unsigned short>(tms->tm_mday));
time_duration_type td2(tms->tm_hour,
tms->tm_min,
tms->tm_sec,
t.time_of_day().fractional_seconds());
return time_type(d,td2);
+7 -100
View File
@@ -1,11 +1,11 @@
#ifndef DATE_TIME_C_TIME_HPP___
#define DATE_TIME_C_TIME_HPP___
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -14,17 +14,14 @@
Provide workarounds related to the ctime header
*/
#include "boost/date_time/compiler_config.hpp"
#include <ctime>
#include <string> // to be able to convert from string literals to exceptions
#include <stdexcept>
#include <boost/throw_exception.hpp>
#include <boost/date_time/compiler_config.hpp>
//Work around libraries that don't put time_t and time in namespace std
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std { using ::time_t; using ::time; using ::localtime;
using ::tm; using ::gmtime; }
#endif // BOOST_NO_STDC_NAMESPACE
#endif
//The following is used to support high precision time clocks
#ifdef BOOST_HAS_GETTIMEOFDAY
@@ -35,94 +32,4 @@ namespace std { using ::time_t; using ::time; using ::localtime;
#include <time.h>
#endif
namespace boost {
namespace date_time {
//! Provides a uniform interface to some 'ctime' functions
/*! Provides a uniform interface to some ctime functions and
* their '_r' counterparts. The '_r' functions require a pointer to a
* user created std::tm struct whereas the regular functions use a
* staticly created struct and return a pointer to that. These wrapper
* functions require the user to create a std::tm struct and send in a
* pointer to it. This struct may be used to store the resulting time.
* The returned pointer may or may not point to this struct, however,
* it will point to the result of the corresponding function.
* All functions do proper checking of the C function results and throw
* exceptions on error. Therefore the functions will never return NULL.
*/
struct c_time {
public:
#if defined(BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS)
//! requires a pointer to a user created std::tm struct
inline
static std::tm* localtime(const std::time_t* t, std::tm* result)
{
// localtime_r() not in namespace std???
#if defined(__VMS) && __INITIAL_POINTER_SIZE == 64
std::tm tmp;
if(!localtime_r(t,&tmp))
result = 0;
else
*result = tmp;
#else
result = localtime_r(t, result);
#endif
if (!result)
boost::throw_exception(std::runtime_error("could not convert calendar time to local time"));
return result;
}
//! requires a pointer to a user created std::tm struct
inline
static std::tm* gmtime(const std::time_t* t, std::tm* result)
{
// gmtime_r() not in namespace std???
#if defined(__VMS) && __INITIAL_POINTER_SIZE == 64
std::tm tmp;
if(!gmtime_r(t,&tmp))
result = 0;
else
*result = tmp;
#else
result = gmtime_r(t, result);
#endif
if (!result)
boost::throw_exception(std::runtime_error("could not convert calendar time to UTC time"));
return result;
}
#else // BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS
#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
//! requires a pointer to a user created std::tm struct
inline
static std::tm* localtime(const std::time_t* t, std::tm* result)
{
result = std::localtime(t);
if (!result)
boost::throw_exception(std::runtime_error("could not convert calendar time to local time"));
return result;
}
//! requires a pointer to a user created std::tm struct
inline
static std::tm* gmtime(const std::time_t* t, std::tm* result)
{
result = std::gmtime(t);
if (!result)
boost::throw_exception(std::runtime_error("could not convert calendar time to UTC time"));
return result;
}
#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
#endif // BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS
};
}} // namespaces
#endif // DATE_TIME_C_TIME_HPP___
+46 -59
View File
@@ -3,19 +3,14 @@
/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <cstdlib>
#include <boost/config.hpp>
#include <boost/detail/workaround.hpp>
// This file performs some local compiler configurations
#include <boost/date_time/locale_config.hpp> //set up locale configurations
#include "boost/date_time/locale_config.hpp" //set up locale configurations
//Set up a configuration parameter for platforms that have
//GetTimeOfDay
@@ -28,13 +23,17 @@
// 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( BOOST_BORLANDC, BOOST_TESTED_AT(0x581) ) )
#if (defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) || (defined(__BORLANDC__)))
#define BOOST_DATE_TIME_NO_MEMBER_INIT
#endif
// include these types before we try to re-define them
#include <boost/cstdint.hpp>
#include "boost/cstdint.hpp"
//Define INT64_C for compilers that don't have it
#if (!defined(INT64_C))
@@ -43,13 +42,13 @@
/* Workaround for Borland iterator error. Error was "Cannot convert 'istream *' to 'wistream *' in function istream_iterator<>::istream_iterator() */
#if defined(BOOST_BORLANDC) && defined(BOOST_BCB_WITH_RW_LIB)
#if defined(__BORLANDC__) && (__BORLANDC__ <= 0x0551)
#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(BOOST_BORLANDC) && defined(BOOST_BCB_WITH_STLPORT)
#if defined(__BORLANDC__) && (__BORLANDC__ >= 0x0564)
#include <locale>
namespace std {
using stlport::tolower;
@@ -64,74 +63,62 @@ namespace std {
// gcc295, msvc (neither with STLPort), any borland
//
#if (((defined(__GNUC__) && (__GNUC__ < 3)) || \
(defined(_MSC_VER) && (_MSC_VER < 1300)) ) && \
(defined(_MSC_VER) && (_MSC_VER <= 1200)) ) && \
!defined(_STLP_OWN_IOSTREAMS) ) || \
BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x581) )
defined(__BORLANDC__)
#define BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS
#endif
// The macro marks up places where compiler complains for missing return statement or
// uninitialized variables after calling to boost::throw_exception.
// BOOST_UNREACHABLE_RETURN doesn't work since even compilers that support
// unreachable statements detection emit such warnings.
#if defined(_MSC_VER)
// Use special MSVC extension to markup unreachable code
# define BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(x) __assume(false)
#elif !defined(BOOST_NO_UNREACHABLE_RETURN_DETECTION)
// Call to a non-returning function should suppress the warning
# if defined(BOOST_NO_STDC_NAMESPACE)
namespace std {
using ::abort;
}
# endif // defined(BOOST_NO_STDC_NAMESPACE)
# define BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(x) std::abort()
#else
// For other poor compilers the specified expression is compiled. Usually, this would be a return statement.
# define BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(x) x
#endif
/* The following handles the definition of the necessary macros
* for dll building on Win32 platforms.
*
* For code that will be placed in the date_time .dll,
* it must be properly prefixed with BOOST_DATE_TIME_DECL.
* The corresponding .cpp file must have BOOST_DATE_TIME_SOURCE
* The corresponding .cpp file must have BOOST_DATE_TIME_SOURCES
* defined before including its header. For examples see:
* greg_month.hpp & greg_month.cpp
*
*/
// we need to import/export our code only if the user has specifically
// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
// libraries to be dynamically linked, or BOOST_DATE_TIME_DYN_LINK
// if they want just this one to be dynamically liked:
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK)
// export if this is our own source, otherwise import:
# ifdef BOOST_DATE_TIME_SOURCE
# define BOOST_DATE_TIME_DECL BOOST_SYMBOL_EXPORT
# else
# define BOOST_DATE_TIME_DECL BOOST_SYMBOL_IMPORT
# endif // BOOST_DATE_TIME_SOURCE
#endif // DYN_LINK
#ifdef BOOST_HAS_DECLSPEC // defined in config system
// we need to import/export our code only if the user has specifically
// asked for it by defining either BOOST_ALL_DYN_LINK if they want all boost
// libraries to be dynamically linked, or BOOST_DATE_TIME_DYN_LINK
// if they want just this one to be dynamically liked:
# if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_DATE_TIME_DYN_LINK)
// export if this is our own source, otherwise import:
# ifdef BOOST_DATE_TIME_SOURCE
# define BOOST_DATE_TIME_DECL __declspec(dllexport)
# else
# define BOOST_DATE_TIME_DECL __declspec(dllimport)
# endif // BOOST_DATE_TIME_SOURCE
# endif // DYN_LINK
#endif // BOOST_HAS_DECLSPEC
//
// if BOOST_WHATEVER_DECL isn't defined yet define it now:
#ifndef BOOST_DATE_TIME_DECL
# define BOOST_DATE_TIME_DECL
#endif
#if defined(BOOST_HAS_THREADS)
# if defined(_MSC_VER) || defined(__MWERKS__) || defined(__MINGW32__) || defined(__BORLANDC__)
//no reentrant posix functions (eg: localtime_r)
# elif (!defined(__hpux) || (defined(__hpux) && defined(_REENTRANT)))
# define BOOST_DATE_TIME_HAS_REENTRANT_STD_FUNCTIONS
# endif
#endif
#if defined(BOOST_NO_CXX11_NULLPTR)
# define BOOST_DATE_TIME_NULLPTR 0
#else
# define BOOST_DATE_TIME_NULLPTR nullptr
//
// 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
#endif
+16 -47
View File
@@ -4,17 +4,12 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
* $Date$
*/
#include <exception>
#include <stdexcept>
#include <boost/config.hpp>
#include <boost/throw_exception.hpp>
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_base_of.hpp>
namespace boost {
@@ -39,33 +34,29 @@ namespace CV {
*
*/
template<class value_policies>
class BOOST_SYMBOL_VISIBLE constrained_value {
class constrained_value {
public:
typedef typename value_policies::value_type value_type;
// typedef except_type exception_type;
BOOST_CXX14_CONSTEXPR constrained_value(value_type value) : value_((min)())
constrained_value(value_type value)
{
assign(value);
}
BOOST_CXX14_CONSTEXPR constrained_value& operator=(value_type v)
{
};
constrained_value& operator=(value_type v)
{
assign(v);
return *this;
}
}
//! Return the max allowed value (traits method)
static BOOST_CONSTEXPR value_type
max BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::max)();}
static value_type max BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::max)();};
//! Return the min allowed value (traits method)
static BOOST_CONSTEXPR value_type
min BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::min)();}
static value_type min BOOST_PREVENT_MACRO_SUBSTITUTION () {return (value_policies::min)();};
//! Coerce into the representation type
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
operator value_type() const {return value_;};
protected:
value_type value_;
private:
BOOST_CXX14_CONSTEXPR void assign(value_type value)
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....
@@ -78,44 +69,22 @@ namespace CV {
return;
}
value_ = value;
}
};
//! Template to shortcut the constrained_value policy creation process
template<typename rep_type, rep_type min_value,
rep_type max_value, class exception_type>
class BOOST_SYMBOL_VISIBLE simple_exception_policy
class simple_exception_policy
{
struct BOOST_SYMBOL_VISIBLE exception_wrapper : public exception_type
{
// In order to support throw_exception mechanism in the BOOST_NO_EXCEPTIONS mode,
// we'll have to provide a way to acquire std::exception from the exception being thrown.
// However, we cannot derive from it, since it would make it interceptable by this class,
// which might not be what the user wanted.
operator std::out_of_range () const
{
// TODO: Make the message more descriptive by using arguments to on_error
return std::out_of_range("constrained value boundary has been violated");
}
};
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 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 rep_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return min_value; };
static rep_type max BOOST_PREVENT_MACRO_SUBSTITUTION () { return max_value;};
static void on_error(rep_type, rep_type, violation_enum)
{
boost::throw_exception(actual_exception_type());
throw exception_type();
}
};
+56 -68
View File
@@ -2,44 +2,43 @@
#define DATE_TIME_DATE_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)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <boost/operators.hpp>
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/year_month_day.hpp>
#include <boost/date_time/special_defs.hpp>
#include "boost/date_time/year_month_day.hpp"
#include "boost/date_time/special_defs.hpp"
#include "boost/operators.hpp"
namespace boost {
namespace date_time {
//!Representation of timepoint at the one day level resolution.
/*!
/*!
The date template represents an interface shell for a date class
that is based on a year-month-day system such as the gregorian
or ISO 8601 systems. It provides basic operations to enable calculation
and comparisons.
or iso systems. It provides basic operations to enable calculation
and comparisons.
<b>Theory</b>
This date representation fundamentally departs from the C tm struct
This date representation fundamentally departs from the C tm struct
approach. The goal for this type is to provide efficient date
operations (add, subtract) and storage (minimize space to represent)
in a concrete class. Thus, the date uses a count internally to
represent a particular date. The calendar parameter defines
represent a particular date. The calendar parameter defines
the policies for converting the the year-month-day and internal
counted form here. Applications that need to perform heavy
formatting of the same date repeatedly will perform better
by using the year-month-day representation.
Internally the date uses a day number to represent the date.
This is a monotonic time representation. This representation
This is a monotonic time representation. This representation
allows for fast comparison as well as simplifying
the creation of writing numeric operations. Essentially, the
the creation of writing numeric operations. Essentially, the
internal day number is like adjusted julian day. The adjustment
is determined by the Epoch date which is represented as day 1 of
the calendar. Day 0 is reserved for negative infinity so that
@@ -49,11 +48,11 @@ namespace date_time {
day representations.
*/
template<class T, class calendar, class duration_type_>
class BOOST_SYMBOL_VISIBLE date : private
boost::less_than_comparable<T
, boost::equality_comparable<T
template<class T, class calendar, class duration_type_>
class date : private
boost::less_than_comparable<T
, boost::equality_comparable<T
> >
{
public:
@@ -68,139 +67,128 @@ 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;
BOOST_CXX14_CONSTEXPR date(year_type y, month_type m, day_type d)
date(year_type y, month_type m, day_type d)
: days_(calendar::day_number(ymd_type(y, m, d)))
{}
BOOST_CXX14_CONSTEXPR date(const ymd_type& ymd)
date(const ymd_type& ymd)
: days_(calendar::day_number(ymd))
{}
{}
//let the compiler write copy, assignment, and destructor
BOOST_CXX14_CONSTEXPR year_type year() const
year_type year() const
{
ymd_type ymd = calendar::from_day_number(days_);
ymd_type ymd = calendar::from_day_number(days_);
return ymd.year;
}
BOOST_CXX14_CONSTEXPR month_type month() const
month_type month() const
{
ymd_type ymd = calendar::from_day_number(days_);
ymd_type ymd = calendar::from_day_number(days_);
return ymd.month;
}
BOOST_CXX14_CONSTEXPR day_type day() const
day_type day() const
{
ymd_type ymd = calendar::from_day_number(days_);
ymd_type ymd = calendar::from_day_number(days_);
return ymd.day;
}
BOOST_CXX14_CONSTEXPR day_of_week_type day_of_week() const
day_of_week_type day_of_week() const
{
ymd_type ymd = calendar::from_day_number(days_);
return calendar::day_of_week(ymd);
}
BOOST_CXX14_CONSTEXPR ymd_type year_month_day() const
ymd_type year_month_day() const
{
return calendar::from_day_number(days_);
}
BOOST_CONSTEXPR bool operator<(const date_type& rhs) const
bool operator<(const date_type& rhs) const
{
return days_ < rhs.days_;
}
BOOST_CONSTEXPR bool operator==(const date_type& rhs) const
bool operator==(const date_type& rhs) const
{
return days_ == rhs.days_;
}
//! check to see if date is a special value
BOOST_CONSTEXPR bool is_special()const
bool is_special()const
{
return(is_not_a_date() || is_infinity());
}
//! check to see if date is not a value
BOOST_CONSTEXPR bool is_not_a_date() const
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
BOOST_CONSTEXPR bool is_infinity() const
bool is_infinity() const
{
return traits_type::is_inf(days_);
}
//! check to see if date is greater than all possible dates
BOOST_CONSTEXPR bool is_pos_infinity() const
bool is_pos_infinity() const
{
return traits_type::is_pos_inf(days_);
}
//! check to see if date is greater than all possible dates
BOOST_CONSTEXPR bool is_neg_infinity() const
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
BOOST_CXX14_CONSTEXPR special_values as_special() const
special_values as_special() const
{
return traits_type::to_special(days_);
}
BOOST_CXX14_CONSTEXPR duration_type operator-(const date_type& d) const
duration_type operator-(const date_type& d) const
{
if (!this->is_special() && !d.is_special())
{
// The duration underlying type may be wider than the date underlying type.
// Thus we calculate the difference in terms of two durations from some common fixed base date.
typedef typename duration_type::duration_rep_type duration_rep_type;
return duration_type(static_cast< duration_rep_type >(days_) - static_cast< duration_rep_type >(d.days_));
}
else
{
// In this case the difference will be a special value, too
date_rep_type val = date_rep_type(days_) - date_rep_type(d.days_);
return duration_type(val.as_special());
}
date_rep_type val = date_rep_type(days_) - date_rep_type(d.days_);
return duration_type(val.as_number());
}
BOOST_CXX14_CONSTEXPR date_type operator-(const duration_type& dd) const
date_type operator-(const duration_type& dd) const
{
if(dd.is_special())
{
return date_type(date_rep_type(days_) - dd.get_rep());
}
return date_type(date_rep_type(days_) - static_cast<date_int_type>(dd.days()));
return date_type(date_rep_type(days_) - dd.days());
}
BOOST_CXX14_CONSTEXPR date_type operator-=(const duration_type& dd)
date_type operator-=(const duration_type& dd)
{
*this = *this - dd;
return date_type(days_);
}
BOOST_CONSTEXPR date_rep_type day_count() const
date_rep_type day_count() const
{
return days_;
}
};
//allow internal access from operators
BOOST_CXX14_CONSTEXPR date_type operator+(const duration_type& dd) const
date_type operator+(const duration_type& dd) const
{
if(dd.is_special())
{
return date_type(date_rep_type(days_) + dd.get_rep());
}
return date_type(date_rep_type(days_) + static_cast<date_int_type>(dd.days()));
return date_type(date_rep_type(days_) + dd.days());
}
BOOST_CXX14_CONSTEXPR date_type operator+=(const duration_type& dd)
date_type operator+=(const duration_type& dd)
{
*this = *this + dd;
*this = *this + dd;
return date_type(days_);
}
//see reference
protected:
/*! This is a private constructor which allows for the creation of new
dates. It is not exposed to users since that would require class
/*! This is a private constructor which allows for the creation of new
dates. It is not exposed to users since that would require class
users to understand the inner workings of the date class.
*/
BOOST_CONSTEXPR explicit date(date_int_type days) : days_(days) {}
BOOST_CXX14_CONSTEXPR explicit date(date_rep_type days) : days_(days.as_number()) {}
explicit date(date_int_type days) : days_(days) {};
explicit date(date_rep_type days) : days_(days.as_number()) {};
date_int_type days_;
};
} } // namespace date_time
+15 -17
View File
@@ -1,11 +1,11 @@
#ifndef DATE_CLOCK_DEVICE_HPP___
#define DATE_CLOCK_DEVICE_HPP___
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
* $Date$
*/
@@ -34,20 +34,18 @@ namespace date_time {
//! Get the local day as a ymd_type
static typename date_type::ymd_type local_day_ymd()
{
::std::tm result;
::std::tm* curr = get_local_time(result);
return ymd_type(static_cast<unsigned short>(curr->tm_year + 1900),
static_cast<unsigned short>(curr->tm_mon + 1),
static_cast<unsigned short>(curr->tm_mday));
::std::tm* curr = get_local_time();
return ymd_type(curr->tm_year + 1900,
curr->tm_mon + 1,
curr->tm_mday);
}
//! Get the current day in universal date as a ymd_type
static typename date_type::ymd_type universal_day_ymd()
{
::std::tm result;
::std::tm* curr = get_universal_time(result);
return ymd_type(static_cast<unsigned short>(curr->tm_year + 1900),
static_cast<unsigned short>(curr->tm_mon + 1),
static_cast<unsigned short>(curr->tm_mday));
::std::tm* curr = get_universal_time();
return ymd_type(curr->tm_year + 1900,
curr->tm_mon + 1,
curr->tm_mday);
}
//! Get the UTC day as a date type
static date_type universal_day()
@@ -56,17 +54,17 @@ namespace date_time {
}
private:
static ::std::tm* get_local_time(std::tm& result)
static ::std::tm* get_local_time()
{
::std::time_t t;
::std::time(&t);
return c_time::localtime(&t, &result);
return ::std::localtime(&t);
}
static ::std::tm* get_universal_time(std::tm& result)
static ::std::tm* get_universal_time()
{
::std::time_t t;
::std::time(&t);
return c_time::gmtime(&t, &result);
return ::std::gmtime(&t);
}
};
+1 -1
View File
@@ -4,7 +4,7 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
* $Date$
*/
+39 -38
View File
@@ -2,18 +2,15 @@
#define DATE_TIME_DATE_DURATION__
/* 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)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#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 {
@@ -21,57 +18,58 @@ namespace date_time {
//! Duration type with date level resolution
template<class duration_rep_traits>
class BOOST_SYMBOL_VISIBLE date_duration : private
boost::less_than_comparable1< date_duration< duration_rep_traits >
, boost::equality_comparable1< date_duration< duration_rep_traits >
, boost::addable1< date_duration< duration_rep_traits >
, boost::subtractable1< date_duration< duration_rep_traits >
, boost::dividable2< date_duration< duration_rep_traits >, int
> > > > >
{
class date_duration : private
boost::less_than_comparable<date_duration< duration_rep_traits>
, boost::equality_comparable< date_duration< duration_rep_traits>
, boost::addable< date_duration< duration_rep_traits>
, boost::subtractable< date_duration< duration_rep_traits>
> > > >
{
public:
typedef typename duration_rep_traits::int_type duration_rep_type;
typedef typename duration_rep_traits::impl_type duration_rep;
//! Construct from a day count
BOOST_CXX14_CONSTEXPR explicit date_duration(duration_rep day_count) : days_(day_count) {}
explicit date_duration(duration_rep day_count) : days_(day_count) {};
/*! construct from special_values - only works when
* instantiated with duration_traits_adapted */
BOOST_CXX14_CONSTEXPR date_duration(special_values sv) :
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
BOOST_CXX14_CONSTEXPR duration_rep get_rep()const
duration_rep get_rep()const
{
return days_;
}
BOOST_CXX14_CONSTEXPR special_values as_special() const
{
return days_.as_special();
}
BOOST_CXX14_CONSTEXPR bool is_special()const
bool is_special()const
{
return days_.is_special();
}
//! returns days as value, not object.
BOOST_CXX14_CONSTEXPR duration_rep_type days() const
duration_rep_type days() const
{
return duration_rep_traits::as_number(days_);
}
//! Returns the smallest duration -- used by to calculate 'end'
static BOOST_CXX14_CONSTEXPR date_duration unit()
static date_duration unit()
{
return date_duration<duration_rep_traits>(1);
}
//! Equality
BOOST_CXX14_CONSTEXPR bool operator==(const date_duration& rhs) const
bool operator==(const date_duration& rhs) const
{
return days_ == rhs.days_;
}
//! Less
BOOST_CXX14_CONSTEXPR bool operator<(const date_duration& rhs) const
bool operator<(const date_duration& rhs) const
{
return days_ < rhs.days_;
}
@@ -82,37 +80,40 @@ namespace date_time {
* so this will not compile */
//! Subtract another duration -- result is signed
BOOST_CXX14_CONSTEXPR date_duration& operator-=(const date_duration& rhs)
date_duration operator-=(const date_duration& rhs)
{
//days_ -= rhs.days_;
days_ = days_ - rhs.days_;
return *this;
}
//! Add a duration -- result is signed
BOOST_CXX14_CONSTEXPR date_duration& operator+=(const date_duration& rhs)
date_duration operator+=(const date_duration& rhs)
{
days_ = days_ + rhs.days_;
return *this;
}
//! unary- Allows for dd = -date_duration(2); -> dd == -2
BOOST_CXX14_CONSTEXPR date_duration operator-() const
date_duration operator-()const
{
return date_duration<duration_rep_traits>(get_rep() * (-1));
}
//! Division operations on a duration with an integer.
BOOST_CXX14_CONSTEXPR date_duration& operator/=(int divisor)
date_duration<duration_rep_traits> operator/=(int divisor)
{
days_ = days_ / divisor;
return *this;
}
date_duration<duration_rep_traits> operator/(int divisor)
{
return date_duration<duration_rep_traits>(days_ / divisor);
}
//! return sign information
BOOST_CXX14_CONSTEXPR bool is_negative() const
bool is_negative() const
{
return days_ < 0;
}
private:
duration_rep days_;
};
@@ -121,23 +122,23 @@ namespace date_time {
/*! Struct for instantiating date_duration with <b>NO</b> special values
* functionality. Allows for transparent implementation of either
* date_duration<long> or date_duration<int_adapter<long> > */
struct BOOST_SYMBOL_VISIBLE duration_traits_long
struct duration_traits_long
{
typedef long int_type;
typedef long impl_type;
static BOOST_CXX14_CONSTEXPR int_type as_number(impl_type i) { return i; }
static int_type as_number(impl_type i) { return i; };
};
/*! Struct for instantiating date_duration <b>WITH</b> special values
* functionality. Allows for transparent implementation of either
* date_duration<long> or date_duration<int_adapter<long> > */
struct BOOST_SYMBOL_VISIBLE duration_traits_adapted
struct duration_traits_adapted
{
typedef long int_type;
typedef boost::date_time::int_adapter<long> impl_type;
static BOOST_CXX14_CONSTEXPR int_type as_number(impl_type i) { return i.as_number(); }
static int_type as_number(impl_type i) { return i.as_number(); };
};
} } //namspace date_time
+56 -52
View File
@@ -3,13 +3,12 @@
/* Copyright (c) 2004 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or
* http://www.boost.org/LICENSE_1_0.txt)
* (See accompanying file LICENSE-1.0 or
* http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/int_adapter.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/date_duration.hpp>
@@ -20,17 +19,17 @@ namespace date_time {
//! Additional duration type that represents a number of n*7 days
template <class duration_config>
class BOOST_SYMBOL_VISIBLE weeks_duration : public date_duration<duration_config> {
class weeks_duration : public date_duration<duration_config> {
public:
BOOST_CXX14_CONSTEXPR weeks_duration(typename duration_config::impl_type w)
weeks_duration(typename duration_config::impl_type w)
: date_duration<duration_config>(w * 7) {}
BOOST_CXX14_CONSTEXPR weeks_duration(special_values sv)
weeks_duration(special_values sv)
: date_duration<duration_config>(sv) {}
};
// predeclare
template<class t>
class BOOST_SYMBOL_VISIBLE years_duration;
class years_duration;
//! additional duration type that represents a logical month
/*! A logical month enables things like: "date(2002,Mar,2) + months(2) ->
@@ -38,7 +37,7 @@ namespace date_time {
* also be a last-day-of-the-month.
*/
template<class base_config>
class BOOST_SYMBOL_VISIBLE months_duration
class months_duration
{
private:
typedef typename base_config::int_rep int_rep;
@@ -49,104 +48,106 @@ namespace date_time {
typedef months_duration<base_config> months_type;
typedef years_duration<base_config> years_type;
public:
BOOST_CXX14_CONSTEXPR months_duration(int_rep num) : _m(num) {}
BOOST_CXX14_CONSTEXPR months_duration(special_values sv) : _m(sv)
months_duration(int_rep num) : _m(num) {}
months_duration(special_values sv) : _m(sv)
{
_m = int_rep::from_special(sv);
}
int_rep number_of_months() const { return _m; }
//! returns a negative duration
BOOST_CXX14_CONSTEXPR duration_type get_neg_offset(const date_type& d) const
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));
}
BOOST_CXX14_CONSTEXPR duration_type get_offset(const date_type& d) const
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));
}
BOOST_CONSTEXPR bool operator==(const months_type& rhs) const
bool operator==(const months_type& rhs) const
{
return(_m == rhs._m);
}
BOOST_CONSTEXPR bool operator!=(const months_type& rhs) const
bool operator!=(const months_type& rhs) const
{
return(_m != rhs._m);
}
BOOST_CXX14_CONSTEXPR months_type operator+(const months_type& rhs)const
months_type operator+(const months_type& rhs)const
{
return months_type(_m + rhs._m);
}
BOOST_CXX14_CONSTEXPR months_type& operator+=(const months_type& rhs)
months_type& operator+=(const months_type& rhs)
{
_m = _m + rhs._m;
return *this;
}
BOOST_CXX14_CONSTEXPR months_type operator-(const months_type& rhs)const
months_type operator-(const months_type& rhs)const
{
return months_type(_m - rhs._m);
}
BOOST_CXX14_CONSTEXPR months_type& operator-=(const months_type& rhs)
months_type& operator-=(const months_type& rhs)
{
_m = _m - rhs._m;
return *this;
}
BOOST_CXX14_CONSTEXPR months_type operator*(const int_type rhs)const
months_type operator*(const int_type rhs)const
{
return months_type(_m * rhs);
}
BOOST_CXX14_CONSTEXPR months_type& operator*=(const int_type rhs)
months_type& operator*=(const int_type rhs)
{
_m = _m * rhs;
return *this;
}
BOOST_CXX14_CONSTEXPR months_type operator/(const int_type rhs)const
months_type operator/(const int_type rhs)const
{
return months_type(_m / rhs);
}
BOOST_CXX14_CONSTEXPR months_type& operator/=(const int_type rhs)
months_type& operator/=(const int_type rhs)
{
_m = _m / rhs;
return *this;
}
BOOST_CXX14_CONSTEXPR months_type operator+(const years_type& y)const
months_type operator+(const years_type& y)const
{
return months_type(y.number_of_years() * 12 + _m);
}
BOOST_CXX14_CONSTEXPR months_type& operator+=(const years_type& y)
months_type& operator+=(const years_type& y)
{
_m = y.number_of_years() * 12 + _m;
return *this;
}
BOOST_CXX14_CONSTEXPR months_type operator-(const years_type& y) const
months_type operator-(const years_type& y) const
{
return months_type(_m - y.number_of_years() * 12);
}
BOOST_CXX14_CONSTEXPR months_type& operator-=(const years_type& y)
months_type& operator-=(const years_type& y)
{
_m = _m - y.number_of_years() * 12;
return *this;
}
//
BOOST_CXX14_CONSTEXPR friend date_type operator+(const date_type& d, const months_type& m)
friend date_type operator+(const date_type& d, const months_type& m)
{
return d + m.get_offset(d);
}
BOOST_CXX14_CONSTEXPR friend date_type operator+=(date_type& d, const months_type& m)
friend date_type operator+=(date_type& d, const months_type& m)
{
return d += m.get_offset(d);
}
BOOST_CXX14_CONSTEXPR friend date_type operator-(const date_type& d, const months_type& m)
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);
}
BOOST_CXX14_CONSTEXPR friend date_type operator-=(date_type& d, const months_type& m)
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;
};
@@ -158,7 +159,7 @@ namespace date_time {
* 2004-Feb-29).
*/
template<class base_config>
class BOOST_SYMBOL_VISIBLE years_duration
class years_duration
{
private:
typedef typename base_config::int_rep int_rep;
@@ -169,24 +170,24 @@ namespace date_time {
typedef years_duration<base_config> years_type;
typedef months_duration<base_config> months_type;
public:
BOOST_CXX14_CONSTEXPR years_duration(int_rep num) : _y(num) {}
BOOST_CXX14_CONSTEXPR years_duration(special_values sv) : _y(sv)
years_duration(int_rep num) : _y(num) {}
years_duration(special_values sv) : _y(sv)
{
_y = int_rep::from_special(sv);
}
BOOST_CXX14_CONSTEXPR int_rep number_of_years() const { return _y; }
int_rep number_of_years() const { return _y; }
//! returns a negative duration
BOOST_CXX14_CONSTEXPR duration_type get_neg_offset(const date_type& d) const
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));
}
BOOST_CXX14_CONSTEXPR duration_type get_offset(const date_type& d) const
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));
}
BOOST_CXX14_CONSTEXPR bool operator==(const years_type& rhs) const
bool operator==(const years_type& rhs) const
{
return(_y == rhs._y);
}
@@ -194,72 +195,75 @@ namespace date_time {
{
return(_y != rhs._y);
}
BOOST_CXX14_CONSTEXPR years_type operator+(const years_type& rhs)const
years_type operator+(const years_type& rhs)const
{
return years_type(_y + rhs._y);
}
BOOST_CXX14_CONSTEXPR years_type& operator+=(const years_type& rhs)
years_type& operator+=(const years_type& rhs)
{
_y = _y + rhs._y;
return *this;
}
BOOST_CXX14_CONSTEXPR years_type operator-(const years_type& rhs)const
years_type operator-(const years_type& rhs)const
{
return years_type(_y - rhs._y);
}
BOOST_CXX14_CONSTEXPR years_type& operator-=(const years_type& rhs)
years_type& operator-=(const years_type& rhs)
{
_y = _y - rhs._y;
return *this;
}
BOOST_CXX14_CONSTEXPR years_type operator*(const int_type rhs)const
years_type operator*(const int_type rhs)const
{
return years_type(_y * rhs);
}
BOOST_CXX14_CONSTEXPR years_type& operator*=(const int_type rhs)
years_type& operator*=(const int_type rhs)
{
_y = _y * rhs;
return *this;
}
BOOST_CXX14_CONSTEXPR years_type operator/(const int_type rhs)const
years_type operator/(const int_type rhs)const
{
return years_type(_y / rhs);
}
BOOST_CXX14_CONSTEXPR years_type& operator/=(const int_type rhs)
years_type& operator/=(const int_type rhs)
{
_y = _y / rhs;
return *this;
}
BOOST_CXX14_CONSTEXPR months_type operator+(const months_type& m) const
months_type operator+(const months_type& m) const
{
return(months_type(_y * 12 + m.number_of_months()));
}
BOOST_CXX14_CONSTEXPR months_type operator-(const months_type& m) const
months_type operator-(const months_type& m) const
{
return(months_type(_y * 12 - m.number_of_months()));
}
//
BOOST_CXX14_CONSTEXPR friend date_type operator+(const date_type& d, const years_type& y)
friend date_type operator+(const date_type& d, const years_type& y)
{
return d + y.get_offset(d);
}
BOOST_CXX14_CONSTEXPR friend date_type operator+=(date_type& d, const years_type& y)
friend date_type operator+=(date_type& d, const years_type& y)
{
return d += y.get_offset(d);
}
BOOST_CXX14_CONSTEXPR friend date_type operator-(const date_type& d, const years_type& y)
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);
}
BOOST_CXX14_CONSTEXPR friend date_type operator-=(date_type& d, const years_type& y)
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___
+98 -640
View File
@@ -1,72 +1,37 @@
#ifndef _DATE_TIME_DATE_FACET__HPP___
#define _DATE_TIME_DATE_FACET__HPP___
/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
/* Copyright (c) 2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Martin Andrian, Jeff Garland, Bart Garst
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Martin Andrian, Jeff Garland
* $Date$
*/
#include <iterator> // ostreambuf_iterator
#include <locale>
#include "boost/algorithm/string.hpp" //todo narrow this
#include "boost/date_time/period.hpp"
#include "boost/date_time/special_values_formatter.hpp"
#include "boost/date_time/period_formatter.hpp"
#include <string>
#include <vector>
#include <boost/throw_exception.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/period.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/special_values_formatter.hpp>
#include <boost/date_time/period_formatter.hpp>
#include <boost/date_time/period_parser.hpp>
#include <boost/date_time/date_generator_formatter.hpp>
#include <boost/date_time/date_generator_parser.hpp>
#include <boost/date_time/format_date_parser.hpp>
namespace boost { namespace date_time {
/*! Class that provides format based I/O facet for date types.
*
* This class allows the formatting of dates by using format string.
* Format strings are:
*
* - %A => long_weekday_format - Full name Ex: Tuesday
* - %a => short_weekday_format - Three letter abbreviation Ex: Tue
* - %B => long_month_format - Full name Ex: October
* - %b => short_month_format - Three letter abbreviation Ex: Oct
* - %x => standard_format_specifier - defined by the locale
* - %Y-%b-%d => default_date_format - YYYY-Mon-dd
*
* Default month format == %b
* Default weekday format == %a
*/
template <class date_type,
class CharT,
class CharT,
class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
class BOOST_SYMBOL_VISIBLE date_facet : public std::locale::facet {
class date_facet : public std::locale::facet {
public:
typedef typename date_type::duration_type duration_type;
// greg_weekday is gregorian_calendar::day_of_week_type
typedef typename date_type::day_of_week_type day_of_week_type;
typedef typename date_type::day_type day_type;
typedef typename date_type::month_type month_type;
typedef boost::date_time::period<date_type,duration_type> period_type;
typedef std::basic_string<CharT> string_type;
typedef CharT char_type;
typedef boost::date_time::period_formatter<CharT> period_formatter_type;
typedef boost::date_time::special_values_formatter<CharT> special_values_formatter_type;
typedef std::vector<std::basic_string<CharT> > input_collection_type;
// used for the output of the date_generators
typedef date_generator_formatter<date_type, CharT> date_gen_formatter_type;
typedef partial_date<date_type> partial_date_type;
typedef nth_kday_of_month<date_type> nth_kday_type;
typedef first_kday_of_month<date_type> first_kday_type;
typedef last_kday_of_month<date_type> last_kday_type;
typedef first_kday_after<date_type> kday_after_type;
typedef first_kday_before<date_type> kday_before_type;
static const char_type long_weekday_format[3];
static const char_type short_weekday_format[3];
static const char_type long_month_format[3];
@@ -75,47 +40,33 @@ namespace boost { namespace date_time {
static const char_type standard_format_specifier[3];
static const char_type iso_format_specifier[7];
static const char_type iso_format_extended_specifier[9];
static const char_type default_date_format[9]; // YYYY-Mon-DD
static std::locale::id id;
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
std::locale::id& __get_id (void) const { return id; }
#endif
explicit date_facet(::size_t a_ref = 0)
: std::locale::facet(a_ref),
//m_format(standard_format_specifier)
m_format(default_date_format),
m_month_format(short_month_format),
m_weekday_format(short_weekday_format)
explicit date_facet(::size_t a_ref = 0)
: std::locale::facet(a_ref),
m_format(standard_format_specifier)
{}
explicit date_facet(const char_type* format_str,
const input_collection_type& short_names,
::size_t ref_count = 0)
: std::locale::facet(ref_count),
m_format(format_str),
m_month_format(short_month_format),
m_weekday_format(short_weekday_format),
m_month_short_names(short_names)
explicit date_facet(const char_type* format,
const input_collection_type& short_month_names,
::size_t ref_count = 0)
: std::locale::facet(ref_count),
m_format(format),
m_month_short_names(short_month_names)
{}
explicit date_facet(const char_type* format_str,
period_formatter_type per_formatter = period_formatter_type(),
special_values_formatter_type sv_formatter = special_values_formatter_type(),
date_gen_formatter_type dg_formatter = date_gen_formatter_type(),
explicit date_facet(const char_type* format,
period_formatter_type period_formatter = period_formatter_type(),
special_values_formatter_type special_values_formatter = special_values_formatter_type(),
::size_t ref_count = 0)
: std::locale::facet(ref_count),
m_format(format_str),
m_month_format(short_month_format),
m_weekday_format(short_weekday_format),
m_period_formatter(per_formatter),
m_date_gen_formatter(dg_formatter),
m_special_values_formatter(sv_formatter)
: std::locale::facet(ref_count),
m_format(format),
m_period_formatter(period_formatter),
m_special_values_formatter(special_values_formatter)
{}
void format(const char_type* const format_str) {
m_format = format_str;
void format(const char_type* const format) {
m_format = format;
}
virtual void set_iso_format()
{
@@ -125,232 +76,102 @@ namespace boost { namespace date_time {
{
m_format = iso_format_extended_specifier;
}
void month_format(const char_type* const format_str) {
m_month_format = format_str;
void period_formatter(period_formatter_type period_formatter) {
m_period_formatter= period_formatter;
}
void weekday_format(const char_type* const format_str) {
m_weekday_format = format_str;
}
void period_formatter(period_formatter_type per_formatter) {
m_period_formatter= per_formatter;
}
void special_values_formatter(const special_values_formatter_type& svf)
void special_value_formatting(const special_values_formatter_type& svf)
{
m_special_values_formatter = svf;
}
void short_weekday_names(const input_collection_type& short_names)
void short_weekday_names(const input_collection_type& short_weekday_names)
{
m_weekday_short_names = short_names;
m_weekday_short_names = short_weekday_names;
}
void long_weekday_names(const input_collection_type& long_names)
void long_weekday_names(const input_collection_type& long_weekday_names)
{
m_weekday_long_names = long_names;
m_weekday_long_names = long_weekday_names;
}
void short_month_names(const input_collection_type& short_names)
void short_month_names(const input_collection_type& short_month_names)
{
m_month_short_names = short_names;
m_month_short_names = short_month_names;
}
void long_month_names(const input_collection_type& long_names)
void long_month_names(const input_collection_type& long_month_names)
{
m_month_long_names = long_names;
m_month_long_names = long_month_names;
}
void date_gen_phrase_strings(const input_collection_type& new_strings,
typename date_gen_formatter_type::phrase_elements beg_pos=date_gen_formatter_type::first)
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const date_type& d) const
{
m_date_gen_formatter.elements(new_strings, beg_pos);
}
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const date_type& d) const
{
if (d.is_special()) {
if (d.is_special()) {
return do_put_special(next, a_ios, fill_char, d.as_special());
}
//The following line of code required the date to support a to_tm function
return do_put_tm(next, a_ios, fill_char, to_tm(d), m_format);
}
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const duration_type& dd) const
{
if (dd.is_special()) {
return do_put_special(next, a_ios, fill_char, dd.get_rep().as_special());
}
// date durations don't interact with the facet...no put code needed here.
// todo is that really true? What about special values?
typedef std::num_put<CharT, OutItrT> num_put;
if (std::has_facet<num_put>(a_ios.getloc())) {
return std::use_facet<num_put>(a_ios.getloc()).put(next, a_ios, fill_char, dd.get_rep().as_number());
}
else {
num_put* f = new num_put();
std::locale l = std::locale(a_ios.getloc(), f);
a_ios.imbue(l);
return f->put(next, a_ios, fill_char, dd.get_rep().as_number());
}
}
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const month_type& m) const
{
//if (d.is_special()) {
// return do_put_special(next, a_ios, fill_char, d.as_special());
//}
//The following line of code required the date to support a to_tm function
std::tm dtm;
std::memset(&dtm, 0, sizeof(dtm));
dtm.tm_mon = m - 1;
return do_put_tm(next, a_ios, fill_char, dtm, m_month_format);
}
//! puts the day of month
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const day_type& day) const
{
std::tm dtm;
std::memset(&dtm, 0, sizeof(dtm));
dtm.tm_mday = day.as_number();
char_type tmp[3] = {'%','d'};
string_type temp_format(tmp);
return do_put_tm(next, a_ios, fill_char, dtm, temp_format);
}
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const day_of_week_type& dow) const
{
//if (d.is_special()) {
// return do_put_special(next, a_ios, fill_char, d.as_special());
//}
//The following line of code required the date to support a to_tm function
std::tm dtm;
std::memset(&dtm, 0, sizeof(dtm));
dtm.tm_wday = dow;
return do_put_tm(next, a_ios, fill_char, dtm, m_weekday_format);
}
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const period_type& p) const
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const period_type& p) const
{
return m_period_formatter.put_period(next, a_ios, fill_char, p, *this);
}
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const partial_date_type& pd) const
{
return m_date_gen_formatter.put_partial_date(next, a_ios, fill_char, pd, *this);
}
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const nth_kday_type& nkd) const
{
return m_date_gen_formatter.put_nth_kday(next, a_ios, fill_char, nkd, *this);
}
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const first_kday_type& fkd) const
{
return m_date_gen_formatter.put_first_kday(next, a_ios, fill_char, fkd, *this);
}
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const last_kday_type& lkd) const
{
return m_date_gen_formatter.put_last_kday(next, a_ios, fill_char, lkd, *this);
}
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const kday_before_type& fkb) const
{
return m_date_gen_formatter.put_kday_before(next, a_ios, fill_char, fkb, *this);
}
OutItrT put(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const kday_after_type& fka) const
{
return m_date_gen_formatter.put_kday_after(next, a_ios, fill_char, fka, *this);
}
protected:
virtual OutItrT do_put_special(OutItrT next,
std::ios_base& /*a_ios*/,
char_type /*fill_char*/,
const boost::date_time::special_values sv) const
virtual OutItrT do_put_special(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const boost::date_time::special_values sv) const
{
m_special_values_formatter.put_special(next, sv);
return next;
}
virtual OutItrT do_put_tm(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
virtual OutItrT do_put_tm(OutItrT next,
std::ios_base& a_ios,
char_type fill_char,
const tm& tm_value,
string_type a_format) const
string_type a_format) const
{
// update format string with custom names
if (!m_weekday_long_names.empty()) {
boost::algorithm::replace_all(a_format,
long_weekday_format,
if (m_weekday_long_names.size()) {
boost::algorithm::replace_all(a_format,
long_weekday_format,
m_weekday_long_names[tm_value.tm_wday]);
}
if (!m_weekday_short_names.empty()) {
boost::algorithm::replace_all(a_format,
short_weekday_format,
if (m_weekday_short_names.size()) {
boost::algorithm::replace_all(a_format,
short_weekday_format,
m_weekday_short_names[tm_value.tm_wday]);
}
if (!m_month_long_names.empty()) {
boost::algorithm::replace_all(a_format,
long_month_format,
if (m_month_long_names.size()) {
boost::algorithm::replace_all(a_format,
long_month_format,
m_month_long_names[tm_value.tm_mon]);
}
if (!m_month_short_names.empty()) {
boost::algorithm::replace_all(a_format,
short_month_format,
if (m_month_short_names.size()) {
boost::algorithm::replace_all(a_format,
short_month_format,
m_month_short_names[tm_value.tm_mon]);
}
// use time_put facet to create final string
const char_type* p_format = a_format.c_str();
return std::use_facet<std::time_put<CharT> >(a_ios.getloc()).put(next, a_ios,
fill_char,
return std::use_facet<std::time_put<CharT> >(a_ios.getloc()).put(next, a_ios,
fill_char,
&tm_value,
p_format,
p_format + a_format.size());
&*a_format.begin(),
&*a_format.end());
}
protected:
string_type m_format;
string_type m_month_format;
string_type m_weekday_format;
period_formatter_type m_period_formatter;
date_gen_formatter_type m_date_gen_formatter;
special_values_formatter_type m_special_values_formatter;
input_collection_type m_month_short_names;
input_collection_type m_month_long_names;
@@ -362,405 +183,42 @@ namespace boost { namespace date_time {
template <class date_type, class CharT, class OutItrT>
std::locale::id date_facet<date_type, CharT, OutItrT>::id;
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::long_weekday_format[3] = {'%','A'};
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::short_weekday_format[3] = {'%','a'};
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::long_month_format[3] = {'%','B'};
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::short_month_format[3] = {'%','b'};
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::default_period_separator[4] = { ' ', '/', ' '};
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::standard_format_specifier[3] =
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::standard_format_specifier[3] =
{'%', 'x' };
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::iso_format_specifier[7] =
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::iso_format_specifier[7] =
{'%', 'Y', '%', 'm', '%', 'd' };
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::iso_format_extended_specifier[9] =
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::iso_format_extended_specifier[9] =
{'%', 'Y', '-', '%', 'm', '-', '%', 'd' };
template <class date_type, class CharT, class OutItrT>
const typename date_facet<date_type, CharT, OutItrT>::char_type
date_facet<date_type, CharT, OutItrT>::default_date_format[9] =
{'%','Y','-','%','b','-','%','d'};
} }
//! Input facet
template <class date_type,
class CharT,
class InItrT = std::istreambuf_iterator<CharT, std::char_traits<CharT> > >
class BOOST_SYMBOL_VISIBLE date_input_facet : public std::locale::facet {
public:
typedef typename date_type::duration_type duration_type;
// greg_weekday is gregorian_calendar::day_of_week_type
typedef typename date_type::day_of_week_type day_of_week_type;
typedef typename date_type::day_type day_type;
typedef typename date_type::month_type month_type;
typedef typename date_type::year_type year_type;
typedef boost::date_time::period<date_type,duration_type> period_type;
typedef std::basic_string<CharT> string_type;
typedef CharT char_type;
typedef boost::date_time::period_parser<date_type, CharT> period_parser_type;
typedef boost::date_time::special_values_parser<date_type,CharT> special_values_parser_type;
typedef std::vector<std::basic_string<CharT> > input_collection_type;
typedef format_date_parser<date_type, CharT> format_date_parser_type;
// date_generators stuff goes here
typedef date_generator_parser<date_type, CharT> date_gen_parser_type;
typedef partial_date<date_type> partial_date_type;
typedef nth_kday_of_month<date_type> nth_kday_type;
typedef first_kday_of_month<date_type> first_kday_type;
typedef last_kday_of_month<date_type> last_kday_type;
typedef first_kday_after<date_type> kday_after_type;
typedef first_kday_before<date_type> kday_before_type;
static const char_type long_weekday_format[3];
static const char_type short_weekday_format[3];
static const char_type long_month_format[3];
static const char_type short_month_format[3];
static const char_type four_digit_year_format[3];
static const char_type two_digit_year_format[3];
static const char_type default_period_separator[4];
static const char_type standard_format_specifier[3];
static const char_type iso_format_specifier[7];
static const char_type iso_format_extended_specifier[9];
static const char_type default_date_format[9]; // YYYY-Mon-DD
static std::locale::id id;
explicit date_input_facet(::size_t a_ref = 0)
: std::locale::facet(a_ref),
m_format(default_date_format),
m_month_format(short_month_format),
m_weekday_format(short_weekday_format),
m_year_format(four_digit_year_format),
m_parser(m_format, std::locale::classic())
// default period_parser & special_values_parser used
{}
explicit date_input_facet(const string_type& format_str,
::size_t a_ref = 0)
: std::locale::facet(a_ref),
m_format(format_str),
m_month_format(short_month_format),
m_weekday_format(short_weekday_format),
m_year_format(four_digit_year_format),
m_parser(m_format, std::locale::classic())
// default period_parser & special_values_parser used
{}
explicit date_input_facet(const string_type& format_str,
const format_date_parser_type& date_parser,
const special_values_parser_type& sv_parser,
const period_parser_type& per_parser,
const date_gen_parser_type& date_gen_parser,
::size_t ref_count = 0)
: std::locale::facet(ref_count),
m_format(format_str),
m_month_format(short_month_format),
m_weekday_format(short_weekday_format),
m_year_format(four_digit_year_format),
m_parser(date_parser),
m_date_gen_parser(date_gen_parser),
m_period_parser(per_parser),
m_sv_parser(sv_parser)
{}
void format(const char_type* const format_str) {
m_format = format_str;
}
virtual void set_iso_format()
{
m_format = iso_format_specifier;
}
virtual void set_iso_extended_format()
{
m_format = iso_format_extended_specifier;
}
void month_format(const char_type* const format_str) {
m_month_format = format_str;
}
void weekday_format(const char_type* const format_str) {
m_weekday_format = format_str;
}
void year_format(const char_type* const format_str) {
m_year_format = format_str;
}
void period_parser(period_parser_type per_parser) {
m_period_parser = per_parser;
}
void short_weekday_names(const input_collection_type& weekday_names)
{
m_parser.short_weekday_names(weekday_names);
}
void long_weekday_names(const input_collection_type& weekday_names)
{
m_parser.long_weekday_names(weekday_names);
}
void short_month_names(const input_collection_type& month_names)
{
m_parser.short_month_names(month_names);
}
void long_month_names(const input_collection_type& month_names)
{
m_parser.long_month_names(month_names);
}
void date_gen_element_strings(const input_collection_type& col)
{
m_date_gen_parser.element_strings(col);
}
void date_gen_element_strings(const string_type& first,
const string_type& second,
const string_type& third,
const string_type& fourth,
const string_type& fifth,
const string_type& last,
const string_type& before,
const string_type& after,
const string_type& of)
{
m_date_gen_parser.element_strings(first,second,third,fourth,fifth,last,before,after,of);
}
void special_values_parser(special_values_parser_type sv_parser)
{
m_sv_parser = sv_parser;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& /*a_ios*/,
date_type& d) const
{
d = m_parser.parse_date(from, to, m_format, m_sv_parser);
return from;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& /*a_ios*/,
month_type& m) const
{
m = m_parser.parse_month(from, to, m_month_format);
return from;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& /*a_ios*/,
day_of_week_type& wd) const
{
wd = m_parser.parse_weekday(from, to, m_weekday_format);
return from;
}
//! Expects 1 or 2 digit day range: 1-31
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& /*a_ios*/,
day_type& d) const
{
d = m_parser.parse_var_day_of_month(from, to);
return from;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& /*a_ios*/,
year_type& y) const
{
y = m_parser.parse_year(from, to, m_year_format);
return from;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& a_ios,
duration_type& dd) const
{
// skip leading whitespace
while(std::isspace(*from) && from != to) { ++from; }
/* num_get.get() will always consume the first character if it
* is a sign indicator (+/-). Special value strings may begin
* with one of these signs so we'll need a copy of it
* in case num_get.get() fails. */
char_type c = '\0';
// TODO Are these characters somewhere in the locale?
if(*from == '-' || *from == '+') {
c = *from;
}
typedef std::num_get<CharT, InItrT> num_get;
typename duration_type::duration_rep_type val = 0;
std::ios_base::iostate err = std::ios_base::goodbit;
if (std::has_facet<num_get>(a_ios.getloc())) {
from = std::use_facet<num_get>(a_ios.getloc()).get(from, to, a_ios, err, val);
}
else {
num_get* ng = new num_get();
std::locale l = std::locale(a_ios.getloc(), ng);
a_ios.imbue(l);
from = ng->get(from, to, a_ios, err, val);
}
if(err & std::ios_base::failbit){
typedef typename special_values_parser_type::match_results match_results;
match_results mr;
if(c == '-' || c == '+') { // was the first character consumed?
mr.cache += c;
}
m_sv_parser.match(from, to, mr);
if(mr.current_match == match_results::PARSE_ERROR) {
boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'"));
BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(return from); // should never reach
}
dd = duration_type(static_cast<special_values>(mr.current_match));
}
else {
dd = duration_type(val);
}
return from;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& a_ios,
period_type& p) const
{
p = m_period_parser.get_period(from, to, a_ios, p, duration_type::unit(), *this);
return from;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& a_ios,
nth_kday_type& nkd) const
{
nkd = m_date_gen_parser.get_nth_kday_type(from, to, a_ios, *this);
return from;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& a_ios,
partial_date_type& pd) const
{
pd = m_date_gen_parser.get_partial_date_type(from, to, a_ios, *this);
return from;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& a_ios,
first_kday_type& fkd) const
{
fkd = m_date_gen_parser.get_first_kday_type(from, to, a_ios, *this);
return from;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& a_ios,
last_kday_type& lkd) const
{
lkd = m_date_gen_parser.get_last_kday_type(from, to, a_ios, *this);
return from;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& a_ios,
kday_before_type& fkb) const
{
fkb = m_date_gen_parser.get_kday_before_type(from, to, a_ios, *this);
return from;
}
InItrT get(InItrT& from,
InItrT& to,
std::ios_base& a_ios,
kday_after_type& fka) const
{
fka = m_date_gen_parser.get_kday_after_type(from, to, a_ios, *this);
return from;
}
protected:
string_type m_format;
string_type m_month_format;
string_type m_weekday_format;
string_type m_year_format;
format_date_parser_type m_parser;
date_gen_parser_type m_date_gen_parser;
period_parser_type m_period_parser;
special_values_parser_type m_sv_parser;
private:
};
template <class date_type, class CharT, class OutItrT>
std::locale::id date_input_facet<date_type, CharT, OutItrT>::id;
template <class date_type, class CharT, class OutItrT>
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::long_weekday_format[3] = {'%','A'};
template <class date_type, class CharT, class OutItrT>
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::short_weekday_format[3] = {'%','a'};
template <class date_type, class CharT, class OutItrT>
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::long_month_format[3] = {'%','B'};
template <class date_type, class CharT, class OutItrT>
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::short_month_format[3] = {'%','b'};
template <class date_type, class CharT, class OutItrT>
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::four_digit_year_format[3] = {'%','Y'};
template <class date_type, class CharT, class OutItrT>
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::two_digit_year_format[3] = {'%','y'};
template <class date_type, class CharT, class OutItrT>
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::default_period_separator[4] = { ' ', '/', ' '};
template <class date_type, class CharT, class OutItrT>
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::standard_format_specifier[3] =
{'%', 'x' };
template <class date_type, class CharT, class OutItrT>
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::iso_format_specifier[7] =
{'%', 'Y', '%', 'm', '%', 'd' };
template <class date_type, class CharT, class OutItrT>
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::iso_format_extended_specifier[9] =
{'%', 'Y', '-', '%', 'm', '-', '%', 'd' };
template <class date_type, class CharT, class OutItrT>
const typename date_input_facet<date_type, CharT, OutItrT>::char_type
date_input_facet<date_type, CharT, OutItrT>::default_date_format[9] =
{'%','Y','-','%','b','-','%','d'};
} } // namespaces
#endif
@@ -4,7 +4,7 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
+4 -15
View File
@@ -4,14 +4,13 @@
/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include "boost/date_time/iso_format.hpp"
#include "boost/date_time/compiler_config.hpp"
#include <boost/io/ios_state.hpp>
#include <string>
#include <sstream>
#include <iomanip>
@@ -28,15 +27,14 @@ namespace date_time {
template<class month_type, class format_type, class charT=char>
class month_formatter
{
typedef std::basic_ostream<charT> ostream_type;
public:
//! Formats a month as as string into an ostream
/*! This function demands that month_type provide
* functions for converting to short and long strings
* if that capability is used.
*/
static ostream_type& format_month(const month_type& month,
ostream_type &os)
static std::basic_ostream<charT>& format_month(const month_type& month,
std::basic_ostream<charT>& os)
{
switch (format_type::month_format())
{
@@ -52,13 +50,10 @@ namespace date_time {
}
case month_as_integer:
{
boost::io::basic_ios_fill_saver<charT> ifs(os);
os << std::setw(2) << std::setfill(os.widen('0')) << month.as_number();
break;
}
default:
break;
}
return os;
} // format_month
@@ -83,13 +78,7 @@ namespace date_time {
{
typedef typename ymd_type::month_type month_type;
std::basic_ostringstream<charT> ss;
// Temporarily switch to classic locale to prevent possible formatting
// of year with comma or other character (for example 2,008).
ss.imbue(std::locale::classic());
ss << ymd.year;
ss.imbue(std::locale());
if (format_type::has_date_sep_chars()) {
ss << format_type::month_sep_char();
}
@@ -4,7 +4,7 @@
/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -4,7 +4,7 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -17,7 +17,6 @@
#include "boost/date_time/iso_format.hpp"
#include "boost/date_time/date_names_put.hpp"
#include "boost/date_time/parse_format_base.hpp"
#include <boost/io/ios_state.hpp>
//#include <string>
#include <sstream>
#include <iomanip>
@@ -57,8 +56,8 @@ namespace date_time {
}
case month_as_integer:
{
boost::io::basic_ios_fill_saver<charT> ifs(os);
os << std::setw(2) << std::setfill(os.widen('0')) << month.as_number();
charT fill_char = '0';
os << std::setw(2) << std::setfill(fill_char) << month.as_number();
break;
}
@@ -133,8 +132,8 @@ namespace date_time {
ostream_type& os,
const facet_type& f)
{
boost::io::basic_ios_fill_saver<charT> ifs(os);
std::ostreambuf_iterator<charT> oitr(os);
charT fill_char = '0';
switch (f.date_order()) {
case ymd_order_iso: {
os << ymd.year;
@@ -145,7 +144,7 @@ namespace date_time {
if (f.has_date_sep_chars()) {
f.day_sep_char(oitr);
}
os << std::setw(2) << std::setfill(os.widen('0'))
os << std::setw(2) << std::setfill(fill_char)
<< ymd.day;
break;
}
@@ -154,7 +153,7 @@ namespace date_time {
if (f.has_date_sep_chars()) {
f.day_sep_char(oitr);
}
os << std::setw(2) << std::setfill(os.widen('0'))
os << std::setw(2) << std::setfill(fill_char)
<< ymd.day;
if (f.has_date_sep_chars()) {
f.month_sep_char(oitr);
@@ -163,7 +162,7 @@ namespace date_time {
break;
}
case ymd_order_dmy: {
os << std::setw(2) << std::setfill(os.widen('0'))
os << std::setw(2) << std::setfill(fill_char)
<< ymd.day;
if (f.has_date_sep_chars()) {
f.day_sep_char(oitr);
@@ -1,265 +0,0 @@
#ifndef _DATE_TIME_DATE_GENERATOR_FORMATTER__HPP___
#define _DATE_TIME_DATE_GENERATOR_FORMATTER__HPP___
/* Copyright (c) 2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include "boost/date_time/date_generators.hpp"
namespace boost {
namespace date_time {
//! Formats date_generators for output
/*! Formatting of date_generators follows specific orders for the
* various types of date_generators.
* - partial_date => "dd Month"
* - nth_day_of_the_week_in_month => "nth weekday of month"
* - first_day_of_the_week_in_month => "first weekday of month"
* - last_day_of_the_week_in_month => "last weekday of month"
* - first_day_of_the_week_after => "weekday after"
* - first_day_of_the_week_before => "weekday before"
* While the order of the elements in these phrases cannot be changed,
* the elements themselves can be. Weekday and Month get their formats
* and names from the date_facet. The remaining elements are stored in
* the date_generator_formatter and can be customized upon construction
* or via a member function. The default elements are those shown in the
* examples above.
*/
template <class date_type, class CharT, class OutItrT = std::ostreambuf_iterator<CharT, std::char_traits<CharT> > >
class date_generator_formatter {
public:
typedef partial_date<date_type> partial_date_type;
typedef nth_kday_of_month<date_type> nth_kday_type;
typedef first_kday_of_month<date_type> first_kday_type;
typedef last_kday_of_month<date_type> last_kday_type;
typedef first_kday_after<date_type> kday_after_type;
typedef first_kday_before<date_type> kday_before_type;
typedef CharT char_type;
typedef std::basic_string<char_type> string_type;
typedef std::vector<string_type> collection_type;
static const char_type first_string[6];
static const char_type second_string[7];
static const char_type third_string[6];
static const char_type fourth_string[7];
static const char_type fifth_string[6];
static const char_type last_string[5];
static const char_type before_string[8];
static const char_type after_string[6];
static const char_type of_string[3];
enum phrase_elements {first=0, second, third, fourth, fifth, last,
before, after, of, number_of_phrase_elements};
//! Default format elements used
date_generator_formatter()
{
phrase_strings.reserve(number_of_phrase_elements);
phrase_strings.push_back(string_type(first_string));
phrase_strings.push_back(string_type(second_string));
phrase_strings.push_back(string_type(third_string));
phrase_strings.push_back(string_type(fourth_string));
phrase_strings.push_back(string_type(fifth_string));
phrase_strings.push_back(string_type(last_string));
phrase_strings.push_back(string_type(before_string));
phrase_strings.push_back(string_type(after_string));
phrase_strings.push_back(string_type(of_string));
}
//! Constructor that allows for a custom set of phrase elements
date_generator_formatter(const string_type& first_str,
const string_type& second_str,
const string_type& third_str,
const string_type& fourth_str,
const string_type& fifth_str,
const string_type& last_str,
const string_type& before_str,
const string_type& after_str,
const string_type& of_str)
{
phrase_strings.reserve(number_of_phrase_elements);
phrase_strings.push_back(first_str);
phrase_strings.push_back(second_str);
phrase_strings.push_back(third_str);
phrase_strings.push_back(fourth_str);
phrase_strings.push_back(fifth_str);
phrase_strings.push_back(last_str);
phrase_strings.push_back(before_str);
phrase_strings.push_back(after_str);
phrase_strings.push_back(of_str);
}
//! Replace the set of phrase elements with those contained in new_strings
/*! The order of the strings in the given collection is important.
* They must follow:
* - first, second, third, fourth, fifth, last, before, after, of.
*
* It is not necessary to send in a complete set if only a few
* elements are to be replaced as long as the correct beg_pos is used.
*
* Ex: To keep the default first through fifth elements, but replace
* the rest with a collection of:
* - "final", "prior", "following", "in".
* The beg_pos of date_generator_formatter::last would be used.
*/
void elements(const collection_type& new_strings,
phrase_elements beg_pos=first)
{
if(beg_pos < number_of_phrase_elements) {
typename collection_type::iterator itr = phrase_strings.begin();
itr += beg_pos;
std::copy(new_strings.begin(), new_strings.end(),
itr);
//phrase_strings.begin());
}
}
//!Put a partial_date => "dd Month"
template<class facet_type>
OutItrT put_partial_date(OutItrT next, std::ios_base& a_ios,
CharT a_fill, const partial_date_type& pd,
const facet_type& facet) const
{
facet.put(next, a_ios, a_fill, pd.day());
next = a_fill; //TODO change this ???
facet.put(next, a_ios, a_fill, pd.month());
return next;
}
//! Put an nth_day_of_the_week_in_month => "nth weekday of month"
template<class facet_type>
OutItrT put_nth_kday(OutItrT next, std::ios_base& a_ios,
CharT a_fill, const nth_kday_type& nkd,
const facet_type& facet) const
{
put_string(next, phrase_strings[nkd.nth_week() -1]);
next = a_fill; //TODO change this ???
facet.put(next, a_ios, a_fill, nkd.day_of_week());
next = a_fill; //TODO change this ???
put_string(next, string_type(of_string));
next = a_fill; //TODO change this ???
facet.put(next, a_ios, a_fill, nkd.month());
return next;
}
//! Put a first_day_of_the_week_in_month => "first weekday of month"
template<class facet_type>
OutItrT put_first_kday(OutItrT next, std::ios_base& a_ios,
CharT a_fill, const first_kday_type& fkd,
const facet_type& facet) const
{
put_string(next, phrase_strings[first]);
next = a_fill; //TODO change this ???
facet.put(next, a_ios, a_fill, fkd.day_of_week());
next = a_fill; //TODO change this ???
put_string(next, string_type(of_string));
next = a_fill; //TODO change this ???
facet.put(next, a_ios, a_fill, fkd.month());
return next;
}
//! Put a last_day_of_the_week_in_month => "last weekday of month"
template<class facet_type>
OutItrT put_last_kday(OutItrT next, std::ios_base& a_ios,
CharT a_fill, const last_kday_type& lkd,
const facet_type& facet) const
{
put_string(next, phrase_strings[last]);
next = a_fill; //TODO change this ???
facet.put(next, a_ios, a_fill, lkd.day_of_week());
next = a_fill; //TODO change this ???
put_string(next, string_type(of_string));
next = a_fill; //TODO change this ???
facet.put(next, a_ios, a_fill, lkd.month());
return next;
}
//! Put a first_day_of_the_week_before => "weekday before"
template<class facet_type>
OutItrT put_kday_before(OutItrT next, std::ios_base& a_ios,
CharT a_fill, const kday_before_type& fkb,
const facet_type& facet) const
{
facet.put(next, a_ios, a_fill, fkb.day_of_week());
next = a_fill; //TODO change this ???
put_string(next, phrase_strings[before]);
return next;
}
//! Put a first_day_of_the_week_after => "weekday after"
template<class facet_type>
OutItrT put_kday_after(OutItrT next, std::ios_base& a_ios,
CharT a_fill, const kday_after_type& fka,
const facet_type& facet) const
{
facet.put(next, a_ios, a_fill, fka.day_of_week());
next = a_fill; //TODO change this ???
put_string(next, phrase_strings[after]);
return next;
}
private:
collection_type phrase_strings;
//! helper function to put the various member string into stream
OutItrT put_string(OutItrT next, const string_type& str) const
{
typename string_type::const_iterator itr = str.begin();
while(itr != str.end()) {
*next = *itr;
++itr;
++next;
}
return next;
}
};
template<class date_type, class CharT, class OutItrT>
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
date_generator_formatter<date_type, CharT, OutItrT>::first_string[6] =
{'f','i','r','s','t'};
template<class date_type, class CharT, class OutItrT>
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
date_generator_formatter<date_type, CharT, OutItrT>::second_string[7] =
{'s','e','c','o','n','d'};
template<class date_type, class CharT, class OutItrT>
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
date_generator_formatter<date_type, CharT, OutItrT>::third_string[6] =
{'t','h','i','r','d'};
template<class date_type, class CharT, class OutItrT>
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
date_generator_formatter<date_type, CharT, OutItrT>::fourth_string[7] =
{'f','o','u','r','t','h'};
template<class date_type, class CharT, class OutItrT>
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
date_generator_formatter<date_type, CharT, OutItrT>::fifth_string[6] =
{'f','i','f','t','h'};
template<class date_type, class CharT, class OutItrT>
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
date_generator_formatter<date_type, CharT, OutItrT>::last_string[5] =
{'l','a','s','t'};
template<class date_type, class CharT, class OutItrT>
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
date_generator_formatter<date_type, CharT, OutItrT>::before_string[8] =
{'b','e','f','o','r','e'};
template<class date_type, class CharT, class OutItrT>
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
date_generator_formatter<date_type, CharT, OutItrT>::after_string[6] =
{'a','f','t','e','r'};
template<class date_type, class CharT, class OutItrT>
const typename date_generator_formatter<date_type, CharT, OutItrT>::char_type
date_generator_formatter<date_type, CharT, OutItrT>::of_string[3] =
{'o','f'};
} } // namespaces
#endif // _DATE_TIME_DATE_GENERATOR_FORMATTER__HPP___
@@ -1,330 +0,0 @@
#ifndef DATE_TIME_DATE_GENERATOR_PARSER_HPP__
#define DATE_TIME_DATE_GENERATOR_PARSER_HPP__
/* Copyright (c) 2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <string>
#include <vector>
#include <iterator> // istreambuf_iterator
#include <boost/throw_exception.hpp>
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/string_parse_tree.hpp>
#include <boost/date_time/date_generators.hpp>
#include <boost/date_time/format_date_parser.hpp>
namespace boost { namespace date_time {
//! Class for date_generator parsing
/*! The elements of a date_generator "phrase" are parsed from the input stream in a
* particular order. All elements are required and the order in which they appear
* cannot change, however, the elements themselves can be changed. The default
* elements and their order are as follows:
*
* - partial_date => "dd Month"
* - nth_day_of_the_week_in_month => "nth weekday of month"
* - first_day_of_the_week_in_month => "first weekday of month"
* - last_day_of_the_week_in_month => "last weekday of month"
* - first_day_of_the_week_after => "weekday after"
* - first_day_of_the_week_before => "weekday before"
*
* Weekday and Month names and formats are handled via the date_input_facet.
*
*/
template<class date_type, typename charT>
class date_generator_parser
{
public:
typedef std::basic_string<charT> string_type;
typedef std::istreambuf_iterator<charT> stream_itr_type;
typedef typename date_type::month_type month_type;
typedef typename date_type::day_of_week_type day_of_week_type;
typedef typename date_type::day_type day_type;
typedef string_parse_tree<charT> parse_tree_type;
typedef typename parse_tree_type::parse_match_result_type match_results;
typedef std::vector<std::basic_string<charT> > collection_type;
typedef partial_date<date_type> partial_date_type;
typedef nth_kday_of_month<date_type> nth_kday_type;
typedef first_kday_of_month<date_type> first_kday_type;
typedef last_kday_of_month<date_type> last_kday_type;
typedef first_kday_after<date_type> kday_after_type;
typedef first_kday_before<date_type> kday_before_type;
typedef charT char_type;
static const char_type first_string[6];
static const char_type second_string[7];
static const char_type third_string[6];
static const char_type fourth_string[7];
static const char_type fifth_string[6];
static const char_type last_string[5];
static const char_type before_string[8];
static const char_type after_string[6];
static const char_type of_string[3];
enum phrase_elements {first=0, second, third, fourth, fifth, last,
before, after, of, number_of_phrase_elements};
//! Creates a date_generator_parser with the default set of "element_strings"
date_generator_parser()
{
element_strings(string_type(first_string),
string_type(second_string),
string_type(third_string),
string_type(fourth_string),
string_type(fifth_string),
string_type(last_string),
string_type(before_string),
string_type(after_string),
string_type(of_string));
}
//! Creates a date_generator_parser using a user defined set of element strings
date_generator_parser(const string_type& first_str,
const string_type& second_str,
const string_type& third_str,
const string_type& fourth_str,
const string_type& fifth_str,
const string_type& last_str,
const string_type& before_str,
const string_type& after_str,
const string_type& of_str)
{
element_strings(first_str, second_str, third_str, fourth_str, fifth_str,
last_str, before_str, after_str, of_str);
}
//! Replace strings that determine nth week for generator
void element_strings(const string_type& first_str,
const string_type& second_str,
const string_type& third_str,
const string_type& fourth_str,
const string_type& fifth_str,
const string_type& last_str,
const string_type& before_str,
const string_type& after_str,
const string_type& of_str)
{
collection_type phrases;
phrases.push_back(first_str);
phrases.push_back(second_str);
phrases.push_back(third_str);
phrases.push_back(fourth_str);
phrases.push_back(fifth_str);
phrases.push_back(last_str);
phrases.push_back(before_str);
phrases.push_back(after_str);
phrases.push_back(of_str);
m_element_strings = parse_tree_type(phrases, this->first); // enum first
}
void element_strings(const collection_type& col)
{
m_element_strings = parse_tree_type(col, this->first); // enum first
}
//! returns partial_date parsed from stream
template<class facet_type>
partial_date_type
get_partial_date_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
day_type d(1);
month_type m(1);
facet.get(sitr, stream_end, a_ios, d);
facet.get(sitr, stream_end, a_ios, m);
return partial_date_type(d,m);
}
//! returns nth_kday_of_week parsed from stream
template<class facet_type>
nth_kday_type
get_nth_kday_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
typename nth_kday_type::week_num wn;
day_of_week_type wd(0); // no default constructor
month_type m(1); // no default constructor
match_results mr = m_element_strings.match(sitr, stream_end);
switch(mr.current_match) {
case first : { wn = nth_kday_type::first; break; }
case second : { wn = nth_kday_type::second; break; }
case third : { wn = nth_kday_type::third; break; }
case fourth : { wn = nth_kday_type::fourth; break; }
case fifth : { wn = nth_kday_type::fifth; break; }
default:
{
boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'"));
BOOST_DATE_TIME_UNREACHABLE_EXPRESSION(wn = nth_kday_type::first);
}
} // week num
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
extract_element(sitr, stream_end, of); // "of" element
facet.get(sitr, stream_end, a_ios, m); // month
return nth_kday_type(wn, wd, m);
}
//! returns first_kday_of_week parsed from stream
template<class facet_type>
first_kday_type
get_first_kday_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
day_of_week_type wd(0); // no default constructor
month_type m(1); // no default constructor
extract_element(sitr, stream_end, first); // "first" element
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
extract_element(sitr, stream_end, of); // "of" element
facet.get(sitr, stream_end, a_ios, m); // month
return first_kday_type(wd, m);
}
//! returns last_kday_of_week parsed from stream
template<class facet_type>
last_kday_type
get_last_kday_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
day_of_week_type wd(0); // no default constructor
month_type m(1); // no default constructor
extract_element(sitr, stream_end, last); // "last" element
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
extract_element(sitr, stream_end, of); // "of" element
facet.get(sitr, stream_end, a_ios, m); // month
return last_kday_type(wd, m);
}
//! returns first_kday_of_week parsed from stream
template<class facet_type>
kday_before_type
get_kday_before_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
day_of_week_type wd(0); // no default constructor
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
extract_element(sitr, stream_end, before);// "before" element
return kday_before_type(wd);
}
//! returns first_kday_of_week parsed from stream
template<class facet_type>
kday_after_type
get_kday_after_type(stream_itr_type& sitr,
stream_itr_type& stream_end,
std::ios_base& a_ios,
const facet_type& facet) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
day_of_week_type wd(0); // no default constructor
facet.get(sitr, stream_end, a_ios, wd); // day_of_week
extract_element(sitr, stream_end, after); // "after" element
return kday_after_type(wd);
}
private:
parse_tree_type m_element_strings;
//! Extracts phrase element from input. Throws ios_base::failure on error.
void extract_element(stream_itr_type& sitr,
stream_itr_type& stream_end,
typename date_generator_parser::phrase_elements ele) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
match_results mr = m_element_strings.match(sitr, stream_end);
if(mr.current_match != ele) {
boost::throw_exception(std::ios_base::failure("Parse failed. No match found for '" + mr.cache + "'"));
}
}
};
template<class date_type, class CharT>
const typename date_generator_parser<date_type, CharT>::char_type
date_generator_parser<date_type, CharT>::first_string[6] =
{'f','i','r','s','t'};
template<class date_type, class CharT>
const typename date_generator_parser<date_type, CharT>::char_type
date_generator_parser<date_type, CharT>::second_string[7] =
{'s','e','c','o','n','d'};
template<class date_type, class CharT>
const typename date_generator_parser<date_type, CharT>::char_type
date_generator_parser<date_type, CharT>::third_string[6] =
{'t','h','i','r','d'};
template<class date_type, class CharT>
const typename date_generator_parser<date_type, CharT>::char_type
date_generator_parser<date_type, CharT>::fourth_string[7] =
{'f','o','u','r','t','h'};
template<class date_type, class CharT>
const typename date_generator_parser<date_type, CharT>::char_type
date_generator_parser<date_type, CharT>::fifth_string[6] =
{'f','i','f','t','h'};
template<class date_type, class CharT>
const typename date_generator_parser<date_type, CharT>::char_type
date_generator_parser<date_type, CharT>::last_string[5] =
{'l','a','s','t'};
template<class date_type, class CharT>
const typename date_generator_parser<date_type, CharT>::char_type
date_generator_parser<date_type, CharT>::before_string[8] =
{'b','e','f','o','r','e'};
template<class date_type, class CharT>
const typename date_generator_parser<date_type, CharT>::char_type
date_generator_parser<date_type, CharT>::after_string[6] =
{'a','f','t','e','r'};
template<class date_type, class CharT>
const typename date_generator_parser<date_type, CharT>::char_type
date_generator_parser<date_type, CharT>::of_string[3] =
{'o','f'};
} } //namespace
#endif // DATE_TIME_DATE_GENERATOR_PARSER_HPP__
+54 -114
View File
@@ -1,23 +1,21 @@
#ifndef DATE_TIME_DATE_GENERATORS_HPP__
#define DATE_TIME_DATE_GENERATORS_HPP__
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
/*! @file date_generators.hpp
Definition and implementation of date algorithm templates
*/
#include <sstream>
#include <stdexcept>
#include <boost/throw_exception.hpp>
#include <boost/date_time/date.hpp>
#include <boost/date_time/compiler_config.hpp>
#include <sstream>
#include "boost/date_time/date.hpp"
#include "boost/date_time/compiler_config.hpp"
namespace boost {
namespace date_time {
@@ -25,7 +23,7 @@ namespace date_time {
//! Base class for all generators that take a year and produce a date.
/*! This class is a base class for polymorphic function objects that take
a year and produce a concrete date.
@tparam date_type The type representing a date. This type must
@param date_type The type representing a date. This type must
export a calender_type which defines a year_type.
*/
template<class date_type>
@@ -34,16 +32,14 @@ namespace date_time {
public:
typedef typename date_type::calendar_type calendar_type;
typedef typename calendar_type::year_type year_type;
year_based_generator() {}
virtual ~year_based_generator() {}
year_based_generator() {};
virtual ~year_based_generator() {};
virtual date_type get_date(year_type y) const = 0;
//! Returns a string for use in a POSIX time_zone string
virtual std::string to_string() const = 0;
};
//! Generates a date by applying the year to the given month and day.
/*!
Example usage:
Example usage:
@code
partial_date pd(1, Jan);
partial_date pd2(70);
@@ -98,14 +94,16 @@ namespace date_time {
* pg.get_date(2000); // returns 2000-2-29
* @endcode
*/
date_type get_date(year_type y) const BOOST_OVERRIDE
date_type get_date(year_type y) const
{
if((day_ == 29) && (month_ == 2) && !(calendar_type::is_leap_year(y))) {
std::ostringstream ss;
std::stringstream ss("");
ss << "No Feb 29th in given year of " << y << ".";
boost::throw_exception(std::invalid_argument(ss.str()));
throw std::invalid_argument(ss.str());
//return date_type(1,1,1); // should never reach
} else {
return date_type(y, month_, day_);
}
return date_type(y, month_, day_);
}
date_type operator()(year_type y) const
{
@@ -123,63 +121,31 @@ namespace date_time {
//months are equal
return (day_ < rhs.day_);
}
// added for streaming purposes
month_type month() const
{
return month_;
}
day_type day() const
{
return day_;
}
//! Returns string suitable for use in POSIX time zone string
/*! Returns string formatted with up to 3 digits:
* Jan-01 == "0"
* Feb-29 == "58"
* Dec-31 == "365" */
std::string to_string() const BOOST_OVERRIDE
{
std::ostringstream ss;
date_type d(2004, month_, day_);
unsigned short c = d.day_of_year();
c--; // numbered 0-365 while day_of_year is 1 based...
ss << c;
return ss.str();
}
month_type month()const{return month_;}
day_type day()const{return day_;}
private:
day_type day_;
month_type month_;
};
//! Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5.
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
* the 'first Monday of September'. When instantiated with
* 'fifth' kday of month, the result will be the last kday of month
* which can be the fourth or fifth depending on the structure of
* which can be the fourth or fifth depending on the structure of
* the month.
*
* The algorithm here basically guesses for the first
* day of the month. Then finds the first day of the correct
* type. That is, if the first of the month is a Tuesday
* and it needs Wednesday then we simply increment by a day
* and it needs Wenesday then we simply increment by a day
* and then we can add the length of a week until we get
* to the 'nth kday'. There are probably more efficient
* algorithms based on using a mod 7, but this one works
* to the 'nth kday'. There are probably more efficient
* algorithms based on using a mod 7, but this one works
* reasonably well for basic applications.
* \ingroup date_alg
*/
@@ -201,7 +167,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 BOOST_OVERRIDE
date_type get_date(year_type y) const
{
date_type d(y, month_, 1); //first day of month
duration_type one_day(1);
@@ -237,22 +203,14 @@ namespace date_time {
{
return nth_as_str(wn_);
}
//! Returns string suitable for use in POSIX time zone string
/*! Returns a string formatted as "M4.3.0" ==> 3rd Sunday in April. */
std::string to_string() const BOOST_OVERRIDE
{
std::ostringstream ss;
ss << 'M'
<< static_cast<int>(month_) << '.'
<< static_cast<int>(wn_) << '.'
<< static_cast<int>(dow_);
return ss.str();
}
private:
month_type month_;
week_num wn_;
day_of_week_type dow_;
};
//! Returns nth arg as string. 1 -> "first", 2 -> "second", max is 5.
BOOST_DATE_TIME_DECL const char* nth_as_str(int n);
//! Useful generator functor for finding holidays and daylight savings
/*! Similar to nth_kday_of_month, but requires less paramters
@@ -276,7 +234,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 BOOST_OVERRIDE
date_type get_date(year_type year) const
{
date_type d(year, month_,1);
duration_type one_day(1);
@@ -284,7 +242,7 @@ namespace date_time {
d = d + one_day;
}
return d;
}
}
// added for streaming
month_type month() const
{
@@ -294,29 +252,18 @@ namespace date_time {
{
return dow_;
}
//! Returns string suitable for use in POSIX time zone string
/*! Returns a string formatted as "M4.1.0" ==> 1st Sunday in April. */
std::string to_string() const BOOST_OVERRIDE
{
std::ostringstream ss;
ss << 'M'
<< static_cast<int>(month_) << '.'
<< 1 << '.'
<< static_cast<int>(dow_);
return ss.str();
}
private:
month_type month_;
day_of_week_type dow_;
};
//! Calculate something like Last Sunday of January
/*! Useful generator functor for finding holidays and daylight savings
* Get the last day of the month and then calculate the difference
* to the last previous day.
* @tparam date_type A date class that exports day_of_week, month_type, etc.
* @param date_type A date class that exports day_of_week, month_type, etc.
* \ingroup date_alg
*/
template<class date_type>
@@ -337,7 +284,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 BOOST_OVERRIDE
date_type get_date(year_type year) const
{
date_type d(year, month_, calendar_type::end_of_month_day(year,month_));
duration_type one_day(1);
@@ -355,23 +302,12 @@ namespace date_time {
{
return dow_;
}
//! Returns string suitable for use in POSIX time zone string
/*! Returns a string formatted as "M4.5.0" ==> last Sunday in April. */
std::string to_string() const BOOST_OVERRIDE
{
std::ostringstream ss;
ss << 'M'
<< static_cast<int>(month_) << '.'
<< 5 << '.'
<< static_cast<int>(dow_);
return ss.str();
}
private:
month_type month_;
day_of_week_type dow_;
};
//! Calculate something like "First Sunday after Jan 1,2002
/*! Date generator that takes a date and finds kday after
*@code
@@ -409,7 +345,7 @@ namespace date_time {
private:
day_of_week_type dow_;
};
//! Calculate something like "First Sunday before Jan 1,2002
/*! Date generator that takes a date and finds kday after
*@code
@@ -447,10 +383,10 @@ namespace date_time {
private:
day_of_week_type dow_;
};
//! Calculates the number of days until the next weekday
/*! Calculates the number of days until the next weekday.
* If the date given falls on a Sunday and the given weekday
* If the date given falls on a Sunday and the given weekday
* is Tuesday the result will be 2 days */
template<typename date_type, class weekday_type>
inline
@@ -467,8 +403,8 @@ namespace date_time {
//! Calculates the number of days since the previous weekday
/*! Calculates the number of days since the previous weekday
* If the date given falls on a Sunday and the given weekday
* is Tuesday the result will be 5 days. The answer will be a positive
* If the date given falls on a Sunday and the given weekday
* is Tuesday the result will be 5 days. The answer will be a positive
* number because Tuesday is 5 days before Sunday, not -5 days before. */
template<typename date_type, class weekday_type>
inline
@@ -486,9 +422,9 @@ namespace date_time {
}
//! Generates a date object representing the date of the following weekday from the given date
/*! Generates a date object representing the date of the following
* weekday from the given date. If the date given is 2004-May-9
* (a Sunday) and the given weekday is Tuesday then the resulting date
/*! Generates a date object representing the date of the following
* weekday from the given date. If the date given is 2004-May-9
* (a Sunday) and the given weekday is Tuesday then the resulting date
* will be 2004-May-11. */
template<class date_type, class weekday_type>
inline
@@ -498,9 +434,9 @@ namespace date_time {
}
//! Generates a date object representing the date of the previous weekday from the given date
/*! Generates a date object representing the date of the previous
* weekday from the given date. If the date given is 2004-May-9
* (a Sunday) and the given weekday is Tuesday then the resulting date
/*! Generates a date object representing the date of the previous
* weekday from the given date. If the date given is 2004-May-9
* (a Sunday) and the given weekday is Tuesday then the resulting date
* will be 2004-May-4. */
template<class date_type, class weekday_type>
inline
@@ -511,4 +447,8 @@ namespace date_time {
} } //namespace date_time
#endif
+20 -20
View File
@@ -2,9 +2,9 @@
#define DATE_ITERATOR_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)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -32,7 +32,7 @@ namespace date_time {
template<class date_type>
class date_itr_base {
// works, but benefit unclear at the moment
// class date_itr_base : public std::iterator<std::input_iterator_tag,
// class date_itr_base : public std::iterator<std::input_iterator_tag,
// date_type, void, void, void>{
public:
typedef typename date_type::duration_type duration_type;
@@ -40,31 +40,31 @@ namespace date_time {
typedef std::input_iterator_tag iterator_category;
date_itr_base(date_type d) : current_(d) {}
virtual ~date_itr_base() {}
date_itr_base& operator++()
virtual ~date_itr_base() {};
date_itr_base& operator++()
{
current_ = current_ + get_offset(current_);
return *this;
}
date_itr_base& operator--()
date_itr_base& operator--()
{
current_ = current_ + get_neg_offset(current_);
return *this;
}
virtual duration_type get_offset(const date_type& current) const=0;
virtual duration_type get_neg_offset(const date_type& current) const=0;
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;}
date_type operator*() {return current_;};
date_type* operator->() {return &current_;};
bool operator< (const date_type& d) {return current_ < d;}
bool operator<= (const date_type& d) {return current_ <= d;}
bool operator> (const date_type& d) {return current_ > d;}
bool operator>= (const date_type& d) {return current_ >= d;}
bool operator== (const date_type& d) {return current_ == d;}
bool operator!= (const date_type& d) {return current_ != d;}
private:
date_type current_;
};
//! Overrides the base date iterator providing hook for functors
/*
* <b>offset_functor</b>
@@ -77,9 +77,9 @@ namespace date_time {
class date_itr : public date_itr_base<date_type> {
public:
typedef typename date_type::duration_type duration_type;
date_itr(date_type d, int factor=1) :
date_itr_base<date_type>(d),
of_(factor)
date_itr(date_type d, int factor=1) :
date_itr_base<date_type>(d),
of_(factor)
{}
private:
virtual duration_type get_offset(const date_type& current) const
@@ -92,9 +92,9 @@ namespace date_time {
}
offset_functor of_;
};
} } //namespace date_time
+53 -58
View File
@@ -1,24 +1,23 @@
#ifndef DATE_TIME_DATE_NAMES_PUT_HPP___
#define DATE_TIME_DATE_NAMES_PUT_HPP___
/* Copyright (c) 2002-2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <boost/date_time/locale_config.hpp> // set BOOST_DATE_TIME_NO_LOCALE
#include "boost/date_time/locale_config.hpp" // set BOOST_DATE_TIME_NO_LOCALE
#ifndef BOOST_DATE_TIME_NO_LOCALE
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/date_defs.hpp>
#include <boost/date_time/parse_format_base.hpp>
#include <boost/lexical_cast.hpp>
#include "boost/date_time/special_defs.hpp"
#include "boost/date_time/date_defs.hpp"
#include "boost/date_time/parse_format_base.hpp"
#include "boost/lexical_cast.hpp"
#include <locale>
@@ -28,22 +27,22 @@ namespace date_time {
//! Output facet base class for gregorian dates.
/*! This class is a base class for date facets used to localize the
* names of months and the names of days in the week.
*
*
* Requirements of Config
* - define an enumeration month_enum that enumerates the months.
* - define an enumeration month_enum that enumerates the months.
* The enumeration should be '1' based eg: Jan==1
* - define as_short_string and as_long_string
*
* (see langer & kreft p334).
*
*
*/
template<class Config,
class charT = char,
class charT = char,
class OutputIterator = std::ostreambuf_iterator<charT> >
class BOOST_SYMBOL_VISIBLE date_names_put : public std::locale::facet
class date_names_put : public std::locale::facet
{
public:
date_names_put() {}
date_names_put() {};
typedef OutputIterator iter_type;
typedef typename Config::month_type month_type;
typedef typename Config::month_enum month_enum;
@@ -51,16 +50,8 @@ namespace date_time {
typedef typename Config::special_value_enum special_value_enum;
//typedef typename Config::format_type format_type;
typedef std::basic_string<charT> string_type;
typedef charT char_type;
static const char_type default_special_value_names[3][17];
static const char_type separator[2];
static std::locale::id id;
#if defined (__SUNPRO_CC) && defined (_RWSTD_VER)
std::locale::id& __get_id (void) const { return id; }
#endif
void put_special_value(iter_type& oitr, special_value_enum sv) const
{
do_put_special_value(oitr, sv);
@@ -119,7 +110,7 @@ namespace date_time {
put_string(oitr, gm.as_short_string(c));
}
//! Default facet implementation uses month_type defaults
virtual void do_put_month_long(iter_type& oitr,
virtual void do_put_month_long(iter_type& oitr,
month_enum moy) const
{
month_type gm(moy);
@@ -129,9 +120,26 @@ namespace date_time {
//! Default facet implementation for special value types
virtual void do_put_special_value(iter_type& oitr, special_value_enum sv) const
{
if(sv <= 2) { // only output not_a_date_time, neg_infin, or pos_infin
string_type s(default_special_value_names[sv]);
put_string(oitr, s);
switch (sv) {
case not_a_date_time:
{
string_type s(boost::lexical_cast<string_type>("not-a-date-time"));
put_string(oitr, s);
break;
}
case pos_infin:
{
string_type s(boost::lexical_cast<string_type>("+infinity"));
put_string(oitr, s);
break;
}
case neg_infin:
{
string_type s(boost::lexical_cast<string_type>("-infinity"));
put_string(oitr, s);
break;
}
default: {} //quiet compilers that want all cases covered here (eg: gcc 3.1)
}
}
virtual void do_put_weekday_short(iter_type&, weekday_enum) const
@@ -146,22 +154,22 @@ namespace date_time {
}
virtual void do_year_sep_char(iter_type& oitr) const
{
string_type s(separator);
string_type s(boost::lexical_cast<string_type>("-"));
put_string(oitr, s);
}
//! char between year-month
virtual void do_month_sep_char(iter_type& oitr) const
{
string_type s(separator);
string_type s(boost::lexical_cast<string_type>("-"));
put_string(oitr, s);
}
//! Char to separate month-day
virtual void do_day_sep_char(iter_type& oitr) const
{
string_type s(separator); //put in '-'
string_type s(boost::lexical_cast<string_type>("-"));
put_string(oitr, s);
}
//! Default for date order
//! Default for date order
virtual ymd_order_spec do_date_order() const
{
return ymd_order_iso;
@@ -187,29 +195,16 @@ namespace date_time {
}
}
};
template<class Config, class charT, class OutputIterator>
const typename date_names_put<Config, charT, OutputIterator>::char_type
date_names_put<Config, charT, OutputIterator>::default_special_value_names[3][17] = {
{'n','o','t','-','a','-','d','a','t','e','-','t','i','m','e'},
{'-','i','n','f','i','n','i','t','y'},
{'+','i','n','f','i','n','i','t','y'} };
template<class Config, class charT, class OutputIterator>
const typename date_names_put<Config, charT, OutputIterator>::char_type
date_names_put<Config, charT, OutputIterator>::separator[2] =
{'-', '\0'} ;
//! Generate storage location for a std::locale::id
//! Generate storage location for a std::locale::id
template<class Config, class charT, class OutputIterator>
std::locale::id date_names_put<Config, charT, OutputIterator>::id;
//! A date name output facet that takes an array of char* to define strings
//! An date name output facet that takes an array of char* to define strings
template<class Config,
class charT = char,
class charT = char,
class OutputIterator = std::ostreambuf_iterator<charT> >
class BOOST_SYMBOL_VISIBLE all_date_names_put : public date_names_put<Config, charT, OutputIterator>
class all_date_names_put : public date_names_put<Config, charT, OutputIterator>
{
public:
all_date_names_put(const charT* const month_short_names[],
@@ -231,29 +226,29 @@ namespace date_time {
separator_char_[0] = separator_char;
separator_char_[1] = '\0';
}
};
typedef OutputIterator iter_type;
typedef typename Config::month_enum month_enum;
typedef typename Config::weekday_enum weekday_enum;
typedef typename Config::special_value_enum special_value_enum;
const charT* const* get_short_month_names() const
const charT* const* get_short_month_names() const
{
return month_short_names_;
}
const charT* const* get_long_month_names() const
const charT* const* get_long_month_names() const
{
return month_long_names_;
}
const charT* const* get_special_value_names() const
const charT* const* get_special_value_names() const
{
return special_value_names_;
}
const charT* const* get_short_weekday_names()const
const charT* const* get_short_weekday_names()const
{
return weekday_short_names_;
}
const charT* const* get_long_weekday_names()const
const charT* const* get_long_weekday_names()const
{
return weekday_long_names_;
}
@@ -264,7 +259,7 @@ namespace date_time {
{
this->put_string(oitr, month_short_names_[moy-1]);
}
//! Long month names
//! Long month names
virtual void do_put_month_long(iter_type& oitr, month_enum moy) const
{
this->put_string(oitr, month_long_names_[moy-1]);
@@ -311,7 +306,7 @@ namespace date_time {
const charT* const* weekday_long_names_;
charT separator_char_[2];
ymd_order_spec order_spec_;
month_format_spec month_format_spec_;
month_format_spec month_format_spec_;
};
} } //namespace boost::date_time
+121 -196
View File
@@ -1,26 +1,23 @@
#ifndef _DATE_TIME_DATE_PARSING_HPP___
#define _DATE_TIME_DATE_PARSING_HPP___
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <map>
#include "boost/tokenizer.hpp"
#include "boost/lexical_cast.hpp"
#include "boost/date_time/compiler_config.hpp"
#include "boost/date_time/parse_format_base.hpp"
#include <string>
#include <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)
#if defined(BOOST_NO_STD_LOCALE)
#include <cctype> // ::tolower(int)
#else
#include <locale> // std::tolower(char, locale)
@@ -32,213 +29,167 @@ namespace date_time {
//! A function to replace the std::transform( , , ,tolower) construct
/*! This function simply takes a string, and changes all the characters
* in that string to lowercase (according to the default system locale).
* In the event that a compiler does not support locales, the old
* In the event that a compiler does not support locales, the old
* C style tolower() is used.
*/
inline
std::string
convert_to_lower(std::string inp)
{
#if !defined(BOOST_DATE_TIME_NO_LOCALE)
const std::locale loc(std::locale::classic());
#endif
std::string::size_type i = 0, n = inp.length();
for (; i < n; ++i) {
inp[i] =
#if defined(BOOST_DATE_TIME_NO_LOCALE)
static_cast<char>(std::tolower(inp[i]));
std::string
convert_to_lower(const std::string& inp) {
std::string tmp;
unsigned i = 0;
#if defined(BOOST_NO_STD_LOCALE)
while(i < inp.length()) {
tmp += static_cast<char>(std::tolower(inp.at(i++)));
#else
std::locale loc("");
while(i < inp.length()) {
// tolower and others were brought in to std for borland >= v564
// in compiler_config.hpp
std::tolower(inp[i], loc);
std::string::value_type c(inp.at(i++));
tmp += std::tolower(c, loc);
#endif
}
return tmp;
}
return inp;
}
//! 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) {
unsigned short
month_str_to_ushort(std::string s) {
if((s.at(0) >= '0') && (s.at(0) <= '9')) {
return boost::lexical_cast<unsigned short>(s);
}
}
else {
std::string str = convert_to_lower(s);
//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;
s = convert_to_lower(s);
typename month_type::month_map_ptr_type ptr = month_type::get_month_map_ptr();
typename month_type::month_map_type::iterator iter = ptr->find(s);
if(iter != ptr->end()) { // required for STLport
return iter->second;
}
}
return 13; // intentionally out of range - name not found
}
//! Find index of a string in either of 2 arrays
/*! find_match searches both arrays for a match to 's'. Indexing of the
* arrays is from 0 to 'limit'. The index of the match is returned.
* Ex. "Jan" returns 0, "Dec" returns 11, "Tue" returns 2.
* 'limit' can be sent in with: greg_month::max(),
* greg_weekday::max() or date_time::NumSpecialValues */
template<class charT>
short find_match(const charT* const* short_names,
const charT* const* long_names, const int limit,
const std::basic_string<charT>& s) {
for(int i = 0; i <= limit; ++i){
if(short_names[i] == s || long_names[i] == s){
return i;
}
}
return limit+1; // not-found, return a value out of range
}
//! Generic function to parse a delimited date (eg: 2002-02-10)
/*! Accepted formats are: "2003-02-10" or " 2003-Feb-10" or
* "2003-Feburary-10"
* The order in which the Month, Day, & Year appear in the argument
* string can be accomodated by passing in the appropriate ymd_order_spec
* "2003-Feburary-10"
* The order in which the Month, Day, & Year appear in the argument
* string can be accomodated by passing in the appropriate ymd_order_spec
*/
template<class date_type>
date_type
parse_date(const std::string& s, int order_spec = ymd_order_iso) {
std::string spec_str;
std::string spec_str("");
if(order_spec == ymd_order_iso) {
spec_str = "ymd";
}
}
else if(order_spec == ymd_order_dmy) {
spec_str = "dmy";
}
}
else { // (order_spec == ymd_order_us)
spec_str = "mdy";
}
typedef typename date_type::year_type year_type;
typedef typename date_type::month_type month_type;
unsigned pos = 0;
unsigned short year(0), month(0), day(0);
typedef typename std::basic_string<char>::traits_type traits_type;
typedef boost::char_separator<char, traits_type> char_separator_type;
typedef boost::tokenizer<char_separator_type,
std::basic_string<char>::const_iterator,
std::basic_string<char> > tokenizer;
typedef boost::tokenizer<char_separator_type,
std::basic_string<char>::const_iterator,
std::basic_string<char> >::iterator tokenizer_iterator;
// may need more delimiters, these work for the regression tests
const char sep_char[] = {',','-','.',' ','/','\0'};
char_separator_type sep(sep_char);
tokenizer tok(s,sep);
for(tokenizer_iterator beg=tok.begin();
beg!=tok.end() && pos < spec_str.size();
++beg, ++pos) {
typename date_type::ymd_type ymd((year_type::min)(),1,1);
boost::tokenizer<boost::char_delimiters_separator<char> > tok(s);
for(boost::tokenizer<>::iterator beg=tok.begin(); beg!=tok.end(), pos < spec_str.size(); ++beg, ++pos) {
unsigned short i =0;
switch(spec_str.at(pos)) {
case 'y':
case 'y':
{
year = boost::lexical_cast<unsigned short>(*beg);
i = boost::lexical_cast<unsigned short>(*beg);
ymd.year = i;
break;
}
case 'm':
case 'm':
{
month = month_str_to_ushort<month_type>(*beg);
ymd.month = month_str_to_ushort<month_type>(*beg);
break;
}
case 'd':
case 'd':
{
day = boost::lexical_cast<unsigned short>(*beg);
i = boost::lexical_cast<unsigned short>(*beg);
ymd.day = i;
break;
}
default: break;
} //switch
}
return date_type(year, month, day);
return date_type(ymd);
}
//! Generic function to parse undelimited date (eg: 20020201)
template<class date_type>
date_type
parse_undelimited_date(const std::string& s) {
int offsets[] = {4,2,2};
int pos = 0;
//typename date_type::ymd_type ymd((year_type::min)(),1,1);
unsigned short y = 0, m = 0, d = 0;
/* The two bool arguments state that parsing will not wrap
* (only the first 8 characters will be parsed) and partial
* strings will not be parsed.
* Ex:
* "2005121" will parse 2005 & 12, but not the "1" */
boost::offset_separator osf(offsets, offsets+3, false, false);
typedef typename boost::tokenizer<boost::offset_separator,
std::basic_string<char>::const_iterator,
std::basic_string<char> > tokenizer_type;
tokenizer_type tok(s, osf);
for(typename tokenizer_type::iterator ti=tok.begin(); ti!=tok.end();++ti) {
typedef typename date_type::year_type year_type;
typename date_type::ymd_type ymd((year_type::min)(),1,1);
boost::offset_separator osf(offsets, offsets+3);
boost::tokenizer<boost::offset_separator> tok(s, osf);
for(boost::tokenizer<boost::offset_separator>::iterator ti=tok.begin(); ti!=tok.end();++ti) {
unsigned short i = boost::lexical_cast<unsigned short>(*ti);
switch(pos) {
case 0: y = i; break;
case 1: m = i; break;
case 2: d = i; break;
default: break;
case 0: ymd.year = i; break;
case 1: ymd.month = i; break;
case 2: ymd.day = i; break;
}
pos++;
}
return date_type(y,m,d);
return date_type(ymd);
}
//! Helper function for 'date gregorian::from_stream()'
/*! Creates a string from the iterators that reference the
* begining & end of a char[] or string. All elements are
* begining & end of a char[] or string. All elements are
* used in output string */
template<class date_type, class iterator_type>
inline
inline
date_type
from_stream_type(iterator_type& beg,
iterator_type const& end,
char)
from_stream_type(iterator_type& beg,
iterator_type& end,
char)
{
std::ostringstream ss;
std::stringstream ss("");
while(beg != end) {
ss << *beg++;
}
return parse_date<date_type>(ss.str());
}
//! Helper function for 'date gregorian::from_stream()'
/*! Returns the first string found in the stream referenced by the
* begining & end iterators */
template<class date_type, class iterator_type>
inline
inline
date_type
from_stream_type(iterator_type& beg,
iterator_type const& /* end */,
std::string const&)
from_stream_type(iterator_type& beg,
iterator_type& end,
std::string)
{
return parse_date<date_type>(*beg);
}
@@ -247,30 +198,18 @@ namespace date_time {
* parse_date<>()? In the mean time this gets us started... */
//! Helper function for 'date gregorian::from_stream()'
/*! Creates a string from the iterators that reference the
* begining & end of a wstring. All elements are
* begining & end of a wstring. All elements are
* used in output string */
template<class date_type, class iterator_type>
inline
date_type from_stream_type(iterator_type& beg,
iterator_type const& end,
wchar_t)
inline
date_type from_stream_type(iterator_type& beg,
iterator_type& end,
wchar_t)
{
std::ostringstream ss;
#if !defined(BOOST_DATE_TIME_NO_LOCALE)
std::locale loc;
std::ctype<wchar_t> const& fac = std::use_facet<std::ctype<wchar_t> >(loc);
std::stringstream ss("");
while(beg != end) {
ss << fac.narrow(*beg++, 'X'); // 'X' will cause exception to be thrown
ss << ss.narrow(*beg++, 'X'); // 'X' will cause exception to be thrown
}
#else
while(beg != end) {
char c = 'X'; // 'X' will cause exception to be thrown
const wchar_t wc = *beg++;
if (wc >= 0 && wc <= 127)
c = static_cast< char >(wc);
ss << c;
}
#endif
return parse_date<date_type>(ss.str());
}
#ifndef BOOST_NO_STD_WSTRING
@@ -278,61 +217,47 @@ namespace date_time {
/*! Creates a string from the first wstring found in the stream
* referenced by the begining & end iterators */
template<class date_type, class iterator_type>
inline
inline
date_type
from_stream_type(iterator_type& beg,
iterator_type const& /* end */,
std::wstring const&) {
from_stream_type(iterator_type& beg,
iterator_type& end,
std::wstring) {
std::wstring ws = *beg;
std::ostringstream ss;
std::stringstream ss("");
std::wstring::iterator wsb = ws.begin(), wse = ws.end();
#if !defined(BOOST_DATE_TIME_NO_LOCALE)
std::locale loc;
std::ctype<wchar_t> const& fac = std::use_facet<std::ctype<wchar_t> >(loc);
while(wsb != wse) {
ss << fac.narrow(*wsb++, 'X'); // 'X' will cause exception to be thrown
ss << ss.narrow(*wsb++, 'X'); // 'X' will cause exception to be thrown
}
#else
while(wsb != wse) {
char c = 'X'; // 'X' will cause exception to be thrown
const wchar_t wc = *wsb++;
if (wc >= 0 && wc <= 127)
c = static_cast< char >(wc);
ss << c;
}
#endif
return parse_date<date_type>(ss.str());
}
#endif // BOOST_NO_STD_WSTRING
#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
#if (defined(BOOST_MSVC) && (_MSC_VER <= 1200))
// This function cannot be compiled with MSVC 6.0 due to internal compiler shorcomings
#else
//! function called by wrapper functions: date_period_from_(w)string()
template<class date_type, class charT>
period<date_type, typename date_type::duration_type>
period<date_type, typename date_type::duration_type>
from_simple_string_type(const std::basic_string<charT>& s){
typedef typename std::basic_string<charT>::traits_type traits_type;
typedef typename boost::char_separator<charT, traits_type> char_separator;
typedef typename boost::tokenizer<char_separator,
typename std::basic_string<charT>::const_iterator,
std::basic_string<charT> > tokenizer;
const charT sep_list[4] = {'[','/',']','\0'};
typedef typename boost::char_separator<charT> char_separator;
typedef typename boost::tokenizer<char_separator, typename std::basic_string<charT>::const_iterator,
std::basic_string<charT> > tokenizer;
const charT sep_list[] = {'[','/',']','\0'};
char_separator sep(sep_list);
tokenizer tokens(s, sep);
typename tokenizer::iterator tok_it = tokens.begin();
typename tokenizer::iterator tok_it = tokens.begin();
std::basic_string<charT> date_string = *tok_it;
// get 2 string iterators and generate a date from them
typename std::basic_string<charT>::iterator date_string_start = date_string.begin(),
date_string_end = date_string.end();
typename std::basic_string<charT>::iterator date_string_start = date_string.begin(),
date_string_end = date_string.end();
typedef typename std::iterator_traits<typename std::basic_string<charT>::iterator>::value_type value_type;
date_type d1 = from_stream_type<date_type>(date_string_start, date_string_end, value_type());
date_string = *(++tok_it); // next token
date_string_start = date_string.begin(), date_string_end = date_string.end();
date_string_start = date_string.begin(), date_string_end = date_string.end();
date_type d2 = from_stream_type<date_type>(date_string_start, date_string_end, value_type());
return period<date_type, typename date_type::duration_type>(d1, d2);
return period<date_type, typename date_type::duration_type>(d1, d2);
}
#endif
#endif // _MSC_VER <= 1200
} } //namespace date_time
+70 -81
View File
@@ -1,10 +1,10 @@
#ifndef DATE_TIME_DST_RULES_HPP__
#define DATE_TIME_DST_RULES_HPP__
/* Copyright (c) 2002,2003, 2007 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -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,32 +86,32 @@ 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
* @param dst_end_offset Time offset within day given in dst for dst boundary
* @param dst_length_minutes length of dst adjusment
* @param dst_length lenght of dst adjusment
* @retval The time is either ambiguous, invalid, in dst, or not in dst
*/
static time_is_dst_result
static time_is_dst_result
local_is_dst(const date_type& current_day,
const time_duration_type& time_of_day,
const date_type& dst_start_day,
const time_duration_type& dst_start_offset,
const date_type& dst_end_day,
const time_duration_type& dst_end_offset,
const time_duration_type& dst_length)
const time_duration_type& dst_length_minutes)
{
unsigned int start_minutes = static_cast<unsigned>(
dst_start_offset.hours() * 60 + dst_start_offset.minutes());
unsigned int end_minutes = static_cast<unsigned>(
dst_end_offset.hours() * 60 + dst_end_offset.minutes());
long length_minutes = static_cast<long>(
dst_length.hours() * 60 + dst_length.minutes());
unsigned int start_minutes =
dst_start_offset.hours() * 60 + dst_start_offset.minutes();
unsigned int end_minutes =
dst_end_offset.hours() * 60 + dst_end_offset.minutes();
long length_minutes =
dst_length_minutes.hours() * 60 + dst_length_minutes.minutes();
return local_is_dst(current_day, time_of_day,
dst_start_day, start_minutes,
@@ -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,19 +244,25 @@ 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);
typedef typename dst_traits::start_rule_functor start_rule;
start_rule start(dst_traits::start_day(),
dst_traits::start_month());
return start.get_date(year);
}
static date_type local_dst_end_day(year_type year)
{
return dst_traits::local_dst_end_day(year);
typedef typename dst_traits::end_rule_functor end_rule;
end_rule end(dst_traits::end_day(),
dst_traits::end_month());
return end.get_date(year);
}
@@ -264,14 +270,12 @@ namespace boost {
//! Depricated: Class to calculate dst boundaries for US time zones
/* Use dst_calc_engine instead.
* In 2007 US/Canada DST rules changed
* (http://en.wikipedia.org/wiki/Energy_Policy_Act_of_2005#Change_to_daylight_saving_time).
*/
template<class date_type_,
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;
@@ -280,16 +284,15 @@ namespace boost {
typedef typename date_type::calendar_type calendar_type;
typedef date_time::last_kday_of_month<date_type> lkday;
typedef date_time::first_kday_of_month<date_type> fkday;
typedef date_time::nth_kday_of_month<date_type> nkday;
typedef dst_calculator<date_type, time_duration_type> dstcalc;
//! Calculates if the given local time is dst or not
/*! Determines if the time is really in DST or not. Also checks for
/*! 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 +300,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);
}
@@ -312,28 +315,16 @@ namespace boost {
static date_type local_dst_start_day(year_type year)
{
if (year >= year_type(2007)) {
//second sunday in march
nkday ssim(nkday::second, Sunday, date_time::Mar);
return ssim.get_date(year);
} else {
//first sunday in april
fkday fsia(Sunday, date_time::Apr);
return fsia.get_date(year);
}
//first sunday in april
fkday fsia(Sunday, gregorian::Apr);
return fsia.get_date(year);
}
static date_type local_dst_end_day(year_type year)
{
if (year >= year_type(2007)) {
//first sunday in november
fkday fsin(Sunday, date_time::Nov);
return fsin.get_date(year);
} else {
//last sunday in october
lkday lsio(Sunday, date_time::Oct);
return lsio.get_date(year);
}
//last sunday in october
lkday lsio(Sunday, gregorian::Oct);
return lsio.get_date(year);
}
static time_duration_type dst_offset()
@@ -341,8 +332,6 @@ namespace boost {
return time_duration_type(0,dst_length_minutes,0);
}
private:
};
@@ -358,25 +347,25 @@ 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;
}
static bool is_dst_boundary_day(date_type /*d*/)
static bool is_dst_boundary_day(date_type d)
{
return false;
}
static time_duration_type dst_offset()
static time_duration_type dst_offset()
{
return time_duration_type(0,0,0);
}
@@ -1,13 +1,13 @@
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
*/
#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 {
@@ -18,18 +18,16 @@ namespace date_time {
{
public:
typedef typename date_type::year_type year_type;
virtual ~dst_day_calc_rule() {}
virtual ~dst_day_calc_rule() {};
virtual date_type start_day(year_type y) const=0;
virtual std::string start_rule_as_string() const=0;
virtual date_type end_day(year_type y) const=0;
virtual std::string end_rule_as_string() const=0;
};
//! Canonical form for a class that provides day rule calculation
/*! This class is used to generate specific sets of dst rules
*
*@tparam spec Provides a specifiction of the function object types used
*@param spec Provides a specifiction of the function object types used
* to generate start and end days of daylight savings as well
* as the date type.
*/
@@ -50,18 +48,10 @@ namespace date_time {
{
return dst_start_.get_date(y);
}
virtual std::string start_rule_as_string() const
{
return dst_start_.to_string();
}
virtual date_type end_day(year_type y) const
{
return dst_end_.get_date(y);
}
virtual std::string end_rule_as_string() const
{
return dst_end_.to_string();
}
private:
start_rule dst_start_;
end_rule dst_end_;
+40 -46
View File
@@ -4,78 +4,72 @@
/* Copyright (c) 2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
/*! @file filetime_functions.hpp
* Function(s) for converting between a FILETIME structure and a
* Function(s) for converting between a FILETIME structure and a
* time object. This file is only available on systems that have
* BOOST_HAS_FTIME defined.
*/
#include <boost/date_time/compiler_config.hpp>
#if defined(BOOST_HAS_FTIME) // skip this file if no FILETIME
#include <windows.h>
#include <boost/cstdint.hpp>
#include <boost/date_time/time.hpp>
#include <boost/date_time/date_defs.hpp>
namespace boost {
namespace date_time {
//! Create a time object from an initialized FILETIME struct.
/*!
* Create a time object from an initialized FILETIME struct.
* A FILETIME struct holds 100-nanosecond units (0.0000001). When
* built with microsecond resolution the file_time's sub second value
* will be truncated. Nanosecond resolution has no truncation.
*
* \note The function is templated on the FILETIME type, so that
* it can be used with both native FILETIME and the ad-hoc
* boost::detail::winapi::FILETIME_ type.
*/
template< typename TimeT, typename FileTimeT >
inline
TimeT time_from_ftime(const FileTimeT& ft)
{
typedef typename TimeT::date_type date_type;
typedef typename TimeT::date_duration_type date_duration_type;
typedef typename TimeT::time_duration_type time_duration_type;
// https://svn.boost.org/trac/boost/ticket/2523
// Since this function can be called with arbitrary times, including ones that
// are before 1970-Jan-01, we'll have to cast the time a bit differently,
// than it is done in the microsec_clock::file_time_to_microseconds function. This allows to
// avoid integer wrapping for dates before 1970-Jan-01.
//! Create a time object from an initialized FILETIME struct.
/*! Create a time object from an initialized FILETIME struct.
* A FILETIME struct holds 100-nanosecond units (0.0000001). When
* built with microsecond resolution the FILETIME's sub second value
* will be truncated. Nanosecond resolution has no truncation. */
template<class time_type>
inline
time_type time_from_ftime(const FILETIME& ft){
typedef typename time_type::date_type date_type;
typedef typename time_type::date_duration_type date_duration_type;
typedef typename time_type::time_duration_type time_duration_type;
// 100-nanos since 1601-Jan-01
uint64_t ft_as_integer = (static_cast< uint64_t >(ft.dwHighDateTime) << 32) | static_cast< uint64_t >(ft.dwLowDateTime);
uint64_t sec = ft_as_integer / 10000000UL;
uint32_t sub_sec = static_cast< uint32_t >(ft_as_integer % 10000000UL) // 100-nanoseconds since the last second
#if !defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
/ 10U; // microseconds since the last second
/* OFFSET is difference between 1970-Jan-01 & 1601-Jan-01
* in 100-nanosecond intervals */
uint64_t c1 = 27111902UL;
uint64_t c2 = 3577643008UL; // issues warning without 'UL'
const uint64_t OFFSET = (c1 << 32) + c2;
const long sec_pr_day = 86400; // seconds per day
uint64_t filetime = ft.dwHighDateTime;
filetime <<= 32;
filetime += ft.dwLowDateTime;
filetime -= OFFSET; // filetime is now 100-nanos since 1970-Jan-01
uint64_t sec = filetime / 10000000;
#if defined(BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG)
uint64_t sub_sec = (filetime % 10000000) * 100; // nanoseconds
#else
* 100U; // nanoseconds since the last second
uint64_t sub_sec = (filetime % 10000000) / 10; // truncate to microseconds
#endif
// split sec into usable chunks: days, hours, minutes, & seconds
const uint32_t sec_per_day = 86400; // seconds per day
uint32_t days = static_cast< uint32_t >(sec / sec_per_day);
uint32_t tmp = static_cast< uint32_t >(sec % sec_per_day);
uint32_t hours = tmp / 3600; // sec_per_hour
long _d = sec / sec_pr_day;
long tmp = sec % sec_pr_day;
long _h = tmp / 3600; // sec_pr_hour
tmp %= 3600;
uint32_t minutes = tmp / 60; // sec_per_min
long _m = tmp / 60; // sec_pr_min
tmp %= 60;
uint32_t seconds = tmp; // seconds
long _s = tmp; // seconds
date_duration_type dd(days);
date_type d = date_type(1601, Jan, 01) + dd;
return TimeT(d, time_duration_type(hours, minutes, seconds, sub_sec));
}
date_duration_type dd(_d);
date_type d = date_type(1970, Jan, 01) + dd;
return time_type(d, time_duration_type(_h, _m, _s, sub_sec));
}
}} // boost::date_time
-42
View File
@@ -1,42 +0,0 @@
#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
+89 -529
View File
@@ -2,119 +2,59 @@
#ifndef DATE_TIME_FORMAT_DATE_PARSER_HPP__
#define DATE_TIME_FORMAT_DATE_PARSER_HPP__
/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
/* Copyright (c) 2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
* $Date$
*/
#include "boost/lexical_cast.hpp"
#include "boost/algorithm/string.hpp" //todo narrow this
#include "boost/date_time/string_parse_tree.hpp"
#include "boost/date_time/strings_from_facet.hpp"
#include "boost/date_time/special_values_parser.hpp"
#include <string>
#include <vector>
#include <sstream>
#include <iterator>
#ifndef BOOST_NO_STDC_NAMESPACE
# include <cctype>
#else
# include <ctype.h>
#endif
#ifdef BOOST_NO_STDC_NAMESPACE
namespace std {
using ::isspace;
using ::isdigit;
}
#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
* digits in stream. */
//!Helper function for parsing fixed length strings into integers
template<typename int_type, typename charT>
inline
int_type
fixed_string_to_int(std::istreambuf_iterator<charT>& itr,
std::istreambuf_iterator<charT>& stream_end,
parse_match_result<charT>& mr,
unsigned int length,
const charT& fill_char)
unsigned int length)
{
//typedef std::basic_string<charT> string_type;
typedef std::basic_string<charT> string_type;
unsigned int j = 0;
//string_type s;
while (j < length && itr != stream_end &&
(std::isdigit(*itr) || *itr == fill_char)) {
if(*itr == fill_char) {
/* Since a fill_char can be anything, we convert it to a zero.
* lexical_cast will behave predictably when zero is used as fill. */
mr.cache += ('0');
}
else {
mr.cache += (*itr);
}
string_type s;
while (j < length) {
s += (*itr);
itr++;
j++;
}
int_type i = static_cast<int_type>(-1);
// mr.cache will hold leading zeros. size() tells us when input is too short.
if(mr.cache.size() < length) {
return i;
}
try {
i = boost::lexical_cast<int_type>(mr.cache);
}catch(bad_lexical_cast&){
// we want to return -1 if the cast fails so nothing to do here
}
int_type i = boost::lexical_cast<int_type>(s);
return i;
}
//! Helper function for parsing fixed length strings into integers
/*! Will consume 'length' number of characters from stream. Consumed
* character are transfered to parse_match_result struct.
* Returns '-1' if no number can be parsed or incorrect number of
* digits in stream. */
template<typename int_type, typename charT>
inline
int_type
fixed_string_to_int(std::istreambuf_iterator<charT>& itr,
std::istreambuf_iterator<charT>& stream_end,
parse_match_result<charT>& mr,
unsigned int length)
{
return fixed_string_to_int<int_type, charT>(itr, stream_end, mr, length, '0');
}
//! Helper function for parsing varied length strings into integers
/*! Will consume 'max_length' characters from stream only if those
* characters are digits. Returns '-1' if no number can be parsed.
* Will not parse a number preceeded by a '+' or '-'. */
//!Helper function for parsing fixed length strings into integers
template<typename int_type, typename charT>
inline
int_type
var_string_to_int(std::istreambuf_iterator<charT>& itr,
const std::istreambuf_iterator<charT>& stream_end,
unsigned int max_length)
{
typedef std::basic_string<charT> string_type;
unsigned int j = 0;
string_type s;
while (itr != stream_end && (j < max_length) && std::isdigit(*itr)) {
while ((j < max_length) && std::isdigit(*itr)) {
s += (*itr);
++itr;
++j;
}
int_type i = static_cast<int_type>(-1);
if(!s.empty()) {
i = boost::lexical_cast<int_type>(s);
itr++;
j++;
}
int_type i = boost::lexical_cast<int_type>(s);
return i;
}
@@ -125,15 +65,15 @@ var_string_to_int(std::istreambuf_iterator<charT>& itr,
- %A - Long weekday name
- %b - Abbreviated month name
- %B - Full month name
- %d - Day of the month as decimal 01 to 31
- %j - Day of year as decimal from 001 to 366
- %d - Day of the month as decimal
- %j - Day of year as decimal from 1 to 366
- %m - Month name as a decimal 01 to 12
- %U - Week number 00 to 53 with first Sunday as the first day of week 1?
- %w - Weekday as decimal number 0 to 6 where Sunday == 0
- %W - Week number 00 to 53 where Monday is first day of week 1
- %x - facet default date representation
- %y - Year without the century - eg: 04 for 2004
- %Y - Year with century
- %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 +82,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...
@@ -152,573 +92,193 @@ class format_date_parser
{
public:
typedef std::basic_string<charT> string_type;
typedef std::basic_istringstream<charT> stringstream_type;
typedef std::basic_stringstream<charT> stringstream_type;
typedef std::istreambuf_iterator<charT> stream_itr_type;
typedef typename string_type::const_iterator const_itr;
typedef typename date_type::year_type year_type;
typedef typename date_type::month_type month_type;
typedef typename date_type::day_type day_type;
typedef typename date_type::duration_type duration_type;
typedef typename date_type::day_of_week_type day_of_week_type;
typedef typename date_type::day_of_year_type day_of_year_type;
typedef string_parse_tree<charT> parse_tree_type;
typedef typename parse_tree_type::parse_match_result_type match_results;
typedef std::vector<std::basic_string<charT> > input_collection_type;
// TODO sv_parser uses its default constructor - write the others
format_date_parser(const string_type& format_str,
format_date_parser(const string_type& format,
const input_collection_type& month_short_names,
const input_collection_type& month_long_names,
const input_collection_type& weekday_short_names,
const input_collection_type& weekday_long_names) :
m_format(format_str),
m_month_short_names(month_short_names, 1),
m_month_long_names(month_long_names, 1),
m_format(format),
m_month_short_names(month_short_names),
m_month_long_names(month_long_names),
m_weekday_short_names(weekday_short_names),
m_weekday_long_names(weekday_long_names)
{}
format_date_parser(const string_type& format_str,
format_date_parser(const string_type& format,
const std::locale& locale) :
m_format(format_str),
m_month_short_names(gather_month_strings<charT>(locale), 1),
m_month_long_names(gather_month_strings<charT>(locale, false), 1),
m_weekday_short_names(gather_weekday_strings<charT>(locale)),
m_weekday_long_names(gather_weekday_strings<charT>(locale, false))
m_format(format),
m_month_short_names(gather_month_strings<charT>(locale)),
m_month_long_names(gather_month_strings<charT>(locale, false)),
m_weekday_short_names(gather_weekday_strings<char>(locale)),
m_weekday_long_names(gather_weekday_strings<char>(locale, false))
{}
format_date_parser(const format_date_parser<date_type,charT>& fdp)
{
this->m_format = fdp.m_format;
this->m_month_short_names = fdp.m_month_short_names;
this->m_month_long_names = fdp.m_month_long_names;
this->m_weekday_short_names = fdp.m_weekday_short_names;
this->m_weekday_long_names = fdp.m_weekday_long_names;
}
string_type format() const
{
return m_format;
}
void format(string_type format_str)
void format(string_type format)
{
m_format = format_str;
}
void short_month_names(const input_collection_type& month_names)
{
m_month_short_names = parse_tree_type(month_names, 1);
}
void long_month_names(const input_collection_type& month_names)
{
m_month_long_names = parse_tree_type(month_names, 1);
}
void short_weekday_names(const input_collection_type& weekday_names)
{
m_weekday_short_names = parse_tree_type(weekday_names);
}
void long_weekday_names(const input_collection_type& weekday_names)
{
m_weekday_long_names = parse_tree_type(weekday_names);
m_format = format;
}
date_type
parse_date(const string_type& value,
const string_type& format_str,
const special_values_parser<date_type,charT>& sv_parser) const
parse_date(const string_type& value,
const string_type& format) const
{
stringstream_type ss(value);
stringstream_type ss;
ss << value;
stream_itr_type sitr(ss);
stream_itr_type stream_end;
return parse_date(sitr, stream_end, format_str, sv_parser);
return parse_date(sitr, stream_end, format);
}
date_type
parse_date(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end,
const special_values_parser<date_type,charT>& sv_parser) const
parse_date(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end) const
{
return parse_date(sitr, stream_end, m_format, sv_parser);
parse_date(sitr, stream_end, m_format);
}
/*! 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
string_type format) const
{
bool use_current_char = false;
charT current_char = *sitr;
// 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)) {
unsigned short year(0), month(0), day(0), day_of_year(0);
const_itr itr(format.begin());
while (itr != format.end() && (sitr != stream_end)) {
if (*itr == '%') {
if ( ++itr == format_str.end())
break;
if (*itr != '%') {
itr++;
if (*itr != '%') { //ignore '%%'
unsigned short i = 0;
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);
if(mr.current_match == match_results::PARSE_ERROR) {
// check special_values
if(sv_parser.match(sitr, stream_end, mr)) {
return date_type(static_cast<special_values>(mr.current_match));
}
}
wkday = mr.current_match;
unsigned int wkday = mr.current_match;
if (mr.has_remaining()) {
current_char = mr.last_char();
use_current_char = true;
}
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);
if(mr.current_match == match_results::PARSE_ERROR) {
// check special_values
if(sv_parser.match(sitr, stream_end, mr)) {
return date_type(static_cast<special_values>(mr.current_match));
}
}
wkday = mr.current_match;
unsigned int wkday = mr.current_match;
if (mr.has_remaining()) {
current_char = mr.last_char();
use_current_char = true;
}
break;
}
case 'b':
case 'b':
{
match_results mr = m_month_short_names.match(sitr, stream_end);
if(mr.current_match == match_results::PARSE_ERROR) {
// check special_values
if(sv_parser.match(sitr, stream_end, mr)) {
return date_type(static_cast<special_values>(mr.current_match));
}
}
t_month = month_type(mr.current_match);
month = mr.current_match;
if (mr.has_remaining()) {
current_char = mr.last_char();
use_current_char = true;
}
break;
}
case 'B':
case 'B':
{
match_results mr = m_month_long_names.match(sitr, stream_end);
if(mr.current_match == match_results::PARSE_ERROR) {
// check special_values
if(sv_parser.match(sitr, stream_end, mr)) {
return date_type(static_cast<special_values>(mr.current_match));
}
}
t_month = month_type(mr.current_match);
month = mr.current_match;
if (mr.has_remaining()) {
current_char = mr.last_char();
use_current_char = true;
}
break;
}
case 'd':
case 'd':
{
match_results mr;
day = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2);
if(day == -1) {
if(sv_parser.match(sitr, stream_end, mr)) {
return date_type(static_cast<special_values>(mr.current_match));
}
}
t_day = day_type(day);
day = var_string_to_int<unsigned short, charT>(sitr, 2);
break;
}
case 'e':
case 'j':
{
match_results mr;
day = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2, ' ');
if(day == -1) {
if(sv_parser.match(sitr, stream_end, mr)) {
return date_type(static_cast<special_values>(mr.current_match));
}
}
t_day = day_type(day);
day_of_year = fixed_string_to_int<unsigned short, charT>(sitr, 3);
break;
}
case 'j':
case 'm':
{
match_results mr;
day_of_year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 3);
if(day_of_year == -1) {
if(sv_parser.match(sitr, stream_end, mr)) {
return date_type(static_cast<special_values>(mr.current_match));
}
}
// these next two lines are so we get an exception with bad input
day_of_year_type t_day_of_year(1);
t_day_of_year = day_of_year_type(day_of_year);
month = var_string_to_int<unsigned short, charT>(sitr, 2);
break;
}
case 'm':
case 'Y':
{
match_results mr;
month = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2);
if(month == -1) {
if(sv_parser.match(sitr, stream_end, mr)) {
return date_type(static_cast<special_values>(mr.current_match));
}
}
t_month = month_type(month);
year = fixed_string_to_int<unsigned short, charT>(sitr, 4);
break;
}
case 'Y':
case 'y':
{
match_results mr;
year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 4);
if(year == -1) {
if(sv_parser.match(sitr, stream_end, mr)) {
return date_type(static_cast<special_values>(mr.current_match));
}
}
t_year = year_type(year);
break;
}
case 'y':
{
match_results mr;
year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2);
if(year == -1) {
if(sv_parser.match(sitr, stream_end, mr)) {
return date_type(static_cast<special_values>(mr.current_match));
}
}
year = fixed_string_to_int<unsigned short, charT>(sitr, 2);
year += 2000; //make 2 digit years in this century
t_year = year_type(year);
break;
}
default:
{} //ignore those we don't understand
}//switch
}
else { // itr == '%', second consecutive
sitr++;
}
itr++; //advance past format specifier
}
else { //skip past chars in format and in buffer
itr++;
if (use_current_char) {
use_current_char = false;
current_char = *sitr;
}
else {
sitr++;
}
}
}
if (day_of_year > 0) {
date_type d(static_cast<unsigned short>(year-1),12,31); //end of prior year
if (day_of_year != 0) {
date_type d(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(year, month, day);
}
//! Throws bad_month if unable to parse
month_type
parse_month(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end,
string_type format_str) const
{
match_results mr;
return parse_month(sitr, stream_end, format_str, mr);
}
//! Throws bad_month if unable to parse
month_type
parse_month(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end,
string_type format_str,
match_results& mr) const
{
bool use_current_char = false;
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
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;
if (*itr != '%') {
switch(*itr) {
case 'b':
{
mr = m_month_short_names.match(sitr, stream_end);
month = mr.current_match;
if (mr.has_remaining()) {
use_current_char = true;
}
break;
}
case 'B':
{
mr = m_month_long_names.match(sitr, stream_end);
month = mr.current_match;
if (mr.has_remaining()) {
use_current_char = true;
}
break;
}
case 'm':
{
month = var_string_to_int<short, charT>(sitr, stream_end, 2);
// var_string_to_int returns -1 if parse failed. That will
// cause a bad_month exception to be thrown so we do nothing here
break;
}
default:
{} //ignore those we don't understand
}//switch
}
else { // itr == '%', second consecutive
sitr++;
}
itr++; //advance past format specifier
}
else { //skip past chars in format and in buffer
itr++;
if (use_current_char) {
use_current_char = false;
}
else {
sitr++;
}
}
}
return month_type(month); // throws bad_month exception when values are zero
}
//! Expects 1 or 2 digits 1-31. Throws bad_day_of_month if unable to parse
day_type
parse_var_day_of_month(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
return day_type(var_string_to_int<short, charT>(sitr, stream_end, 2));
}
//! Expects 2 digits 01-31. Throws bad_day_of_month if unable to parse
day_type
parse_day_of_month(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end) const
{
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
//return day_type(var_string_to_int<short, charT>(sitr, stream_end, 2));
match_results mr;
return day_type(fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2));
}
day_of_week_type
parse_weekday(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end,
string_type format_str) const
{
match_results mr;
return parse_weekday(sitr, stream_end, format_str, mr);
}
day_of_week_type
parse_weekday(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end,
string_type format_str,
match_results& mr) const
{
bool use_current_char = false;
// skip leading whitespace
while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
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;
if (*itr != '%') {
switch(*itr) {
case 'a':
{
//this value is just throw away. It could be used for
//error checking potentially, but it isn't helpful in
//actually constructing the date - we just need to get it
//out of the stream
mr = m_weekday_short_names.match(sitr, stream_end);
wkday = mr.current_match;
if (mr.has_remaining()) {
use_current_char = true;
}
break;
}
case 'A':
{
//this value is just throw away. It could be used for
//error checking potentially, but it isn't helpful in
//actually constructing the date - we just need to get it
//out of the stream
mr = m_weekday_long_names.match(sitr, stream_end);
wkday = mr.current_match;
if (mr.has_remaining()) {
use_current_char = true;
}
break;
}
case 'w':
{
// weekday as number 0-6, Sunday == 0
wkday = var_string_to_int<short, charT>(sitr, stream_end, 2);
break;
}
default:
{} //ignore those we don't understand
}//switch
}
else { // itr == '%', second consecutive
sitr++;
}
itr++; //advance past format specifier
}
else { //skip past chars in format and in buffer
itr++;
if (use_current_char) {
use_current_char = false;
}
else {
sitr++;
}
}
}
return day_of_week_type(wkday); // throws bad_day_of_month exception
// when values are zero
}
//! throws bad_year if unable to parse
year_type
parse_year(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end,
string_type format_str) const
{
match_results mr;
return parse_year(sitr, stream_end, format_str, mr);
}
//! throws bad_year if unable to parse
year_type
parse_year(std::istreambuf_iterator<charT>& sitr,
std::istreambuf_iterator<charT>& stream_end,
string_type format_str,
match_results& mr) const
{
// skip leading whitespace
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;
if (*itr != '%') {
//match_results mr;
switch(*itr) {
case 'Y':
{
// year from 4 digit string
year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 4);
break;
}
case 'y':
{
// year from 2 digit string (no century)
year = fixed_string_to_int<short, charT>(sitr, stream_end, mr, 2);
year += 2000; //make 2 digit years in this century
break;
}
default:
{} //ignore those we don't understand
}//switch
}
else { // itr == '%', second consecutive
sitr++;
}
itr++; //advance past format specifier
}
else { //skip past chars in format and in buffer
itr++;
sitr++;
}
}
return year_type(year); // throws bad_year exception when values are zero
}
private:
string_type m_format;
parse_tree_type m_month_short_names;
parse_tree_type m_month_long_names;
parse_tree_type m_weekday_short_names;
parse_tree_type m_weekday_long_names;
};
} } //namespace
#endif
@@ -1,68 +1,60 @@
#ifndef _GREGORIAN__CONVERSION_HPP___
#define _GREGORIAN__CONVERSION_HPP___
/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
/* Copyright (c) 2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <cstring>
#include <string>
#include <stdexcept>
#include <boost/throw_exception.hpp>
#include <boost/date_time/c_time.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <exception>
#include "boost/date_time/gregorian/gregorian_types.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 // BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS
#include "boost/date_time/c_time.hpp"
namespace boost {
namespace gregorian {
//! Converts a date to a tm struct. Throws out_of_range exception if date is a special value
inline
std::tm to_tm(const date& d)
tm to_tm(const date& d)
{
if (d.is_special())
{
std::string s = "tm unable to handle ";
switch (d.as_special())
{
case date_time::not_a_date_time:
s += "not-a-date-time value"; break;
case date_time::neg_infin:
s += "-infinity date value"; break;
case date_time::pos_infin:
s += "+infinity date value"; break;
default:
s += "a special date value"; break;
}
boost::throw_exception(std::out_of_range(s));
if(d.is_pos_infinity() || d.is_neg_infinity() || d.is_not_a_date()){
std::string s("tm unable to handle date value of " + to_simple_string(d));
throw std::out_of_range(s);
}
std::tm datetm;
std::memset(&datetm, 0, sizeof(datetm));
tm datetm;
boost::gregorian::date::ymd_type ymd = d.year_month_day();
datetm.tm_year = ymd.year - 1900;
datetm.tm_mon = ymd.month - 1;
datetm.tm_year = ymd.year-1900;
datetm.tm_mon = ymd.month-1;
datetm.tm_mday = ymd.day;
datetm.tm_wday = d.day_of_week();
datetm.tm_yday = d.day_of_year() - 1;
datetm.tm_yday = d.day_of_year()-1;
datetm.tm_hour = datetm.tm_min = datetm.tm_sec = 0;
datetm.tm_isdst = -1; // negative because not enough info to set tm_isdst
return datetm;
}
//! Converts a tm structure into a date dropping the any time values.
inline
date date_from_tm(const std::tm& datetm)
date date_from_tm(const tm& datetm)
{
return date(static_cast<unsigned short>(datetm.tm_year+1900),
static_cast<unsigned short>(datetm.tm_mon+1),
static_cast<unsigned short>(datetm.tm_mday));
return date(datetm.tm_year+1900, datetm.tm_mon+1, datetm.tm_mday);
}
} } //namespace boost::gregorian
#endif
@@ -4,13 +4,14 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include "boost/date_time/compiler_config.hpp"
#include "boost/date_time/gregorian/gregorian_types.hpp"
#include "boost/date_time/gregorian/greg_facet.hpp"
#if defined(BOOST_DATE_TIME_INCLUDE_LIMITED_HEADERS)
#include "boost/date_time/date_formatting_limited.hpp"
#else
@@ -65,7 +66,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 8601 standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
//! Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date_period& d) {
@@ -78,7 +79,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 8601 extended format string CCYY-MM-DD. Example 2002-12-31
//! Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31
/*!\ingroup date_format
*/
inline std::string to_iso_extended_string(const date& d) {
@@ -90,7 +91,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 8601 standard string YYYYMMDD. Example: 20021231
//! Convert to iso standard string YYYYMMDD. Example: 20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date& d) {
@@ -4,12 +4,13 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include "boost/date_time/gregorian/gregorian_types.hpp"
#include "boost/date_time/gregorian/greg_facet.hpp"
#include "boost/date_time/date_formatting_limited.hpp"
#include "boost/date_time/iso_format.hpp"
#include "boost/date_time/date_format_simple.hpp"
@@ -35,7 +36,7 @@ namespace gregorian {
return std::string("[" + d1 + "/" + d2 + "]");
}
//! Date period to ISO 8601 standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
//! Date period to iso standard format CCYYMMDD/CCYYMMDD. Example: 20021225/20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date_period& d) {
@@ -44,14 +45,14 @@ namespace gregorian {
}
//! Convert to ISO 8601 extended format string CCYY-MM-DD. Example 2002-12-31
//! Convert to iso extended format string CCYY-MM-DD. Example 2002-12-31
/*!\ingroup date_format
*/
inline std::string to_iso_extended_string(const date& d) {
return date_time::date_formatter<date,date_time::iso_extended_format<char> >::date_to_string(d);
}
//! Convert to ISO 8601 standard string YYYYMMDD. Example: 20021231
//! Convert to iso standard string YYYYMMDD. Example: 20021231
/*!\ingroup date_format
*/
inline std::string to_iso_string(const date& d) {
@@ -2,29 +2,27 @@
#define GREGORIAN_GREGORIAN_CALENDAR_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
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
* $Date$
*/
#include <boost/cstdint.hpp>
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/gregorian/greg_weekday.hpp>
#include <boost/date_time/gregorian/greg_day_of_year.hpp>
#include <boost/date_time/gregorian_calendar.hpp>
#include <boost/date_time/gregorian/greg_ymd.hpp>
#include <boost/date_time/int_adapter.hpp>
#include "boost/date_time/gregorian/greg_weekday.hpp"
#include "boost/date_time/gregorian/greg_day_of_year.hpp"
#include "boost/date_time/gregorian_calendar.hpp"
#include "boost/date_time/gregorian/greg_ymd.hpp"
#include "boost/date_time/int_adapter.hpp"
namespace boost {
namespace gregorian {
//!An internal date representation that includes infinities, not a date
typedef date_time::int_adapter<uint32_t> fancy_date_rep;
typedef date_time::int_adapter<unsigned long> fancy_date_rep;
//! Gregorian calendar for this implementation, hard work in the base
class BOOST_SYMBOL_VISIBLE gregorian_calendar :
class gregorian_calendar :
public date_time::gregorian_calendar_base<greg_year_month_day, fancy_date_rep::int_type> {
public:
//! Type to hold a weekday (eg: Sunday, Monday,...)
@@ -36,14 +34,14 @@ namespace gregorian {
//! Date rep implements the traits stuff as well
typedef fancy_date_rep date_traits_type;
private:
};
} } //namespace gregorian
#endif
+43 -52
View File
@@ -1,20 +1,18 @@
#ifndef GREG_DATE_HPP___
#define GREG_DATE_HPP___
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
* $Date$
*/
#include <boost/throw_exception.hpp>
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/date.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/gregorian/greg_calendar.hpp>
#include <boost/date_time/gregorian/greg_duration.hpp>
#include "boost/date_time/date.hpp"
#include "boost/date_time/special_defs.hpp"
#include "boost/date_time/gregorian/greg_calendar.hpp"
#include "boost/date_time/gregorian/greg_duration.hpp"
namespace boost {
namespace gregorian {
@@ -29,13 +27,13 @@ namespace gregorian {
using date_time::min_date_time;
//! A date type based on gregorian_calendar
/*! This class is the primary interface for programming with
/*! This class is the primary interface for programming with
greogorian dates. The is a lightweight type that can be
freely passed by value. All comparison operators are
supported.
freely passed by value. All comparison operators are
supported.
\ingroup date_basics
*/
class BOOST_SYMBOL_VISIBLE date : public date_time::date<date, gregorian_calendar, date_duration>
class date : public date_time::date<date, gregorian_calendar, date_duration>
{
public:
typedef gregorian_calendar::year_type year_type;
@@ -48,93 +46,86 @@ namespace gregorian {
typedef date_duration duration_type;
#if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR)
//! Default constructor constructs with not_a_date_time
BOOST_CXX14_CONSTEXPR date():
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
BOOST_CXX14_CONSTEXPR date(year_type y, month_type m, day_type d)
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) {
boost::throw_exception(bad_day_of_month(std::string("Day of month is not valid for year")));
throw bad_day_of_month(std::string("Day of month is not valid for year"));
}
}
//! Constructor from a ymd_type structure
BOOST_CXX14_CONSTEXPR explicit date(const ymd_type& ymd)
explicit date(const ymd_type& ymd)
: date_time::date<date, gregorian_calendar, date_duration>(ymd)
{}
//! Needed copy constructor
BOOST_CXX14_CONSTEXPR explicit date(const date_int_type& rhs):
explicit date(const date_int_type& rhs):
date_time::date<date,gregorian_calendar, date_duration>(rhs)
{}
//! Needed copy constructor
BOOST_CXX14_CONSTEXPR explicit date(date_rep_type rhs):
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
BOOST_CXX14_CONSTEXPR explicit date(special_values sv):
date_time::date<date, gregorian_calendar, date_duration>(from_special_adjusted(sv))
{}
explicit date(special_values sv):
date_time::date<date, gregorian_calendar, date_duration>(date_rep_type::from_special(sv))
{
if (sv == min_date_time)
{
*this = date(1400, 1, 1);
}
if (sv == max_date_time)
{
*this = date(9999, 12, 31);
}
}
//!Return the Julian Day number for the date.
BOOST_CXX14_CONSTEXPR date_int_type julian_day() const
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)
BOOST_CXX14_CONSTEXPR day_of_year_type day_of_year() const
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.
BOOST_CXX14_CONSTEXPR date_int_type modjulian_day() const
long modjulian_day() const
{
ymd_type ymd = year_month_day();
return gregorian_calendar::modjulian_day_number(ymd);
return gregorian_calendar::modjulian_day_number(ymd);
}
//!Return the ISO 8601 week number 1..53
BOOST_CXX14_CONSTEXPR int week_number() const
//!Return the iso 8601 week number 1..53
int week_number() const
{
ymd_type ymd = year_month_day();
return gregorian_calendar::week_number(ymd);
return gregorian_calendar::week_number(ymd);
}
//! Return the day number from the calendar
BOOST_CXX14_CONSTEXPR date_int_type day_number() const
date_int_type day_number() const
{
return days_;
}
//! Return the last day of the current month
BOOST_CXX14_CONSTEXPR date end_of_month() const
date end_of_month() const
{
ymd_type ymd = year_month_day();
unsigned short eom_day = gregorian_calendar::end_of_month_day(ymd.year, ymd.month);
ymd_type ymd = year_month_day();
short eom_day = gregorian_calendar::end_of_month_day(ymd.year, ymd.month);
return date(ymd.year, ymd.month, eom_day);
}
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,16 +1,15 @@
#ifndef GREG_DAY_HPP___
#define GREG_DAY_HPP___
/* Copyright (c) 2002,2003,2020 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
* $Date$
*/
#include <boost/date_time/constrained_value.hpp>
#include <boost/date_time/compiler_config.hpp>
#include "boost/date_time/constrained_value.hpp"
#include <stdexcept>
#include <string>
@@ -18,7 +17,7 @@ namespace boost {
namespace gregorian {
//! Exception type for gregorian day of month (1..31)
struct BOOST_SYMBOL_VISIBLE bad_day_of_month : public std::out_of_range
struct bad_day_of_month : public std::out_of_range
{
bad_day_of_month() :
std::out_of_range(std::string("Day of month value is out of range 1..31"))
@@ -40,11 +39,11 @@ namespace gregorian {
is automatically range checked so values outside of the range 1-31
will cause a bad_day_of_month exception
*/
class BOOST_SYMBOL_VISIBLE greg_day : public greg_day_rep {
class greg_day : public greg_day_rep {
public:
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_;}
greg_day(unsigned short day_of_month) : greg_day_rep(day_of_month) {}
unsigned short as_number() const {return value_;}
operator unsigned short() const {return value_;}
private:
};
@@ -4,13 +4,12 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
* $Date$
*/
#include <boost/date_time/constrained_value.hpp>
#include <boost/date_time/compiler_config.hpp>
#include "boost/date_time/constrained_value.hpp"
#include <stdexcept>
#include <string>
@@ -18,7 +17,7 @@ namespace boost {
namespace gregorian {
//! Exception type for day of year (1..366)
struct BOOST_SYMBOL_VISIBLE bad_day_of_year : public std::out_of_range
struct bad_day_of_year : public std::out_of_range
{
bad_day_of_year() :
std::out_of_range(std::string("Day of year value is out of range 1..366"))
@@ -1,147 +1,38 @@
#ifndef GREG_DURATION_HPP___
#define GREG_DURATION_HPP___
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/date_duration.hpp>
#include <boost/date_time/int_adapter.hpp>
#include <boost/date_time/special_defs.hpp>
#include "boost/date_time/date_duration.hpp"
#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
#include "boost/date_time/date_duration_types.hpp"
#endif
#include "boost/date_time/int_adapter.hpp"
namespace boost {
namespace gregorian {
//!An internal date representation that includes infinities, not a date
typedef boost::date_time::duration_traits_adapted date_duration_rep;
//! Durations in days for gregorian system
/*! \ingroup date_basics
*/
class BOOST_SYMBOL_VISIBLE date_duration :
public boost::date_time::date_duration< date_duration_rep >
{
typedef boost::date_time::date_duration< date_duration_rep > base_type;
public:
typedef base_type::duration_rep duration_rep;
//! Construct from a 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) {}
//! Construct from another date_duration
BOOST_CXX14_CONSTEXPR
date_duration(const base_type& other) : base_type(other)
{}
// Relational operators
// 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.
BOOST_CXX14_CONSTEXPR bool operator== (const date_duration& rhs) const
{
return base_type::operator== (rhs);
}
BOOST_CXX14_CONSTEXPR bool operator!= (const date_duration& rhs) const
{
return !operator== (rhs);
}
BOOST_CXX14_CONSTEXPR bool operator< (const date_duration& rhs) const
{
return base_type::operator< (rhs);
}
BOOST_CXX14_CONSTEXPR bool operator> (const date_duration& rhs) const
{
return !(base_type::operator< (rhs) || base_type::operator== (rhs));
}
BOOST_CXX14_CONSTEXPR bool operator<= (const date_duration& rhs) const
{
return (base_type::operator< (rhs) || base_type::operator== (rhs));
}
BOOST_CXX14_CONSTEXPR bool operator>= (const date_duration& rhs) const
{
return !base_type::operator< (rhs);
}
//! Subtract another duration -- result is signed
BOOST_CXX14_CONSTEXPR date_duration& operator-= (const date_duration& rhs)
{
base_type::operator-= (rhs);
return *this;
}
BOOST_CXX14_CONSTEXPR friend
date_duration operator- (date_duration rhs, date_duration const& lhs);
//! Add a duration -- result is signed
BOOST_CXX14_CONSTEXPR date_duration& operator+= (const date_duration& rhs)
{
base_type::operator+= (rhs);
return *this;
}
BOOST_CXX14_CONSTEXPR friend
date_duration operator+ (date_duration rhs, date_duration const& lhs);
//! unary- Allows for dd = -date_duration(2); -> dd == -2
BOOST_CXX14_CONSTEXPR date_duration operator- ()const
{
return date_duration(get_rep() * (-1));
}
//! Division operations on a duration with an integer.
BOOST_CXX14_CONSTEXPR date_duration& operator/= (int divisor)
{
base_type::operator/= (divisor);
return *this;
}
BOOST_CXX14_CONSTEXPR friend date_duration operator/ (date_duration rhs, int lhs);
//! Returns the smallest duration -- used by to calculate 'end'
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;
}
typedef date_time::date_duration<date_duration_rep> date_duration;
//! Shorthand for date_duration
typedef date_duration days;
} } //namespace gregorian
#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
#include <boost/date_time/date_duration_types.hpp>
#endif
#endif
@@ -1,26 +1,25 @@
#ifndef GREG_DURATION_TYPES_HPP___
#define GREG_DURATION_TYPES_HPP___
/* Copyright (c) 2004 CrystalClear Software, Inc.
* Subject to Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/gregorian/greg_date.hpp>
#include <boost/date_time/int_adapter.hpp>
#include <boost/date_time/adjust_functors.hpp>
#include <boost/date_time/date_duration_types.hpp>
#include <boost/date_time/gregorian/greg_duration.hpp>
#include "boost/date_time/gregorian/greg_date.hpp"
#include "boost/date_time/int_adapter.hpp"
#include "boost/date_time/adjust_functors.hpp"
#include "boost/date_time/date_duration.hpp"
#include "boost/date_time/date_duration_types.hpp"
namespace boost {
namespace gregorian {
//! config struct for additional duration types (ie months_duration<> & years_duration<>)
struct BOOST_SYMBOL_VISIBLE greg_durations_config {
struct greg_durations_config {
typedef date date_type;
typedef date_time::int_adapter<int> int_rep;
typedef date_time::month_functor<date_type> month_adjustor_type;
@@ -28,16 +27,7 @@ namespace gregorian {
typedef date_time::months_duration<greg_durations_config> months;
typedef date_time::years_duration<greg_durations_config> years;
class BOOST_SYMBOL_VISIBLE weeks_duration : public date_duration {
public:
BOOST_CXX14_CONSTEXPR weeks_duration(duration_rep w)
: date_duration(w * 7) {}
BOOST_CXX14_CONSTEXPR weeks_duration(date_time::special_values sv)
: date_duration(sv) {}
};
typedef weeks_duration weeks;
typedef date_time::weeks_duration<date_time::duration_traits_adapted> weeks;
}} // namespace boost::gregorian
@@ -4,31 +4,26 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <boost/date_time/date_formatting_locales.hpp> // sets BOOST_DATE_TIME_NO_LOCALE
#include <boost/date_time/gregorian/parsers.hpp>
#include <boost/io/ios_state.hpp>
#include "boost/date_time/gregorian/gregorian_types.hpp"
#include "boost/date_time/date_formatting_locales.hpp" // sets BOOST_DATE_TIME_NO_LOCALE
#include "boost/date_time/gregorian/parsers.hpp"
#include <string>
#include <exception>
//This file is basically commented out if locales are not supported
#ifndef BOOST_DATE_TIME_NO_LOCALE
#include <string>
#include <memory>
#include <locale>
#include <iostream>
#include <exception>
namespace boost {
namespace gregorian {
//! Configuration of the output facet template
struct BOOST_SYMBOL_VISIBLE greg_facet_config
struct greg_facet_config
{
typedef boost::gregorian::greg_month month_type;
typedef boost::date_time::special_values special_value_enum;
@@ -36,7 +31,6 @@ namespace gregorian {
typedef boost::date_time::weekdays weekday_enum;
};
#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
//! Create the base facet type for gregorian::date
typedef boost::date_time::date_names_put<greg_facet_config> greg_base_facet;
@@ -76,9 +70,9 @@ namespace gregorian {
greg_month_formatter::format_month(m, os, f);
}
else { // default to numeric
boost::io::basic_ios_fill_saver<charT> ifs(os);
os << std::setw(2) << std::setfill(os.widen('0')) << m.as_number();
else { //default to numeric
charT fill_char = '0';
os << std::setw(2) << std::setfill(fill_char) << m.as_number();
}
return os;
@@ -99,7 +93,7 @@ namespace gregorian {
std::locale locale = os.getloc();
if (std::has_facet<facet_def>(locale)) {
const facet_def& f = std::use_facet<facet_def>(locale);
greg_weekday_formatter::format_weekday(wd, os, f, true);
greg_weekday_formatter::format_weekday(wd.as_enum(), os, f, true);
}
else { //default to short English string eg: Sun, Mon, Tue, Wed...
os << wd.as_short_string();
@@ -143,9 +137,7 @@ namespace gregorian {
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const partial_date& pd)
{
boost::io::basic_ios_fill_saver<charT> ifs(os);
os << std::setw(2) << std::setfill(os.widen('0')) << pd.day() << ' '
<< pd.month().as_short_string() ;
os << pd.day() << ' ' << pd.month().as_short_string() ;
return os;
}
@@ -207,7 +199,7 @@ namespace gregorian {
os << fkb.day_of_week() << " before";
return os;
}
#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
/**************** Input Streaming ******************/
#if !defined(BOOST_NO_STD_ITERATOR_TRAITS)
@@ -217,6 +209,8 @@ namespace gregorian {
std::basic_istream<charT>& operator>>(std::basic_istream<charT>& is, date& d)
{
std::istream_iterator<std::basic_string<charT>, charT> beg(is), eos;
typedef boost::date_time::all_date_names_put<greg_facet_config, charT> facet_def;
d = from_stream(beg, eos);
return is;
}
@@ -285,33 +279,22 @@ namespace gregorian {
const facet_def& f = std::use_facet<facet_def>(is.getloc());
num = date_time::find_match(f.get_short_month_names(),
f.get_long_month_names(),
(greg_month::max)(), s); // greg_month spans 1..12, so max returns the array size,
// which is needed by find_match
greg_month::max(), s);
}
/* bad_cast will be thrown if the desired facet is not accessible
* so we can generate the facet. This has the drawback of using english
* names as a default. */
catch(std::bad_cast&){
catch(std::bad_cast bc){
std::cout << "Month exception caught" << std::endl;
charT a = '\0';
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr< const facet_def > f(create_facet_def(a));
#else
std::unique_ptr< const facet_def > f(create_facet_def(a));
#endif
const facet_def* f = create_facet_def(a);
num = date_time::find_match(f->get_short_month_names(),
f->get_long_month_names(),
(greg_month::max)(), s); // greg_month spans 1..12, so max returns the array size,
// which is needed by find_match
greg_month::max(), s);
delete(f);
}
++num; // months numbered 1-12
m = greg_month(num);
m = greg_month(num +1); // months numbered 1-12
return is;
}
@@ -337,29 +320,19 @@ namespace gregorian {
const facet_def& f = std::use_facet<facet_def>(is.getloc());
num = date_time::find_match(f.get_short_weekday_names(),
f.get_long_weekday_names(),
(greg_weekday::max)() + 1, s); // greg_weekday spans 0..6, so increment is needed
// to form the array size which is needed by find_match
greg_weekday::max(), s);
}
/* bad_cast will be thrown if the desired facet is not accessible
* so we can generate the facet. This has the drawback of using english
* names as a default. */
catch(std::bad_cast&){
catch(std::bad_cast bc){
//std::cout << "Weekday exception caught" << std::endl;
charT a = '\0';
#if defined(BOOST_NO_CXX11_SMART_PTR)
std::auto_ptr< const facet_def > f(create_facet_def(a));
#else
std::unique_ptr< const facet_def > f(create_facet_def(a));
#endif
const facet_def* f = create_facet_def(a);
num = date_time::find_match(f->get_short_weekday_names(),
f->get_long_weekday_names(),
(greg_weekday::max)() + 1, s); // greg_weekday spans 0..6, so increment is needed
// to form the array size which is needed by find_match
greg_weekday::max(), s);
delete(f);
}
wd = greg_weekday(num); // weekdays numbered 0-6
@@ -368,7 +341,8 @@ namespace gregorian {
} } //namespace gregorian
#endif
#endif
#endif
@@ -1,19 +1,23 @@
#ifndef GREG_MONTH_HPP___
#define GREG_MONTH_HPP___
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <boost/date_time/constrained_value.hpp>
#include <boost/date_time/date_defs.hpp>
#include <boost/date_time/compiler_config.hpp>
#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 {
@@ -35,9 +39,9 @@ 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
struct bad_month : public std::out_of_range
{
bad_month() : std::out_of_range(std::string("Month number is out of range 1..12")) {}
};
@@ -46,65 +50,31 @@ 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_SYMBOL_VISIBLE greg_month : public greg_month_rep {
class BOOST_DATE_TIME_DECL greg_month : public greg_month_rep {
public:
typedef date_time::months_of_year month_enum;
typedef std::map<std::string, unsigned short> month_map_type;
typedef boost::shared_ptr<month_map_type> month_map_ptr_type;
//! Construct a month from the months_of_year enumeration
BOOST_CXX14_CONSTEXPR greg_month(month_enum theMonth) :
greg_month(month_enum theMonth) :
greg_month_rep(static_cast<greg_month_rep::value_type>(theMonth)) {}
//! Construct from a short value
BOOST_CXX14_CONSTEXPR greg_month(value_type theMonth) : greg_month_rep(theMonth) {}
greg_month(unsigned short theMonth) : greg_month_rep(theMonth) {}
//! Convert the value back to a short
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
operator unsigned short() const {return value_;}
//! Returns month as number from 1 to 12
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];
}
unsigned short as_number() const {return value_;}
month_enum as_enum() const {return static_cast<month_enum>(value_);}
const char* as_short_string() const;
const char* as_long_string() const;
#ifndef BOOST_NO_STD_WSTRING
//! 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];
}
const wchar_t* as_short_wstring() const;
const wchar_t* as_long_wstring() const;
#endif // BOOST_NO_STD_WSTRING
//! Shared pointer to a map of Month strings (Names & Abbrev) & numbers
static month_map_ptr_type get_month_map_ptr();
/* parameterized as_*_string functions are intended to be called
* from a template function: "... as_short_string(charT c='\0');" */
@@ -130,4 +100,6 @@ namespace gregorian {
} } //namespace gregorian
#endif
@@ -1,57 +1,48 @@
#ifndef GREGORIAN_SERIALIZE_HPP___
#define GREGORIAN_SERIALIZE_HPP___
/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
/* Copyright (c) 2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include "boost/date_time/gregorian/gregorian_types.hpp"
#include "boost/date_time/gregorian/parsers.hpp"
#include "boost/core/nvp.hpp"
#include "boost/serialization/split_free.hpp"
namespace boost {
namespace gregorian {
std::string to_iso_string(const date&);
}
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); \
}
// macros to split serialize functions into save & load functions
// An expanded version is below for gregorian::date
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_duration)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_duration::duration_rep)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::date_period)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_month)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_day)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::greg_weekday)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::partial_date)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::nth_kday_of_month)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_of_month)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::last_kday_of_month)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_before)
BOOST_SERIALIZATION_SPLIT_FREE(::boost::gregorian::first_kday_after)
/*! Method that does serialization for gregorian::date -- splits to load/save
*/
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
template<class Archive>
inline void serialize(Archive & ar,
::boost::gregorian::date & d,
const unsigned int file_version)
{
split_free(ar, d, file_version);
}
//! Function to save gregorian::date objects using serialization lib
/*! Dates are serialized into a string for transport and storage.
@@ -61,7 +52,7 @@ BOOST_DATE_TIME_SPLIT_FREE(::boost::gregorian::first_kday_after)
template<class Archive>
void save(Archive & ar,
const ::boost::gregorian::date & d,
unsigned int /* version */)
unsigned int version)
{
std::string ds = to_iso_string(d);
ar & make_nvp("date", ds);
@@ -75,29 +66,19 @@ void save(Archive & ar,
template<class Archive>
void load(Archive & ar,
::boost::gregorian::date & d,
unsigned int /*version*/)
unsigned int version)
{
std::string ds;
ar & make_nvp("date", ds);
try{
d = ::boost::gregorian::from_undelimited_string(ds);
}catch(bad_lexical_cast&) {
gregorian::special_values sv = gregorian::special_value_from_string(ds);
if(sv == gregorian::not_special) {
throw; // no match found, rethrow original exception
}
else {
d = gregorian::date(sv);
}
}
d = ::boost::gregorian::from_undelimited_string(ds);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/,
inline void load_construct_data(Archive & ar,
::boost::gregorian::date* dp,
const unsigned int /*file_version*/)
const unsigned int file_version)
{
// retrieve data from archive required to construct new
// invoke inplace constructor to initialize instance of date
@@ -109,14 +90,14 @@ inline void load_construct_data(Archive & /*ar*/,
//! Function to save gregorian::date_duration objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::date_duration & dd,
unsigned int /*version*/)
unsigned int version)
{
typename gregorian::date_duration::duration_rep dr = dd.get_rep();
ar & make_nvp("date_duration", dr);
}
//! Function to load gregorian::date_duration objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::date_duration & dd, unsigned int /*version*/)
void load(Archive & ar, gregorian::date_duration & dd, unsigned int version)
{
typename gregorian::date_duration::duration_rep dr(0);
ar & make_nvp("date_duration", dr);
@@ -124,8 +105,8 @@ void load(Archive & ar, gregorian::date_duration & dd, unsigned int /*version*/)
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/, gregorian::date_duration* dd,
const unsigned int /*file_version*/)
inline void load_construct_data(Archive & ar, gregorian::date_duration* dd,
const unsigned int file_version)
{
::new(dd) gregorian::date_duration(gregorian::not_a_date_time);
}
@@ -135,14 +116,14 @@ inline void load_construct_data(Archive & /*ar*/, gregorian::date_duration* dd,
//! helper unction to save date_duration objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::date_duration::duration_rep & dr,
unsigned int /*version*/)
unsigned int version)
{
typename gregorian::date_duration::duration_rep::int_type it = dr.as_number();
ar & make_nvp("date_duration_duration_rep", it);
}
//! helper function to load date_duration objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::date_duration::duration_rep & dr, unsigned int /*version*/)
void load(Archive & ar, gregorian::date_duration::duration_rep & dr, unsigned int version)
{
typename gregorian::date_duration::duration_rep::int_type it(0);
ar & make_nvp("date_duration_duration_rep", it);
@@ -150,8 +131,8 @@ void load(Archive & ar, gregorian::date_duration::duration_rep & dr, unsigned in
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/, gregorian::date_duration::duration_rep* dr,
const unsigned int /*file_version*/)
inline void load_construct_data(Archive & ar, gregorian::date_duration::duration_rep* dr,
const unsigned int file_version)
{
::new(dr) gregorian::date_duration::duration_rep(0);
}
@@ -164,10 +145,10 @@ inline void load_construct_data(Archive & /*ar*/, gregorian::date_duration::dura
*/
template<class Archive>
void save(Archive & ar, const gregorian::date_period& dp,
unsigned int /*version*/)
unsigned int version)
{
gregorian::date d1 = dp.begin();
gregorian::date d2 = dp.end();
typename gregorian::date d1 = dp.begin();
typename gregorian::date d2 = dp.end();
ar & make_nvp("date_period_begin_date", d1);
ar & make_nvp("date_period_end_date", d2);
}
@@ -176,63 +157,37 @@ void save(Archive & ar, const gregorian::date_period& dp,
* the begining date object and the end date object
*/
template<class Archive>
void load(Archive & ar, gregorian::date_period& dp, unsigned int /*version*/)
void load(Archive & ar, gregorian::date_period& dp, unsigned int version)
{
gregorian::date d1(gregorian::not_a_date_time);
gregorian::date d2(gregorian::not_a_date_time);
typename gregorian::date d1(gregorian::not_a_date_time);
typename gregorian::date d2(gregorian::not_a_date_time);
ar & make_nvp("date_period_begin_date", d1);
ar & make_nvp("date_period_end_date", d2);
dp = gregorian::date_period(d1,d2);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/, gregorian::date_period* dp,
const unsigned int /*file_version*/)
inline void load_construct_data(Archive & ar, gregorian::date_period* dp,
const unsigned int file_version)
{
gregorian::date d(gregorian::not_a_date_time);
gregorian::date_duration dd(1);
typename gregorian::date d(gregorian::not_a_date_time);
typename gregorian::date_duration dd(1);
::new(dp) gregorian::date_period(d,dd);
}
/**** greg_year ****/
//! Function to save gregorian::greg_year objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::greg_year& gy,
unsigned int /*version*/)
{
unsigned short us = gy;
ar & make_nvp("greg_year", us);
}
//! Function to load gregorian::greg_year objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::greg_year& gy, unsigned int /*version*/)
{
unsigned short us;
ar & make_nvp("greg_year", us);
gy = gregorian::greg_year(us);
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/, gregorian::greg_year* gy,
const unsigned int /*file_version*/)
{
::new(gy) gregorian::greg_year(1900);
}
/**** greg_month ****/
//! Function to save gregorian::greg_month objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::greg_month& gm,
unsigned int /*version*/)
unsigned int version)
{
unsigned short us = gm.as_number();
ar & make_nvp("greg_month", us);
}
//! Function to load gregorian::greg_month objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::greg_month& gm, unsigned int /*version*/)
void load(Archive & ar, gregorian::greg_month& gm, unsigned int version)
{
unsigned short us;
ar & make_nvp("greg_month", us);
@@ -240,8 +195,8 @@ void load(Archive & ar, gregorian::greg_month& gm, unsigned int /*version*/)
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/, gregorian::greg_month* gm,
const unsigned int /*file_version*/)
inline void load_construct_data(Archive & ar, gregorian::greg_month* gm,
const unsigned int file_version)
{
::new(gm) gregorian::greg_month(1);
}
@@ -251,14 +206,14 @@ inline void load_construct_data(Archive & /*ar*/, gregorian::greg_month* gm,
//! Function to save gregorian::greg_day objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::greg_day& gd,
unsigned int /*version*/)
unsigned int version)
{
unsigned short us = gd.as_number();
ar & make_nvp("greg_day", us);
}
//! Function to load gregorian::greg_day objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::greg_day& gd, unsigned int /*version*/)
void load(Archive & ar, gregorian::greg_day& gd, unsigned int version)
{
unsigned short us;
ar & make_nvp("greg_day", us);
@@ -266,8 +221,8 @@ void load(Archive & ar, gregorian::greg_day& gd, unsigned int /*version*/)
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/, gregorian::greg_day* gd,
const unsigned int /*file_version*/)
inline void load_construct_data(Archive & ar, gregorian::greg_day* gd,
const unsigned int file_version)
{
::new(gd) gregorian::greg_day(1);
}
@@ -277,14 +232,14 @@ inline void load_construct_data(Archive & /*ar*/, gregorian::greg_day* gd,
//! Function to save gregorian::greg_weekday objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::greg_weekday& gd,
unsigned int /*version*/)
unsigned int version)
{
unsigned short us = gd.as_number();
ar & make_nvp("greg_weekday", us);
}
//! Function to load gregorian::greg_weekday objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::greg_weekday& gd, unsigned int /*version*/)
void load(Archive & ar, gregorian::greg_weekday& gd, unsigned int version)
{
unsigned short us;
ar & make_nvp("greg_weekday", us);
@@ -292,8 +247,8 @@ void load(Archive & ar, gregorian::greg_weekday& gd, unsigned int /*version*/)
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/, gregorian::greg_weekday* gd,
const unsigned int /*file_version*/)
inline void load_construct_data(Archive & ar, gregorian::greg_weekday* gd,
const unsigned int file_version)
{
::new(gd) gregorian::greg_weekday(1);
}
@@ -308,7 +263,7 @@ inline void load_construct_data(Archive & /*ar*/, gregorian::greg_weekday* gd,
*/
template<class Archive>
void save(Archive & ar, const gregorian::partial_date& pd,
unsigned int /*version*/)
unsigned int version)
{
gregorian::greg_day gd(pd.day());
gregorian::greg_month gm(pd.month().as_number());
@@ -320,7 +275,7 @@ void save(Archive & ar, const gregorian::partial_date& pd,
* the day (greg_day) and month (greg_month) objects
*/
template<class Archive>
void load(Archive & ar, gregorian::partial_date& pd, unsigned int /*version*/)
void load(Archive & ar, gregorian::partial_date& pd, unsigned int version)
{
gregorian::greg_day gd(1);
gregorian::greg_month gm(1);
@@ -330,8 +285,8 @@ void load(Archive & ar, gregorian::partial_date& pd, unsigned int /*version*/)
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/, gregorian::partial_date* pd,
const unsigned int /*file_version*/)
inline void load_construct_data(Archive & ar, gregorian::partial_date* pd,
const unsigned int file_version)
{
gregorian::greg_month gm(1);
gregorian::greg_day gd(1);
@@ -346,7 +301,7 @@ inline void load_construct_data(Archive & /*ar*/, gregorian::partial_date* pd,
*/
template<class Archive>
void save(Archive & ar, const gregorian::nth_kday_of_month& nkd,
unsigned int /*version*/)
unsigned int version)
{
typename gregorian::nth_kday_of_month::week_num wn(nkd.nth_week());
typename gregorian::nth_kday_of_month::day_of_week_type d(nkd.day_of_week().as_number());
@@ -360,7 +315,7 @@ void save(Archive & ar, const gregorian::nth_kday_of_month& nkd,
* serialization: the week number, the day of the week, and the month
*/
template<class Archive>
void load(Archive & ar, gregorian::nth_kday_of_month& nkd, unsigned int /*version*/)
void load(Archive & ar, gregorian::nth_kday_of_month& nkd, unsigned int version)
{
typename gregorian::nth_kday_of_month::week_num wn(gregorian::nth_kday_of_month::first);
typename gregorian::nth_kday_of_month::day_of_week_type d(gregorian::Monday);
@@ -373,12 +328,12 @@ void load(Archive & ar, gregorian::nth_kday_of_month& nkd, unsigned int /*versio
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/,
inline void load_construct_data(Archive & ar,
gregorian::nth_kday_of_month* nkd,
const unsigned int /*file_version*/)
const unsigned int file_version)
{
// values used are not significant
::new(nkd) gregorian::nth_kday_of_month(gregorian::nth_kday_of_month::first,
::new(pd) gregorian::nth_kday_of_month(gregorian::nth_kday_of_month::first,
gregorian::Monday,gregorian::Jan);
}
@@ -390,7 +345,7 @@ inline void load_construct_data(Archive & /*ar*/,
*/
template<class Archive>
void save(Archive & ar, const gregorian::first_kday_of_month& fkd,
unsigned int /*version*/)
unsigned int version)
{
typename gregorian::first_kday_of_month::day_of_week_type d(fkd.day_of_week().as_number());
typename gregorian::first_kday_of_month::month_type m(fkd.month().as_number());
@@ -402,7 +357,7 @@ void save(Archive & ar, const gregorian::first_kday_of_month& fkd,
* serialization: the day of the week, and the month
*/
template<class Archive>
void load(Archive & ar, gregorian::first_kday_of_month& fkd, unsigned int /*version*/)
void load(Archive & ar, gregorian::first_kday_of_month& fkd, unsigned int version)
{
typename gregorian::first_kday_of_month::day_of_week_type d(gregorian::Monday);
typename gregorian::first_kday_of_month::month_type m(gregorian::Jan);
@@ -413,12 +368,12 @@ void load(Archive & ar, gregorian::first_kday_of_month& fkd, unsigned int /*vers
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/,
inline void load_construct_data(Archive & ar,
gregorian::first_kday_of_month* fkd,
const unsigned int /*file_version*/)
const unsigned int file_version)
{
// values used are not significant
::new(fkd) gregorian::first_kday_of_month(gregorian::Monday,gregorian::Jan);
::new(pd) gregorian::first_kday_of_month(gregorian::Monday,gregorian::Jan);
}
/**** last_kday_of_month ****/
@@ -429,7 +384,7 @@ inline void load_construct_data(Archive & /*ar*/,
*/
template<class Archive>
void save(Archive & ar, const gregorian::last_kday_of_month& lkd,
unsigned int /*version*/)
unsigned int version)
{
typename gregorian::last_kday_of_month::day_of_week_type d(lkd.day_of_week().as_number());
typename gregorian::last_kday_of_month::month_type m(lkd.month().as_number());
@@ -441,7 +396,7 @@ void save(Archive & ar, const gregorian::last_kday_of_month& lkd,
* serialization: the day of the week, and the month
*/
template<class Archive>
void load(Archive & ar, gregorian::last_kday_of_month& lkd, unsigned int /*version*/)
void load(Archive & ar, gregorian::last_kday_of_month& lkd, unsigned int version)
{
typename gregorian::last_kday_of_month::day_of_week_type d(gregorian::Monday);
typename gregorian::last_kday_of_month::month_type m(gregorian::Jan);
@@ -452,12 +407,12 @@ void load(Archive & ar, gregorian::last_kday_of_month& lkd, unsigned int /*versi
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/,
inline void load_construct_data(Archive & ar,
gregorian::last_kday_of_month* lkd,
const unsigned int /*file_version*/)
const unsigned int file_version)
{
// values used are not significant
::new(lkd) gregorian::last_kday_of_month(gregorian::Monday,gregorian::Jan);
::new(pd) gregorian::last_kday_of_month(gregorian::Monday,gregorian::Jan);
}
/**** first_kday_before ****/
@@ -465,14 +420,14 @@ inline void load_construct_data(Archive & /*ar*/,
//! Function to save first_day_of_the_week_before objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::first_kday_before& fkdb,
unsigned int /*version*/)
unsigned int version)
{
typename gregorian::first_kday_before::day_of_week_type d(fkdb.day_of_week().as_number());
ar & make_nvp("first_kday_before_day_of_week", d);
}
//! Function to load first_day_of_the_week_before objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::first_kday_before& fkdb, unsigned int /*version*/)
void load(Archive & ar, gregorian::first_kday_before& fkdb, unsigned int version)
{
typename gregorian::first_kday_before::day_of_week_type d(gregorian::Monday);
ar & make_nvp("first_kday_before_day_of_week", d);
@@ -481,12 +436,12 @@ void load(Archive & ar, gregorian::first_kday_before& fkdb, unsigned int /*versi
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/,
inline void load_construct_data(Archive & ar,
gregorian::first_kday_before* fkdb,
const unsigned int /*file_version*/)
const unsigned int file_version)
{
// values used are not significant
::new(fkdb) gregorian::first_kday_before(gregorian::Monday);
::new(pd) gregorian::first_kday_before(gregorian::Monday);
}
/**** first_kday_after ****/
@@ -494,14 +449,14 @@ inline void load_construct_data(Archive & /*ar*/,
//! Function to save first_day_of_the_week_after objects using serialization lib
template<class Archive>
void save(Archive & ar, const gregorian::first_kday_after& fkda,
unsigned int /*version*/)
unsigned int version)
{
typename gregorian::first_kday_after::day_of_week_type d(fkda.day_of_week().as_number());
ar & make_nvp("first_kday_after_day_of_week", d);
}
//! Function to load first_day_of_the_week_after objects using serialization lib
template<class Archive>
void load(Archive & ar, gregorian::first_kday_after& fkda, unsigned int /*version*/)
void load(Archive & ar, gregorian::first_kday_after& fkda, unsigned int version)
{
typename gregorian::first_kday_after::day_of_week_type d(gregorian::Monday);
ar & make_nvp("first_kday_after_day_of_week", d);
@@ -510,12 +465,12 @@ void load(Archive & ar, gregorian::first_kday_after& fkda, unsigned int /*versio
}
//!override needed b/c no default constructor
template<class Archive>
inline void load_construct_data(Archive & /*ar*/,
inline void load_construct_data(Archive & ar,
gregorian::first_kday_after* fkda,
const unsigned int /*file_version*/)
const unsigned int file_version)
{
// values used are not significant
::new(fkda) gregorian::first_kday_after(gregorian::Monday);
::new(pd) gregorian::first_kday_after(gregorian::Monday);
}
} // namespace serialization
@@ -1,17 +1,17 @@
#ifndef GREG_WEEKDAY_HPP___
#define GREG_WEEKDAY_HPP___
/* Copyright (c) 2002,2003,2020 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <boost/date_time/constrained_value.hpp>
#include <boost/date_time/date_defs.hpp>
#include <boost/date_time/compiler_config.hpp>
#include "boost/date_time/constrained_value.hpp"
#include "boost/date_time/date_defs.hpp"
#include "boost/date_time/compiler_config.hpp"
#include <stdexcept>
#include <string>
@@ -29,64 +29,30 @@ namespace gregorian {
//! Exception that flags that a weekday number is incorrect
struct BOOST_SYMBOL_VISIBLE bad_weekday : public std::out_of_range
struct bad_weekday : public std::out_of_range
{
bad_weekday() : std::out_of_range(std::string("Weekday is out of range 0..6")) {}
bad_weekday() : std::out_of_range(std::string("Weekday os out of range 0..6")) {}
};
typedef CV::simple_exception_policy<unsigned short, 0, 6, bad_weekday> greg_weekday_policies;
typedef CV::constrained_value<greg_weekday_policies> greg_weekday_rep;
//! Represent a day within a week (range 0==Sun to 6==Sat)
class BOOST_SYMBOL_VISIBLE greg_weekday : public greg_weekday_rep {
class BOOST_DATE_TIME_DECL greg_weekday : public greg_weekday_rep {
public:
typedef boost::date_time::weekdays weekday_enum;
BOOST_CXX14_CONSTEXPR greg_weekday(value_type day_of_week_num) :
greg_weekday(unsigned short day_of_week_num) :
greg_weekday_rep(day_of_week_num)
{}
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_];
}
unsigned short as_number() const {return value_;}
const char* as_short_string() const;
const char* as_long_string() const;
#ifndef BOOST_NO_STD_WSTRING
//! 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_];
}
const wchar_t* as_short_wstring() const;
const wchar_t* as_long_wstring() const;
#endif // BOOST_NO_STD_WSTRING
weekday_enum as_enum() const {return static_cast<weekday_enum>(value_);}
};
+13 -12
View File
@@ -1,16 +1,15 @@
#ifndef GREG_YEAR_HPP___
#define GREG_YEAR_HPP___
/* Copyright (c) 2002,2003, 2020 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
* $Date$
*/
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/constrained_value.hpp>
#include "boost/date_time/constrained_value.hpp"
#include <stdexcept>
#include <string>
@@ -18,29 +17,31 @@ namespace boost {
namespace gregorian {
//! Exception type for gregorian year
struct BOOST_SYMBOL_VISIBLE bad_year : public std::out_of_range
struct bad_year : public std::out_of_range
{
bad_year() :
std::out_of_range(std::string("Year is out of valid range: 1400..9999"))
std::out_of_range(std::string("Year is out of valid range: 1400..10000"))
{}
};
//! Policy class that declares error handling gregorian year type
typedef CV::simple_exception_policy<unsigned short, 1400, 9999, bad_year> greg_year_policies;
typedef CV::simple_exception_policy<unsigned short, 1400, 10000, bad_year> greg_year_policies;
//! Generated representation for gregorian year
typedef CV::constrained_value<greg_year_policies> greg_year_rep;
//! Represent a year (range 1400 - 9999)
//! Represent a day of the month (range 1900 - 10000)
/*! This small class allows for simple conversion an integer value into
a year for the gregorian calendar. This currently only allows a
range of 1400 to 9999. Both ends of the range are a bit arbitrary
range of 1900 to 10000. Both ends of the range are a bit arbitrary
at the moment, but they are the limits of current testing of the
library. As such they may be increased in the future.
*/
class BOOST_SYMBOL_VISIBLE greg_year : public greg_year_rep {
class greg_year : public greg_year_rep {
public:
BOOST_CXX14_CONSTEXPR greg_year(value_type year) : greg_year_rep(year) {}
BOOST_CXX14_CONSTEXPR operator value_type() const {return value_;}
greg_year(unsigned short year) : greg_year_rep(year) {}
operator unsigned short() const {return value_;}
private:
};
@@ -4,7 +4,7 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
* $Date$
*/
@@ -4,7 +4,7 @@
/* Copyright (c) 2002-2004 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -24,13 +24,7 @@
#else
#include "boost/date_time/gregorian/formatters.hpp"
#endif
#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
#include "boost/date_time/gregorian/greg_facet.hpp"
#else
#include "boost/date_time/gregorian/gregorian_io.hpp"
#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
#include "boost/date_time/gregorian/parsers.hpp"
@@ -1,784 +0,0 @@
#ifndef DATE_TIME_GREGORIAN_IO_HPP__
#define DATE_TIME_GREGORIAN_IO_HPP__
/* Copyright (c) 2004-2005 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <locale>
#include <iostream>
#include <iterator> // i/ostreambuf_iterator
#include <boost/io/ios_state.hpp>
#include <boost/date_time/date_facet.hpp>
#include <boost/date_time/period_parser.hpp>
#include <boost/date_time/period_formatter.hpp>
#include <boost/date_time/special_values_parser.hpp>
#include <boost/date_time/special_values_formatter.hpp>
#include <boost/date_time/gregorian/gregorian_types.hpp>
#include <boost/date_time/gregorian/conversion.hpp> // to_tm will be needed in the facets
namespace boost {
namespace gregorian {
typedef boost::date_time::period_formatter<wchar_t> wperiod_formatter;
typedef boost::date_time::period_formatter<char> period_formatter;
typedef boost::date_time::date_facet<date,wchar_t> wdate_facet;
typedef boost::date_time::date_facet<date,char> date_facet;
typedef boost::date_time::period_parser<date,char> period_parser;
typedef boost::date_time::period_parser<date,wchar_t> wperiod_parser;
typedef boost::date_time::special_values_formatter<char> special_values_formatter;
typedef boost::date_time::special_values_formatter<wchar_t> wspecial_values_formatter;
typedef boost::date_time::special_values_parser<date,char> special_values_parser;
typedef boost::date_time::special_values_parser<date,wchar_t> wspecial_values_parser;
typedef boost::date_time::date_input_facet<date,char> date_input_facet;
typedef boost::date_time::date_input_facet<date,wchar_t> wdate_input_facet;
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date& d) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), d);
else {
//instantiate a custom facet for dealing with dates since the user
//has not put one in the stream so far. This is for efficiency
//since we would always need to reconstruct for every date
//if the locale did not already exist. Of course this will be overridden
//if the user imbues at some later point. With the default settings
//for the facet the resulting format will be the same as the
//std::time_facet settings.
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), d);
}
return os;
}
//! input operator for date
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, date& d)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, d);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, d);
}
}
catch(...) {
// mask tells us what exceptions are turned on
std::ios_base::iostate exception_mask = is.exceptions();
// if the user wants exceptions on failbit, we'll rethrow our
// date_time exception & set the failbit
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {} // ignore this one
throw; // rethrow original exception
}
else {
// if the user want's to fail quietly, we simply set the failbit
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date_duration& dd) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), dd);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), dd);
}
return os;
}
//! input operator for date_duration
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, date_duration& dd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, dd);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, dd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::date_period& dp) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), dp);
else {
//instantiate a custom facet for dealing with date periods since the user
//has not put one in the stream so far. This is for efficiency
//since we would always need to reconstruct for every time period
//if the local did not already exist. Of course this will be overridden
//if the user imbues at some later point. With the default settings
//for the facet the resulting format will be the same as the
//std::time_facet settings.
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), dp);
}
return os;
}
//! input operator for date_period
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, date_period& dp)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, dp);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, dp);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
/********** small gregorian types **********/
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::greg_month& gm) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), gm);
else {
custom_date_facet* f = new custom_date_facet();//-> 10/1074199752/32 because year & day not initialized in put(...)
//custom_date_facet* f = new custom_date_facet("%B");
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), gm);
}
return os;
}
//! input operator for greg_month
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, greg_month& m)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, m);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, m);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::greg_weekday& gw) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), gw);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), gw);
}
return os;
}
//! input operator for greg_weekday
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, greg_weekday& wd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, wd);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, wd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
//NOTE: output operator for greg_day was not necessary
//! input operator for greg_day
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, greg_day& gd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, gd);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, gd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
//NOTE: output operator for greg_year was not necessary
//! input operator for greg_year
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, greg_year& gy)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, gy);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, gy);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
/********** date generator types **********/
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::partial_date& pd) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), pd);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), pd);
}
return os;
}
//! input operator for partial_date
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, partial_date& pd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, pd);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, pd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::nth_day_of_the_week_in_month& nkd) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), nkd);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), nkd);
}
return os;
}
//! input operator for nth_day_of_the_week_in_month
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
nth_day_of_the_week_in_month& nday)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, nday);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, nday);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_in_month& fkd) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fkd);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), fkd);
}
return os;
}
//! input operator for first_day_of_the_week_in_month
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
first_day_of_the_week_in_month& fkd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fkd);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fkd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::last_day_of_the_week_in_month& lkd) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc()))
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), lkd);
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), lkd);
}
return os;
}
//! input operator for last_day_of_the_week_in_month
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
last_day_of_the_week_in_month& lkd)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, lkd);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, lkd);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_after& fda) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc())) {
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fda);
}
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), fda);
}
return os;
}
//! input operator for first_day_of_the_week_after
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
first_day_of_the_week_after& fka)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fka);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fka);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
template <class CharT, class TraitsT>
inline std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const boost::gregorian::first_day_of_the_week_before& fdb) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::date_facet<date, CharT> custom_date_facet;
std::ostreambuf_iterator<CharT> output_itr(os);
if (std::has_facet<custom_date_facet>(os.getloc())) {
std::use_facet<custom_date_facet>(os.getloc()).put(output_itr, os, os.fill(), fdb);
}
else {
custom_date_facet* f = new custom_date_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(output_itr, os, os.fill(), fdb);
}
return os;
}
//! input operator for first_day_of_the_week_before
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is,
first_day_of_the_week_before& fkb)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::date_input_facet<date, CharT> date_input_facet_local;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<date_input_facet_local>(is.getloc())) {
std::use_facet<date_input_facet_local>(is.getloc()).get(sit, str_end, is, fkb);
}
else {
date_input_facet_local* f = new date_input_facet_local();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, fkb);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
} } // namespaces
#endif // DATE_TIME_GREGORIAN_IO_HPP__
@@ -4,7 +4,7 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
+18 -43
View File
@@ -1,75 +1,50 @@
#ifndef GREGORIAN_PARSERS_HPP___
#define GREGORIAN_PARSERS_HPP___
/* Copyright (c) 2002,2003,2005 CrystalClear Software, Inc.
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $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/special_defs.hpp>
#include <boost/date_time/find_match.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 <string>
#include <iterator>
#include <sstream>
namespace boost {
namespace gregorian {
//! Return special_value from string argument
/*! Return special_value from string argument. If argument is
* not one of the special value names (defined in names.hpp),
* return 'not_special' */
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(const std::string& s) {
inline date from_string(std::string s) {
return date_time::parse_date<date>(s);
}
//! From delimited date string where with order year-month-day eg: 2002-1-25 or 2003-Jan-25 (full month name is also accepted)
inline date from_simple_string(const std::string& s) {
inline date from_simple_string(std::string s) {
return date_time::parse_date<date>(s, date_time::ymd_order_iso);
}
//! From delimited date string where with order year-month-day eg: 1-25-2003 or Jan-25-2003 (full month name is also accepted)
inline date from_us_string(const std::string& s) {
inline date from_us_string(std::string s) {
return date_time::parse_date<date>(s, date_time::ymd_order_us);
}
//! From delimited date string where with order day-month-year eg: 25-1-2002 or 25-Jan-2003 (full month name is also accepted)
inline date from_uk_string(const std::string& s) {
inline date from_uk_string(std::string s) {
return date_time::parse_date<date>(s, date_time::ymd_order_dmy);
}
//! From ISO 8601 type date string where with order year-month-day eg: 20020125
inline date from_undelimited_string(const std::string& s) {
//! From iso type date string where with order year-month-day eg: 20020125
inline date from_undelimited_string(std::string s) {
return date_time::parse_undelimited_date<date>(s);
}
//! From ISO 8601 type date string where with order year-month-day eg: 20020125
//! From iso type date string where with order year-month-day eg: 20020125
inline date date_from_iso_string(const std::string& s) {
return date_time::parse_undelimited_date<date>(s);
}
@@ -90,20 +65,20 @@ namespace gregorian {
}
#endif //BOOST_NO_STD_ITERATOR_TRAITS
#if (defined(_MSC_VER) && (_MSC_VER < 1300))
#if (defined(_MSC_VER) && (_MSC_VER <= 1200))
// This function cannot be compiled with MSVC 6.0 due to internal compiler shorcomings
#else
//! Function to parse a date_period from a string (eg: [2003-Oct-31/2003-Dec-25])
inline date_period date_period_from_string(const std::string& s){
return date_time::from_simple_string_type<date,char>(s);
}
# if !defined(BOOST_NO_STD_WSTRING)
#if !defined(BOOST_NO_STD_WSTRING)
//! Function to parse a date_period from a wstring (eg: [2003-Oct-31/2003-Dec-25])
inline date_period date_period_from_wstring(const std::wstring& s){
return date_time::from_simple_string_type<date,wchar_t>(s);
}
# endif // BOOST_NO_STD_WSTRING
#endif
#endif // BOOST_NO_STD_WSTRING
#endif // _MSC_VER <= 1200
} } //namespace gregorian
+24 -23
View File
@@ -2,14 +2,13 @@
#define DATE_TIME_GREGORIAN_CALENDAR_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
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland
* $Date$
*/
#include <boost/date_time/compiler_config.hpp>
namespace boost {
namespace date_time {
@@ -20,15 +19,15 @@ namespace date_time {
can be used in the creation of date systems or just to perform calculations.
All the methods of this class are static functions, so the intent is to
never create instances of this class.
@tparam ymd_type_ Struct type representing the year, month, day. The ymd_type must
@param ymd_type_ Struct type representing the year, month, day. The ymd_type must
define a of types for the year, month, and day. These types need to be
arithmetic types.
@tparam date_int_type_ Underlying type for the date count. Must be an arithmetic type.
@param date_int_type_ Underlying type for the date count. Must be an arithmetic type.
*/
template<typename ymd_type_, typename date_int_type_>
class BOOST_SYMBOL_VISIBLE gregorian_calendar_base {
class gregorian_calendar_base {
public:
//! define a type a date split into components
//! define a type a date split into components
typedef ymd_type_ ymd_type;
//! define a type for representing months
typedef typename ymd_type::month_type month_type;
@@ -40,30 +39,32 @@ namespace date_time {
typedef date_int_type_ date_int_type;
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();
static unsigned short day_of_week(const ymd_type& ymd);
static int week_number(const ymd_type&ymd);
//static unsigned short day_of_year(date_int_type);
static date_int_type day_number(const ymd_type& ymd);
static date_int_type julian_day_number(const ymd_type& ymd);
static long modjulian_day_number(const ymd_type& ymd);
static ymd_type from_day_number(date_int_type);
static ymd_type from_julian_day_number(date_int_type);
static ymd_type from_modjulian_day_number(long);
static bool is_leap_year(year_type);
static unsigned short end_of_month_day(year_type y, month_type m);
static ymd_type epoch();
static unsigned short days_in_week();
};
} } //namespace
#ifndef NO_BOOST_DATE_TIME_INLINE
#include "boost/date_time/gregorian_calendar.ipp"
#endif
#endif
+61 -66
View File
@@ -1,20 +1,23 @@
/* 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)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#ifndef NO_BOOST_DATE_TIME_INLINE
#undef BOOST_DATE_TIME_INLINE
#define BOOST_DATE_TIME_INLINE inline
#endif
namespace boost {
namespace date_time {
//! Return the day of the week (0==Sunday, 1==Monday, etc)
/*! Converts a year-month-day into a day of the week number
/*! Converts a the year-month-day into a day of the week number
*/
template<typename ymd_type_, typename date_int_type_>
BOOST_CXX14_CONSTEXPR
inline
BOOST_DATE_TIME_INLINE
unsigned short
gregorian_calendar_base<ymd_type_,date_int_type_>::day_of_week(const ymd_type& ymd) {
unsigned short a = static_cast<unsigned short>((14-ymd.month)/12);
@@ -24,30 +27,29 @@ namespace date_time {
//std::cout << year << "-" << month << "-" << day << " is day: " << d << "\n";
return d;
}
//!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
//!Return the iso week number for the date
/*!Implements the rules associated with the iso 8601 week number.
Basically the rule is that Week 1 of the year is the week that contains
January 4th or the week that contains the first Thursday in January.
Reference for this algorithm is the Calendar FAQ by Claus Tondering, April 2000.
*/
template<typename ymd_type_, typename date_int_type_>
BOOST_CXX14_CONSTEXPR
inline
BOOST_DATE_TIME_INLINE
int
gregorian_calendar_base<ymd_type_,date_int_type_>::week_number(const ymd_type& ymd) {
unsigned long julianbegin = julian_day_number(ymd_type(ymd.year,1,1));
unsigned long juliantoday = julian_day_number(ymd);
unsigned long day = (julianbegin + 3) % 7;
unsigned long week = (juliantoday + day - julianbegin + 4)/7;
if ((week >= 1) && (week <= 52)) {
return static_cast<int>(week);
return week;
}
if (week == 53) {
if ((week == 53)) {
if((day==6) ||(day == 5 && is_leap_year(ymd.year))) {
return static_cast<int>(week); //under these circumstances week == 53.
return week; //under these circumstances week == 53.
} else {
return 1; //monday - wednesday is in week 1 of next year
}
@@ -58,37 +60,35 @@ namespace date_time {
juliantoday = julian_day_number(ymd);
day = (julianbegin + 3) % 7;
week = (juliantoday + day - julianbegin + 4)/7;
return static_cast<int>(week);
return week;
}
return static_cast<int>(week); //not reachable -- well except if day == 5 and is_leap_year != true
return week; //not reachable -- well except if day == 5 and is_leap_year != true
}
//! Convert a ymd_type into a day number
/*! The day number is an absolute number of days since the start of count
*/
template<typename ymd_type_, typename date_int_type_>
BOOST_CXX14_CONSTEXPR
inline
BOOST_DATE_TIME_INLINE
date_int_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::day_number(const ymd_type& ymd)
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 = 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);
unsigned long d = ymd.day + ((153*m + 2)/5) + 365*y + (y/4) - (y/100) + (y/400) - 32045;
return d;
}
//! Convert a year-month-day into the julian day number
/*! Since this implementation uses julian day internally, this is the same as the day_number.
*/
template<typename ymd_type_, typename date_int_type_>
BOOST_CXX14_CONSTEXPR
inline
BOOST_DATE_TIME_INLINE
date_int_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::julian_day_number(const ymd_type& ymd)
gregorian_calendar_base<ymd_type_,date_int_type_>::julian_day_number(const ymd_type& ymd)
{
return day_number(ymd);
}
@@ -98,20 +98,18 @@ 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_CXX14_CONSTEXPR
inline
date_int_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::modjulian_day_number(const ymd_type& ymd)
BOOST_DATE_TIME_INLINE
long
gregorian_calendar_base<ymd_type_,date_int_type_>::modjulian_day_number(const ymd_type& ymd)
{
return julian_day_number(ymd)-2400001; //prerounded
}
//! Change a day number into a year-month-day
template<typename ymd_type_, typename date_int_type_>
BOOST_CXX14_CONSTEXPR
inline
BOOST_DATE_TIME_INLINE
ymd_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::from_day_number(date_int_type dayNumber)
gregorian_calendar_base<ymd_type_,date_int_type_>::from_day_number(date_int_type dayNumber)
{
date_int_type a = dayNumber + 32044;
date_int_type b = (4*a + 3)/146097;
@@ -123,16 +121,15 @@ namespace date_time {
unsigned short month = static_cast<unsigned short>(m + 3 - 12 * (m/10));
year_type year = static_cast<unsigned short>(100*b + d - 4800 + (m/10));
//std::cout << year << "-" << month << "-" << day << "\n";
return ymd_type(static_cast<unsigned short>(year),month,day);
}
//! Change a day number into a year-month-day
template<typename ymd_type_, typename date_int_type_>
BOOST_CXX14_CONSTEXPR
inline
BOOST_DATE_TIME_INLINE
ymd_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::from_julian_day_number(date_int_type dayNumber)
gregorian_calendar_base<ymd_type_,date_int_type_>::from_julian_day_number(date_int_type dayNumber)
{
date_int_type a = dayNumber + 32044;
date_int_type b = (4*a+3)/146097;
@@ -144,44 +141,41 @@ namespace date_time {
unsigned short month = static_cast<unsigned short>(m + 3 - 12 * (m/10));
year_type year = static_cast<year_type>(100*b + d - 4800 + (m/10));
//std::cout << year << "-" << month << "-" << day << "\n";
return ymd_type(year,month,day);
}
//! Change a modified julian day number into a year-month-day
template<typename ymd_type_, typename date_int_type_>
BOOST_CXX14_CONSTEXPR
inline
BOOST_DATE_TIME_INLINE
ymd_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::from_modjulian_day_number(date_int_type dayNumber) {
gregorian_calendar_base<ymd_type_,date_int_type_>::from_modjulian_day_number(long dayNumber) {
date_int_type jd = dayNumber + 2400001; //is 2400000.5 prerounded
return from_julian_day_number(jd);
}
//! Determine if the provided year is a leap year
/*!
*@return true if year is a leap year, false otherwise
*/
template<typename ymd_type_, typename date_int_type_>
BOOST_CXX14_CONSTEXPR
inline
BOOST_DATE_TIME_INLINE
bool
gregorian_calendar_base<ymd_type_,date_int_type_>::is_leap_year(year_type year)
gregorian_calendar_base<ymd_type_,date_int_type_>::is_leap_year(year_type year)
{
//divisible by 4, not if divisible by 100, but true if divisible by 400
return (!(year % 4)) && ((year % 100) || (!(year % 400)));
}
//! Calculate the last day of the month
/*! Find the day which is the end of the month given year and month
* No error checking is performed.
*/
template<typename ymd_type_, typename date_int_type_>
BOOST_CXX14_CONSTEXPR
inline
BOOST_DATE_TIME_INLINE
unsigned short
gregorian_calendar_base<ymd_type_,date_int_type_>::end_of_month_day(year_type year,
month_type month)
month_type month)
{
switch (month) {
case 2:
@@ -189,7 +183,7 @@ namespace date_time {
return 29;
} else {
return 28;
}
};
case 4:
case 6:
case 9:
@@ -197,28 +191,29 @@ namespace date_time {
return 30;
default:
return 31;
}
}
};
//! Provide the ymd_type specification for the calendar start
}
//! Provide the ymd_type specification for the calandar start
template<typename ymd_type_, typename date_int_type_>
BOOST_CXX14_CONSTEXPR
inline
BOOST_DATE_TIME_INLINE
ymd_type_
gregorian_calendar_base<ymd_type_,date_int_type_>::epoch()
gregorian_calendar_base<ymd_type_,date_int_type_>::epoch()
{
return ymd_type(1400,1,1);
}
//! Defines length of a week for week calculations
template<typename ymd_type_, typename date_int_type_>
BOOST_CXX14_CONSTEXPR
inline
BOOST_DATE_TIME_INLINE
unsigned short
gregorian_calendar_base<ymd_type_,date_int_type_>::days_in_week()
gregorian_calendar_base<ymd_type_,date_int_type_>::days_in_week()
{
return 7;
}
} } //namespace gregorian
+80 -89
View File
@@ -4,7 +4,7 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -14,15 +14,7 @@
#include "boost/limits.hpp" //work around compilers without limits
#include "boost/date_time/special_defs.hpp"
#include "boost/date_time/locale_config.hpp"
#ifndef BOOST_DATE_TIME_NO_LOCALE
# include <ostream>
#endif
#if defined(BOOST_MSVC)
#pragma warning(push)
// conditional expression is constant
#pragma warning(disable: 4127)
#endif
#include <iostream>
namespace boost {
namespace date_time {
@@ -46,34 +38,34 @@ template<typename int_type_>
class int_adapter {
public:
typedef int_type_ int_type;
BOOST_CXX14_CONSTEXPR int_adapter(int_type v) :
int_adapter(int_type v) :
value_(v)
{}
static BOOST_CONSTEXPR bool has_infinity()
static bool has_infinity()
{
return true;
}
static BOOST_CONSTEXPR int_adapter pos_infinity()
static const int_adapter pos_infinity()
{
return (::std::numeric_limits<int_type>::max)();
}
static BOOST_CONSTEXPR int_adapter neg_infinity()
static const int_adapter neg_infinity()
{
return (::std::numeric_limits<int_type>::min)();
}
static BOOST_CONSTEXPR int_adapter not_a_number()
static const int_adapter not_a_number()
{
return (::std::numeric_limits<int_type>::max)()-1;
}
static BOOST_CONSTEXPR int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION ()
static int_adapter max BOOST_PREVENT_MACRO_SUBSTITUTION ()
{
return (::std::numeric_limits<int_type>::max)()-2;
}
static BOOST_CONSTEXPR int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION ()
static int_adapter min BOOST_PREVENT_MACRO_SUBSTITUTION ()
{
return (::std::numeric_limits<int_type>::min)()+1;
}
static BOOST_CXX14_CONSTEXPR int_adapter from_special(special_values sv)
static int_adapter from_special(special_values sv)
{
switch (sv) {
case not_a_date_time: return not_a_number();
@@ -84,25 +76,25 @@ public:
default: return not_a_number();
}
}
static BOOST_CONSTEXPR bool is_inf(int_type v)
static bool is_inf(int_type v)
{
return (v == neg_infinity().as_number() ||
v == pos_infinity().as_number());
}
static BOOST_CXX14_CONSTEXPR bool is_neg_inf(int_type v)
static bool is_neg_inf(int_type v)
{
return (v == neg_infinity().as_number());
}
static BOOST_CXX14_CONSTEXPR bool is_pos_inf(int_type v)
static bool is_pos_inf(int_type v)
{
return (v == pos_infinity().as_number());
}
static BOOST_CXX14_CONSTEXPR bool is_not_a_number(int_type v)
static bool is_not_a_number(int_type v)
{
return (v == not_a_number().as_number());
}
//! Returns either special value type or is_not_special
static BOOST_CXX14_CONSTEXPR special_values to_special(int_type v)
static special_values to_special(int_type v)
{
if (is_not_a_number(v)) return not_a_date_time;
if (is_neg_inf(v)) return neg_infin;
@@ -111,38 +103,40 @@ public:
}
//-3 leaves room for representations of infinity and not a date
static BOOST_CONSTEXPR int_type maxcount()
static int_type maxcount()
{
return (::std::numeric_limits<int_type>::max)()-3;
}
BOOST_CONSTEXPR bool is_infinity() const
bool is_infinity() const
{
return (value_ == neg_infinity().as_number() ||
value_ == pos_infinity().as_number());
}
BOOST_CONSTEXPR bool is_pos_infinity()const
bool is_pos_infinity()const
{
return(value_ == pos_infinity().as_number());
}
BOOST_CONSTEXPR bool is_neg_infinity()const
bool is_neg_infinity()const
{
return(value_ == neg_infinity().as_number());
}
BOOST_CONSTEXPR bool is_nan() const
bool is_nan() const
{
return (value_ == not_a_number().as_number());
}
BOOST_CONSTEXPR bool is_special() const
bool is_special() const
{
return(is_infinity() || is_nan());
}
BOOST_CONSTEXPR bool operator==(const int_adapter& rhs) const
bool operator==(const int_adapter& rhs) const
{
return (compare(rhs) == 0);
}
BOOST_CXX14_CONSTEXPR bool operator==(const int& rhs) const
bool operator==(const int& rhs) const
{
if(!std::numeric_limits<int_type>::is_signed)
// quiets compiler warnings
bool is_signed = std::numeric_limits<int_type>::is_signed;
if(!is_signed)
{
if(is_neg_inf(value_) && rhs == 0)
{
@@ -151,29 +145,32 @@ public:
}
return (compare(rhs) == 0);
}
BOOST_CONSTEXPR bool operator!=(const int_adapter& rhs) const
bool operator!=(const int_adapter& rhs) const
{
return (compare(rhs) != 0);
}
BOOST_CXX14_CONSTEXPR bool operator!=(const int& rhs) const
{
if(!std::numeric_limits<int_type>::is_signed)
{
if(is_neg_inf(value_) && rhs == 0)
{
return true;
}
}
return (compare(rhs) != 0);
}
BOOST_CONSTEXPR bool operator<(const int_adapter& rhs) const
{
return (compare(rhs) == -1);
}
BOOST_CXX14_CONSTEXPR bool operator<(const int& rhs) const
bool operator!=(const int& rhs) const
{
// quiets compiler warnings
if(!std::numeric_limits<int_type>::is_signed)
bool is_signed = std::numeric_limits<int_type>::is_signed;
if(!is_signed)
{
if(is_neg_inf(value_) && rhs == 0)
{
return true;
}
}
return (compare(rhs) != 0);
}
bool operator<(const int_adapter& rhs) const
{
return (compare(rhs) == -1);
}
bool operator<(const int& rhs) const
{
// quiets compiler warnings
bool is_signed = std::numeric_limits<int_type>::is_signed;
if(!is_signed)
{
if(is_neg_inf(value_) && rhs == 0)
{
@@ -182,16 +179,16 @@ public:
}
return (compare(rhs) == -1);
}
BOOST_CONSTEXPR bool operator>(const int_adapter& rhs) const
bool operator>(const int_adapter& rhs) const
{
return (compare(rhs) == 1);
}
BOOST_CONSTEXPR int_type as_number() const
int_type as_number() const
{
return value_;
}
//! Returns either special value type or is_not_special
BOOST_CONSTEXPR special_values as_special() const
special_values as_special() const
{
return int_adapter::to_special(value_);
}
@@ -204,7 +201,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>
BOOST_CXX14_CONSTEXPR
inline
int_adapter operator+(const int_adapter<rhs_type>& rhs) const
{
if(is_special() || rhs.is_special())
@@ -231,10 +228,9 @@ public:
return int_adapter::neg_infinity();
}
}
return int_adapter<int_type>(value_ + static_cast<int_type>(rhs.as_number()));
return int_adapter<int_type>(value_ + rhs.as_number());
}
BOOST_CXX14_CONSTEXPR
int_adapter operator+(const int_type rhs) const
{
if(is_special())
@@ -254,7 +250,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>
BOOST_CXX14_CONSTEXPR
inline
int_adapter operator-(const int_adapter<rhs_type>& rhs)const
{
if(is_special() || rhs.is_special())
@@ -281,10 +277,8 @@ public:
return int_adapter::pos_infinity();
}
}
return int_adapter<int_type>(value_ - static_cast<int_type>(rhs.as_number()));
return int_adapter<int_type>(value_ - rhs.as_number());
}
BOOST_CXX14_CONSTEXPR
int_adapter operator-(const int_type rhs) const
{
if(is_special())
@@ -302,7 +296,6 @@ 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())
@@ -311,10 +304,8 @@ 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())
@@ -325,7 +316,6 @@ 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())
@@ -339,27 +329,23 @@ public:
return mult_div_specials(rhs);
}
else { // let divide by zero blow itself up
return int_adapter<int_type>(value_ / rhs.value_); //NOLINT
return int_adapter<int_type>(value_ / rhs.value_);
}
}
return int_adapter<int_type>(value_ / rhs.value_);
}
/*! Provided for cases when automatic conversion from
* 'int' to 'int_adapter' causes incorrect results. */
BOOST_CXX14_CONSTEXPR
int_adapter operator/(const int rhs) const
{
if(is_special() && rhs != 0)
{
return mult_div_specials(rhs);
}
// let divide by zero blow itself up like int
return int_adapter<int_type>(value_ / rhs); //NOLINT
return int_adapter<int_type>(value_ / rhs);
}
// 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())
@@ -373,31 +359,26 @@ public:
return mult_div_specials(rhs);
}
else { // let divide by zero blow itself up
return int_adapter<int_type>(value_ % rhs.value_); //NOLINT
return int_adapter<int_type>(value_ % rhs.value_);
}
}
return int_adapter<int_type>(value_ % rhs.value_);
}
/*! Provided for cases when automatic conversion from
* 'int' to 'int_adapter' causes incorrect results. */
BOOST_CXX14_CONSTEXPR
int_adapter operator%(const int rhs) const
{
if(is_special() && rhs != 0)
{
return mult_div_specials(rhs);
}
// let divide by zero blow itself up
return int_adapter<int_type>(value_ % rhs); //NOLINT
return int_adapter<int_type>(value_ % rhs);
}
private:
int_type value_;
//! returns -1, 0, 1, or 2 if 'this' is <, ==, >, or 'nan comparison' rhs
BOOST_CXX14_CONSTEXPR
int compare( const int_adapter& rhs ) const
int compare(const int_adapter& rhs)const
{
if(this->is_special() || rhs.is_special())
{
@@ -424,19 +405,25 @@ 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
BOOST_CXX14_CONSTEXPR
int_adapter mult_div_specials(const int_adapter& rhs) const
int_adapter mult_div_specials(const int_adapter& rhs)const
{
int min_value;
// quiets compiler warnings
bool is_signed = std::numeric_limits<int_type>::is_signed;
if(is_signed) {
min_value = 0;
}
else {
min_value = 1;// there is no zero with unsigned
}
if(this->is_nan() || rhs.is_nan()) {
return int_adapter<int_type>(not_a_number());
}
BOOST_CONSTEXPR_OR_CONST int min_value = std::numeric_limits<int_type>::is_signed ? 0 : 1;
if((*this > 0 && rhs > 0) || (*this < min_value && rhs < min_value)) {
return int_adapter<int_type>(pos_infinity());
}
@@ -446,20 +433,26 @@ 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
{
int min_value;
// quiets compiler warnings
bool is_signed = std::numeric_limits<int_type>::is_signed;
if(is_signed) {
min_value = 0;
}
else {
min_value = 1;// there is no zero with unsigned
}
if(this->is_nan()) {
return int_adapter<int_type>(not_a_number());
}
BOOST_CONSTEXPR_OR_CONST int min_value = std::numeric_limits<int_type>::is_signed ? 0 : 1;
if((*this > 0 && rhs > 0) || (*this < min_value && rhs < 0)) {
return int_adapter<int_type>(pos_infinity());
}
@@ -469,7 +462,7 @@ private:
//implied -> if(this->value_ == 0 || rhs.value_ == 0)
return int_adapter<int_type>(not_a_number());
}
};
#ifndef BOOST_DATE_TIME_NO_LOCALE
@@ -509,8 +502,6 @@ private:
} } //namespace date_time
#if defined(BOOST_MSVC)
#pragma warning(pop)
#endif
#endif
+14 -14
View File
@@ -4,7 +4,7 @@
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
* Use, modification and distribution is subject to the
* Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -14,11 +14,11 @@
namespace boost {
namespace date_time {
//! Class to provide common ISO 8601 formatting spec
//! Class to provide common iso formatting spec
template<class charT>
class iso_format_base {
public:
//! Describe month format -- its an integer in ISO 8601 format
//! Describe month format -- its an integer in iso format
static month_format_spec month_format()
{
return month_as_integer;
@@ -40,17 +40,17 @@ public:
return "-infinity";
}
//! ISO 8601 char for a year -- used in durations
//! ISO char for a year -- used in durations
static charT year_sep_char()
{
return 'Y';
}
//! ISO 8601 char for a month
//! ISO char for a month
static charT month_sep_char()
{
return '-';
}
//! ISO 8601 char for a day
//! ISO char for a day
static charT day_sep_char()
{
return '-';
@@ -70,7 +70,7 @@ public:
{
return ':';
}
//! ISO 8601 char for a period
//! ISO 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 8601 formatting spec
//! Class to provide common iso formatting spec
template<>
class iso_format_base<wchar_t> {
public:
//! Describe month format -- its an integer in ISO 8601 format
//! Describe month format -- its an integer in iso format
static month_format_spec month_format()
{
return month_as_integer;
@@ -169,17 +169,17 @@ public:
return L"-infinity";
}
//! ISO 8601 char for a year -- used in durations
//! ISO char for a year -- used in durations
static wchar_t year_sep_char()
{
return 'Y';
}
//! ISO 8601 char for a month
//! ISO char for a month
static wchar_t month_sep_char()
{
return '-';
}
//! ISO 8601 char for a day
//! ISO char for a day
static wchar_t day_sep_char()
{
return '-';
@@ -199,7 +199,7 @@ public:
{
return ':';
}
//! ISO 8601 char for a period
//! ISO 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 8601 normal YYYYMMDD
//! Format description for iso normal YYYYMMDD
template<class charT>
class iso_format : public iso_format_base<charT> {
public:
@@ -3,7 +3,7 @@
/* Copyright (c) 2003-2004 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -18,8 +18,9 @@ namespace local_time {
//! Function that creates a tm struct from a local_date_time
inline
std::tm to_tm(const local_date_time& lt) {
std::tm lt_tm = posix_time::to_tm(lt.local_time());
tm to_tm(const local_date_time& lt) {
tm lt_tm;
lt_tm = posix_time::to_tm(lt.local_time());
if(lt.is_dst()){
lt_tm.tm_isdst = 1;
}
@@ -1,168 +0,0 @@
#ifndef LOCAL_TIME_CUSTOM_TIME_ZONE_HPP__
#define LOCAL_TIME_CUSTOM_TIME_ZONE_HPP__
/* Copyright (c) 2003-2005 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include "boost/date_time/time_zone_base.hpp"
#include "boost/date_time/time_zone_names.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/local_time/dst_transition_day_rules.hpp"
#include "boost/date_time/string_convert.hpp"
//#include "boost/date_time/special_defs.hpp"
#include "boost/shared_ptr.hpp"
namespace boost {
namespace local_time {
//typedef boost::date_time::time_zone_names time_zone_names;
typedef boost::date_time::dst_adjustment_offsets<boost::posix_time::time_duration> dst_adjustment_offsets;
//typedef boost::date_time::time_zone_base<boost::posix_time::ptime> time_zone;
typedef boost::shared_ptr<dst_calc_rule> dst_calc_rule_ptr;
//! A real time zone
template<class CharT>
class custom_time_zone_base : public date_time::time_zone_base<posix_time::ptime,CharT> {
public:
typedef boost::posix_time::time_duration time_duration_type;
typedef date_time::time_zone_base<posix_time::ptime,CharT> base_type;
typedef typename base_type::string_type string_type;
typedef typename base_type::stringstream_type stringstream_type;
typedef date_time::time_zone_names_base<CharT> time_zone_names;
typedef CharT char_type;
custom_time_zone_base(const time_zone_names& zone_names,
const time_duration_type& utc_offset,
const dst_adjustment_offsets& dst_shift,
boost::shared_ptr<dst_calc_rule> calc_rule) :
zone_names_(zone_names),
base_utc_offset_(utc_offset),
dst_offsets_(dst_shift),
dst_calc_rules_(calc_rule)
{}
virtual ~custom_time_zone_base() {}
virtual string_type dst_zone_abbrev() const
{
return zone_names_.dst_zone_abbrev();
}
virtual string_type std_zone_abbrev() const
{
return zone_names_.std_zone_abbrev();
}
virtual string_type dst_zone_name() const
{
return zone_names_.dst_zone_name();
}
virtual string_type std_zone_name() const
{
return zone_names_.std_zone_name();
}
//! True if zone uses daylight savings adjustments
virtual bool has_dst() const
{
return (bool) dst_calc_rules_; //if calc_rule is set the tz has dst
}
//! Local time that DST starts -- NADT if has_dst is false
virtual posix_time::ptime dst_local_start_time(gregorian::greg_year y) const
{
gregorian::date d(gregorian::not_a_date_time);
if (dst_calc_rules_) {
d = dst_calc_rules_->start_day(y);
}
return posix_time::ptime(d, dst_offsets_.dst_start_offset_);
}
//! Local time that DST ends -- NADT if has_dst is false
virtual posix_time::ptime dst_local_end_time(gregorian::greg_year y) const
{
gregorian::date d(gregorian::not_a_date_time);
if (dst_calc_rules_) {
d = dst_calc_rules_->end_day(y);
}
return posix_time::ptime(d, dst_offsets_.dst_end_offset_);
}
//! Base offset from UTC for zone (eg: -07:30:00)
virtual time_duration_type base_utc_offset() const
{
return base_utc_offset_;
}
//! Adjustment forward or back made while DST is in effect
virtual time_duration_type dst_offset() const
{
return dst_offsets_.dst_adjust_;
}
//! Returns a POSIX time_zone string for this object
virtual string_type to_posix_string() const
{
// std offset dst [offset],start[/time],end[/time] - w/o spaces
stringstream_type ss;
ss.fill('0');
boost::shared_ptr<dst_calc_rule> no_rules;
// std
ss << std_zone_abbrev();
// offset
if(base_utc_offset().is_negative()) {
// inverting the sign guarantees we get two digits
ss << '-' << std::setw(2) << base_utc_offset().invert_sign().hours();
}
else {
ss << '+' << std::setw(2) << base_utc_offset().hours();
}
if(base_utc_offset().minutes() != 0 || base_utc_offset().seconds() != 0) {
ss << ':' << std::setw(2) << base_utc_offset().minutes();
if(base_utc_offset().seconds() != 0) {
ss << ':' << std::setw(2) << base_utc_offset().seconds();
}
}
if(dst_calc_rules_ != no_rules) {
// dst
ss << dst_zone_abbrev();
// dst offset
if(dst_offset().is_negative()) {
// inverting the sign guarantees we get two digits
ss << '-' << std::setw(2) << dst_offset().invert_sign().hours();
}
else {
ss << '+' << std::setw(2) << dst_offset().hours();
}
if(dst_offset().minutes() != 0 || dst_offset().seconds() != 0) {
ss << ':' << std::setw(2) << dst_offset().minutes();
if(dst_offset().seconds() != 0) {
ss << ':' << std::setw(2) << dst_offset().seconds();
}
}
// start/time
ss << ',' << date_time::convert_string_type<char, char_type>(dst_calc_rules_->start_rule_as_string()) << '/'
<< std::setw(2) << dst_offsets_.dst_start_offset_.hours() << ':'
<< std::setw(2) << dst_offsets_.dst_start_offset_.minutes();
if(dst_offsets_.dst_start_offset_.seconds() != 0) {
ss << ':' << std::setw(2) << dst_offsets_.dst_start_offset_.seconds();
}
// end/time
ss << ',' << date_time::convert_string_type<char, char_type>(dst_calc_rules_->end_rule_as_string()) << '/'
<< std::setw(2) << dst_offsets_.dst_end_offset_.hours() << ':'
<< std::setw(2) << dst_offsets_.dst_end_offset_.minutes();
if(dst_offsets_.dst_end_offset_.seconds() != 0) {
ss << ':' << std::setw(2) << dst_offsets_.dst_end_offset_.seconds();
}
}
return ss.str();
}
private:
time_zone_names zone_names_;
time_duration_type base_utc_offset_;
dst_adjustment_offsets dst_offsets_;
boost::shared_ptr<dst_calc_rule> dst_calc_rules_;
};
typedef custom_time_zone_base<char> custom_time_zone;
} }//namespace
#endif
@@ -1,115 +0,0 @@
#ifndef LOCAL_TIME_DATE_DURATION_OPERATORS_HPP___
#define LOCAL_TIME_DATE_DURATION_OPERATORS_HPP___
/* Copyright (c) 2004 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or
* http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include "boost/date_time/gregorian/greg_duration_types.hpp"
#include "boost/date_time/local_time/local_date_time.hpp"
namespace boost {
namespace local_time {
/*!@file date_duration_operators.hpp Operators for local_date_time and
* optional gregorian types. Operators use snap-to-end-of-month behavior.
* Further details on this behavior can be found in reference for
* date_time/date_duration_types.hpp and documentation for
* month and year iterators.
*/
/*! Adds a months object and a local_date_time. Result will be same
* day-of-month as local_date_time unless original day was the last day of month.
* see date_time::months_duration for more details */
inline
local_date_time
operator+(const local_date_time& t, const boost::gregorian::months& m)
{
return t + m.get_offset(t.utc_time().date());
}
/*! Adds a months object to a local_date_time. Result will be same
* day-of-month as local_date_time unless original day was the last day of month.
* see date_time::months_duration for more details */
inline
local_date_time
operator+=(local_date_time& t, const boost::gregorian::months& m)
{
return t += m.get_offset(t.utc_time().date());
}
/*! Subtracts a months object and a local_date_time. Result will be same
* day-of-month as local_date_time unless original day was the last day of month.
* see date_time::months_duration for more details */
inline
local_date_time
operator-(const local_date_time& t, const boost::gregorian::months& m)
{
// get_neg_offset returns a negative duration, so we add
return t + m.get_neg_offset(t.utc_time().date());
}
/*! Subtracts a months object from a local_date_time. Result will be same
* day-of-month as local_date_time unless original day was the last day of month.
* see date_time::months_duration for more details */
inline
local_date_time
operator-=(local_date_time& t, const boost::gregorian::months& m)
{
// get_neg_offset returns a negative duration, so we add
return t += m.get_neg_offset(t.utc_time().date());
}
// local_date_time & years
/*! Adds a years object and a local_date_time. Result will be same
* month and day-of-month as local_date_time unless original day was the
* last day of month. see date_time::years_duration for more details */
inline
local_date_time
operator+(const local_date_time& t, const boost::gregorian::years& y)
{
return t + y.get_offset(t.utc_time().date());
}
/*! Adds a years object to a local_date_time. Result will be same
* month and day-of-month as local_date_time unless original day was the
* last day of month. see date_time::years_duration for more details */
inline
local_date_time
operator+=(local_date_time& t, const boost::gregorian::years& y)
{
return t += y.get_offset(t.utc_time().date());
}
/*! Subtracts a years object and a local_date_time. Result will be same
* month and day-of-month as local_date_time unless original day was the
* last day of month. see date_time::years_duration for more details */
inline
local_date_time
operator-(const local_date_time& t, const boost::gregorian::years& y)
{
// get_neg_offset returns a negative duration, so we add
return t + y.get_neg_offset(t.utc_time().date());
}
/*! Subtracts a years object from a local_date_time. Result will be same
* month and day-of-month as local_date_time unless original day was the
* last day of month. see date_time::years_duration for more details */
inline
local_date_time
operator-=(local_date_time& t, const boost::gregorian::years& y)
{
// get_neg_offset returns a negative duration, so we add
return t += y.get_neg_offset(t.utc_time().date());
}
}} // namespaces
#endif // LOCAL_TIME_DATE_DURATION_OPERATORS_HPP___
@@ -3,7 +3,7 @@
/* Copyright (c) 2003-2004 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -35,7 +35,7 @@ namespace local_time {
typedef gregorian::last_kday_of_month end_rule;
};
//! Provides rule of the form first Sunday in April, last Saturday in Oct
//! Provides rule of the form last Sunday in April, last Saturday in Oct
typedef date_time::day_calc_dst_rule<first_last_rule_spec> first_last_dst_rule;
struct last_last_rule_spec
@@ -45,7 +45,6 @@ namespace local_time {
typedef gregorian::last_kday_of_month end_rule;
};
//! Provides rule of the form last Sunday in April, last Saturday in Oct
typedef date_time::day_calc_dst_rule<last_last_rule_spec> last_last_dst_rule;
struct nth_last_rule_spec
@@ -67,8 +66,6 @@ namespace local_time {
//! Provides rule in form of [1st|2nd|3rd|4th] Sunday in April/October
typedef date_time::day_calc_dst_rule<nth_kday_rule_spec> nth_kday_dst_rule;
//! Provides rule in form of [1st|2nd|3rd|4th] Sunday in April/October
typedef date_time::day_calc_dst_rule<nth_kday_rule_spec> nth_day_of_the_week_in_month_dst_rule;
} }//namespace
@@ -1,112 +1,98 @@
#ifndef LOCAL_TIME_LOCAL_DATE_TIME_HPP__
#define LOCAL_TIME_LOCAL_DATE_TIME_HPP__
/* Copyright (c) 2003-2005 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
/* Copyright (c) 2003-2004 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <string>
#include <iomanip>
#include "boost/date_time/time.hpp"
#include "boost/date_time/posix_time/posix_time.hpp" //todo remove?
#include "boost/shared_ptr.hpp"
#include "boost/date_time/dst_rules.hpp"
#include "boost/date_time/time_zone_base.hpp"
#include "boost/date_time/special_defs.hpp"
#include <sstream>
#include <stdexcept>
#include <boost/shared_ptr.hpp>
#include <boost/throw_exception.hpp>
#include <boost/date_time/time.hpp>
#include <boost/date_time/posix_time/posix_time.hpp> //todo remove?
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/dst_rules.hpp>
#include <boost/date_time/time_zone_base.hpp>
#include <boost/date_time/special_defs.hpp>
#include <boost/date_time/time_resolution_traits.hpp> // absolute_value
namespace boost {
namespace local_time {
//! simple exception for reporting when STD or DST cannot be determined
struct BOOST_SYMBOL_VISIBLE ambiguous_result : public std::logic_error
struct ambiguous_result : public std::logic_error
{
ambiguous_result (std::string const& msg = std::string()) :
std::logic_error(std::string("Daylight Savings Results are ambiguous: " + msg)) {}
ambiguous_result (std::string _msg="") :
std::logic_error(std::string("Daylight Savings Results are ambiguous: " + _msg)) {}
};
//! simple exception for when time label given cannot exist
struct BOOST_SYMBOL_VISIBLE time_label_invalid : public std::logic_error
//
struct InvalidTimeLabel : public std::logic_error
{
time_label_invalid (std::string const& msg = std::string()) :
std::logic_error(std::string("Time label given is invalid: " + msg)) {}
InvalidTimeLabel(std::string _msg="") :
std::logic_error(std::string("Time label given is invalid: " + _msg)) {}
};
struct BOOST_SYMBOL_VISIBLE dst_not_valid: public std::logic_error
struct DSTNotValid: public std::logic_error
{
dst_not_valid(std::string const& msg = std::string()) :
std::logic_error(std::string("is_dst flag does not match resulting dst for time label given: " + msg)) {}
DSTNotValid(std::string _msg="") :
std::logic_error(std::string("is_dst flag does not match resulting dst for time label given: " + _msg)) {}
};
//TODO: I think these should be in local_date_time_base and not
//TODO: I think these should be in local_date_time_base and not
// necessarily brought into the namespace
using date_time::time_is_dst_result;
using date_time::is_in_dst;
using date_time::is_not_in_dst;
using date_time::ambiguous;
using date_time::invalid_time_label;
//! Representation of "wall-clock" time in a particular time zone
/*! Representation of "wall-clock" time in a particular time zone
* Local_date_time_base holds a time value (date and time offset from 00:00)
* along with a time zone. The time value is stored as UTC and conversions
* to wall clock time are made as needed. This approach allows for
* operations between wall-clock times in different time zones, and
* daylight savings time considerations, to be made. Time zones are
* required to be in the form of a boost::shared_ptr<time_zone_base>.
*/
template<class utc_time_=posix_time::ptime,
class tz_type=date_time::time_zone_base<utc_time_,char> >
class BOOST_SYMBOL_VISIBLE local_date_time_base : public date_time::base_time<utc_time_,
boost::posix_time::posix_time_system> {
template<class utc_time_=posix_time::ptime,
class tz_type=date_time::time_zone_base<typename posix_time::ptime> >
class local_date_time_base : public date_time::base_time<boost::posix_time::ptime,
boost::posix_time::posix_time_system> {
public:
typedef utc_time_ utc_time_type;
typedef typename utc_time_type::time_duration_type time_duration_type;
typedef typename utc_time_type::date_type date_type;
typedef typename date_type::duration_type date_duration_type;
typedef typename utc_time_type::time_system_type time_system_type;
/*! This constructor interprets the passed time as a UTC time.
/** This constructor interprets the passed time as a UTC time.
* So, for example, if the passed timezone is UTC-5 then the
* time will be adjusted back 5 hours. The time zone allows for
* time will be adjusted back 5 hours. The time zone allows for
* automatic calculation of whether the particular time is adjusted for
* daylight savings, etc.
* If the time zone shared pointer is null then time stays unadjusted.
*@param t A UTC time
*@param tz Timezone for to adjust the UTC time to.
*/
local_date_time_base(utc_time_type t,
boost::shared_ptr<tz_type> tz) :
local_date_time_base(utc_time_type t,
boost::shared_ptr<tz_type> tz) :
date_time::base_time<utc_time_type, time_system_type>(t),
zone_(tz)
{
// param was already utc so nothing more to do
}
}
/*! This constructs a local time -- the passed time information
* understood to be in the passed tz. The DST flag must be passed
* to indicate whether the time is in daylight savings or not.
* @throws -- time_label_invalid if the time passed does not exist in
* the given locale. The non-existent case occurs typically
* during the shift-back from daylight savings time. When
* the clock is shifted forward a range of times
/** This constructs a local time -- the passed time information
* understood to be in the passed tz. The DST flag must be passed
* to indicate whether the time is in daylight savings or not.
* @throws -- InvalidTimeLabel if the time passed does not exist in
* the given locale. The non-existant case occurs typically
* during the shift-back from daylight savings time. When
* the clock is shifted forward a range of times
* (2 am to 3 am in the US) is skipped and hence is invalid.
* @throws -- dst_not_valid if the DST flag is passed for a period
* @throws -- DSTNotValid if the DST flag is passed for a period
* where DST is not active.
*/
local_date_time_base(date_type d,
local_date_time_base(date_type d,
time_duration_type td,
boost::shared_ptr<tz_type> tz,
boost::shared_ptr<tz_type> tz,
bool dst_flag) : //necessary for constr_adj()
date_time::base_time<utc_time_type,time_system_type>(construction_adjustment(utc_time_type(d, td), tz, dst_flag)),
zone_(tz)
{
if(tz != boost::shared_ptr<tz_type>() && tz->has_dst()){
if(tz != NULL && tz->has_dst()){
// d & td are already local so we use them
time_is_dst_result result = check_dst(d, td, tz);
bool in_dst = (result == is_in_dst); // less processing than is_dst()
@@ -114,35 +100,35 @@ namespace local_time {
// ambig occurs at end, invalid at start
if(result == invalid_time_label){
// Ex: 2:15am local on trans-in day in nyc, dst_flag irrelevant
std::ostringstream ss;
std:: stringstream ss;
ss << "time given: " << d << ' ' << td;
boost::throw_exception(time_label_invalid(ss.str()));
throw InvalidTimeLabel(ss.str());
}
else if(result != ambiguous && in_dst != dst_flag){
// is dst_flag accurate?
// Ex: false flag in NYC in June
std::ostringstream ss;
ss.setf(std::ios_base::boolalpha);
ss << "flag given: dst=" << dst_flag << ", dst calculated: dst=" << in_dst;
boost::throw_exception(dst_not_valid(ss.str()));
std:: stringstream ss;
ss << "flag given: " << (dst_flag ? "dst=true" : "dst=false")
<< ", dst calculated: " << (in_dst ? "dst=true" : "dst=false");
throw DSTNotValid(ss.str());
}
// everything checks out and conversion to utc already done
}
}
}
//TODO maybe not the right set...Ignore the last 2 for now...
enum DST_CALC_OPTIONS { EXCEPTION_ON_ERROR, NOT_DATE_TIME_ON_ERROR };
enum DST_CALC_OPTIONS { EXCEPTION_ON_ERROR, NOT_DATE_TIME_ON_ERROR };
//ASSUME_DST_ON_ERROR, ASSUME_NOT_DST_ON_ERROR };
/*! This constructs a local time -- the passed time information
* understood to be in the passed tz. The DST flag is calculated
* according to the specified rule.
/** This constructs a local time -- the passed time information
* understood to be in the passed tz. The DST flag is calculated
* according to the specified rule.
*/
local_date_time_base(date_type d,
local_date_time_base(date_type d,
time_duration_type td,
boost::shared_ptr<tz_type> tz,
DST_CALC_OPTIONS calc_option) :
boost::shared_ptr<tz_type> tz,
DST_CALC_OPTIONS calc_option) :
// dummy value - time_ is set in constructor code
date_time::base_time<utc_time_type,time_system_type>(utc_time_type(d,td)),
zone_(tz)
@@ -150,55 +136,54 @@ namespace local_time {
time_is_dst_result result = check_dst(d, td, tz);
if(result == ambiguous) {
if(calc_option == EXCEPTION_ON_ERROR){
std::ostringstream ss;
std:: stringstream ss;
ss << "time given: " << d << ' ' << td;
boost::throw_exception(ambiguous_result(ss.str()));
throw ambiguous_result(ss.str());
}
else{ // NADT on error
this->time_ = posix_time::posix_time_system::get_time_rep(date_type(date_time::not_a_date_time), time_duration_type(date_time::not_a_date_time));
time_ = posix_time::posix_time_system::get_time_rep(date_type(date_time::not_a_date_time), time_duration_type(date_time::not_a_date_time));
}
}
else if(result == invalid_time_label){
if(calc_option == EXCEPTION_ON_ERROR){
std::ostringstream ss;
std:: stringstream ss;
ss << "time given: " << d << ' ' << td;
boost::throw_exception(time_label_invalid(ss.str()));
throw InvalidTimeLabel(ss.str());
}
else{ // NADT on error
this->time_ = posix_time::posix_time_system::get_time_rep(date_type(date_time::not_a_date_time), time_duration_type(date_time::not_a_date_time));
time_ = posix_time::posix_time_system::get_time_rep(date_type(date_time::not_a_date_time), time_duration_type(date_time::not_a_date_time));
}
}
else if(result == is_in_dst){
utc_time_type t =
utc_time_type t =
construction_adjustment(utc_time_type(d, td), tz, true);
this->time_ = posix_time::posix_time_system::get_time_rep(t.date(),
time_ = posix_time::posix_time_system::get_time_rep(t.date(),
t.time_of_day());
}
else{
utc_time_type t =
utc_time_type t =
construction_adjustment(utc_time_type(d, td), tz, false);
this->time_ = posix_time::posix_time_system::get_time_rep(t.date(),
time_ = posix_time::posix_time_system::get_time_rep(t.date(),
t.time_of_day());
}
}
//! Determines if given time label is in daylight savings for given zone
/*! Determines if given time label is in daylight savings for given zone.
* Takes a date and time_duration representing a local time, along
* with time zone, and returns a time_is_dst_result object as result.
//! takes a date and time_duration representing a local time
/*!
* returns TODO: ...
*/
static time_is_dst_result check_dst(date_type d,
static time_is_dst_result check_dst(date_type d,
time_duration_type td,
boost::shared_ptr<tz_type> tz)
boost::shared_ptr<tz_type> tz)
{
if(tz != boost::shared_ptr<tz_type>() && tz->has_dst()) {
if(tz != NULL && tz->has_dst()) {
typedef typename date_time::dst_calculator<date_type, time_duration_type> dst_calculator;
return dst_calculator::local_is_dst(
d, td,
tz->dst_local_start_time(d.year()).date(),
tz->dst_local_start_time(d.year()).time_of_day(),
tz->dst_local_end_time(d.year()).date(),
d, td,
tz->dst_local_start_time(d.year()).date(),
tz->dst_local_start_time(d.year()).time_of_day(),
tz->dst_local_end_time(d.year()).date(),
tz->dst_local_end_time(d.year()).time_of_day(),
tz->dst_offset()
);
@@ -208,11 +193,11 @@ namespace local_time {
}
}
//! Simple destructor, releases time zone if last referrer
~local_date_time_base() {}
//! Simple destructor, releases time zone if last referer
~local_date_time_base() {};
//! Copy constructor
local_date_time_base(const local_date_time_base& rhs) :
local_date_time_base(const local_date_time_base& rhs) :
date_time::base_time<utc_time_type, time_system_type>(rhs),
zone_(rhs.zone_)
{}
@@ -224,17 +209,16 @@ namespace local_time {
zone_(tz)
{}
//! returns time zone associated with calling instance
boost::shared_ptr<tz_type> zone() const
boost::shared_ptr<tz_type> zone() const
{
return zone_;
}
//! returns false is time_zone is NULL and if time value is a special_value
bool is_dst() const
{
if(zone_ != boost::shared_ptr<tz_type>() && zone_->has_dst() && !this->is_special()) {
if(zone_ != NULL && zone_->has_dst() && !is_special()) {
// check_dst takes a local time, *this is utc
utc_time_type lt(this->time_);
utc_time_type lt(time_);
lt += zone_->base_utc_offset();
// dst_offset only needs to be considered with ambiguous time labels
// make that adjustment there
@@ -242,14 +226,16 @@ namespace local_time {
switch(check_dst(lt.date(), lt.time_of_day(), zone_)){
case is_not_in_dst:
return false;
break;
case is_in_dst:
return true;
case ambiguous:
break;
case ambiguous:
if(lt + zone_->dst_offset() < zone_->dst_local_end_time(lt.date().year())) {
return true;
}
break;
case invalid_time_label:
case invalid_time_label:
if(lt >= zone_->dst_local_start_time(lt.date().year())) {
return true;
}
@@ -259,35 +245,34 @@ namespace local_time {
return false;
}
//! Returns object's time value as a utc representation
utc_time_type utc_time() const
utc_time_type utc_time() const
{
return utc_time_type(this->time_);
return utc_time_type(time_);
}
//! Returns object's time value as a local representation
utc_time_type local_time() const
utc_time_type local_time() const
{
if(zone_ != boost::shared_ptr<tz_type>()){
if(zone_ != NULL){
utc_time_type lt = this->utc_time() + zone_->base_utc_offset();
if (is_dst()) {
lt += zone_->dst_offset();
}
return lt;
}
return utc_time_type(this->time_);
return utc_time_type(time_);
}
//! Returns string in the form "2003-Aug-20 05:00:00 EDT"
/*! Returns string in the form "2003-Aug-20 05:00:00 EDT". If
* time_zone is NULL the time zone abbreviation will be "UTC". The time
* time_zone is NULL the time zone abbreviation will be "UTC". The time
* zone abbrev will not be included if calling object is a special_value*/
std::string to_string() const
{
//TODO is this a temporary function ???
std::ostringstream ss;
if(this->is_special()){
std::stringstream ss;
if(is_special()){
ss << utc_time();
return ss.str();
}
if(zone_ == boost::shared_ptr<tz_type>()) {
if(zone_ == NULL) {
ss << utc_time() << " UTC";
return ss.str();
}
@@ -296,6 +281,10 @@ namespace local_time {
if (is_dst_) {
lt += zone_->dst_offset();
}
if(zone_ == NULL) {
ss << utc_time() << " UTC";
return ss.str();
}
ss << local_time() << " ";
if (is_dst()) {
ss << zone_->dst_zone_abbrev();
@@ -305,92 +294,15 @@ namespace local_time {
}
return ss.str();
}
/*! returns a local_date_time_base in the given time zone with the
/*! returns a local_date_time_base in the given time zone with the
* optional time_duration added. */
local_date_time_base local_time_in(boost::shared_ptr<tz_type> new_tz,
time_duration_type td=time_duration_type(0,0,0)) const
local_date_time_base local_time_in(boost::shared_ptr<tz_type> new_tz,
time_duration_type td=time_duration_type(0,0,0)) const
{
return local_date_time_base(utc_time_type(this->time_) + td, new_tz);
return local_date_time_base(utc_time_type(time_) + td, new_tz);
}
//! Returns name of associated time zone or "Coordinated Universal Time".
/*! Optional bool parameter will return time zone as an offset
* (ie "+07:00" extended ISO 8601 format). Empty string is returned for
* classes that do not use a time_zone */
std::string zone_name(bool as_offset=false) const
{
if(zone_ == boost::shared_ptr<tz_type>()) {
if(as_offset) {
return std::string("Z");
}
else {
return std::string("Coordinated Universal Time");
}
}
if (is_dst()) {
if(as_offset) {
time_duration_type td = zone_->base_utc_offset();
td += zone_->dst_offset();
return zone_as_offset(td, ":");
}
else {
return zone_->dst_zone_name();
}
}
else {
if(as_offset) {
time_duration_type td = zone_->base_utc_offset();
return zone_as_offset(td, ":");
}
else {
return zone_->std_zone_name();
}
}
}
//! Returns abbreviation of associated time zone or "UTC".
/*! Optional bool parameter will return time zone as an offset
* (ie "+0700" ISO 8601 format). Empty string is returned for classes
* that do not use a time_zone */
std::string zone_abbrev(bool as_offset=false) const
{
if(zone_ == boost::shared_ptr<tz_type>()) {
if(as_offset) {
return std::string("Z");
}
else {
return std::string("UTC");
}
}
if (is_dst()) {
if(as_offset) {
time_duration_type td = zone_->base_utc_offset();
td += zone_->dst_offset();
return zone_as_offset(td, "");
}
else {
return zone_->dst_zone_abbrev();
}
}
else {
if(as_offset) {
time_duration_type td = zone_->base_utc_offset();
return zone_as_offset(td, "");
}
else {
return zone_->std_zone_abbrev();
}
}
}
//! returns a posix_time_zone string for the associated time_zone. If no time_zone, "UTC+00" is returned.
std::string zone_as_posix_string() const
{
if(zone_ == shared_ptr<tz_type>()) {
return std::string("UTC+00");
}
return zone_->to_posix_string();
}
//! Equality comparison operator
/*bool operator==(const date_time::base_time<boost::posix_time::ptime,boost::posix_time::posix_time_system>& rhs) const
{ // fails due to rhs.time_ being protected
@@ -428,54 +340,29 @@ namespace local_time {
return (*this > rhs || *this == rhs);
}
//! Local_date_time + date_duration
/* Math operators. local_date_time_base inherits it's math operators
* from base_time. The shortcut operators (-= & +=) work but the
* others don't (they return a time_type which in local_date_time
* is a ptime). */
//! Local_date_time + date_duration
local_date_time_base operator+(const date_duration_type& dd) const
{
return local_date_time_base(time_system_type::add_days(this->time_,dd), zone_);
return local_date_time_base(time_system_type::add_days(time_,dd), zone_);
}
//! Local_date_time += date_duration
local_date_time_base operator+=(const date_duration_type& dd)
{
this->time_ = time_system_type::add_days(this->time_,dd);
return *this;
}
//! Local_date_time - date_duration
//! Local_date_time - date_duration
local_date_time_base operator-(const date_duration_type& dd) const
{
return local_date_time_base(time_system_type::subtract_days(this->time_,dd), zone_);
return local_date_time_base(time_system_type::subtract_days(time_,dd), zone_);
}
//! Local_date_time -= date_duration
local_date_time_base operator-=(const date_duration_type& dd)
{
this->time_ = time_system_type::subtract_days(this->time_,dd);
return *this;
}
//! Local_date_time + time_duration
//! Local_date_time + time_duration
local_date_time_base operator+(const time_duration_type& td) const
{
return local_date_time_base(time_system_type::add_time_duration(this->time_,td), zone_);
return local_date_time_base(time_system_type::add_time_duration(time_,td), zone_);
}
//! Local_date_time += time_duration
local_date_time_base operator+=(const time_duration_type& td)
{
this->time_ = time_system_type::add_time_duration(this->time_,td);
return *this;
}
//! Local_date_time - time_duration
//! Local_date_time - time_duration
local_date_time_base operator-(const time_duration_type& td) const
{
return local_date_time_base(time_system_type::subtract_time_duration(this->time_,td), zone_);
}
//! Local_date_time -= time_duration
local_date_time_base operator-=(const time_duration_type& td)
{
this->time_ = time_system_type::subtract_time_duration(this->time_,td);
return *this;
}
//! local_date_time -= local_date_time --> time_duration_type
time_duration_type operator-(const local_date_time_base& rhs) const
{
return utc_time_type(this->time_) - utc_time_type(rhs.time_);
return local_date_time_base(time_system_type::subtract_time_duration(time_,td), zone_);
}
private:
boost::shared_ptr<tz_type> zone_;
@@ -483,41 +370,18 @@ namespace local_time {
/*! Adjust the passed in time to UTC?
*/
utc_time_type construction_adjustment(utc_time_type t,
boost::shared_ptr<tz_type> z,
bool dst_flag)
utc_time_type construction_adjustment(utc_time_type t,
boost::shared_ptr<tz_type> zone,
bool is_dst)
{
if(z != boost::shared_ptr<tz_type>()) {
if(dst_flag && z->has_dst()) {
t -= z->dst_offset();
if(zone != NULL) {
if(is_dst && zone->has_dst()) {
t -= zone->dst_offset();
} // else no adjust
t -= z->base_utc_offset();
t -= zone->base_utc_offset();
}
return t;
}
/*! Simple formatting code -- todo remove this?
*/
std::string zone_as_offset(const time_duration_type& td,
const std::string& separator) const
{
std::ostringstream ss;
if(td.is_negative()) {
// a negative duration is represented as "-[h]h:mm"
// we require two digits for the hour. A positive duration
// with the %H flag will always give two digits
ss << "-";
}
else {
ss << "+";
}
ss << std::setw(2) << std::setfill('0')
<< date_time::absolute_value(td.hours())
<< separator
<< std::setw(2) << std::setfill('0')
<< date_time::absolute_value(td.minutes());
return ss.str();
}
};
//!Use the default parameters to define local_date_time
@@ -3,7 +3,7 @@
/* Copyright (c) 2003-2004 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -11,11 +11,8 @@
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/local_time/local_date_time.hpp"
#include "boost/date_time/local_time/local_time_types.hpp"
#if !defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
#include "boost/date_time/local_time/local_time_io.hpp"
#endif // USE_DATE_TIME_PRE_1_33_FACET_IO
#include "boost/date_time/local_time/posix_time_zone.hpp"
#include "boost/date_time/local_time/custom_time_zone.hpp"
#include "boost/date_time/local_time/time_zone.hpp"
#include "boost/date_time/local_time/tz_database.hpp"
#include "boost/date_time/local_time/conversion.hpp"
#include "boost/date_time/time_zone_base.hpp"
@@ -1,187 +0,0 @@
#ifndef BOOST_DATE_TIME_LOCAL_TIME_IO_HPP__
#define BOOST_DATE_TIME_LOCAL_TIME_IO_HPP__
/* Copyright (c) 2003-2004 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#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
namespace boost {
namespace local_time {
typedef boost::date_time::time_facet<local_date_time, wchar_t> wlocal_time_facet;
typedef boost::date_time::time_facet<local_date_time, char> local_time_facet;
typedef boost::date_time::time_input_facet<local_date_time::utc_time_type,wchar_t> wlocal_time_input_facet;
typedef boost::date_time::time_input_facet<local_date_time::utc_time_type,char> local_time_input_facet;
//! operator<< for local_date_time - see local_time docs for formatting details
template<class CharT, class TraitsT>
inline
std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os, const local_date_time& ldt)
{
boost::io::ios_flags_saver iflags(os);
typedef local_date_time time_type;//::utc_time_type typename
typedef date_time::time_facet<time_type, CharT> custom_time_facet;
std::ostreambuf_iterator<CharT> oitr(os);
if(std::has_facet<custom_time_facet>(os.getloc())) {
std::use_facet<custom_time_facet>(os.getloc()).put(oitr,
os,
os.fill(),
ldt);
}
else {
custom_time_facet* f = new custom_time_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(oitr, os, os.fill(), ldt);
}
return os;
}
//! input operator for local_date_time
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, local_date_time& ldt)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename local_date_time::utc_time_type utc_time_type;
typedef typename date_time::time_input_facet<utc_time_type, CharT> time_input_facet;
// intermediate objects
std::basic_string<CharT> tz_str;
utc_time_type pt(not_a_date_time);
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<time_input_facet>(is.getloc())) {
std::use_facet<time_input_facet>(is.getloc()).get_local_time(sit, str_end, is, pt, tz_str);
}
else {
time_input_facet* f = new time_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get_local_time(sit, str_end, is, pt, tz_str);
}
if(tz_str.empty()) {
time_zone_ptr null_ptr;
// a null time_zone_ptr creates a local_date_time that is UTC
ldt = local_date_time(pt, null_ptr);
}
else {
time_zone_ptr tz_ptr(new posix_time_zone(date_time::convert_string_type<CharT,char>(tz_str)));
// the "date & time" constructor expects the time label to *not* be utc.
// a posix_tz_string also expects the time label to *not* be utc.
ldt = local_date_time(pt.date(), pt.time_of_day(), tz_ptr, local_date_time::EXCEPTION_ON_ERROR);
}
}
catch(...) {
// mask tells us what exceptions are turned on
std::ios_base::iostate exception_mask = is.exceptions();
// if the user wants exceptions on failbit, we'll rethrow our
// date_time exception & set the failbit
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {} // ignore this one
throw; // rethrow original exception
}
else {
// if the user want's to fail quietly, we simply set the failbit
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
//! output operator for local_time_period
template <class CharT, class TraitsT>
inline
std::basic_ostream<CharT, TraitsT>&
operator<<(std::basic_ostream<CharT, TraitsT>& os,
const boost::local_time::local_time_period& p) {
boost::io::ios_flags_saver iflags(os);
typedef boost::date_time::time_facet<local_date_time, CharT> custom_facet;
std::ostreambuf_iterator<CharT> oitr(os);
if (std::has_facet<custom_facet>(os.getloc())) {
std::use_facet<custom_facet>(os.getloc()).put(oitr, os, os.fill(), p);
}
else {
//instantiate a custom facet for dealing with periods since the user
//has not put one in the stream so far. This is for efficiency
//since we would always need to reconstruct for every time period
//if the local did not already exist. Of course this will be overridden
//if the user imbues as some later point.
custom_facet* f = new custom_facet();
std::locale l = std::locale(os.getloc(), f);
os.imbue(l);
f->put(oitr, os, os.fill(), p);
}
return os;
}
//! input operator for local_time_period
template <class CharT, class Traits>
inline
std::basic_istream<CharT, Traits>&
operator>>(std::basic_istream<CharT, Traits>& is, boost::local_time::local_time_period& tp)
{
boost::io::ios_flags_saver iflags(is);
typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
if (strm_sentry) {
try {
typedef typename date_time::time_input_facet<local_date_time, CharT> time_input_facet;
std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
if(std::has_facet<time_input_facet>(is.getloc())) {
std::use_facet<time_input_facet>(is.getloc()).get(sit, str_end, is, tp);
}
else {
time_input_facet* f = new time_input_facet();
std::locale l = std::locale(is.getloc(), f);
is.imbue(l);
f->get(sit, str_end, is, tp);
}
}
catch(...) {
std::ios_base::iostate exception_mask = is.exceptions();
if(std::ios_base::failbit & exception_mask) {
try { is.setstate(std::ios_base::failbit); }
catch(std::ios_base::failure&) {}
throw; // rethrow original exception
}
else {
is.setstate(std::ios_base::failbit);
}
}
}
return is;
}
} } // namespaces
#endif // BOOST_DATE_TIME_LOCAL_TIME_IO_HPP__
@@ -3,7 +3,7 @@
/* Copyright (c) 2003-2004 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* (See accompanying file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
@@ -11,11 +11,6 @@
#include "boost/date_time/local_time/local_date_time.hpp"
#include "boost/date_time/period.hpp"
#include "boost/date_time/time_iterator.hpp"
#include "boost/date_time/compiler_config.hpp"
#if defined(BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES)
#include "boost/date_time/local_time/date_duration_operators.hpp"
#endif //BOOST_DATE_TIME_OPTIONAL_GREGORIAN_TYPES
#include "boost/date_time/local_time/custom_time_zone.hpp"
namespace boost {
namespace local_time {
@@ -25,19 +20,8 @@ namespace local_time {
typedef date_time::time_itr<local_date_time> local_time_iterator;
typedef date_time::second_clock<local_date_time> local_sec_clock;
typedef date_time::microsec_clock<local_date_time> local_microsec_clock;
//todo -- add clock definitions in here...
typedef date_time::time_zone_base<posix_time::ptime, char> time_zone;
typedef date_time::time_zone_base<posix_time::ptime, wchar_t> wtime_zone;
//! Shared Pointer for custom_time_zone and posix_time_zone objects
typedef boost::shared_ptr<time_zone> time_zone_ptr;
typedef boost::shared_ptr<wtime_zone> wtime_zone_ptr;
typedef date_time::time_zone_names_base<char> time_zone_names;
typedef date_time::time_zone_names_base<wchar_t> wtime_zone_names;
//bring special enum values into the namespace
using date_time::special_values;
using date_time::not_special;
@@ -1,56 +1,52 @@
#ifndef _DATE_TIME_POSIX_TIME_ZONE__
#define _DATE_TIME_POSIX_TIME_ZONE__
#define _DATE_TIME_POSIX_TIME_ZONE__
/* Copyright (c) 2003-2005 CrystalClear Software, Inc.
/* Copyright (c) 2003-2004 CrystalClear Software, Inc.
* Subject to the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
* file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
* Author: Jeff Garland, Bart Garst
* $Date$
*/
#include <string>
#include <sstream>
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/time_zone_names.hpp"
#include "boost/date_time/time_zone_base.hpp"
#include "boost/date_time/local_time/dst_transition_day_rules.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/tokenizer.hpp"
#include <stdexcept>
#include <boost/tokenizer.hpp>
#include <boost/throw_exception.hpp>
#include <boost/date_time/compiler_config.hpp>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/time_zone_names.hpp>
#include <boost/date_time/time_zone_base.hpp>
#include <boost/date_time/local_time/dst_transition_day_rules.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/string_convert.hpp>
#include <boost/date_time/time_parsing.hpp>
namespace boost{
namespace local_time{
//! simple exception for UTC and Daylight savings start/end offsets
struct BOOST_SYMBOL_VISIBLE bad_offset : public std::out_of_range
struct bad_offset : public std::out_of_range
{
bad_offset(std::string const& msg = std::string()) :
std::out_of_range(std::string("Offset out of range: " + msg)) {}
bad_offset(std::string _msg="") : std::out_of_range(std::string("Offset out of range: " + _msg)) {}
};
//! simple exception for UTC daylight savings adjustment
struct BOOST_SYMBOL_VISIBLE bad_adjustment : public std::out_of_range
struct bad_adjustment : public std::out_of_range
{
bad_adjustment(std::string const& msg = std::string()) :
std::out_of_range(std::string("Adjustment out of range: " + msg)) {}
bad_adjustment(std::string _msg="") : std::out_of_range(std::string("Adjustment out of range: " + _msg)) {}
};
typedef boost::date_time::time_zone_names time_zone_names;
typedef boost::date_time::dst_adjustment_offsets<boost::posix_time::time_duration> dst_adjustment_offsets;
typedef boost::date_time::time_zone_base<boost::posix_time::ptime> time_zone_base;
//! A time zone class constructed from a POSIX time zone string
/*! A POSIX time zone string takes the form of:<br>
/*! A POSIX time zone string takes to form of:<br>
* "std offset dst [offset],start[/time],end[/time]" (w/no spaces)
* 'std' specifies the abbrev of the time zone.<br>
* 'std' specifies the abbrev of the time zone.<br>
* 'offset' is the offset from UTC.<br>
* 'dst' specifies the abbrev of the time zone during daylight savings time.<br>
* The second offset is how many hours changed during DST. Default=1<br>
* 'start' and'end' are the dates when DST goes into (and out of) effect.<br>
* 'start' & 'end' are the dates when DST goes into (and out of) effect.<br>
* 'offset' takes the form of: [+|-]hh[:mm[:ss]] {h=0-23, m/s=0-59}<br>
* 'time' and 'offset' take the same form. Time defaults=02:00:00<br>
* 'start' and 'end' can be one of three forms:<br>
* 'start' & 'end' can be one of three forms:<br>
* Mm.w.d {month=1-12, week=1-5 (5 is always last), day=0-6}<br>
* Jn {n=1-365 Feb29 is never counted}<br>
* n {n=0-365 Feb29 is counted in leap years}<br>
@@ -60,86 +56,56 @@ namespace local_time{
* An invalid date spec (see date class)<br>
* A boost::local_time::bad_offset exception will be thrown for:<br>
* A DST start or end offset that is negative or more than 24 hours<br>
* A UTC zone that is greater than +14 or less than -12 hours<br>
* A UTC zone that is greater than +12 or less than -12 hours<br>
* A boost::local_time::bad_adjustment exception will be thrown for:<br>
* A DST adjustment that is 24 hours or more (positive or negative)<br>
*
* Note that UTC zone offsets can be greater than +12:
* http://www.worldtimezone.com/utc/utc+1200.html
*/
template<class CharT>
class BOOST_SYMBOL_VISIBLE posix_time_zone_base : public date_time::time_zone_base<posix_time::ptime,CharT> {
class posix_time_zone : public time_zone_base {
public:
typedef boost::posix_time::time_duration time_duration_type;
typedef date_time::time_zone_names_base<CharT> time_zone_names;
typedef date_time::time_zone_base<posix_time::ptime,CharT> base_type;
typedef typename base_type::string_type string_type;
typedef CharT char_type;
typedef typename base_type::stringstream_type stringstream_type;
typedef boost::char_separator<char_type, std::char_traits<char_type> > char_separator_type;
typedef boost::tokenizer<char_separator_type,
typename string_type::const_iterator,
string_type> tokenizer_type;
typedef typename tokenizer_type::iterator tokenizer_iterator_type;
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
//! Construct from a POSIX time zone string
posix_time_zone_base(const string_type& s) :
//zone_names_("std_name","std_abbrev","no-dst","no-dst"),
zone_names_(),
has_dst_(false),
posix_time_zone(const std::string& s) :
zone_names_("std_name","std_abbrev","no-dst","no-dst"),
has_dst_(false),
base_utc_offset_(posix_time::hours(0)),
dst_offsets_(posix_time::hours(0),posix_time::hours(0),posix_time::hours(0)),
dst_calc_rules_()
{
#ifdef __HP_aCC
// Work around bug in aC++ compiler: see QXCR1000880488 in the
// HP bug tracking system
const char_type sep_chars[2] = {',',0};
#else
const char_type sep_chars[2] = {','};
#endif
char_separator_type sep(sep_chars);
tokenizer_type tokens(s, sep);
tokenizer_iterator_type it = tokens.begin(), end = tokens.end();
if (it == end)
BOOST_THROW_EXCEPTION(std::invalid_argument("Could not parse time zone name"));
boost::char_separator<char> sep(",");
tokenizer tokens(s, sep);
tokenizer::iterator it = tokens.begin();
calc_zone(*it++);
if(has_dst_)
{
if (it == end)
BOOST_THROW_EXCEPTION(std::invalid_argument("Could not parse DST begin time"));
string_type dst_begin = *it++;
if (it == end)
BOOST_THROW_EXCEPTION(std::invalid_argument("Could not parse DST end time"));
string_type dst_end = *it;
calc_rules(dst_begin, dst_end);
if(has_dst_){
std::string tmp_str = *it++;
calc_rules(tmp_str, *it);
}
}
virtual ~posix_time_zone_base() {}
}
virtual ~posix_time_zone() {};
//!String for the zone when not in daylight savings (eg: EST)
virtual string_type std_zone_abbrev()const
virtual std::string std_zone_abbrev()const
{
return zone_names_.std_zone_abbrev();
}
//!String for the timezone when in daylight savings (eg: EDT)
/*! For those time zones that have no DST, an empty string is used */
virtual string_type dst_zone_abbrev() const
virtual std::string dst_zone_abbrev() const
{
return zone_names_.dst_zone_abbrev();
}
//!String for the zone when not in daylight savings (eg: Eastern Standard Time)
/*! The full STD name is not extracted from the posix time zone string.
/*! The full STD name is not extracted from the posix time zone string.
* Therefore, the STD abbreviation is used in it's place */
virtual string_type std_zone_name()const
virtual std::string std_zone_name()const
{
return zone_names_.std_zone_name();
}
//!String for the timezone when in daylight savings (eg: Eastern Daylight Time)
/*! The full DST name is not extracted from the posix time zone string.
* Therefore, the STD abbreviation is used in it's place. For time zones
/*! The full DST name is not extracted from the posix time zone string.
* Therefore, the STD abbreviation is used in it's place. For time zones
* that have no DST, an empty string is used */
virtual string_type dst_zone_name()const
virtual std::string dst_zone_name()const
{
return zone_names_.dst_zone_name();
}
@@ -148,20 +114,20 @@ namespace local_time{
{
return has_dst_;
}
//! Local time that DST starts -- NADT if has_dst is false
//! Local time that DST starts -- undefined if has_dst is false
virtual posix_time::ptime dst_local_start_time(gregorian::greg_year y)const
{
gregorian::date d(gregorian::not_a_date_time);
gregorian::date d(1900,1,1);
if(has_dst_)
{
d = dst_calc_rules_->start_day(y);
}
return posix_time::ptime(d, dst_offsets_.dst_start_offset_);
}
//! Local time that DST ends -- NADT if has_dst is false
//! Local time that DST ends -- undefined if has_dst is false
virtual posix_time::ptime dst_local_end_time(gregorian::greg_year y)const
{
gregorian::date d(gregorian::not_a_date_time);
gregorian::date d(1900,1,1);
if(has_dst_)
{
d = dst_calc_rules_->end_day(y);
@@ -179,64 +145,6 @@ namespace local_time{
return dst_offsets_.dst_adjust_;
}
//! Returns a POSIX time_zone string for this object
virtual string_type to_posix_string() const
{
// std offset dst [offset],start[/time],end[/time] - w/o spaces
stringstream_type ss;
ss.fill('0');
boost::shared_ptr<dst_calc_rule> no_rules;
// std
ss << std_zone_abbrev();
// offset
if(base_utc_offset().is_negative()) {
// inverting the sign guarantees we get two digits
ss << '-' << std::setw(2) << base_utc_offset().invert_sign().hours();
}
else {
ss << '+' << std::setw(2) << base_utc_offset().hours();
}
if(base_utc_offset().minutes() != 0 || base_utc_offset().seconds() != 0) {
ss << ':' << std::setw(2) << base_utc_offset().minutes();
if(base_utc_offset().seconds() != 0) {
ss << ':' << std::setw(2) << base_utc_offset().seconds();
}
}
if(dst_calc_rules_ != no_rules) {
// dst
ss << dst_zone_abbrev();
// dst offset
if(dst_offset().is_negative()) {
// inverting the sign guarantees we get two digits
ss << '-' << std::setw(2) << dst_offset().invert_sign().hours();
}
else {
ss << '+' << std::setw(2) << dst_offset().hours();
}
if(dst_offset().minutes() != 0 || dst_offset().seconds() != 0) {
ss << ':' << std::setw(2) << dst_offset().minutes();
if(dst_offset().seconds() != 0) {
ss << ':' << std::setw(2) << dst_offset().seconds();
}
}
// start/time
ss << ',' << date_time::convert_string_type<char, char_type>(dst_calc_rules_->start_rule_as_string()) << '/'
<< std::setw(2) << dst_offsets_.dst_start_offset_.hours() << ':'
<< std::setw(2) << dst_offsets_.dst_start_offset_.minutes();
if(dst_offsets_.dst_start_offset_.seconds() != 0) {
ss << ':' << std::setw(2) << dst_offsets_.dst_start_offset_.seconds();
}
// end/time
ss << ',' << date_time::convert_string_type<char, char_type>(dst_calc_rules_->end_rule_as_string()) << '/'
<< std::setw(2) << dst_offsets_.dst_end_offset_.hours() << ':'
<< std::setw(2) << dst_offsets_.dst_end_offset_.minutes();
if(dst_offsets_.dst_end_offset_.seconds() != 0) {
ss << ':' << std::setw(2) << dst_offsets_.dst_end_offset_.seconds();
}
}
return ss.str();
}
private:
time_zone_names zone_names_;
bool has_dst_;
@@ -245,90 +153,83 @@ namespace local_time{
boost::shared_ptr<dst_calc_rule> dst_calc_rules_;
/*! Extract time zone abbreviations for STD & DST as well
* as the offsets for the time shift that occurs and how
* as the offsets for the time the shift occurs and how
* much of a shift. At this time full time zone names are
* NOT extracted so the abbreviations are used in their place */
void calc_zone(const string_type& obj){
const char_type empty_string[2] = {'\0'};
stringstream_type ss(empty_string);
typename string_type::const_pointer sit = obj.c_str(), obj_end = sit + obj.size();
string_type l_std_zone_abbrev, l_dst_zone_abbrev;
void calc_zone(const std::string& obj){
std::stringstream ss("");
std::string::const_iterator sit = obj.begin();
std::string std_zone_abbrev("std_abbrev"), dst_zone_abbrev("");
// get 'std' name/abbrev
while(std::isalpha(*sit)){
while(isalpha(*sit)){
ss << *sit++;
}
l_std_zone_abbrev = ss.str();
ss.str(empty_string);
std_zone_abbrev = ss.str();
ss.str("");
// get UTC offset
if(sit != obj_end){
if(sit != obj.end()){
// get duration
while(sit != obj_end && !std::isalpha(*sit)){
ss << *sit++;
}
base_utc_offset_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(ss.str());
ss.str(empty_string);
while(!isalpha(*sit) && sit != obj.end()){
ss << *sit++;
}
base_utc_offset_ = posix_time::duration_from_string(ss.str());
ss.str("");
// base offset must be within range of -12 hours to +14 hours
if(base_utc_offset_ < time_duration_type(-12,0,0) ||
base_utc_offset_ > time_duration_type(14,0,0))
{
boost::throw_exception(bad_offset(posix_time::to_simple_string(base_utc_offset_)));
}
// base offset must be within range of -12 hours to +12 hours
if(base_utc_offset_ < time_duration_type(-12,0,0) ||
base_utc_offset_ > time_duration_type(12,0,0))
{
throw bad_offset(posix_time::to_simple_string(base_utc_offset_));
}
}
// get DST data if given
if(sit != obj_end){
has_dst_ = true;
if(sit != obj.end()){
has_dst_ = true;
// get 'dst' name/abbrev
while(sit != obj_end && std::isalpha(*sit)){
while(isalpha(*sit)){
ss << *sit++;
}
l_dst_zone_abbrev = ss.str();
ss.str(empty_string);
dst_zone_abbrev = ss.str();
ss.str("");
// get DST offset if given
if(sit != obj_end){
if(sit != obj.end()){
// get duration
while(sit != obj_end && !std::isalpha(*sit)){
while(!isalpha(*sit) && sit != obj.end()){
ss << *sit++;
}
dst_offsets_.dst_adjust_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(ss.str());
ss.str(empty_string);
dst_offsets_.dst_adjust_ =
posix_time::duration_from_string(ss.str());
ss.str("");
}
else{ // default DST offset
dst_offsets_.dst_adjust_ = posix_time::hours(1);
}
// adjustment must be within +|- 1 day
if(dst_offsets_.dst_adjust_ <= time_duration_type(-24,0,0) ||
dst_offsets_.dst_adjust_ >= time_duration_type(24,0,0))
{
boost::throw_exception(bad_adjustment(posix_time::to_simple_string(dst_offsets_.dst_adjust_)));
}
// adjustment must be within +|- 1 day
if(dst_offsets_.dst_adjust_ <= time_duration_type(-24,0,0) ||
dst_offsets_.dst_adjust_ >= time_duration_type(24,0,0))
{
throw bad_adjustment(posix_time::to_simple_string(dst_offsets_.dst_adjust_));
}
}
// full names not extracted so abbrevs used in their place
zone_names_ = time_zone_names(l_std_zone_abbrev, l_std_zone_abbrev, l_dst_zone_abbrev, l_dst_zone_abbrev);
zone_names_ = time_zone_names(std_zone_abbrev, std_zone_abbrev, dst_zone_abbrev, dst_zone_abbrev);
}
void calc_rules(const string_type& start, const string_type& end){
#ifdef __HP_aCC
// Work around bug in aC++ compiler: see QXCR1000880488 in the
// HP bug tracking system
const char_type sep_chars[2] = {'/',0};
#else
const char_type sep_chars[2] = {'/'};
#endif
char_separator_type sep(sep_chars);
tokenizer_type st_tok(start, sep);
tokenizer_type et_tok(end, sep);
tokenizer_iterator_type sit = st_tok.begin();
tokenizer_iterator_type eit = et_tok.begin();
void calc_rules(const std::string& start, const std::string& end){
boost::char_separator<char> sep("/");
tokenizer st_tok(start, sep);
tokenizer et_tok(end, sep);
tokenizer::iterator sit = st_tok.begin();
tokenizer::iterator eit = et_tok.begin();
// generate date spec
char_type x = string_type(*sit).at(0);
char x = std::string(*sit).at(0);
if(x == 'M'){
M_func(*sit, *eit);
}
@@ -344,7 +245,7 @@ namespace local_time{
// generate durations
// starting offset
if(sit != st_tok.end()){
dst_offsets_.dst_start_offset_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(*sit);
dst_offsets_.dst_start_offset_ = posix_time::duration_from_string(*sit);
}
else{
// default
@@ -354,12 +255,12 @@ namespace local_time{
if(dst_offsets_.dst_start_offset_ < time_duration_type(0,0,0) ||
dst_offsets_.dst_start_offset_ >= time_duration_type(24,0,0))
{
boost::throw_exception(bad_offset(posix_time::to_simple_string(dst_offsets_.dst_start_offset_)));
throw bad_offset(posix_time::to_simple_string(dst_offsets_.dst_start_offset_));
}
// ending offset
if(eit != et_tok.end()){
dst_offsets_.dst_end_offset_ = date_time::str_from_delimited_time_duration<time_duration_type,char_type>(*eit);
dst_offsets_.dst_end_offset_ = posix_time::duration_from_string(*eit);
}
else{
// default
@@ -369,7 +270,7 @@ namespace local_time{
if(dst_offsets_.dst_end_offset_ < time_duration_type(0,0,0) ||
dst_offsets_.dst_end_offset_ >= time_duration_type(24,0,0))
{
boost::throw_exception(bad_offset(posix_time::to_simple_string(dst_offsets_.dst_end_offset_)));
throw bad_offset(posix_time::to_simple_string(dst_offsets_.dst_end_offset_));
}
}
@@ -377,70 +278,61 @@ namespace local_time{
* Date specs come in three possible formats, this function handles
* the 'M' spec. Ex "M2.2.4" => 2nd month, 2nd week, 4th day .
*/
void M_func(const string_type& s, const string_type& e){
void M_func(const std::string& s, const std::string& e){
typedef gregorian::nth_kday_of_month nkday;
unsigned short sm=0,sw=0,sd=0,em=0,ew=0,ed=0; // start/end month,week,day
#ifdef __HP_aCC
// Work around bug in aC++ compiler: see QXCR1000880488 in the
// HP bug tracking system
const char_type sep_chars[3] = {'M','.',0};
#else
const char_type sep_chars[3] = {'M','.'};
#endif
char_separator_type sep(sep_chars);
tokenizer_type stok(s, sep), etok(e, sep);
tokenizer_iterator_type it = stok.begin();
sm = lexical_cast<unsigned short>(*it++);
sw = lexical_cast<unsigned short>(*it++);
sd = lexical_cast<unsigned short>(*it);
int sm=0,sw=0,sd=0,em=0,ew=0,ed=0; // start/end month,week,day
char_separator<char> sep("M.");
tokenizer stok(s, sep), etok(e, sep);
tokenizer::iterator it = stok.begin();
sm = lexical_cast<int>(*it++);
sw = lexical_cast<int>(*it++);
sd = lexical_cast<int>(*it);
it = etok.begin();
em = lexical_cast<unsigned short>(*it++);
ew = lexical_cast<unsigned short>(*it++);
ed = lexical_cast<unsigned short>(*it);
em = lexical_cast<int>(*it++);
ew = lexical_cast<int>(*it++);
ed = lexical_cast<int>(*it);
dst_calc_rules_ = shared_ptr<dst_calc_rule>(
new nth_kday_dst_rule(
nth_last_dst_rule::start_rule(
static_cast<nkday::week_num>(sw),sd,sm),
static_cast<nkday::week_num>(sw),sd,sm),
nth_last_dst_rule::start_rule(
static_cast<nkday::week_num>(ew),ed,em)
static_cast<nkday::week_num>(ew),ed,em)
)
);
}
//! Julian day. Feb29 is never counted, even in leap years
// expects range of 1-365
void julian_no_leap(const string_type& s, const string_type& e){
void julian_no_leap(const std::string& s, const std::string& e){
typedef gregorian::gregorian_calendar calendar;
const unsigned short year = 2001; // Non-leap year
unsigned short sm=1;
int sd=0;
int sm=1, sd=0;
sd = lexical_cast<int>(s.substr(1)); // skip 'J'
while(sd >= calendar::end_of_month_day(year,sm)){
sd -= calendar::end_of_month_day(year,sm++);
}
unsigned short em=1;
int ed=0;
int em=1, ed=0;
ed = lexical_cast<int>(e.substr(1)); // skip 'J'
while(ed > calendar::end_of_month_day(year,em)){
while(ed >= calendar::end_of_month_day(year,em)){
ed -= calendar::end_of_month_day(year,em++);
}
dst_calc_rules_ = shared_ptr<dst_calc_rule>(
new partial_date_dst_rule(
partial_date_dst_rule::start_rule(
static_cast<unsigned short>(sd), static_cast<date_time::months_of_year>(sm)),
sd, static_cast<date_time::months_of_year>(sm)),
partial_date_dst_rule::end_rule(
static_cast<unsigned short>(ed), static_cast<date_time::months_of_year>(em))
ed, static_cast<date_time::months_of_year>(em))
)
);
}
//! Julian day. Feb29 is always counted, but exception thrown in non-leap years
// expects range of 0-365
void julian_day(const string_type& s, const string_type& e){
void julian_day(const std::string& s, const std::string& e){
int sd=0, ed=0;
sd = lexical_cast<int>(s);
ed = lexical_cast<int>(e);
@@ -452,24 +344,9 @@ namespace local_time{
);
}
//! helper function used when throwing exceptions
static std::string td_as_string(const time_duration_type& td)
{
std::string s;
#if defined(USE_DATE_TIME_PRE_1_33_FACET_IO)
s = posix_time::to_simple_string(td);
#else
std::stringstream ss;
ss << td;
s = ss.str();
#endif
return s;
}
};
typedef posix_time_zone_base<char> posix_time_zone;
} } // namespace boost::local_time
#endif // _DATE_TIME_POSIX_TIME_ZONE__
#endif // _DATE_TIME_POSIX_TIME_ZONE__

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