Skip to content

Commit 0c576d4

Browse files
committed
[共通] Timer の残り時間(秒)を切り上げて取得する Timer::s_ceil() #1233
1 parent f10b18a commit 0c576d4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Siv3D/include/Siv3D/Timer.hpp

+12
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ namespace s3d
168168
[[nodiscard]]
169169
double usF() const;
170170

171+
/// @brief 残り時間を [秒] で返します。小数点以下は切り上げられます。
172+
/// @remark 例えば、残り 2.1 秒の場合は 3 を返します
173+
/// @return 残り時間 [秒]
174+
[[nodiscard]]
175+
int32 s_ceil() const;
176+
177+
/// @brief 残り時間を [秒] で返します。小数点以下は切り上げられます。
178+
/// @remark 例えば、残り 2.1 秒の場合は 3 を返します
179+
/// @return 残り時間 [秒]
180+
[[nodiscard]]
181+
int64 s64_ceil() const;
182+
171183
/// @brief 設定されているカウントダウン時間を返します。
172184
/// @return 設定されているカウントダウン時間
173185
[[nodiscard]]

Siv3D/src/Siv3D/Timer/SivTimer.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,16 @@ namespace s3d
220220
return static_cast<double>(us());
221221
}
222222

223+
int32 Timer::s_ceil() const
224+
{
225+
return static_cast<int32>(s64_ceil());
226+
}
227+
228+
int64 Timer::s64_ceil() const
229+
{
230+
return static_cast<int64>(std::ceil(usF() / (1000LL * 1000LL)));
231+
}
232+
223233
Duration Timer::duration() const
224234
{
225235
return SecondsF{ m_durationMicrosec / static_cast<double>(1000LL * 1000LL) };

0 commit comments

Comments
 (0)