octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #64933] Stat sometimes produces wrong timestam


From: INVALID.NOREPLY
Subject: [Octave-bug-tracker] [bug #64933] Stat sometimes produces wrong timestamp
Date: Mon, 27 Nov 2023 04:08:52 -0500 (EST)

URL:
  <https://savannah.gnu.org/bugs/?64933>

                 Summary: Stat sometimes produces wrong timestamp
                   Group: GNU Octave
               Submitter: mspo
               Submitted: Mon 27 Nov 2023 09:08:49 AM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: 8.4.0
         Discussion Lock: Any
        Operating System: Microsoft Windows
           Fixed Release: None
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Mon 27 Nov 2023 09:08:49 AM UTC By: Anonymous
I'll simply copy from my post on octave.discourse.group:
https://octave.discourse.group/t/stat-sometimes-produces-wrong-timestamp/4965

I’m using Windows in Germany. We just switched back to standard time this
weekend and I noticed a timestamp issue:
Calling stat() directly on a file path which points to files written during
daylight savings time, e.g., last week, produces timestamps which are off by 1
hour. Files saved during standard time produce correct results currently. I
assume that the opposite was true last week, but that’s harder to test. The
issue is due to stat() itself and not localtime() or strftime() since the
stat() result structure is already off by 1 hour. I finally found a
workaround: Calling stat() on a file ID doesn’t show this problem. This can
be reproduced under Windows using the following:


% make an empty text file
fpath = 'test.txt';
fid = fopen(fpath, 'w');
fclose(fid);

% use powershell command to change mtime to last week
system(sprintf('powershell (Get-Item \\"%s\\").LastWriteTime = Get-Date
(\\"%s\\")', fpath, '2023-10-27 12:00:00'));

% retrieve mtime directly from file path
t = stat(fpath);
strftime('%Y-%m-%d %T', localtime(t.mtime))

% retrieve mtime from fid
fid = fopen(fpath);
t = stat(fid);
fclose(fid);
strftime('%Y-%m-%d %T', localtime(t.mtime))


This gives me:



ans = 2023-10-27 11:00:00
ans = 2023-10-27 12:00:00


I hope that this is unintended and can be fixed. By the way, this issue
doesn’t seem to appear on Ubuntu.

My system:
OS: Windows 10 (version 22H2)
Octave version: Version 8.4.0







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64933>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]