Summary: | ASTERISK-14104: STRFTIME returns incorrect time | ||
Reporter: | Alec Davis (alecdavis) | Labels: | |
Date Opened: | 2009-05-11 06:52:02 | Date Closed: | 2011-06-07 14:08:10 |
Priority: | Minor | Regression? | No |
Status: | Closed/Complete | Components: | Functions/func_strings |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ||
Description: | For NZ (GMT+12) function STRFTIME seems to require GMT-12 to get the date and time right. by example, the date and time now in NZ is 11th May 2009 , 11:27PM Dialplan code: exten => _9.,1,NoOp(${STRFTIME(${EPOCH},GMT-12,%Z %z %C%y%m%d%H%M)}) exten => _9.,n,Set(CallTime=${STRFTIME(${EPOCH},GMT-12,%C%y%m%d%H%M)}) exten => _9.,n,Set(CALLFILENAME=${CallTime}_${CALLERID(num)}) Console output: The Date and Time are correct. 200905112327 -- Executing [9045609100@outbound:1] NoOp("SIP/100-09fc4128", "NZST +1200 200905112327") in new stack -- Executing [9045609100@outbound:2] Set("SIP/100-09fc4128", "CallTime=200905112327") in new stack System time: ======================================== asterisk:/# date Mon May 11 23:27:44 NZST 2009 asterisk:/# ****** ADDITIONAL INFORMATION ****** Using NZST as the time zone it incorrectly reports +0000 offset. ==================================================== exten => _9.,1,NoOp(${STRFTIME(${EPOCH},NZST,%Z %z %C%y%m%d%H%M)}) exten => _9.,n,Set(CallTime=${STRFTIME(${EPOCH},NZST,%C%y%m%d%H%M)}) exten => _9.,n,Set(CALLFILENAME=${CallTime}_${CALLERID(num)}) -- Executing [9045609100@outbound:1] NoOp("SIP/100-0a1584c0", "NZST +0000 200905111139") in new stack -- Executing [9045609100@outbound:2] Set("SIP/100-0a1584c0", "CallTime=200905111139") in new stack Using GMT+12 we go back a day, but at least the time is right. =============================== Dialplan code: exten => _9.,1,NoOp(${STRFTIME(${EPOCH},GMT+12,%Z %z %C%y%m%d%H%M)}) exten => _9.,n,Set(CallTime=${STRFTIME(${EPOCH},GMT+12,%C%y%m%d%H%M)}) Console output: -- Executing [9045609100@outbound:1] NoOp("SIP/100-0a11bf78", "NZST -1200 200905102342") in new stack -- Executing [9045609100@outbound:2] Set("SIP/100-0a11bf78", "CallTime=200905102342") in new stack | ||
Comments: | By: Tilghman Lesher (tilghman) 2009-05-11 11:13:36 ls -l /usr/share/zoneinfo/NZST ls: cannot access /usr/share/zoneinfo/NZST: No such file or directory When localtime cannot find the zoneinfo file, it reverts to using GMT. I suspect the zone you want is REALLY "NZ" or "NZ-CHAT": ls -l /usr/share/zoneinfo/NZ* -rw-r--r-- 1 root root 2434 2009-03-30 09:55 /usr/share/zoneinfo/NZ -rw-r--r-- 1 root root 2018 2009-03-30 09:55 /usr/share/zoneinfo/NZ-CHAT By: Alec Davis (alecdavis) 2009-05-11 15:59:59 not sure that explains the "GMT-12" changing to "+1200". The timezone offset parameter '%z' prints +1200 when timezone is set to 'GMT-12' In all cases, the timezone parameter '%Z' always printed "NZST" dialplan code: exten => _9.,1,NoOp(${STRFTIME(${EPOCH},GMT-12,%Z %z %C%y%m%d%H%M)}) printed Console output: The Date and Time are correct. 200905112327 -- Executing [9045609100@outbound:1] NoOp("SIP/100-09fc4128", "NZST +1200 200905112327") in new stack By: Tilghman Lesher (tilghman) 2009-05-11 16:16:02 alecdavis: that is 100% dependent upon the contents of the zoneinfo file. This is therefore not an Asterisk issue. If you want to contest the values within your zoneinfo file, please open an issue with your Linux distribution. |