Handle delayed date in notification at the end of the month
At specific dates, notification won't contain the date when router will reboot automatically.
Žádosti o restart zařízení
===============================
The system was updated, but some changes will take effect only after reboot. Please reboot the device.
Zařízení bude automaticky restartováno dne . <--- date should be here
The culprit is that we don't actually handle end of the month properly and just add N days of delay. So for example:
220131 => 2022/01/31
220131 + 3 (delay) = 220134 => 2022/01/34
https://gitlab.nic.cz/turris/user-notify/-/blob/master/src/scripts/notifier#L159
Actually sometimes the updated date works fine, for example:
# 2022/02/28 + 3 == 2022/02/31 => 2022/03/03
$ date "+%y%m%d%H%M" -d 2202310550
2203030550
But the formatting %d
does not allow day outside range (1, 31), therefore even if "2022/02/31" is nonsense date, it is handled fine by date
command.
On the other hand other, another nonsense date "2022/01/34" won't be processed, because the 34th day is outside of the range of the %d
.