MCPcopy Create free account
hub / github.com/comaps/comaps / GetUnixtimeByWeekday

Function GetUnixtimeByWeekday

libs/platform/platform_tests_support/helpers.cpp:20–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20time_t GetUnixtimeByWeekday(uint16_t year, Month month, Weekday weekday, uint8_t hours, uint8_t minutes)
21{
22 int monthDay = 1;
23 auto createUnixtime = [&]()
24 {
25 std::tm t{};
26 t.tm_year = year - 1900;
27 t.tm_mon = static_cast<int>(month) - 1;
28 t.tm_mday = monthDay;
29 t.tm_wday = static_cast<int>(weekday) - 1;
30 t.tm_hour = hours;
31 t.tm_min = minutes;
32 return std::mktime(&t);
33 };
34
35 for (; monthDay < 32; ++monthDay)
36 {
37 auto const unixtime = createUnixtime();
38 auto const timeOut = std::localtime(&unixtime);
39 if (timeOut->tm_wday == static_cast<int>(weekday) - 1)
40 return unixtime;
41 }
42
43 UNREACHABLE();
44}
45} // namespace platform::tests_support

Callers 3

UNIT_TESTFunction · 0.85
UNIT_CLASS_TESTFunction · 0.85
UNIT_TESTFunction · 0.85

Calls

no outgoing calls

Tested by 3

UNIT_TESTFunction · 0.68
UNIT_CLASS_TESTFunction · 0.68
UNIT_TESTFunction · 0.68