bugGNU Octave - Bugs: bug #45592, strftime problem with %z

 
 

bug #45592: strftime problem with %z

Submitter:  Vic Norton <vicnorton>
Submitted:  Mon 20 Jul 2015 09:42:37 PM UTC
   
 
Category:  Libraries Severity:  1 - Wish
Priority:  3 - Low Item Group:  Feature Request
Status:  Fixed Assigned to:  mtmiller
Originator Name:  Vic Norton Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 23 Jul 2015 12:32:01 AM UTC, comment #5: 

Fixed on the default branch in the following changeset

http://hg.savannah.gnu.org/hgweb/octave/rev/31f89b12aaf7

Thanks again for noticing that this wasn't working, as you can see from the change a couple different pieces needed to be fixed to get this fully working.

Mike Miller <mtmiller>
Group Member
Wed 22 Jul 2015 02:23:26 PM UTC, comment #4: 

I think this is a reasonable enhancement and a pretty easy change, I'm looking at this (also document %z in the help text).

Mike Miller <mtmiller>
Group Member
Tue 21 Jul 2015 01:53:26 PM UTC, comment #3: 

I realize that %z is not a valid format carrier in Octave. Perhaps it
should be. For example an email message I recently received had
(partial) headers


  Received: from frontend.savannah.gnu.org by mx02.nic.name
  for <vic@norton.name>; Tue, 21 Jul 2015 01:34:59 +0000 (UTC)

  Received: from mx02.nic.name by smtp3.cros.net
  for <NORTON@DACOR.NET>; Mon, 20 Jul 2015 21:34:59 -0400 (EDT)


The two times are identical. One is +0000 (UTC) time and the other is
-0400 (EDT) time. I believe the %z codes, +0000 and -0400, are much more
rational than the %Z codes, UTC and EDT. And, if the %z format is
standard in emails, perhaps Octave should start allowing it as well.

Vic Norton <vicnorton>
Tue 21 Jul 2015 03:15:38 AM UTC, comment #2: 

Looked into this a bit, it is not the gnulib function that is to blame. Octave doesn't save/restore the "gmtoff" field in a struct tm when converting to and from octave values, so an uninitialized random value is passed to the underlying strftime C function.

This would be an enhancement to support the "%z" format conversion by preserving the "gmtoff" field correctly.

Mike Miller <mtmiller>
Group Member
Tue 21 Jul 2015 01:34:57 AM UTC, comment #1: 

I dont think %z is a valid format character according to the octave documentation.

%Z is though.

John Donoghue <lostbard>
Group Member
Mon 20 Jul 2015 09:42:37 PM UTC, original submission:  

The commands

  printf("  %sn", strftime("%Y-%m-%d %X %Z", gmtime(1420027200)));
  printf("  %sn", strftime("%Y-%m-%d %X %Z", gmtime(1435665600)));
  printf("  %sn", strftime("%Y-%m-%d %X %Z", gmtime(1451563200)));

but

  printf("  %sn", strftime("%Y-%m-%d %X %z", gmtime(1420027200)));
  printf("  %sn", strftime("%Y-%m-%d %X %z", gmtime(1435665600)));
  printf("  %sn", strftime("%Y-%m-%d %X %z", gmtime(1451563200)));

give gibberish in the time zone field.
See <http://search.cpan.org/~dexter/POSIX-strftime-GNU-0.0301/lib/POSIX/strftime/GNU.pm>.

Vic Norton <vicnorton>

 

(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 mtmiller (Posted a comment)
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by vicnorton (Submitted the item)
  • -email is unavailable- added by vicnorton
  •  

    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.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-07-23 mtmiller StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2015-07-22 mtmiller Assigned toNone mtmiller
    2015-07-21 mtmiller Severity3 - Normal 1 - Wish
        Priority5 - Normal 3 - Low
        Item GroupNone Feature Request
        StatusNone Confirmed
        Release3.8.2 dev
    2015-07-20 vicnorton Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code