0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C++ Builder XE4, 10.2 Tokyo > DateUtils > MilliSecondsBetween > 秒とミリ秒の違いをミリ秒の単位で返す

Last updated at Posted at 2018-01-05
動作環境
C++ Builder XE4
RAD Studio 10.2 Tokyo Update 2

Returns the number of milliseconds between two specified TDateTime values.

Call MilliSecondsBetween to obtain the difference, in milliseconds, between two TDateTime values.

MilliSecondsBetween always returns a positive result and therefore the parameter values are interchangeable.

SecondsBetween()という関数は「秒の違い」を「秒の単位」で返す。

MilliSecondsBetween()は「秒とミリ秒の違い」を「ミリ秒の単位」で返す。
「ミリ秒の違い」を「ミリ秒の単位」で返す、のではない。
例として、9909ミリ秒などが返される。

想定される失敗

__int64 interval_sec = SecondsBetween(Now(), nextdt);
__int64 interval_msec = MilliSecondsBetween(Now(), nextdt);

/* (interval_sec * 1000 + interval_msec)ミリ秒後の処理 */

上記を実装すると9.9秒差の場合に18.9秒後の処理になってしまう(秒の差のダブルカウント)。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?