```
milovidov-desktop :) SELECT toString(toDateTime('-922337203.6854775808', 1))

SELECT toString(toDateTime('-922337203.6854775808', 1))

Query id: 3d51ba80-4993-4f64-b6ef-da0c0f1bdf43

┌─toString(toDateTime('-922337203.6854775808', 1))─┐
│ 2106-02-07 :rE:�.6                                │
└──────────────────────────────────────────────────┘
```
{
        YearWeek yw(0, 0);
        UInt16 offset_day = monday_first_mode ? 0U : 1U;
        
        yw.first = toYear(DayNum(d + 7 - toDayOfWeek(DayNum(d + offset_day))));
        DayNum first_day = makeDayNum(yw.first, 1, 1);
        DayNum this_day = d;
        if (monday_first_mode)
        {
            
            first_day = toFirstDayNumOfWeek(first_day);
            this_day = toFirstDayNumOfWeek(d);
        }
        else
        {
            
            if (toDayOfWeek(first_day) != 7)
                first_day = DayNum(first_day - toDayOfWeek(first_day));
            if (toDayOfWeek(d) != 7)
                this_day = DayNum(d - toDayOfWeek(d));
        }
        yw.second = (this_day - first_day) / 7 + 1;
        return yw;
    }
    /**
     * get first day of week with week_mode, return Sunday or Monday
     */
    inline DayNum toFirstDayNumOfWeek(DayNum d, UInt8 week_mode) const