nlib
nn::nlib::TimeSpan クラスfinal

時間を表すクラスです。 [詳解]

#include "nn/nlib/DateTime.h"

公開メンバ関数

void Get (int *days, int *seconds, int *milliseconds, int *microseconds) noexcept
 時間を日数,秒,ミリ秒,マイクロ秒の単位に分けて取得します。 [詳解]
 
TimeValue ToTimeValue () const noexcept
 TimeValueオブジェクトに変換します。
 
int ToDays () const noexcept
 時間を日数にして返します。端数は切り捨てられます。
 
int ToHours () const noexcept
 時間を一時間単位の値として返します。端数は切り捨てられます。
 
int64_t ToMinutes () const noexcept
 時間を分数にして返します。端数は切り捨てられます。
 
int64_t ToSeconds () const noexcept
 時間を秒数にして返します。端数は切り捨てられます。
 
int64_t ToMilliSeconds () const noexcept
 時間をミリ秒数にして返します。端数は切り捨てられます。
 
int64_t ToMicroSeconds () const noexcept
 時間をマイクロ秒数にして返します。端数は切り捨てられます。
 
 TimeSpan (const struct timespec *tm) noexcept
 timespec構造体からオブジェクトを構築します。
 
void ToTimeSpec (struct timespec *tm) const noexcept
 timespec構造体の値に変換します。
 
TimeSpanoperator+= (const TimeSpan &rhs) noexcept
 時間を加算します。
 
TimeSpanoperator-= (const TimeSpan &rhs) noexcept
 時間を減算します。
 
TimeSpanoperator*= (int i) noexcept
 時間をi で乗算します。
 
TimeSpanoperator*= (double d) noexcept
 時間をd で乗算します。
 
TimeSpan operator- () const noexcept
 単項演算子です。
 
TimeSpan operator+ () const noexcept
 単項演算子です。
 
基本的なメンバ関数
constexpr TimeSpan () noexcept
 時間を 0 で初期化するコンストラクタです。
 
 TimeSpan (const TimeValue &rhs) noexcept
 TimeValue オブジェクトを用いて初期化します。
 
constexpr TimeSpan (int days) noexcept
 期間として日数を指定して初期化します。 [詳解]
 
constexpr TimeSpan (int days, int seconds) noexcept
 期間として日数と秒を指定して初期化します。 [詳解]
 
constexpr TimeSpan (int days, int seconds, int milliseconds, int microseconds=0) noexcept
 期間として日数,秒,ミリ秒,マイクロ秒を指定して初期化します。 [詳解]
 

詳解

時間を表すクラスです。

説明
100ナノ秒を1単位として64bit整数で時間を表しています。 各種演算子を用いてTimeSpanの加算・減算・比較等を行うことができます。
DateTime& dt = ....;
TimeSpan span(0, 60 * 60 * 10); // 10時間
DateTime dt_plus_10 = dt + span; // 10時間進める
なお、うるう秒は考慮されていません。
各種例:
misc/datetime/datetime.cpp, misc/threading/callonce/callonce.cpp, misc/threading/simpleringbuffer/simpleringbuffer.cpp, misc/threading/tls/tls.cpp, msgpack/jsonrpc/jsonrpc.cpp, msgpack/jsonrpc/server.cpp.

DateTime.h97 行目に定義があります。

構築子と解体子

◆ TimeSpan() [1/3]

nn::nlib::TimeSpan::TimeSpan ( int  days)
inlineexplicitnoexcept

期間として日数を指定して初期化します。

引数
[in]days日数

DateTime.h101 行目に定義があります。

◆ TimeSpan() [2/3]

nn::nlib::TimeSpan::TimeSpan ( int  days,
int  seconds 
)
inlinenoexcept

期間として日数と秒を指定して初期化します。

引数
[in]days日数
[in]seconds秒数

DateTime.h103 行目に定義があります。

◆ TimeSpan() [3/3]

nn::nlib::TimeSpan::TimeSpan ( int  days,
int  seconds,
int  milliseconds,
int  microseconds = 0 
)
inlinenoexcept

期間として日数,秒,ミリ秒,マイクロ秒を指定して初期化します。

引数
[in]days日数
[in]seconds
[in]millisecondsミリ秒
[in]microsecondsマイクロ秒

DateTime.h106 行目に定義があります。

関数詳解

◆ Get()

nn::nlib::TimeSpan::Get ( int *  days,
int *  seconds,
int *  milliseconds,
int *  microseconds 
)
noexcept

時間を日数,秒,ミリ秒,マイクロ秒の単位に分けて取得します。

引数
[out]days日数が設定されます。
[out]seconds秒数が設定されます。
[out]millisecondsミリ秒が設定されます。
[out]microsecondsマイクロ秒が設定されます。

このクラス詳解は次のファイルから抽出されました: