111 Commits

Author SHA1 Message Date
Tomasz Kamiński
5345d135b7 Implemented custom time zone deduction test.
Implemented test for deduction from the custom time zone ptr.
Used OffsetZone extracted for that purpose.
2019-09-01 14:43:50 -04:00
Tomasz Kamiński
1d721d9afd Implemented set of basic deduction test.
Implemented test for deduction from string, string_view,
time_zone ptr and other zoned_time.
2019-09-01 14:43:50 -04:00
Paul Dreik
6f0b645df1 #388 add comment on unit test failure (#442) 2019-07-21 20:47:33 -04:00
tomaszkam
e31daf8093 Unit tests for !year_month::ok() arithmetic. (#425) 2019-03-19 20:22:23 -04:00
Howard Hinnant
b5d025ea2f Align time_of_day with hh_mm_ss
Per committee review
2019-03-19 19:50:30 -04:00
Howard Hinnant
5a62c405e0 Remove unneeded make_precision 2019-02-03 23:21:36 -05:00
Howard Hinnant
9cb0013aef Update time_of_day to be more consistent ...
the needs of formatting.
2019-02-02 14:06:12 -05:00
Howard Hinnant
8f91ef27ed Revert "Model the TAI-UTC difference between 1961 and 1972"
This reverts commit 1eed461d06b02854d9310d5ab0198eccd2be1d1d.
2018-11-08 13:56:23 -08:00
Howard Hinnant
1eed461d06 Model the TAI-UTC difference between 1961 and 1972 2018-10-03 17:51:55 -04:00
Howard Hinnant
6a4d93a0bd Silence more shadow warnings 2018-07-01 23:00:33 -04:00
tomaszkam
e86edc3820 Added missing license to unit test files (#356) 2018-06-23 10:39:00 -04:00
tomaszkam
f46885e632 Suffix d for days duration (#354) 2018-06-20 11:39:48 -04:00
Tomasz Kamiński
2d282e35fa Use string_literal for C++11 when possible 2018-06-19 19:37:02 -04:00
tomaszkam
af2b2b70b3 Remove usage of octal literals in tests (#350)
* Remove usage of octal literals

* Fixed July
2018-06-12 13:18:18 -04:00
Howard Hinnant
0197889505 Update to Sunday constants 2018-06-11 15:14:44 -04:00
Tomasz Kamiński
b86def339e Test for utc during leap second insertion 2018-06-11 10:45:41 -04:00
Tomasz Kamiński
aa0494b980 custom clock and noncastable tests 2018-06-11 10:45:41 -04:00
Tomasz Kamiński
df31560701 Moved test to clock_cast_test dir 2018-06-11 10:45:41 -04:00
Tomasz Kamiński
4b687f4c04 Test is now C++11 compatible 2018-06-11 10:45:41 -04:00
Tomasz Kamiński
db60c5eb8e Unit test and typo fix 2018-06-11 10:45:41 -04:00
Howard Hinnant
40b83654b6 [API BREAKING] Remove conversion from weekday to unsigned
* There has been a great deal of anguish over the encoding of
  weekdays:  whether [0, 6] maps to [Sunday, Saturday] or
  [1, 7] maps to [Monday, Sunday].  This commit attempts
  to address that issue, but will break a small amount of
  code at compile-time.  See below on how to fix that.

* The weekday constructor used to accept [0, 6] to represent
  [Sunday, Saturday].  It now accepts [0, 7] to represent
  [Sunday, Saturday] with both 0 and 7 mapping to Sunday.

* The conversion from weekday to unsigned has been removed.

* To convert a weekday to unsigned replace:

      auto u = unsigned{wd};

  with:

      auto u = (wd - Sunday).count();

  This maps [Sunday, Saturday] to [0, 6], which is the
  C/POSIX mapping.  If you prefer the ISO mapping
  ([Monday, Sunday] -> [1, 7]), then do:

      auto u = (wd - Monday).count() + 1;
2018-06-02 22:56:10 -04:00
Tomasz Kamiński
328cecaa56 Fixed addition of multi-year duration to year_month.
* Added new overloads for operator+/- between year_month and duration
  that is convertible to years, so it is better candidate for operands
  that are convertible to both years and months. To preserve
  functionality, this operator is conditionally noexcept.

* Reworked year_month_day, year_month_day_last, year_month_weekday,
  and year_month_weekday_last.

* Added tests for this new functionality.
2018-05-12 18:21:24 -04:00
Howard Hinnant
1d9e49ea21 to_stream sets failbit if unable to format
*  If a formatting flag requests data that is not available in
   the Streamable object, or if the Streamable object answers !ok(),
   failbit is set.
2018-04-06 11:19:44 -04:00
Harry Mallon
c311db2f1a Clean up tz_test README 2018-03-18 18:14:40 -04:00
Howard Hinnant
43d8a4eab0 Range check minutes under parse 2018-03-02 09:03:41 -05:00
Howard Hinnant
c513a20691 Fix off-by-one bug in iso_week::year_lastweek_weekday
* The conversion from year_lastweek_weekday to sys_days
  and local_days had an off by one error.
* Added test for this case.
2017-11-30 10:28:14 -05:00
Tomasz Kamiński
543315b700 Reversed order of arguments to clock_time_conversion.
Now the order of argument matches the clock_cast function.
The test only is_clock_castable trait still matches is_convertible
order of arguments.
2017-11-26 13:50:21 -05:00
Tomasz Kamiński
dd91be668e Added deprecated functions test for real 2017-11-24 23:42:18 +01:00
Tomasz Kamiński
b13c859ff1 Restored deprecated to_clock_time function.
Fixed the to_utc_time(const gps_time<Duration>& t) function
to correctly use clock_cast<utc_time>.

Added test to deprecated functions.
2017-11-24 23:37:32 +01:00
Tomasz Kamiński
9910f5fcc3 Moved clock_cast test to separate dir.
Fixed naqme of the to_sys_return_reference test, so it
is invoked.
2017-11-24 22:30:54 +01:00
Tomasz Kamiński
58a4a9518a Mismatch in return type of converting function is now hard error.
Change the implementation, in the way that mismatch in return
type of the from/to_sys/utc functions (not returning time_point,
or returning time_point with inappropriate clock) leads to
hard error.

Added appropariate fail test for to_sys function, including:
* returning an int
* returning time_point of wrong clock
* reutrning reference to time_point
2017-11-24 22:23:50 +01:00
Tomasz Kamiński
5a9b44a37a Implemented test for casting non-wall clocks and detecting that clocks cannot be casted.
Added test that detects if clock_cast<Dest>(Source) properly
SFINAEs if clock's are not castable, this includes test for
steady_clock that is not castable to any wall-clock.

Secondly added steady_based_clock based on steady_clock
(as name indicates), that clock_cast may be extended to clock
non-related to wall-time (sys/utc) using conversion traits.

Final example is pair of ambiguous clocks (amb1/amb2_clock) that can convert
to each other either using sys_clock or utc_clock.
Then the conversion from amb2 to amb1 is disambiguated
via trait specialization.
2017-11-24 18:08:00 +01:00
Tomasz Kamiński
a9d2907fa1 Implemented test for custom clocks derived from sys_clock.
Created mil_clock and s2s_clock, that are both using to_sys/from_sys
function and are fully interoperable with existing clocks (including
ones based on utc).

Implemented an trait is used to provide direct conversion
from s2s_clock to mil_clock without converting to sys_clock
(conversion counter is used for this purpose).
2017-11-24 18:07:33 +01:00
Tomasz Kamiński
bf5a4f3cd5 Implemented test for existing clocks.
Implemented test for conversions between existing clocks
(sys_clock, utc_clock, tai_clock, gps_clock) showing that
they can be used instead of to_clock_time functions.
2017-11-24 18:06:55 +01:00
Howard Hinnant
5563d31b2e Update validation.cpp for new directory structure 2017-10-24 12:06:50 -04:00
Howard Hinnant
fc917fe303 Port testit to new directory structure 2017-09-25 19:28:04 -04:00
Howard Hinnant
481771ef5e Add support down to femtosecond precision
* Requires platform specific use of 128bit integral representation
  (e.g. std::chrono::duration<__int128_t, std::femto>).
2017-09-09 10:30:39 -04:00
Howard Hinnant
aad6010831 Add test for custom time zone support 2017-08-31 10:44:07 -04:00
Howard Hinnant
9c181a1440 Update tests for default constructible:
* weekday_indexed
* year_month_weekday
2017-08-05 16:31:18 -04:00
Howard Hinnant
c8d3cc14da Add zoned_time deduction guides 2017-07-06 20:49:53 -04:00
Howard Hinnant
893cf51fd8 Add test for zoned_time 2017-07-06 20:49:28 -04:00
Howard Hinnant
aa4dafcc46 Silence sign conversion warnings 2017-06-12 13:33:47 -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
0fb3921e5b Fail if you need a valid year and don't parse one. 2017-05-20 23:04:49 -04:00
Howard Hinnant
f493bd67f2 Tweak white space parsing rules (again):
* White space matches zero or more white space characters.

  * %n matches one white space character.

  * %t matches zero or one white space characters.
2017-05-07 15:25:07 -04:00
Howard Hinnant
cf0481b9af Reset command, width and modified for %n and %t in from_stream. 2017-05-04 21:03:48 -04:00
Howard Hinnant
2f8997d3ed Make parse fail if fmt string is not completely consumed. 2017-04-18 12:02:21 -04:00
Howard Hinnant
3495c513a1 Enable parse and format for more types:
* year
    * month
    * day
    * weekday
    * year_month
    * month_day
2017-03-25 17:46:17 -04:00
Howard Hinnant
d110f07f59 Clean up time_of_day tests.
* Don't assume int64_t is the rep in the predefined chrono durations.
2017-03-14 11:05:33 -04:00
Howard Hinnant
1e7e7a214d Simplify the implementation of format and parse:
* For format, all a type must do is implement to_stream.

* For parse, each type X must specialize parse_manip<X,CharT,Traits>.
  Each specialization must include a public typedef to itself named
  type.

* Each parse_manip specialization must have a stream extraction
  operator.

* This commit depends on expression-SFINAE.  If this commit breaks
  your build, it is likely that your compiler/version does not
  support expression-SFINAE.  To fix this NO_EXPRESSION_SFINAE
  needs to be defined in the configuration area of date.h for
  that compiler/version.
2017-02-26 14:10:10 -05:00