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