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

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

[Octave-bug-tracker] [bug #56190] localtime and gmtime ignore nonscalar


From: Andrew Janke
Subject: [Octave-bug-tracker] [bug #56190] localtime and gmtime ignore nonscalar array elements
Date: Sun, 21 Apr 2019 18:56:51 -0400 (EDT)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36

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

                 Summary: localtime and gmtime ignore nonscalar array elements
                 Project: GNU Octave
            Submitted by: apjanke
            Submitted on: Sun 21 Apr 2019 06:56:49 PM EDT
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Mac OS

    _______________________________________________________

Details:

When you pass a nonscalar array of time values to localtime() or gmtime(), it
seems that they ignore all elements past the first one. They still return a
scalar structure containing scalar values.


octave:3> localtime(time .* [1 2 3])
ans =
  scalar structure containing the fields:
    usec =  514024
    sec =  27
    min =  53
    hour =  18
    mday =  21
    mon =  3
    year =  119
    wday = 0
    yday =  110
    isdst =  1
    gmtoff = -14400
    zone = EDT

octave:4> gmtime(time .* [1 2 3])
ans =
  scalar structure containing the fields:
    usec =  613960
    sec =  54
    min =  53
    hour =  22
    mday =  21
    mon =  3
    year =  119
    wday = 0
    yday =  110
    isdst = 0
    gmtoff = 0
    zone = UTC



When passed a nonscalar array, I would expect gmtime() and localtime() to do
one of:

a) return a scalar struct with fields containing arrays the same size as the
input
b) return a struct array the same size as the input, with each element
containing scalar fields
c) raise an error

What do you think should be done here? I'm asking not so much because I have a
use case for this, but I'd like guidance on how to handle the conversion from
datetime objects to time structures in my Chrono package, and I don't think
"silently ignore elements past the first" is the right thing to do.




    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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