bugGNU Octave - Bugs: bug #53909, localtime() does not access TZ on...

 
 

bug #53909: localtime() does not access TZ on windows

Submitter:  Ian McCallion <ianmcc>
Submitted:  Tue 15 May 2018 12:14:24 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * 4.4.0 Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 15 May 2018 12:14:24 PM UTC, original submission:  

This script should produce different values for t1, t2 and t3 because they should be representing the current time in three different timezones (unless you are already in CST of course):

     x = time ();
     t1 = localtime (x)
     setenv TZ UTC0
     t2 = localtime (x)
     setenv TZ CST6CDT
     t3 = localtime (x)
     unsetenv TZ


The script works on unix versions of Octave, but at least on Octave Windows 4.2.2 and 4.4.0, after running this t1==t2==t3=

    usec =  140346
    sec =  41
    min =  35
    hour =  8
    mday =  12
    mon =  4
    year =  118
    wday =  6
    yday =  131
    isdst =  1
    gmtoff = 0
    zone = GMT Daylight Time


This next script however DOES produce correct values for t1, t2 and t3.

     x = time ();
     t1 = localtime (x)
     setenv TZ UTC0
     mktime(localtime(1)); % Force Octave to access the TZ environment variable
     t2 = localtime (x)
     setenv TZ CST6CDT
     mktime(localtime(1)); % Force Octave to access the TZ environment variable
     t3 = localtime (x)
     unsetenv TZ
     mktime(localtime(1)); % Force Octave to access the TZ environment variable


The reason this works and the first script didn't is probably a bug that the posix layer shipped with windows versions of Octave where tzset() is not called by localtime() and possible other timezone-dependent functions. If necessary (i.e. can't fix the posix layer) it should be fixed in Octave, by explicitly calling tzset wherever it may be needed.

Ian McCallion <ianmcc>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ianmcc (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code