MCPcopy Create free account
hub / github.com/catboost/catboost / YDayToMonthAndDay

Function YDayToMonthAndDay

util/draft/datetime.cpp:24–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22 };
23
24 void YDayToMonthAndDay(ui32 yday, bool isleap, ui32* month, ui32* mday) {
25 const ui32* begin = MonthDaysNewYear[isleap] + 1;
26 const ui32* end = begin + 12;
27 // [31, ..., 365] or [31, ..., 366] (12 elements)
28
29 const ui32* pos = UpperBound(begin, end, yday);
30 Y_ENSURE(pos != end, "day no. " << yday << " does not exist in " << (isleap ? "leap" : "non-leap") << " year");
31
32 *month = pos - begin;
33 *mday = yday - *(pos - 1) + 1;
34
35 Y_ASSERT((*month < 12) && (1 <= *mday) && (*mday <= MonthDays[isleap][*month]));
36 }
37
38 struct TTimeData {
39 i32 IsDst = 0;

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 1

UpperBoundFunction · 0.85

Tested by

no test coverage detected