nlib
DateTime.h
Go to the documentation of this file.
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_DATETIME_H_
4 #define INCLUDE_NN_NLIB_DATETIME_H_
5 
6 #include "nn/nlib/Config.h"
7 
8 #ifdef NLIB_CXX11_STDLIB_CHRONO
9 #include <chrono> // NOLINT
10 #endif
11 
12 NLIB_NAMESPACE_BEGIN
13 
14 // writes the duration in milliseconds from 2000/01/01.
16 
18  NLIB_EINVAL_IFNULL(t);
19  nlib_time time;
20  errno_t e = nlib_epochtime(&time);
21  if (e != 0) return e;
22  // 1970/01/01 -> 2000/01/01(in milliseconds)
23  *t = time / 10000 - (10957LL * 24LL * 60LL * 60LL * 1000LL);
24  return 0;
25 }
26 
27 // returns in milliseconds after the system boot.
28 inline uint64_t GetTickTime() NLIB_NOEXCEPT {
29  nlib_time t;
30  (void)nlib_ticktime(&t);
31  return static_cast<uint64_t>(t / 10000);
32 }
33 
34 // NOTE:
35 // TimeValue has a 64bit value, and 1 represents 100ns, 1ms is 10000.
36 // We can represent the time from A.D 1 to 9999 within 64bits.
39  NLIB_CEXPR explicit TimeValue(int64_t tick_) NLIB_NOEXCEPT : tick(tick_) {}
40 
42  tick += rhs.tick;
43  return *this;
44  }
46  tick -= rhs.tick;
47  return *this;
48  }
49  void Abs() NLIB_NOEXCEPT {
50  if (tick < 0) tick = -tick;
51  }
52  TimeValue operator-() const NLIB_NOEXCEPT { return TimeValue(-tick); }
53  TimeValue operator+() const NLIB_NOEXCEPT { return *this; }
54 
55  public:
56  int64_t tick; // nlib_time, nlib_duration
57 };
58 
59 inline bool operator==(const TimeValue& lhs, const TimeValue& rhs) NLIB_NOEXCEPT {
60  return lhs.tick == rhs.tick;
61 }
62 inline bool operator<(const TimeValue& lhs, const TimeValue& rhs) NLIB_NOEXCEPT {
63  return lhs.tick < rhs.tick;
64 }
65 inline bool operator!=(const TimeValue& lhs, const TimeValue& rhs) NLIB_NOEXCEPT {
66  return !(lhs == rhs);
67 }
68 inline bool operator>(const TimeValue& lhs, const TimeValue& rhs) NLIB_NOEXCEPT {
69  return rhs < lhs;
70 }
71 inline bool operator<=(const TimeValue& lhs, const TimeValue& rhs) NLIB_NOEXCEPT {
72  return !(lhs > rhs);
73 }
74 inline bool operator>=(const TimeValue& lhs, const TimeValue& rhs) NLIB_NOEXCEPT {
75  return !(lhs < rhs);
76 }
77 
78 inline TimeValue operator+(const TimeValue& lhs, const TimeValue& rhs) NLIB_NOEXCEPT {
79  TimeValue result(lhs);
80  result += rhs;
81  return result;
82 }
83 
84 inline TimeValue operator-(const TimeValue& lhs, const TimeValue& rhs) NLIB_NOEXCEPT {
85  TimeValue result(lhs);
86  result -= rhs;
87  return result;
88 }
89 
90 // TimeValue(tick_1d) is 1 day
91 NLIB_CEXPR const int64_t tick_1d = (10LL * 1000 * 1000 * 60 * 60 * 24);
92 
94  public:
95  NLIB_CEXPR TimeSpan() NLIB_NOEXCEPT : m_Value(0) {}
96  explicit TimeSpan(const TimeValue& rhs) NLIB_NOEXCEPT : m_Value(rhs) {}
97  NLIB_CEXPR explicit TimeSpan(int days) NLIB_NOEXCEPT
98  : m_Value(static_cast<int64_t>(days) * tick_1d) {}
99  NLIB_CEXPR TimeSpan(int days, int seconds) NLIB_NOEXCEPT
100  : m_Value(days* tick_1d + seconds*(10LL * 1000 * 1000)) {}
101  // TimeSpan(0, 0, 1) for 1msec
102  NLIB_CEXPR TimeSpan(int days, int seconds,
103  int milliseconds, int microseconds = 0) NLIB_NOEXCEPT
104  : m_Value(days* tick_1d + seconds*(10LL * 1000 * 1000) + milliseconds*(10LL * 1000) +
105  microseconds * 10LL) {}
106 
107  NLIB_VIS_PUBLIC void Get(int* days, int* seconds,
108  int* milliseconds, int* microseconds) NLIB_NOEXCEPT;
109 
110  TimeValue ToTimeValue() const NLIB_NOEXCEPT { return m_Value; }
111  int ToDays() const NLIB_NOEXCEPT {
112  return static_cast<int>(m_Value.tick / (10LL * 1000 * 1000 * 60 * 60 * 24));
113  }
114  int ToHours() const NLIB_NOEXCEPT {
115  return static_cast<int>(m_Value.tick / (10LL * 1000 * 1000 * 60 * 60));
116  }
117  int64_t ToMinutes() const NLIB_NOEXCEPT {
118  return m_Value.tick / (10 * 1000 * 1000 * 60);
119  }
120  int64_t ToSeconds() const NLIB_NOEXCEPT {
121  return m_Value.tick / (10 * 1000 * 1000);
122  }
123  int64_t ToMilliSeconds() const NLIB_NOEXCEPT {
124  return m_Value.tick / (10 * 1000);
125  }
126  int64_t ToMicroSeconds() const NLIB_NOEXCEPT {
127  return m_Value.tick / (10);
128  }
129 #ifdef NLIB_HAS_STDHEADER_TIME
130  template <class TIMEVAL>
131  void ToTimeVal(TIMEVAL* tv) const NLIB_NOEXCEPT {
132  int64_t usec = ToMicroSeconds();
133  int64_t sec = usec / (1000 * 1000);
134  tv->tv_sec = static_cast<time_t>(sec);
135  tv->tv_usec = static_cast<int32_t>(usec - sec * (1000 * 1000));
136  }
137  template <class TIMESPEC>
138  void ToTimeSpec(TIMESPEC* tp) const NLIB_NOEXCEPT {
139  int64_t usec = ToMicroSeconds();
140  int64_t sec = usec / (1000 * 1000);
141  tp->tv_sec = static_cast<time_t>(sec);
142  tp->tv_nsec = static_cast<long>(usec - sec * (1000 * 1000)) * 1000; // NOLINT
143  }
144 #endif
145 #ifdef NLIB_CXX11_STDLIB_CHRONO
146  template <class Rep, class Period>
147  TimeSpan(const std::chrono::duration<Rep, Period>& rhs) { // NOLINT
148  auto tmp = std::chrono::duration_cast<std::chrono::microseconds>(rhs);
149  m_Value.tick = static_cast<nlib_duration>(tmp.count() * 10);
150  }
151  template <class T>
152  T ToChrono() const {
153  auto tmp = std::chrono::microseconds(m_Value.tick / 10);
154  return std::chrono::duration_cast<T>(tmp);
155  }
156 #endif
157 
158  public:
159  TimeSpan& operator+=(const TimeSpan& rhs) NLIB_NOEXCEPT {
160  m_Value += rhs.m_Value;
161  return *this;
162  }
163  TimeSpan& operator-=(const TimeSpan& rhs) NLIB_NOEXCEPT {
164  m_Value -= rhs.m_Value;
165  return *this;
166  }
167  TimeSpan& operator*=(int i) NLIB_NOEXCEPT {
168  m_Value.tick *= i;
169  return *this;
170  }
171  TimeSpan& operator*=(double d) NLIB_NOEXCEPT {
172  m_Value.tick = static_cast<int64_t>(m_Value.tick * d);
173  return *this;
174  }
175  void Abs() NLIB_NOEXCEPT { m_Value.Abs(); }
176  TimeSpan operator-() const NLIB_NOEXCEPT { return TimeSpan(-m_Value); }
177  TimeSpan operator+() const NLIB_NOEXCEPT { return *this; }
178  bool operator==(const TimeSpan& rhs) const NLIB_NOEXCEPT {
179  return m_Value == rhs.m_Value;
180  }
181  bool operator!=(const TimeSpan& rhs) const NLIB_NOEXCEPT {
182  return m_Value != rhs.m_Value;
183  }
184  bool operator<(const TimeSpan& rhs) const NLIB_NOEXCEPT {
185  return m_Value < rhs.m_Value;
186  }
187  bool operator>(const TimeSpan& rhs) const NLIB_NOEXCEPT {
188  return m_Value > rhs.m_Value;
189  }
190  bool operator<=(const TimeSpan& rhs) const NLIB_NOEXCEPT {
191  return m_Value <= rhs.m_Value;
192  }
193  bool operator>=(const TimeSpan& rhs) const NLIB_NOEXCEPT {
194  return m_Value >= rhs.m_Value;
195  }
196 
197  private:
198  TimeValue m_Value;
199 };
200 
201 inline TimeSpan operator+(const TimeSpan& lhs, const TimeSpan& rhs) NLIB_NOEXCEPT {
202  TimeSpan result(lhs);
203  result += rhs;
204  return result;
205 }
206 
207 inline TimeSpan operator-(const TimeSpan& lhs, const TimeSpan& rhs) NLIB_NOEXCEPT {
208  TimeSpan result(lhs);
209  result -= rhs;
210  return result;
211 }
212 
213 inline TimeSpan operator*(int i, const TimeSpan& rhs) NLIB_NOEXCEPT {
214  TimeSpan result(rhs);
215  result *= i;
216  return result;
217 }
218 
219 inline TimeSpan operator*(double d, const TimeSpan& rhs) NLIB_NOEXCEPT {
220  TimeSpan result(rhs);
221  result *= d;
222  return result;
223 }
224 
225 inline TimeSpan operator*(const TimeSpan& lhs, int i) NLIB_NOEXCEPT {
226  TimeSpan result(lhs);
227  result *= i;
228  return result;
229 }
230 
231 inline TimeSpan operator*(const TimeSpan& lhs, double d) NLIB_NOEXCEPT {
232  TimeSpan result(lhs);
233  result *= d;
234  return result;
235 }
236 
237 // has year/month/day/hour/min/sec/msec/usec
239  int year;
240  int month;
241  int day;
242  int hour;
243  int min;
244  int sec;
245  int msec;
246  int usec;
247 };
248 
250  public:
251  // WEEK_SUNDAY -> WEEK_SATURDAY
252  enum Week {
253  WEEK_SUNDAY = 0,
260  WEEK_MAX
261  };
262 
263  public:
264  NLIB_CEXPR DateTime() NLIB_NOEXCEPT : m_Value(INT64_MIN) {}
265  // You can omit min/sec/msec/usec.
266  NLIB_VIS_PUBLIC errno_t Init(int year, int month, int day, int hour = 0,
267  int min = 0, int sec = 0, int msec = 0,
268  int usec = 0) NLIB_NOEXCEPT;
269  NLIB_VIS_PUBLIC errno_t Init(const DateTimeParams& rhs) NLIB_NOEXCEPT;
270  // nlib_epochtime(&t); dt.Init(TimeValue(t)); for example
271  errno_t Init(const TimeValue& tv) NLIB_NOEXCEPT {
272  m_Value = tv;
273  return IsValid() ? 0 : EINVAL;
274  }
275  // you can pass null pointers
276  NLIB_VIS_PUBLIC errno_t GetDay(int* year, int* month, int* day) const NLIB_NOEXCEPT;
277  // you can pass null pointers
278  NLIB_VIS_PUBLIC errno_t GetTime(int* hour, int* min, int* sec,
279  int* msec, int* usec) const NLIB_NOEXCEPT;
281 
282  TimeValue ToTimeValue() const NLIB_NOEXCEPT { return m_Value; }
283  NLIB_VIS_PUBLIC bool IsValid() const NLIB_NOEXCEPT;
284 
285  // 01-01 becomes 0.
286  NLIB_VIS_PUBLIC errno_t GetDayOfYear(int* nth) const NLIB_NOEXCEPT;
287  // Sunday -> 0(WEEK_SUNDAY), Saturday -> 6(WEEK_SATURDAY)
288  NLIB_VIS_PUBLIC errno_t GetDayOfWeek(Week* week) const NLIB_NOEXCEPT;
289  // returns EINVAL on failure
290  NLIB_VIS_PUBLIC errno_t Add(const TimeSpan& rhs) NLIB_NOEXCEPT;
291  // returns EINVAL on failure
292  NLIB_VIS_PUBLIC errno_t AddYears(int value) NLIB_NOEXCEPT;
293  // returns EINVAL on failure
294  NLIB_VIS_PUBLIC errno_t AddMonths(int value) NLIB_NOEXCEPT;
295  // returns EINVAL on failure
296  NLIB_VIS_PUBLIC errno_t AddDays(double value) NLIB_NOEXCEPT;
297  // returns EINVAL on failure
298  NLIB_VIS_PUBLIC errno_t AddHours(double value) NLIB_NOEXCEPT;
299  // returns EINVAL on failure
300  NLIB_VIS_PUBLIC errno_t AddMinutes(double value) NLIB_NOEXCEPT;
301  // returns EINVAL on failure
302  NLIB_VIS_PUBLIC errno_t AddSeconds(double value) NLIB_NOEXCEPT;
303  // returns EINVAL on failure
304  NLIB_VIS_PUBLIC errno_t AddMilliSeconds(double value) NLIB_NOEXCEPT;
305  // returns EINVAL on failure
306  NLIB_VIS_PUBLIC errno_t AddMicroSeconds(double value) NLIB_NOEXCEPT;
307 
308  // "1994-11-05T13:15:30Z" for example
309  NLIB_VIS_PUBLIC errno_t ToW3cDtf(char(&str)[32], const TimeSpan& zone) const NLIB_NOEXCEPT;
310  errno_t ToW3cDtf(char (&str)[32]) const NLIB_NOEXCEPT { return ToW3cDtf(str, TimeSpan()); }
311 
312  // "Tue, 02 Sep 2014 10:51:34 +0900" for example
313  NLIB_VIS_PUBLIC errno_t ToRfc2822(char(&str)[32], const TimeSpan& zone) const NLIB_NOEXCEPT;
314  errno_t ToRfc2822(char (&str)[32]) const NLIB_NOEXCEPT { return ToRfc2822(str, TimeSpan()); }
315 
316  // "Wed Jan 02 02:03:45 1980\n" for example
317  NLIB_VIS_PUBLIC errno_t ToAscTime(char(&str)[26]) const NLIB_NOEXCEPT;
318 
319  NLIB_SAFE_BOOL(DateTime, IsValid())
320 
321  public:
322  NLIB_VIS_PUBLIC DateTime& operator+=(const TimeSpan& rhs) NLIB_NOEXCEPT;
323  NLIB_VIS_PUBLIC DateTime& operator-=(const TimeSpan& rhs) NLIB_NOEXCEPT;
324  bool operator==(const DateTime& rhs) const NLIB_NOEXCEPT {
325  return m_Value == rhs.m_Value;
326  }
327  bool operator!=(const DateTime& rhs) const NLIB_NOEXCEPT {
328  return m_Value != rhs.m_Value;
329  }
330  bool operator<(const DateTime& rhs) const NLIB_NOEXCEPT {
331  return m_Value < rhs.m_Value;
332  }
333  bool operator>(const DateTime& rhs) const NLIB_NOEXCEPT {
334  return m_Value > rhs.m_Value;
335  }
336  bool operator<=(const DateTime& rhs) const NLIB_NOEXCEPT {
337  return m_Value <= rhs.m_Value;
338  }
339  bool operator>=(const DateTime& rhs) const NLIB_NOEXCEPT {
340  return m_Value >= rhs.m_Value;
341  }
342 
343 #ifdef NLIB_CXX11_STDLIB_CHRONO
344  template <class Clock, class Duration>
345  errno_t Init(const std::chrono::time_point<Clock, Duration>& rhs) {
346  auto tmp = std::chrono::duration_cast<std::chrono::microseconds>(rhs.time_since_epoch());
347  m_Value.tick = static_cast<nlib_duration>(tmp.count() * 10);
348  return 0;
349  }
350  template <class T>
351  T ToChrono() const {
352  auto tmp = std::chrono::microseconds(m_Value.tick / 10);
353  return T(tmp);
354  }
355 #endif
356 
357  public:
358  static bool IsLeapYear(int year) NLIB_NOEXCEPT {
359  return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
360  }
361  NLIB_VIS_PUBLIC static errno_t GetNow(DateTime* p) NLIB_NOEXCEPT;
362  // January has 31 days for example
363  NLIB_VIS_PUBLIC static int GetDaysInMonth(int year, int month) NLIB_NOEXCEPT;
364  // can parse W3CDTF, RFC2822, or ASCTIME
365  NLIB_VIS_PUBLIC static errno_t Parse(const char* str, DateTime* dt,
366  TimeSpan* delta) NLIB_NOEXCEPT NLIB_NONNULL;
367 
368  private:
369  TimeValue m_Value;
370 };
371 
372 inline errno_t DateTime::Init(const DateTimeParams& rhs) NLIB_NOEXCEPT {
373  return this->Init(rhs.year, rhs.month, rhs.day, rhs.hour, rhs.min, rhs.sec, rhs.msec, rhs.usec);
374 }
375 
376 inline errno_t DateTime::Add(const TimeSpan& rhs) NLIB_NOEXCEPT {
377  m_Value += rhs.ToTimeValue();
378  return IsValid() ? 0 : ERANGE;
379 }
380 
381 inline errno_t DateTime::AddDays(double value) NLIB_NOEXCEPT {
382  TimeSpan d(1);
383  d *= value;
384  return this->Add(d);
385 }
386 
387 inline errno_t DateTime::AddHours(double value) NLIB_NOEXCEPT {
388  TimeSpan d(0, 60 * 60);
389  d *= value;
390  return this->Add(d);
391 }
392 
393 inline errno_t DateTime::AddMinutes(double value) NLIB_NOEXCEPT {
394  TimeSpan d(0, 60);
395  d *= value;
396  return this->Add(d);
397 }
398 
399 inline errno_t DateTime::AddSeconds(double value) NLIB_NOEXCEPT {
400  TimeSpan d(0, 1);
401  d *= value;
402  return this->Add(d);
403 }
404 
405 inline errno_t DateTime::AddMilliSeconds(double value) NLIB_NOEXCEPT {
406  TimeSpan d(0, 0, 1);
407  d *= value;
408  return this->Add(d);
409 }
410 
411 inline errno_t DateTime::AddMicroSeconds(double value) NLIB_NOEXCEPT {
412  TimeSpan d(0, 0, 0, 1);
413  d *= value;
414  return this->Add(d);
415 }
416 
417 inline DateTime& DateTime::operator+=(const TimeSpan& rhs) NLIB_NOEXCEPT {
418  this->Add(rhs);
419  return *this;
420 }
421 
422 inline DateTime& DateTime::operator-=(const TimeSpan& rhs) NLIB_NOEXCEPT {
423  *this += (-rhs);
424  return *this;
425 }
426 
427 inline DateTime operator+(const DateTime& lhs, const TimeSpan& rhs) NLIB_NOEXCEPT {
428  DateTime tmp(lhs);
429  tmp += rhs;
430  return tmp;
431 }
432 
433 inline DateTime operator-(const DateTime& lhs, const TimeSpan& rhs) NLIB_NOEXCEPT {
434  DateTime tmp(lhs);
435  tmp -= rhs;
436  return tmp;
437 }
438 
439 inline TimeSpan operator-(const DateTime& lhs, const DateTime& rhs) NLIB_NOEXCEPT {
440  return TimeSpan(lhs.ToTimeValue() - rhs.ToTimeValue());
441 }
442 
443 NLIB_NAMESPACE_END
444 
445 #endif // INCLUDE_NN_NLIB_DATETIME_H_
bool operator<(const TimeValue &lhs, const TimeValue &rhs) noexcept
A relational operator.
Definition: DateTime.h:62
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
Definition: Platform.h:2151
int64_t tick
These can be used for nlib_time and nlib_duration.
Definition: DateTime.h:56
TimeSpan & operator*=(int i) noexcept
Multiplies the time by i.
Definition: DateTime.h:167
int min
The minute (0-59).
Definition: DateTime.h:243
TimeSpan & operator-=(const TimeSpan &rhs) noexcept
Subtracts time.
Definition: DateTime.h:163
bool operator==(const TimeSpan &rhs) const noexcept
Returns true if the time is the same.
Definition: DateTime.h:178
static bool IsLeapYear(int year) noexcept
Checks whether the specified year is a leap year.
Definition: DateTime.h:358
int year
The year (1-9999).
Definition: DateTime.h:239
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
errno_t nlib_ticktime(nlib_duration *t)
Gets the elapsed time since the system was last started.
#define NLIB_NONNULL
Indicates that you cannot specify NULL for all arguments.
Definition: Platform_unix.h:66
#define NLIB_SAFE_BOOL(class_name, exp)
Defines a safe operator bool function in the class. Uses the C++11 explicit bool if it is available f...
Definition: Config.h:141
errno_t ToW3cDtf(char(&str)[32]) const noexcept
Calls ToW3cDtf(str, TimeSpan()).
Definition: DateTime.h:310
bool operator<(const TimeSpan &rhs) const noexcept
Returns true if smaller than rhs.
Definition: DateTime.h:184
TimeSpan operator-() const noexcept
A unary operator.
Definition: DateTime.h:176
int64_t ToMinutes() const noexcept
Returns the time as a number of minutes. Fractions are truncated.
Definition: DateTime.h:117
TimeSpan & operator+=(const TimeSpan &rhs) noexcept
Adds time.
Definition: DateTime.h:159
errno_t ToRfc2822(char(&str)[32]) const noexcept
Calls ToRfc2822(str, TimeSpan()).
Definition: DateTime.h:314
bool operator<=(const TimeSpan &rhs) const noexcept
Returns true if equal to or smaller than rhs.
Definition: DateTime.h:190
TimeSpan operator*(const TimeSpan &lhs, double d) noexcept
Increases rhs by a factor of d.
Definition: DateTime.h:231
int msec
The millisecond (0-999).
Definition: DateTime.h:245
bool operator<=(const TimeValue &lhs, const TimeValue &rhs) noexcept
A relational operator.
Definition: DateTime.h:71
int64_t ToSeconds() const noexcept
Returns the time in terms of a number of seconds. Fractions are truncated.
Definition: DateTime.h:120
bool operator==(const HeapHash &rhs, const HeapHash &lhs)
Returns true if the two compared summaries are equal.
Definition: NMalloc.h:101
bool operator!=(const HeapHash &rhs, const HeapHash &lhs)
Returns true if the two compared summaries are not equal.
Definition: NMalloc.h:106
bool operator<=(const DateTime &rhs) const noexcept
Returns true if the same or further in the past than rhs.
Definition: DateTime.h:336
int64_t nlib_time
The type expressing the time in increments of 100 ns from the zero starting point of 1970-01-01...
Definition: Platform.h:533
DateTime operator+(const DateTime &lhs, const TimeSpan &rhs) noexcept
Returns the time that is the rhs amount of time into the future from lhs.
Definition: DateTime.h:427
The class for representing the date and time.
Definition: DateTime.h:249
uint64_t GetTickTime() noexcept
Returns the time in units of milliseconds that has elapsed since the system started.
Definition: DateTime.h:28
int hour
The hour (0-23).
Definition: DateTime.h:242
int sec
The second (0-59).
Definition: DateTime.h:244
constexpr TimeSpan() noexcept
Instantiates the object and initializes the time to 0.
Definition: DateTime.h:95
#define NLIB_CEXPR
Defines constexpr if it is available for use. If not, holds an empty string.
Week
Constants representing the days of the week.
Definition: DateTime.h:252
The structure for setting date and time information in DateTime and for getting that information from...
Definition: DateTime.h:238
TimeSpan operator-(const DateTime &lhs, const DateTime &rhs) noexcept
Returns the duration between the times of rhs and lhs.
Definition: DateTime.h:439
errno_t GetNintendoTime(int64_t *t) noexcept
Returns the amount of time that has elapsed, in units of milliseconds, starting from 2000-01-01...
Definition: DateTime.h:17
bool operator>=(const TimeValue &lhs, const TimeValue &rhs) noexcept
A relational operator.
Definition: DateTime.h:74
bool operator>=(const DateTime &rhs) const noexcept
Returns true if the same or further in the future than rhs.
Definition: DateTime.h:339
errno_t nlib_epochtime(nlib_time *t)
Gets the current time.
A file that contains the configuration information for each development environment.
int usec
The microsecond (0-999).
Definition: DateTime.h:246
int ToDays() const noexcept
Returns the time in terms of a number of days. Fractions are truncated.
Definition: DateTime.h:111
TimeValue operator-() const noexcept
A unary operator.
Definition: DateTime.h:52
TimeValue ToTimeValue() const noexcept
Returns a TimeValue object.
Definition: DateTime.h:282
bool operator>(const TimeValue &lhs, const TimeValue &rhs) noexcept
A relational operator.
Definition: DateTime.h:68
constexpr TimeSpan(int days) noexcept
Initializes the object with a number of days specified for the period of time.
Definition: DateTime.h:97
TimeSpan operator+() const noexcept
A unary operator.
Definition: DateTime.h:177
TimeValue ToTimeValue() const noexcept
Converts to a TimeValue object.
Definition: DateTime.h:110
int month
The month (1-12).
Definition: DateTime.h:240
int64_t ToMicroSeconds() const noexcept
Returns the time in terms of a number of microseconds. Fractions are truncated.
Definition: DateTime.h:126
bool operator>=(const TimeSpan &rhs) const noexcept
Returns true if equal to or larger than rhs.
Definition: DateTime.h:193
int64_t ToMilliSeconds() const noexcept
Returns the time in terms of a number of milliseconds. Fractions are truncated.
Definition: DateTime.h:123
#define NLIB_VIS_PUBLIC
Symbols for functions and classes are made available outside of the library.
Definition: Platform_unix.h:51
TimeSpan(const TimeValue &rhs) noexcept
Initializes using a TimeValue object.
Definition: DateTime.h:96
The class for representing the time.
Definition: DateTime.h:93
constexpr DateTime() noexcept
Instantiates the object with default parameters (default constructor). Initializes with an invalid ti...
Definition: DateTime.h:264
bool operator<(const DateTime &rhs) const noexcept
Returns true if further in the past than rhs.
Definition: DateTime.h:330
constexpr TimeSpan(int days, int seconds) noexcept
Initializes the object with a number of days and a number of seconds specified for the period of time...
Definition: DateTime.h:99
constexpr TimeValue() noexcept
Instantiates the object with default parameters (default constructor).
Definition: DateTime.h:38
bool operator>(const TimeSpan &rhs) const noexcept
Returns true if larger than rhs.
Definition: DateTime.h:187
constexpr TimeValue(int64_t tick_) noexcept
Initializes with the values of nlib_time and nlib_duration taken as the arguments.
Definition: DateTime.h:39
bool operator!=(const TimeSpan &rhs) const noexcept
Returns true if the time is different.
Definition: DateTime.h:181
TimeSpan & operator*=(double d) noexcept
Multiplies the time by d.
Definition: DateTime.h:171
int ToHours() const noexcept
Returns the time span as a number of hours. Fractions are truncated.
Definition: DateTime.h:114
constexpr TimeSpan(int days, int seconds, int milliseconds, int microseconds=0) noexcept
Initializes the object with a number of days, seconds, milliseconds, and microseconds specified for t...
Definition: DateTime.h:102
The class that wraps 64-bit signed integers.
Definition: DateTime.h:37
TimeValue & operator-=(const TimeValue &rhs) noexcept
Subtracts.
Definition: DateTime.h:45
int64_t nlib_duration
The type expressing the time in increments of 100 ns. A 64-bit signed integer.
Definition: Platform.h:535
TimeValue & operator+=(const TimeValue &rhs) noexcept
Adds.
Definition: DateTime.h:41
TimeValue operator+() const noexcept
A unary operator.
Definition: DateTime.h:53
bool operator>(const DateTime &rhs) const noexcept
Returns true if further in the future than rhs.
Definition: DateTime.h:333
int day
The day (1-).
Definition: DateTime.h:241
bool operator!=(const DateTime &rhs) const noexcept
Returns true if the time is not equal to rhs.
Definition: DateTime.h:327
int errno_t
Indicates with an int-type typedef that a POSIX error value is returned as the return value...
Definition: NMalloc.h:24