@@ -57,19 +57,19 @@ namespace Firebird {
5757class NoThrowTimeStamp
5858{
5959public:
60- static const ISC_DATE MIN_DATE = -678575 ; // 01.01.0001
61- static const ISC_DATE MAX_DATE = 2973483 ; // 31.12.9999
62- static const ISC_DATE UNIX_DATE = 40587 ; // 01.01.1970
60+ static constexpr ISC_DATE MIN_DATE = -678575 ; // 01.01.0001
61+ static constexpr ISC_DATE MAX_DATE = 2973483 ; // 31.12.9999
62+ static constexpr ISC_DATE UNIX_DATE = 40587 ; // 01.01.1970
6363
64- static const SINT64 SECONDS_PER_DAY = 24 * 60 * 60 ;
65- static const SINT64 ISC_TICKS_PER_DAY = SECONDS_PER_DAY * ISC_TIME_SECONDS_PRECISION;
64+ static constexpr SINT64 SECONDS_PER_DAY = 24 * 60 * 60 ;
65+ static constexpr SINT64 ISC_TICKS_PER_DAY = SECONDS_PER_DAY * ISC_TIME_SECONDS_PRECISION;
6666
6767 static const ISC_TIMESTAMP MIN_TIMESTAMP;
6868 static const ISC_TIMESTAMP MAX_TIMESTAMP;
6969
7070private:
71- static const ISC_DATE BAD_DATE = MAX_SLONG;
72- static const ISC_TIME BAD_TIME = MAX_ULONG;
71+ static constexpr ISC_DATE BAD_DATE = MAX_SLONG;
72+ static constexpr ISC_TIME BAD_TIME = MAX_ULONG;
7373
7474public:
7575 // Number of the first day of UNIX epoch in GDS counting
@@ -78,39 +78,39 @@ class NoThrowTimeStamp
7878 static const ISC_TIME POW_10_TABLE[];
7979
8080 // Constructors
81- NoThrowTimeStamp ()
81+ NoThrowTimeStamp () noexcept
8282 {
8383 invalidate ();
8484 }
8585
86- NoThrowTimeStamp (const ISC_TIMESTAMP& from)
86+ NoThrowTimeStamp (const ISC_TIMESTAMP& from) noexcept
8787 : mValue (from)
8888 {}
8989
90- NoThrowTimeStamp (ISC_DATE date, ISC_TIME time)
90+ NoThrowTimeStamp (ISC_DATE date, ISC_TIME time) noexcept
9191 {
9292 mValue .timestamp_date = date;
9393 mValue .timestamp_time = time;
9494 }
9595
96- explicit NoThrowTimeStamp (const struct tm & times, int fractions = 0 )
96+ explicit NoThrowTimeStamp (const struct tm & times, int fractions = 0 ) noexcept
9797 {
9898 encode (×, fractions);
9999 }
100100
101- bool isValid () const
101+ bool isValid () const noexcept
102102 {
103103 return isValidTimeStamp (mValue );
104104 }
105105
106106 // Check if timestamp contains a non-existing value
107- bool isEmpty () const
107+ bool isEmpty () const noexcept
108108 {
109109 return (mValue .timestamp_date == BAD_DATE && mValue .timestamp_time == BAD_TIME);
110110 }
111111
112112 // Set value of timestamp to a non-existing value
113- void invalidate ()
113+ void invalidate () noexcept
114114 {
115115 mValue .timestamp_date = BAD_DATE;
116116 mValue .timestamp_time = BAD_TIME;
@@ -126,32 +126,32 @@ class NoThrowTimeStamp
126126 }
127127
128128 // Encode timestamp from UNIX datetime structure
129- void encode (const struct tm * times, int fractions = 0 );
129+ void encode (const struct tm * times, int fractions = 0 ) noexcept ;
130130
131131 // Decode timestamp into UNIX datetime structure
132- void decode (struct tm * times, int * fractions = NULL ) const ;
132+ void decode (struct tm * times, int * fractions = NULL ) const noexcept ;
133133
134134 // Write access to timestamp structure we wrap
135- ISC_TIMESTAMP& value () { return mValue ; }
135+ ISC_TIMESTAMP& value () noexcept { return mValue ; }
136136
137137 // Read access to timestamp structure we wrap
138- const ISC_TIMESTAMP& value () const { return mValue ; }
138+ const ISC_TIMESTAMP& value () const noexcept { return mValue ; }
139139
140140 // Return current timestamp value
141141 static NoThrowTimeStamp getCurrentTimeStamp (const char ** error) noexcept ;
142142
143143 // Validation routines
144- static bool isValidDate (const ISC_DATE ndate)
144+ static constexpr bool isValidDate (const ISC_DATE ndate) noexcept
145145 {
146146 return (ndate >= MIN_DATE && ndate <= MAX_DATE);
147147 }
148148
149- static bool isValidTime (const ISC_TIME ntime)
149+ static constexpr bool isValidTime (const ISC_TIME ntime) noexcept
150150 {
151151 return (ntime < 24 * 3600 * ISC_TIME_SECONDS_PRECISION);
152152 }
153153
154- static bool isValidTimeStamp (const ISC_TIMESTAMP ts)
154+ static constexpr bool isValidTimeStamp (const ISC_TIMESTAMP ts) noexcept
155155 {
156156 return (isValidDate (ts.timestamp_date ) && isValidTime (ts.timestamp_time ));
157157 }
@@ -165,25 +165,24 @@ class NoThrowTimeStamp
165165 static void decode_time (ISC_TIME ntime, int * hours, int * minutes, int * seconds, int * fractions = NULL ) noexcept ;
166166 static void decode_timestamp (const ISC_TIMESTAMP ntimestamp, struct tm * times, int * fractions = NULL ) noexcept ;
167167
168- static void add10msec (ISC_TIMESTAMP* v, SINT64 msec, SINT64 multiplier);
169- static void round_time (ISC_TIME& ntime, const int precision);
168+ static void add10msec (ISC_TIMESTAMP* v, SINT64 msec, SINT64 multiplier) noexcept ;
169+ static void round_time (ISC_TIME& ntime, const int precision) noexcept ;
170170
171- static int convertGregorianDateToWeekDate (const struct tm & times);
172- static int convertGregorianDateToJulianDate (int year, int month, int day);
173- static void convertJulianDateToGregorianDate (int jdn, int & outYear, int & outMonth, int & outDay);
171+ static int convertGregorianDateToWeekDate (const struct tm & times) noexcept ;
172+ static int convertGregorianDateToJulianDate (int year, int month, int day) noexcept ;
173+ static void convertJulianDateToGregorianDate (int jdn, int & outYear, int & outMonth, int & outDay) noexcept ;
174174
175- static inline bool isLeapYear (const int year) noexcept
175+ static constexpr bool isLeapYear (const int year) noexcept
176176 {
177177 return (year % 4 == 0 && year % 100 != 0 ) || (year % 400 == 0 );
178178 }
179179
180- static SINT64 timeStampToTicks (ISC_TIMESTAMP ts)
180+ static constexpr SINT64 timeStampToTicks (ISC_TIMESTAMP ts) noexcept
181181 {
182- const SINT64 ticks = (ts.timestamp_date - MIN_DATE) * ISC_TICKS_PER_DAY + ts.timestamp_time ;
183- return ticks;
182+ return (static_cast <SINT64>(ts.timestamp_date ) - MIN_DATE) * ISC_TICKS_PER_DAY + ts.timestamp_time ;
184183 }
185184
186- static ISC_TIMESTAMP ticksToTimeStamp (SINT64 ticks)
185+ static constexpr ISC_TIMESTAMP ticksToTimeStamp (SINT64 ticks) noexcept
187186 {
188187 ISC_TIMESTAMP ts;
189188 ts.timestamp_date = (ticks / ISC_TICKS_PER_DAY) + MIN_DATE;
0 commit comments