Skip to content

nshlib/nsh_timcmds.c: fix incorrect time set during summer time#3458

Merged
acassis merged 1 commit intoapache:masterfrom
michallenc:date-fix
Apr 17, 2026
Merged

nshlib/nsh_timcmds.c: fix incorrect time set during summer time#3458
acassis merged 1 commit intoapache:masterfrom
michallenc:date-fix

Conversation

@michallenc
Copy link
Copy Markdown
Contributor

Summary

Value zero in tm_isdst means daylight saving time (or summer time) is not in effect. This is obviously not true for half of the year in most timezones and keeping it at zero leads to incorrect time being set. This commit sets tm_isdst to -1, which means the information is not available and it should be handled according to timezone rules.

Impact

Fixes time set with date command.

Testing

On custom device with Europe/Prague (UTC+2 now in summer time, otherwise UTC+1) timezone set.

Before the fix -> both local and UTC time not correctly set:

vtk25> date -s "Sep 15 11:30:00 2023"
vtk25> date
Fri, Sep 15 12:30:01 2023
vtk25> date -u
Fri, Sep 15 10:30:02 2023

After the fix (tested both with and without daylight saving):

vtk25> date -s "Sep 15 11:30:00 2023"
vtk25> date
Fri, Sep 15 11:30:01 2023
vtk25> date -u
Fri, Sep 15 09:30:05 2023
vtk25> date -s "Jan 15 11:30:00 2023"
vtk25> date
Sun, Jan 15 11:30:01 2023
vtk25> date -u
Sun, Jan 15 10:30:03 2023
vtk25> 

Tests if no timezone is uploaded

vtk25> date -s "Sep 15 11:30:00 2023"
vtk25> date
Fri, Sep 15 11:30:02 2023
vtk25> date -u
Fri, Sep 15 11:30:04 2023
vtk25> 
vtk25> date -s "Jan 15 11:30:00 2023"
vtk25> date
Sun, Jan 15 11:30:01 2023
vtk25> date -u
Sun, Jan 15 11:30:02 2023
vtk25> 

Value zero in tm_isdst means daylight saving time (or summer
time) is not in effect. This is obviously not true for half of the year
in most timezones and keeping it at zero leads to incorrect time
being set. This commit sets tm_isdst to -1, which means the information
is not available and it should be handled according to timezone rules.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
Copy link
Copy Markdown
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michallenc nice finding!

@acassis acassis merged commit 8e9f5a8 into apache:master Apr 17, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants