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

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

[Octave-bug-tracker] [bug #51340] datevec jump hour on 29/03/2009 02:*


From: Mike Miller
Subject: [Octave-bug-tracker] [bug #51340] datevec jump hour on 29/03/2009 02:*
Date: Thu, 29 Jun 2017 18:38:23 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0

Follow-up Comment #13, bug #51340 (project octave):

What I mean is that this wallclock time does not exist in your local time
zone. If you had been recording some kind of time series data at say one
minute intervals on your system, the data log would have gone from "01:58:00"
to "01:59:00" to "03:00:00" because the hour between 02:00:00 and 02:59:59
does not exist on that particular day.

When I use GNU date to try to parse such a date string, I get back a
definitive error:


$ date -d '2017-03-12 01:59:59'
Sun Mar 12 01:59:59 PST 2017
$ date -d '2017-03-12 02:00:00'
date: invalid date ‘2017-03-12 02:00:00’
$ date -d '2017-03-12 03:00:00'
Sun Mar 12 03:00:00 PDT 2017


If you adjust your C program to look at the time_t value returned by mktime(),
you'll see that that value actually represents 03:00:00:


   strptime("29/03/2009 02:00:00", "%d/%m/%Y %H:%M:%S", &tm);
   time_t t = mktime(&tm);
   localtime_r(&t, &tm);
   strftime(buf, sizeof(buf), "%d %b %Y %H:%M", &tm);


That's what I mean when I say that this example time is specifying an invalid
/ nonexistent time in your time zone.

There may be a Matlab compatibility issue here, from comment #11 it looks like
Matlab parses the string into a datevec regardless of whether it can represent
a valid time or not.

nrjank - since you have Matlab 2017 available, and you're on the same US
timezone rules, can you try the following:


format long
fmt = 'yyyy-mm-dd HH:MM:SS';
x = datenum ('2017-03-12 01:59:59', fmt)
x(2) = datenum ('2017-03-12 02:00:01', fmt)
x(3) = datenum ('2017-03-12 02:59:59', fmt)
x(4) = datenum ('2017-03-12 03:00:01', fmt)
round (86400 * diff (x))


In Octave I get


x =

   736766.083321759   736766.125011574   736766.166655093   736766.125011574

ans =

   3602   3598  -3598



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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