I set system time and RTC to the following values.
date -s 2021.08.30-09:59:30 >/dev/null 2>/dev/null //set system time
hwclock -w //sync RTC to system time
Also, /etc/TZ (which is the same file as /etc/localtime in busybox
) is saved as
LMT0:00LMT-1:00,M5.5.1/10,M8.5.1/10
where it means that DST will be in effect at 10:00 a.m. on Monday, last week in May; and will be deactivated at 10:00 a.m. on Monday, last week in August.
I deliberately set the system time and RTC to 30 seconds earlier than the end date of DST, so as to observe system behaviour.
When DST is gone, system time (also RTC maybe?) should be substracted by one hour back.
The following is the result, and it's obvious that only system time is subtracted by one hour, NOT both system time and RTC.
~ # cat /etc/TZ
LMT0:00LMT-1:00,M5.5.1/10,M8.5.1/10
~ # date -s 2021.08.30-09:59:30 >/dev/null 2>/dev/null
~ # hwclock -w
~ #
~ # date
Mon Aug 30 09:59:36 LMT 2021
~ # hwclock
Mon Aug 30 09:59:42 2021 0.000000 seconds
~ #
~ #
~ # date
Mon Aug 30 09:59:49 LMT 2021
~ # hwclock
Mon Aug 30 09:59:53 2021 0.000000 seconds
~ # date
Mon Aug 30 09:00:00 LMT 2021
~ # hwclock
Mon Aug 30 10:00:03 2021 0.000000 seconds
~ # date
Mon Aug 30 09:00:05 LMT 2021
~ # hwclock
Mon Aug 30 10:00:06 2021 0.000000 seconds
However, it behaves differently on the other hand! This time I want to observe system behaviour when entering DST.
With /etc/TZ being saved as
LMT0:00LMT-1:00,M8.5.1/10,M12.5.1/10
where it means that DST will be in effect at 10:00 a.m. on Monday, last week in August; and will be deactivated at 10:00 a.m. on Monday, last week in December.
Also, I set system time and RTC to the following values.
date -s 2021.08.30-09:59:30 >/dev/null 2>/dev/null //set system time
hwclock -w //sync RTC to system time
When DST is in effect, system time (also RTC maybe?) should be added by one hour ahead.
The following is the result, and it's obvious that BOTH system time and RTC is added by one hour.
~ # cat /etc/TZ
LMT0:00LMT-1:00,M8.5.1/10,M12.5.1/10
~ # date -s 2021.08.30-09:59:30 >/dev/null 2>/dev/null
~ # hwclock -w
~ #
~ # date
Mon Aug 30 09:59:35 LMT 2021
~ # hwclock
Mon Aug 30 09:59:37 2021 0.000000 seconds
~ # date
Mon Aug 30 09:59:48 LMT 2021
~ # hwclock
Mon Aug 30 09:59:51 2021 0.000000 seconds
~ # date
Mon Aug 30 11:00:04 LMT 2021
~ # hwclock
Mon Aug 30 11:00:06 2021 0.000000 seconds
I wonder why this contradictory behavior occurs.