nlib
DateTime.h
[詳解]
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
nlib_time, nlib_durationとして利用することができます。
Definition: DateTime.h:70
void Abs() noexcept
時間が負である場合には符号を反転します。
Definition: DateTime.h:63
TimeSpan & operator*=(int i) noexcept
時間をi で乗算します。
Definition: DateTime.h:156
TimeValue ToTimeValue() const noexcept
TimeValueオブジェクトに変換します。
Definition: DateTime.h:112
void Abs() noexcept
時間が負である場合には符号を反転します。
Definition: DateTime.h:164
int64_t ToMilliSeconds() const noexcept
時間をミリ秒数にして返します。端数は切り捨てられます。
Definition: DateTime.h:121
int min
分(0-59)
Definition: DateTime.h:225
TimeSpan & operator-=(const TimeSpan &rhs) noexcept
時間を減算します。
Definition: DateTime.h:152
static constexpr bool IsLeapYear(int year) noexcept
閏年かどうかをチェックします。
Definition: DateTime.h:323
int year
年(1-9999)
Definition: DateTime.h:221
errno_t ToW3cDtf(char(&str)[32]) const noexcept
ToW3cDtf(str, TimeSpan()) を呼び出します。
Definition: DateTime.h:290
errno_t nlib_ticktime(nlib_duration *t)
ブートからの経過時間を取得します。
#define NLIB_SAFE_BOOL(class_name, exp)
クラス内に安全なoperator bool()を定義します。 可能であればC++11のexplicit boolを利用します。 ...
Definition: Config.h:199
#define NLIB_NONNULL_1
1番目の引数にNULLを指定することができないことを示します。
int64_t ToSeconds() const noexcept
時間を秒数にして返します。端数は切り捨てられます。
Definition: DateTime.h:120
TimeSpan & operator+=(const TimeSpan &rhs) noexcept
時間を加算します。
Definition: DateTime.h:148
void ToTimeVal(TIMEVAL *tv) const noexcept
データを秒数とマイクロ秒数に分割して格納します。
Definition: DateTime.h:124
TimeSpan operator*(const TimeSpan &lhs, double d) noexcept
rhs を d 倍します。
Definition: DateTime.h:213
int ToHours() const noexcept
時間を一時間単位の値として返します。端数は切り捨てられます。
Definition: DateTime.h:116
int msec
ミリ秒(0-999)
Definition: DateTime.h:227
bool operator==(const HeapHash &rhs, const HeapHash &lhs)
2つのサマリを比較して等価ならば、trueを返します。
Definition: NMalloc.h:130
int64_t nlib_time
1970/01/01を起点(0)としてから100ns刻みで時刻を表現する型です。64bit符号付き整数です。 ...
Definition: Platform.h:452
errno_t ToRfc2822(char(&str)[32]) const noexcept
ToRfc2822(str, TimeSpan()) を呼び出します。
Definition: DateTime.h:294
DateTime operator+(const DateTime &lhs, const TimeSpan &rhs) noexcept
lhs から rhs だけ未来の時刻を返します。
Definition: DateTime.h:413
日時を表すクラスです。
Definition: DateTime.h:231
static bool IsRfc3339(const nlib_utf8_t *str) noexcept
上記関数の引数省略版で、ヌル終端する文字列を受け取ります。
Definition: DateTime.h:339
#define NLIB_VIS_PUBLIC
関数やクラス等のシンボルをライブラリの外部に公開します。
Definition: Platform_unix.h:87
void ToTimeSpec(struct timespec *tm) const noexcept
timespec構造体の値に変換します。
Definition: DateTime.h:133
uint64_t GetTickTime() noexcept
システムを起動した後の経過時間をミリ秒単位で返します。
Definition: DateTime.h:42
TimeSpan(const struct timespec *tm) noexcept
timespec構造体からオブジェクトを構築します。
Definition: DateTime.h:130
TimeValue operator+() const noexcept
単項演算子です。
Definition: DateTime.h:67
int hour
時(0-23)
Definition: DateTime.h:224
int sec
秒(0-59)
Definition: DateTime.h:226
#define NLIB_NONNULL_2
2番目の引数にNULLを指定することができないことを示します。
TimeValue operator-() const noexcept
単項演算子です。
Definition: DateTime.h:66
constexpr TimeSpan() noexcept
デフォルトコンストラクタです。 時間を0で初期化します。
Definition: DateTime.h:99
int ToDays() const noexcept
時間を日数にして返します。端数は切り捨てられます。
Definition: DateTime.h:113
Week
曜日を表す定数です。
Definition: DateTime.h:234
void ToTimeSpec(struct timespec *tm) const noexcept
timespec構造体の値に変換します。
Definition: DateTime.h:307
日時情報をDateTimeに設定したりDateTimeから取得するための構造体です。
Definition: DateTime.h:220
TimeSpan operator-(const DateTime &lhs, const DateTime &rhs) noexcept
時刻rhs から時刻lhs までの時間を返します。
Definition: DateTime.h:425
errno_t GetNintendoTime(int64_t *t) noexcept
2000/01/01を起点とした経過時間をミリ秒単位で返します。
Definition: DateTime.h:31
TimeSpan operator+() const noexcept
単項演算子です。
Definition: DateTime.h:166
errno_t nlib_epochtime(nlib_time *t)
現在時刻を取得します。
bool operator<(const DateTime &lhs, const DateTime &rhs) noexcept
lhsがrhsより過去の時刻ならtrueを返します。
Definition: DateTime.h:353
static errno_t Parse(const char *str, DateTime *dt, TimeSpan *delta)
ヌル終端する文字列をパースします。ヌル終端する前にパースされない文字に到達した場合へエラーになります...
Definition: DateTime.h:333
#define NLIB_NOEXCEPT
環境に合わせてnoexcept 又は同等の定義がされます。
Definition: Config.h:109
#define NLIB_CEXPR
利用可能であればconstexprが定義されます。そうでない場合は空文字列です。
Definition: Config.h:111
開発環境別の設定が書かれるファイルです。
int usec
マイクロ秒(0-999)
Definition: DateTime.h:228
TimeSpan operator-() const noexcept
単項演算子です。
Definition: DateTime.h:165
constexpr TimeSpan(int days) noexcept
期間として日数を指定して初期化します。
Definition: DateTime.h:101
size_t nlib_strlen(const char *s)
内部でstrlen()を呼び出します。独自の実装が動作する場合もあります。
int month
月(1-12)
Definition: DateTime.h:222
TimeSpan(const TimeValue &rhs) noexcept
TimeValue オブジェクトを用いて初期化します。
Definition: DateTime.h:100
TimeValue ToTimeValue() const noexcept
TimeValueオブジェクトを返します。
Definition: DateTime.h:262
#define NLIB_FINAL
利用可能であればfinalが定義されます。そうでない場合は空文字列です。
Definition: Config.h:250
時間を表すクラスです。
Definition: DateTime.h:97
constexpr DateTime() noexcept
デフォルトコンストラクタです。 無効な時刻で初期化します。
Definition: DateTime.h:246
constexpr TimeSpan(int days, int seconds) noexcept
期間として日数と秒を指定して初期化します。
Definition: DateTime.h:103
constexpr TimeValue() noexcept
デフォルトコンストラクタです。
Definition: DateTime.h:52
int64_t ToMicroSeconds() const noexcept
時間をマイクロ秒数にして返します。端数は切り捨てられます。
Definition: DateTime.h:122
constexpr TimeValue(int64_t tick_) noexcept
nlib_time, nlib_durationの値を引数にして初期化します。
Definition: DateTime.h:53
TimeSpan & operator*=(double d) noexcept
時間をd で乗算します。
Definition: DateTime.h:160
constexpr TimeSpan(int days, int seconds, int milliseconds, int microseconds=0) noexcept
期間として日数,秒,ミリ秒,マイクロ秒を指定して初期化します。
Definition: DateTime.h:106
64bitの符号付き整数をラップするクラスです。
Definition: DateTime.h:51
#define NLIB_NONNULL
全ての引数にNULLを指定することができないことを示します。
TimeValue & operator-=(const TimeValue &rhs) noexcept
減算します。
Definition: DateTime.h:59
int64_t nlib_duration
100ns刻みで時間を表現する型です。64bit符号付き整数です。
Definition: Platform.h:454
int64_t ToMinutes() const noexcept
時間を分数にして返します。端数は切り捨てられます。
Definition: DateTime.h:119
TimeValue & operator+=(const TimeValue &rhs) noexcept
加算します。
Definition: DateTime.h:55
char nlib_utf8_t
charのtypedefです。文字列がUTF-8であることを示します。
Definition: Platform.h:303
int errno_t
intのtypedefで、戻り値としてPOSIXのエラー値を返すことを示します。
Definition: NMalloc.h:37