| 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; |
no test coverage detected