63 Commits

Author SHA1 Message Date
Sascha Zelzer
553affefa4 Work around a compiler bug in VS2013 with explicit conversion constructors. 2016-09-15 20:10:04 -04:00
Howard Hinnant
765d0e8f7a Add parse manipulators 2016-09-15 20:10:04 -04:00
Howard Hinnant
86446a9fac format passes time_point by const& 2016-09-13 20:28:00 -04:00
Howard Hinnant
b2df8cade5 Add trivial default constructors to most calendar types 2016-09-13 20:14:43 -04:00
Howard Hinnant
845ce25bb7 Refine decision to use the std::chrono rounding modes 2016-09-10 11:57:52 -04:00
Howard Hinnant
59d9cfa96d Update the availability of floor, ceil, round 2016-09-09 21:21:22 -04:00
Howard Hinnant
a7b6adae62 Add %F to parse 2016-09-09 21:01:21 -04:00
acolomitchi
3b3a27efe1 Fix for issue #79.
parse was not checking failbit aggressively enough.
2016-09-09 21:00:11 -04:00
Howard Hinnant
32ca148d5c Work around uniform initialization bug for clang-3.6 2016-08-29 12:24:07 -04:00
Howard Hinnant
17ba481e71 Work around [Bug c++/67631] New: brace initialization bug
https://gcc.gnu.org/ml/gcc-bugs/2015-09/msg01520.html
2016-08-28 18:30:12 -04:00
Howard Hinnant
8e2de8587e Eliminate dependence on OS's gmtime_s / gmtime_r
When compiled with -arch i386, Apple's gmtime_s has a 32 bit bug meaning
it can't format dates earlier than 1901-12-13 20:45:52.
2016-08-28 14:52:41 -04:00
Howard Hinnant
7816c3b48f Eliminate dependence on OS's timegm / _mkgmtime
Apple's OS timegm has a 32 bit bug meaning it can't parse dates earlier
than 1901-12-13 20:45:52.
2016-08-28 14:26:22 -04:00
Howard Hinnant
3e25bd45f7 Clean up includes
Alphabetize and survey for missing and unneeded includes.
2016-08-27 14:18:46 -04:00
Howard Hinnant
fcdca67c5b Switch to floor in format
Need to round towards negative infinity for dates prior to the epoch,
else the wrong answer gets formatted.
2016-08-27 13:22:27 -04:00
Matthias Gabriel
2fae542f6a Fix formating of time_points with a resolution finer than system_clock::duration 2016-08-26 10:55:05 +02:00
Matthias Gabriel
ef57f27b38 Added #include <cctype> for windows std::isdigit 2016-08-25 15:41:49 +02:00
Matthias Gabriel
ef8bba9818 Fix missing standard locale 2016-08-25 08:23:19 +02:00
Matthias Gabriel
e8f8a1ffac Added missing sstream include 2016-08-25 08:20:14 +02:00
Howard Hinnant
ebc20c139b Move formatting and parsing
Moved formatting and parsing of sys_time and local_time from tz.h to
date.h in order to make this functionality available to a wider
audience.  Existing code does not need to change.  But future code
can #include "date.h" instead of "tz.h" and need not compile tz.cpp nor
link to curl.

Formatting zoned_time remains in tz.h.
2016-08-24 20:54:24 -04:00
Pavel
52e2a0b2cf Prevent warnings when using -Wundef flag 2016-07-04 11:14:59 -04:00
Howard Hinnant
7d1befb1db Introduce julian.h 2016-06-26 18:49:13 -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
33ddd7e51d Back off the constexpr on time_of_day_storage for C++11. 2016-06-09 21:23:45 -04:00
Howard Hinnant
f44e692540 Add streaming inserter for utc_time.
* Fix bug in utc_to_sys.
2016-06-06 21:05:43 -04: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
008178eee1 Make construction from local_days explicit 2016-05-21 12:46:11 -04:00
Howard Hinnant
76c906d779 Get off of day_point 2016-05-21 10:24:25 -04:00
Howard Hinnant
a8d8776ec7 MSC doesn't do inheriting constructors yet 2016-05-14 11:43:26 -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
95271f8337 Minor fixes 2016-04-21 16:21:01 -04:00
Howard Hinnant
e8f95dddb7 Add format and parse functionality. 2016-04-03 18:57:02 -04:00
gm
a093521890 Remove floor, ceil, round and abs when VS Update 2 is present as it's chrono has this polishing. 2016-03-30 21:47:40 -04:00
Howard Hinnant
f73c4aa486 Deal with warnings. 2016-03-11 23:02:29 -05:00
galik
177032852d prevent GCC warning/error when using -pedantic or -pedantic-errors flags 2016-02-04 00:56:56 +00:00
Howard Hinnant
e988efad90 Small negative floating point values should trunc and round to -0. instead of 0. 2016-01-01 15:27:17 -05:00
Howard Hinnant
4a4a864964 Minor polishing 2015-11-28 17:41:17 -05:00
ivanp2015
ca74113ae8 date.h fixed for VS2013 2015-11-29 00:19:24 +02:00
Howard Hinnant
1d23665bd4 Change __int128 protection. 2015-11-28 12:45:27 -05:00
Howard Hinnant
e08458e279 Update rounding utilities. 2015-11-22 21:57:49 -05:00
Howard Hinnant
c5f307fdb8 Renamed date_literals to date::literals and corrected placement. 2015-11-09 20:28:04 -05:00
Howard Hinnant
819d2c3575 Minor cleanup and crank up warnings. 2015-10-27 12:14:30 -04:00
Howard Hinnant
333894fc9d Merge branch 'gm_issue_19' of git://github.com/gmcode/date into gmcode-gm_issue_19 2015-10-27 11:53:29 -04:00
Howard Hinnant
342d15ce56 Give last_spec an explicit default ctor 2015-10-27 11:52:31 -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
c8ee261043 Added a few convenience field getters:
* year_month_weekday::weekday()
* year_month_weekday::index()
* year_month_weekday_last::weekday()
2015-09-19 13:46:09 -04:00
Howard Hinnant
6af1976e36 Move all literals into namespace date_literals
This includes both the literal operators, and the constexpr literals such as sun and jan.
2015-09-06 17:58:29 -04:00
Howard Hinnant
a0d2343eab Try disabling construction of weekday from int.
Also fix bug in round for negatives.
2015-09-02 20:48:44 -04:00
Howard Hinnant
9b79ad2ce2 Add tests for time_of_day and make_time 2015-08-15 14:21:43 -04:00
Howard Hinnant
4b8ca1c24d Change year_month_day_last to store a {year, month_day_last}
* from storing a {year, month}.
    * Change constructor from {year, month} to {year, month_day_last}.
    * Add getter from year_month_day_last().
    * Fix up operator/() as required.
    * This is an API change, but not a functionality change.
    * Rationale: consistency.
2015-08-09 18:37:46 -04:00
Howard Hinnant
e701a42ced Change month_weekday_last to store a {month, weekday_last}
* from storing a {month, weekday}.
* Change constructor from {month, weekday} to {month, week_last}.
* Change getter from weekday() to weekday_last().
* Fix up operator/() as required.
* This is an API change, but not a functionality change.
* Rationale: consistency.
2015-08-09 16:30:42 -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
2d115a8022 Add to_duration() to time_of_day:
* This is a synonym for static_cast<precision>(*this).
* This variation can be easier to spell when the precision
  is not conveniently available.
2015-08-08 13:38:12 -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
Howard Hinnant
16775dccb9 Remove streaming for time_points with resolution greater...
than a day.

* cout << floor<years>(system_clock::now()) is very confusing.
* The aforementioned streaming operation is now a compile time error.
2015-08-03 22:13:20 -04:00
Howard Hinnant
94237ceaa7 Take into account that year::ok() may now return false. 2015-08-02 12:30:49 -04:00
Howard Hinnant
c99a40b846 Add year_month += and -= operators. 2015-08-01 19:16:33 -04:00
Howard Hinnant
2e715844bb Restrict the range of year:
to within the range of chrono::minutes.
* This prevents overflow when adding minutes to day_point
  when minutes is stored in 32 bits.
* Also added static checks on the range of hours and seconds.
  If these static checks fire, the range of year should be
  further reduced.
* This does not impact gcc at all.  It impacts clang only
  when targeting 32 bit architectures.  And it fixes
  overflow on Visual Studio.
* Thanks much to https://github.com/gmcode for the herculean
  effort in tracking this down.
2015-08-01 16:49:51 -04:00
Howard Hinnant
07361f9d86 Reduce technology down to what VS can handle. 2015-07-28 11:00:53 -04:00
Howard Hinnant
0c44d8c70d Specialize streaming operator for day_point. 2015-07-20 14:58:05 -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