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

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

[Octave-bug-tracker] [bug #50558] datestr() automatic selection of outpu


From: Lars Kindermann
Subject: [Octave-bug-tracker] [bug #50558] datestr() automatic selection of output format is based on the first row of input only
Date: Thu, 16 Mar 2017 07:47:23 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:51.0) Gecko/20100101 Firefox/51.0

URL:
  <http://savannah.gnu.org/bugs/?50558>

                 Summary: datestr() automatic selection of output format is
based on the first row of input only
                 Project: GNU Octave
            Submitted by: larskindermann
            Submitted on: Thu 16 Mar 2017 11:47:22 AM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Inaccurate Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any

    _______________________________________________________

Details:

The output of


datestr([2017 03 16 0 0 1; 2017 03 16 0 0 0])
ans =

16-Mar-2017 00:00:01
16-Mar-2017 00:00:00


looks different from


datestr([2017 03 16 0 0 0; 2017 03 16 0 0 1])
ans =

16-Mar-2017
16-Mar-2017


The reason is, that automatic format selection is based on the first row only.
This is, because the check is performed just once at the very first iteration
of the main loop over the rows of the date vectors.

Attached is a patch that changes this behaviour by moving that code out of the
loop and make it check wether the time-fields of *all* rows are zero or *all*
dates are == [-1, 12, 31]

So nothing changes for a single input but the format of multiple date inputs
does not depend on the order of the array any more:


datestr([2017 03 16 0 0 1; 2017 03 16 0 0 0])
ans =

16-Mar-2017 00:00:01
16-Mar-2017 00:00:00

datestr([2017 03 16 0 0 0; 2017 03 16 0 0 1])
ans =

16-Mar-2017 00:00:00
16-Mar-2017 00:00:01





    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thu 16 Mar 2017 11:47:22 AM UTC  Name: datestr.diff  Size: 702B   By:
larskindermann
patch for datestr.m
<http://savannah.gnu.org/bugs/download.php?file_id=40015>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?50558>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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