[Home]

Summary:ASTERISK-11789: STRPTIME does not respect time dayligh saving time
Reporter:Johan Wilfer (johan)Labels:
Date Opened:2008-04-06 20:27:11Date Closed:2008-04-07 14:03:56
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20080407__bug12374.diff.txt
Description:STRPTIME is an hour off because of daylight saving time.

This dialplan:
 Set(datewithtz=${STRFTIME(${EPOCH},Europe/Stockholm,%Y-%m-%d %H:%M:%S)});
 Set(datenotz=${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)});
 Noop(${STRPTIME(${datewithtz},GMT-2,%Y-%m-%d %H:%M:%S)});
 Noop(${STRPTIME(${datewithtz},Europe/Stockholm,%Y-%m-%d %H:%M:%S)});
 Noop(${EPOCH});

prints this:
Set("datewithtz=2008-04-07 03:22:08") in new stack
Set("datenotz=2008-04-07 03:22:08") in new stack
NoOp("1207531328") in new stack   <--- this one is right (workaround)
NoOp("1207534928") in new stack   <--- this one is wrong (should work)
NoOp("1207531328") in new stack   <--- this is EPOCH.

As you see the result is off by an hour. STRFTIME works fine but STRPTIME does not.
Comments:By: dea (dea) 2008-04-07 11:49:42

The function strptime does not know about DST, but as it happens
the problem is actually with the call to ast_mktime.

By setting t.tm.tm_isdst to -1 before calling ast_mktime, the
ast_mktime will determine if DST rules are in effect.

This would be a one-liner fix in funcs/func_strings.c around
line 707.

By: Digium Subversion (svnbot) 2008-04-07 12:46:59

Repository: asterisk
Revision: 113117

U   branches/1.4/funcs/func_strings.c

------------------------------------------------------------------------
r113117 | tilghman | 2008-04-07 12:46:57 -0500 (Mon, 07 Apr 2008) | 3 lines

Force ast_mktime() to check for DST, since strptime(3) does not.
(Closes issue ASTERISK-11789)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=113117

By: Digium Subversion (svnbot) 2008-04-07 14:01:56

Repository: asterisk
Revision: 113172

_U  trunk/
U   trunk/funcs/func_strings.c

------------------------------------------------------------------------
r113172 | tilghman | 2008-04-07 14:01:55 -0500 (Mon, 07 Apr 2008) | 11 lines

Merged revisions 113117 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r113117 | tilghman | 2008-04-07 12:51:49 -0500 (Mon, 07 Apr 2008) | 3 lines

Force ast_mktime() to check for DST, since strptime(3) does not.
(Closes issue ASTERISK-11789)

........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=113172

By: Digium Subversion (svnbot) 2008-04-07 14:03:56

Repository: asterisk
Revision: 113173

_U  branches/1.6.0/
U   branches/1.6.0/funcs/func_strings.c

------------------------------------------------------------------------
r113173 | tilghman | 2008-04-07 14:03:56 -0500 (Mon, 07 Apr 2008) | 19 lines

Merged revisions 113172 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
r113172 | tilghman | 2008-04-07 14:06:46 -0500 (Mon, 07 Apr 2008) | 11 lines

Merged revisions 113117 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r113117 | tilghman | 2008-04-07 12:51:49 -0500 (Mon, 07 Apr 2008) | 3 lines

Force ast_mktime() to check for DST, since strptime(3) does not.
(Closes issue ASTERISK-11789)

........

................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=113173