5namespace Stroika::Foundation::Time {
15 Require (t < kMaxSecondsPerDay);
16 Assert (fTime_ < kMaxSecondsPerDay);
18 inline constexpr TimeOfDay::TimeOfDay (
unsigned int hour,
unsigned int minute,
unsigned int seconds)
19 : TimeOfDay{static_cast<uint32_t> (((hour * 60) + minute) * 60 + seconds)}
21 Assert (fTime_ < kMaxSecondsPerDay);
23 inline constexpr TimeOfDay TimeOfDay::kMin{0};
24 inline constexpr TimeOfDay TimeOfDay::kMax{TimeOfDay::kMaxSecondsPerDay - 1};
25 inline constexpr unsigned int TimeOfDay::GetAsSecondsCount ()
const
27 Ensure (fTime_ < kMaxSecondsPerDay);
30 constexpr uint8_t TimeOfDay::GetHours ()
const
32 uint32_t n = GetAsSecondsCount () / (60 * 60);
33 Ensure (0 <= n and n <= 23);
34 return static_cast<uint8_t
> (n);
36 constexpr uint8_t TimeOfDay::GetMinutes ()
const
38 uint32_t n = GetAsSecondsCount ();
39 n -= GetHours () * 60 * 60;
41 Ensure (0 <= n and n <= 59);
42 return static_cast<uint8_t
> (n);
44 constexpr uint8_t TimeOfDay::GetSeconds ()
const
46 uint32_t n = GetAsSecondsCount ();
47 n -= GetHours () * 60 * 60;
48 n -= GetMinutes () * 60;
49 Ensure (0 <= n and n <= 59);
50 return static_cast<uint8_t
> (n);
52 inline String TimeOfDay::ToString ()
const
String is like std::u32string, except it is much easier to use, often much more space efficient,...
constexpr TimeOfDay(TimeOfDay &&src) noexcept=default