Prev: Inf
Next: access data from whole cell array
From: enviro on 22 Feb 2010 23:29 Hi there Do you have an idea how to fix a problem with "datevec". there seems to be a problem at 24 O'clock. For instance please try below example. Please note this is in the middle of a code with massive data so I cant change it manually. [year, month, day,hour] =datevec('2008/03/31 24:00:00','yyyy/mm/dd HH:MM:SS')
From: Steven Lord on 23 Feb 2010 10:03 "enviro" <farhadnejadkoorki(a)yahoo.co.uk> wrote in message news:1088818060.255196.1266935417071.JavaMail.root(a)gallium.mathforum.org... > Hi there > Do you have an idea how to fix a problem with "datevec". there seems to be > a problem at 24 O'clock. For instance please try below example. Please > note this is in the middle of a code with massive data so I cant change it > manually. > > > [year, month, day,hour] =datevec('2008/03/31 24:00:00','yyyy/mm/dd > HH:MM:SS') This is not a bug. 24 hours after midnight on 3/31 is 0 hours after midnight on 4/1. You can check this: March31 = datenum('2008/03/31 24:00:00', 'yyyy/mm/dd HH:MM:SS') April1 = datenum('2008/04/01 00:00:00', 'yyyy/mm/dd HH:MM:SS') isequal(March31, April1) If you do not want this behavior, you can use regular expressions to parse the date string into the specific form of the year, month, day, and hour inputs you want. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Jan Simon on 23 Feb 2010 10:07 Dear Enviro! > Do you have an idea how to fix a problem with "datevec". there seems to be a problem at 24 O'clock. For instance please try below example. Please note this is in the middle of a code with massive data so I cant change it manually. > > > [year, month, day,hour] =datevec('2008/03/31 24:00:00','yyyy/mm/dd HH:MM:SS') I get the expected result on Matlab 2009a: >> year = 2008, month = 4, day = 1, hour = 0 So please describe what your problem is and what Matlab version do you use. Kind regards, Jan
From: Walter Roberson on 23 Feb 2010 11:45 Steven Lord wrote: > "enviro" <farhadnejadkoorki(a)yahoo.co.uk> wrote in message > news:1088818060.255196.1266935417071.JavaMail.root(a)gallium.mathforum.org... >> [year, month, day,hour] =datevec('2008/03/31 24:00:00','yyyy/mm/dd >> HH:MM:SS') > This is not a bug. 24 hours after midnight on 3/31 is 0 hours after > midnight on 4/1. You can check this: Question: does datevec take into account leap seconds? The most recent of those was 2008/12/31 24:00:00 which was -not- the same time as 2009/01/01 00:00:00 . My _memory_ of reading the serial date number documentation a couple of years ago is that datevec is not able to adjust for leap seconds.
From: Jan Simon on 23 Feb 2010 15:36
Dear Walter! > Question: does datevec take into account leap seconds? The most recent > of those was 2008/12/31 24:00:00 which was -not- the same time as > 2009/01/01 00:00:00 . > > My _memory_ of reading the serial date number documentation a couple of > years ago is that datevec is not able to adjust for leap seconds. Inspected the source: No leap seconds in DATEVEC. No support of daylight saving time tricks also. Kind regards, Jan |