From eaf13f53eeaba8f6ffe5f2e38ff51eefd273046d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 4 Sep 2018 16:15:39 +0200 Subject: Add timestamp_unreal special value --- libbutl/timestamp.cxx | 3 +++ libbutl/timestamp.mxx | 15 +++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/libbutl/timestamp.cxx b/libbutl/timestamp.cxx index b0bb9ad..bba0865 100644 --- a/libbutl/timestamp.cxx +++ b/libbutl/timestamp.cxx @@ -273,6 +273,9 @@ namespace butl if (ts == timestamp_nonexistent) return os << ""; + + if (ts == timestamp_unreal) + return os << ""; } time_t t (system_clock::to_time_t (ts)); diff --git a/libbutl/timestamp.mxx b/libbutl/timestamp.mxx index af44680..76c7978 100644 --- a/libbutl/timestamp.mxx +++ b/libbutl/timestamp.mxx @@ -56,19 +56,26 @@ LIBBUTL_MODEXPORT namespace butl using timestamp = system_clock::time_point; using duration = system_clock::duration; - // Generally-useful special values. Note that unknown is less than - // nonexistent and is less than any non-special value. + // Generally-useful special values. + // + // Note that unknown is less than nonexistent which in turn is less than + // unreal and all of them are less than any non-special value (strictly + // speaking unreal is no greater (older) than any real value). // #if defined(__cpp_modules) && defined(__clang__) //@@ MOD Clang duplicate sym. inline const timestamp::rep timestamp_unknown_rep = -1; inline const timestamp timestamp_unknown = timestamp (duration (-1)); inline const timestamp::rep timestamp_nonexistent_rep = 0; inline const timestamp timestamp_nonexistent = timestamp (duration (0)); + inline const timestamp::rep timestamp_unreal_rep = 1; + inline const timestamp timestamp_unreal = timestamp (duration (1)); #else const timestamp::rep timestamp_unknown_rep = -1; const timestamp timestamp_unknown = timestamp (duration (-1)); const timestamp::rep timestamp_nonexistent_rep = 0; const timestamp timestamp_nonexistent = timestamp (duration (0)); + const timestamp::rep timestamp_unreal_rep = 1; + const timestamp timestamp_unreal = timestamp (duration (1)); #endif // Print human-readable representation of the timestamp. @@ -86,8 +93,8 @@ LIBBUTL_MODEXPORT namespace butl // part is padded to 9 characters with leading zeros. // // The special argument in the to_stream() function indicates whether the - // special timestamp_unknown and timestamp_nonexistent values should be - // printed as '' and '', respectively. + // special timestamp_{unknown,nonexistent,unreal} values should be printed + // as '', '', and '', respectively. // // The local argument in the to_stream() function indicates whether to use // localtime_r() or gmtime_r(). -- cgit v1.1