89 Commits

Author SHA1 Message Date
Howard Hinnant
88890939d5 Add zone1970.tab to the list of files
that should be ignored by init_tzdb() under USE_OS_TZDB.
2017-06-14 20:48:19 -04:00
Howard Hinnant
aa4dafcc46 Silence sign conversion warnings 2017-06-12 13:33:47 -04:00
Howard Hinnant
cc81c9ea50 Fix minor problems for g++:
* Add missing #include <string>

* Explicitly convert sys_days to sys_seconds in conditional operator
2017-06-12 09:44:41 -04:00
Howard Hinnant
a610f087c1 Add support for the zic-compiled OS-supplied time zone DB:
*  Avoids the need to download the IANA database.

*  Heavily based on contributions by Aaron Bishop.

*  Turn on with -DUSE_OS_TZDB, off by default.

*  Not supported on Windows.

*  Disables HAS_REMOTE_API.

*  get_tzdb().version only supported on Apple.  This string has
   the value "unknown" elsewhere.

*  Leap second support is missing on Apple, and may not be on your
   platform either (please report).  Leap second support is enabled,
   disabled with -DMISSING_LEAP_SECONDS.

   Without leap second support, utc_time, tai_time, and gps_time (and
   those clocks) are not available.

*  On Apple, time zone transitions are only supported in the range:

   1901-12-13 20:45:52 to 2038-01-19 03:14:07

*  On Linux, time zone transitions are only as far in the future as
   the OS-provided transitions go.  There is no support for POSIX-
   style transitions.
2017-06-04 21:04:53 -04:00
Howard Hinnant
5132385454 Remove obsolete LAZY_INIT flag. 2017-06-04 20:32:37 -04:00
Howard Hinnant
5c38ad84e8 Eliminate TIMEZONE_MAPPING by making it equivalent to _WIN32.
*  Clean up indenting and whitespace.
*  No functionality changes intended.
2017-06-04 20:32:37 -04:00
Tullio Menga
83c8b4d522 changes for compatibility with Clang with Microsoft CodeGen (v140_clang_c2):
- added date:: namespace to flloor() and abs() calls
- added IUnknown forward declaration before including Windows headers to prevent issue with objbase.h
- minor changes
2017-05-08 10:04:20 -04:00
Tomi Valkeinen
44f6dfc58e fix compile warning about unused get_download_gz_file()
get_download_gz_file() is not used when HAS_REMOTE_API=0, and causes:

warning: 'std::__cxx11::string date::get_download_gz_file(const string&)' defined but not used [-Wunused-function]

Wrap get_download_gz_file() inside #ifdef to remove the warning.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
2017-05-02 20:10:44 -04:00
Jaak Ristioja
ec7db09085 Use system_error instead of strerror_r:
* Addresses portability issues.
2017-05-02 20:10:44 -04:00
Howard Hinnant
b2dc8b1f6e Tweak getTimeZoneKeyName():
* for systems that return "Coordinated Universal Time".
 * return "UTC" instead.
2017-04-18 20:48:28 -04:00
Howard Hinnant
c64d69b1e1 Avoid getting localized time zone names from Windows OS.
* Use GetDynamicTimeZoneInformation to get .TimeZoneKeyName
  https://msdn.microsoft.com/en-us/library/windows/desktop/ms724318(v=vs.85).aspx
  > Retrieves the current time zone and dynamic daylight saving time settings.
  https://msdn.microsoft.com/en-us/library/windows/desktop/ms724253(v=vs.85).aspx
  > The name of the time zone registry key on the local computer.

* This avoids the need to map from StandardName to TimeZoneKeyName.

* Using .DynamicDaylightTimeDisabled = true forces the OS to return a
  non-daylight saving time result.

* Use of wcstombs is preferred over wstring_convert as the latter is now
  deprecated in C++17 because the implementors could not interpret the
  specification.
2017-04-17 19:06:58 -04:00
gm
885910375f Fix pragma warnings. Displayed at least by MSVC. 2017-04-16 23:53:37 +12:00
Jan Kratochvil
a4eef8e20c Fix gcc -O -D_FORTIFY_SOURCE. 2017-04-03 20:46:36 -04:00
Jan Kratochvil
1fd0806757 Fix -Wshadow for gcc and clang. 2017-04-03 20:46:36 -04:00
Florian Dang
c4c2550b29 Ignore GCC warnings.
* 4.9 missing initializer warnings
* pedantic for __int128 case
* Wrap diagnostic push and pop in tz.cpp and date.h.
2017-04-01 12:36:54 -04:00
Howard Hinnant
3ab6510cab Update copyright to 2017 2017-03-21 21:52:51 -04:00
Florian Dang
5e86f2c5ba Create downloads folder when it does not exist yet. 2017-03-20 18:25:19 -04:00
Gaspard Petit
a811a20748 Fixes minor typos in comments - no actual change to code 2017-03-08 11:28:35 -05:00
Jiangang (Jeff) Zhuang
3e906a2409 Remove a leftover output to std::cout 2017-02-13 12:17:11 -05:00
Howard Hinnant
5c09ae73f2 Work around {} bug for older compilers 2017-02-08 11:32:33 -05:00
Howard Hinnant
098223cf6d Second try at silencing "unused" warning for strerror_r 2017-02-07 17:31:14 -05:00
Howard Hinnant
6a31edcb38 Silence "unused" warning for strerror_r 2017-02-06 10:18:40 -05:00
Nicolas Veloz Savino
c1034550d2 Exclude expand_path when INSTALL is not defined 2017-01-30 18:02:06 -05:00
Jiangang (Jeff) Zhuang
095f66af28 resolve /etc/localtime by calling realpath 2017-01-14 07:46:05 -05:00
Howard Hinnant
659cdca5dc Only define get_windows_zones_install() under TIMEZONE_MAPPING 2017-01-09 21:01:39 -05:00
Howard Hinnant
634b84eb60 Introduce set_install as suggested by PR 99
* Retain install variable as a function local static to maintain
  recent fixes to initialization order problems.
2017-01-07 18:27:40 -05:00
Jiangang (Jeff) Zhuang
c6f3dd2832 make the location of windowsZones.xml configurable 2017-01-05 20:28:12 -05:00
Roel Standaert
09537c4e19 Added missing #include <tuple> in tz.cpp
This is needed for std::tie. GCC and Clang are fine with it missing, but
my Visual Studio doesn't like it.
2017-01-03 10:23:38 -05:00
Howard Hinnant
2935f80109 Have get_version check for the file named version first 2017-01-01 15:02:08 -05:00
gm
07d9e8a0fe Enable the c++14 CONSTDATA code path for VS2017 and fix const const warning. 2017-01-01 18:01:20 +13:00
Jiangang (Jeff) Zhuang
64ea0a5bc3 move file scope static variables into functions to deal with static initialization order problem 2016-12-02 20:57:21 -05:00
Howard Hinnant
806c29fddc Lots of minor changes motivated by reviews of the draft proposal 2016-10-15 17:31:08 -04:00
Howard Hinnant
19c83e47ed Get local version from NEWS instead of Makefile 2016-09-28 18:08:50 -04:00
Sascha Zelzer
641cd739c3 VS2013's std::vector does not support incomplete template types.
This commit works around this by exposing the zonelet class declaration
to the public tz.h header.
2016-09-15 20:10:04 -04:00
Sascha Zelzer
553affefa4 Work around a compiler bug in VS2013 with explicit conversion constructors. 2016-09-15 20:10:04 -04:00
Howard Hinnant
7e9d9075d9 Miscellaneous changes while enabling iOS support
Put all of the logic for discovering iOS in one place in ios.h.

Make TAR_DEBUG configurable and default it to 0.

Various whitespace style pickiness.
2016-08-23 20:55:13 -04:00
schmidt9
927fc619ef Namespaces, ios macro 2016-08-21 21:37:24 +03:00
schmidt9
78025bf922 Add iOS support 2016-08-14 20:35:22 -04:00
Howard Hinnant
137c317cc6 Add INSTALL configuration. 2016-08-06 14:57:47 -04:00
Howard Hinnant
b4ca58d9a8 Revert "Remove support for using system() now other means proven."
This reverts commit ebf3b0776ab8d68ca9b3f4f02415092bc8935d75.
2016-08-05 20:16:09 -04:00
gm
ebf3b0776a Remove support for using system() now other means proven.
* Other miscellaneous improvements.
2016-07-27 18:45:10 -04:00
Pavel
52e2a0b2cf Prevent warnings when using -Wundef flag 2016-07-04 11:14:59 -04:00
gm
d252405747 Remove tinyxml2 dependency. 2016-06-25 17:00:05 -04:00
gm
9435e7b687 Fix a todo and a few micro optimisations. Trying harder to locate unzip program.
TZ will now work when 7-zip is installed somewhere other than its default location.
2016-06-23 02:54:36 +12:00
nico-engels
91c05caaff Check if mapping file exists when !AUTO_DOWNLOAD
~ Check if the windowsZones.xml realy exists to not segfault in TinyXml parser.
~ Remove old TimeZoneMappings.csv mapping from repo. Use the http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml instead.
2016-06-21 21:46:33 -04:00
gm
de458e9b99 Allow the option to not use the std::system api and make the default NOT use it for all platforms. 2016-06-20 23:34:24 -04:00
gm
55087c6cbd HAS_REMOTE_API support for Windows. Adds support for MingW too.
* HAS_REMOTE_API still defaults to 0
* When HAS_REMOTE_API=0 only libraries advapi32.lib, ole32.lib and shell32.lib are required.
* Setting HAS_REMOTE_API=1 requires curl: https://curl.haxx.se/libcurl/
*- Also need to manually install 7-Zip (http://www.7-zip.org).
*- Will automatically install Tinyxml2 (http://www.grinninglizard.com/tinyxml2/).
*- Will automatically install http://unicode.org/repos/cldr/trunk/common/supplemental/windowsZones.xml
2016-06-16 22:03:12 -04:00
Howard Hinnant
5aa704d5f7 Port current_zone to Red Hat 2016-06-10 21:15:59 -04:00
gm
7e66cb2e83 Improve cross platform support.
Make validate work for C++11 because the library supports it.
Fix an unused variable mistake i made earlier.
Make constructor public, seems it should be. Possible compiler bug?
2016-06-04 13:38:50 -04:00
gm
3293637e70 Tighten up parsing. Detect missing quotes. Use istringstream for clarity. 2016-06-04 13:36:40 -04:00
gm
ee96fe5c6d Make mapping file handle windows line endings and generalize copyright format and checking slightly. 2016-06-02 00:49:11 +12:00
Howard Hinnant
a89aab05cf Protect from overflow when minutes is 32 bits 2016-05-31 11:12:20 -04:00
Howard Hinnant
ea2d0d3357 constexpr more stuff and clean up whitespace 2016-05-30 22:09:21 -04:00
Howard Hinnant
76bef1fe01 Support wide streams 2016-05-29 00:15:33 -04:00
Howard Hinnant
f60f61201c Rename Leap to leap 2016-05-28 20:27:02 -04:00
Howard Hinnant
b0a23f2cff Rename Link to link 2016-05-28 20:20:28 -04:00
Howard Hinnant
67c31d794e Protect undocumented constructors 2016-05-28 14:09:46 -04:00
Howard Hinnant
f5f0f80778 Get rid of tz. Hide unnecessary API. Clean up get_info 2016-05-08 22:59:39 -04:00
Howard Hinnant
1e5d2fa8dd Create local and system time types for timezone functions.
* Add sys_time.
* Add sys_days.
* Add sys_seconds.
* Add local_time.
* Add local_days.
* Add local_seconds.
* Rename day_point to sys_days.
* Rename Zone to time_zone.
2016-05-03 23:19:09 -04:00
Howard Hinnant
cd79376546 Add remote API and auto-download of tzdata. 2016-04-09 14:07:19 -04:00
Howard Hinnant
e79634f61d Optimize initialization of tz database
* Defer expensive parts of the initialization
* The deferment can be turned off with -DLAZY_INIT=0
2016-04-05 16:33:20 -07:00
Howard Hinnant
e8f95dddb7 Add format and parse functionality. 2016-04-03 18:57:02 -04:00
Howard Hinnant
bf9fe449cd Correct buffer management with Windows system calls.
Credit: Reiner Eiteljörge
2016-03-27 15:35:14 -04:00
Howard Hinnant
f1d2e869d7 Print out time zone database version 2016-02-19 18:48:23 -05:00
Howard Hinnant
5acaffc2b3 Add timezone db version and misc cleanup 2016-01-27 20:34:48 -05:00
Ivan Pizhenko
0e64070a33 Correction after code review 2015-12-02 16:22:09 +02:00
ivanp2015
50802176f3 TZ stuff fixed for VS2013 2015-11-29 07:56:59 +02:00
Ivan Pizhenko
bf699e573b Fixed GCC 4.8 compilation issue 2015-11-08 00:54:02 +02:00
Howard Hinnant
819d2c3575 Minor cleanup and crank up warnings. 2015-10-27 12:14:30 -04:00
gm
2467d56f11 Address issue 19: define NOMINMAX and WIN32_LEAN_AND_MEAN. In addition, fix some warnings so MSVC will compile at /W4 with no warnings.
No functional change intended.
2015-10-22 22:36:37 +13:00
Howard Hinnant
6b03ff2e70 Push tz configuration up higher in the source file. 2015-09-27 10:49:10 -04:00
gm
635ec55065 Throw a runtime error if the install folder does not exist.
Replace my accidental use of NULL with nullptr.
Improve some comments.
2015-09-27 20:55:55 +13:00
gm
0791828329 Fix a WIN32 -> _WIN32 typo and try to make some comments more readable. 2015-09-24 14:46:20 +12:00
Howard Hinnant
479cd16986 Add validate test for timezones 2015-08-15 16:00:42 -04:00
Ville Voutilainen
eb32682e99 Comment typos 2015-08-10 23:14:15 +03:00
Ville Voutilainen
13de3eb7f2 Add myself to tz.cpp copyright 2015-08-10 09:59:01 +03:00
Howard Hinnant
28eadffa06 Implement '%z' 2015-08-08 18:11:35 -04:00
Howard Hinnant
999dfc4b37 Change to MIT copyright
* Added unicode copyright to CLDR-derived mapping.
2015-08-08 17:03:43 -04:00
Howard Hinnant
33f923b508 Rename seconds_point to second_point for consistency with day_point. 2015-08-08 13:20:12 -04:00
Howard Hinnant
0d0841f5b8 Rename current_timezone() to current_zone():
* Better symmetry with locate_zone(name).
2015-08-08 13:06:04 -04:00
gm
c21e392c81 Initial Win32 support.
This library now compiles on Windows but requires VS2015 for Windows.
VS2013 may work but this has not been tested yet.
Requires NOMINMAX to be defined to avoid clashes with the Windows.h
headers and the C++ stl and this libraries Date max functions.
Also known to work equivalently with recent g++ and mingw combinations
but -std=C++14 flag should be set.
C++14 restrictions may be relaxed later. Patches welcome!
g++ 5.1 was tested. It may work with other version but that hasn't been tried.
Mac OS and Linux systems are known to compile with -std=c++11
current_timezone and locate_zone will return iana names not windows
time zone names. This is expected and as designed.
2015-08-06 23:16:03 -04:00
Ville Voutilainen
17bd48d23c An attempt to tidy up current_timezone() 2015-07-30 01:01:19 +03:00
Howard Hinnant
a2c632bb5b Silence a few warnings on VS. 2015-07-28 21:56:14 -04:00
gm
51864f56c1 Try to make current time zone work with Linux. e.g. Ubuntu and Fedora 2015-07-27 18:45:43 -04:00
Howard Hinnant
5c370dbfd9 Port to gcc-5.2.0 on OS X.
*  This also fixes an overflow bug in Zone::get_info.
2015-07-25 18:01:31 -04:00
Howard Hinnant
12a769653e Fix rule finding logic for falling off the front of the rule list 2015-07-18 23:11:20 -04:00
Howard Hinnant
9858887551 Correct some silly spelling errors. 2015-07-18 18:58:48 -04:00
Howard Hinnant
a431164fcd Add missing 'backward' file and correct output of negative values for time_of_day_storage. 2015-07-18 17:40:18 -04:00
Howard Hinnant
796448e4ad Initial commit 2015-07-17 22:30:53 -04:00