Reproduces on master.

```
SELECT toDateTime64('2021-03-22', 3, 'Asia/Tehran')

Query id: 26f7c373-f473-4209-8976-6ada79a8627f

┌─toDateTime64('2021-03-22', 3, 'Asia/Tehran')─┐
│                      2157-04-28 06:28:16.000 │
└──────────────────────────────────────────────┘
```
{
        return d;
    }
    template <typename DateOrTime>
    inline ExtendedDayNum toDayNum(DateOrTime v) const
    {
        return ExtendedDayNum{static_cast<ExtendedDayNum::UnderlyingType>(toLUTIndex(v).toUnderType() - daynum_offset_epoch)};
    }
    
    template <typename DateOrTime>
    inline Time toFirstDayOfWeek(DateOrTime v) const
    {
        const LUTIndex i = toLUTIndex(v);
        return lut[i - (lut[i].day_of_week - 1)].date;
    }
    template <typename DateOrTime>
    inline ExtendedDayNum toFirstDayNumOfWeek(DateOrTime v) const
    {
        const LUTIndex i = toLUTIndex(v);
        return toDayNum(i - (lut[i].day_of_week - 1));
    }
    
    template <typename DateOrTime>
    inline Time toFirstDayOfMonth(DateOrTime v) const
    {
        const LUTIndex i = toLUTIndex(v);
        return lut[i - (lut[i].day_of_month - 1)].date;
    }
    template <typename DateOrTime>
    inline ExtendedDayNum toFirstDayNumOfMonth(DateOrTime v) const