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

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

[Octave-bug-tracker] [bug #65219] datenum/datestr/datevec: Inconsistent


From: anonymous
Subject: [Octave-bug-tracker] [bug #65219] datenum/datestr/datevec: Inconsistent behavior for '' input
Date: Mon, 29 Jan 2024 02:51:39 -0500 (EST)

Follow-up Comment #1, bug#65219 (group octave):

I did raise the ticket. To improve resolution, here is what I found:

The regression was introduced with 8.4.0 and the new possible format 'yyyy',
the function __date_str2vec__ calls [tm, nc] = strptime (ds, f);

For 'yyyy' the function __date_vfmt2sfmt__ returned f = '%Y'.

Now [tm, nc] = strptime ('', '%Y') returns empty struct for tm, but nc = 1.

Since nc = 1 and columns('') = 0, the following default values are applied:
if (nc == columns (ds) + 1)
    found = true
    y = tm.year + 1900
    m = tm.mon + 1
    d = tm.mday

Therefore we get back the inconsistent datevec [1900 1 0 0 0 0].

In my personal view the weird behavior is in function strptime, since it
returns "number of chars" = 1 for an empty string as a result for fmt
matching.

So either correct it there of catch the empty string right in the datevec
function at the earliest possible state.

Best,
Stefan




    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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