help-octave
[Top][All Lists]
Advanced

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

Re: Time confusion?


From: Vic Norton
Subject: Re: Time confusion?
Date: Thu, 11 Mar 2004 15:01:19 -0500

I don't think the problem has anything to do with time zones, Paul. The line

   octave> strptime('23-Feb-04', "%e-%b-%y")

produces a time structure with

   mday = 23
   mon = 1
   wday = 0
   year = 104

The weekday here corresponds to Sunday, and there was no Sunday, February 24, 2004.


There is really nothing special about '23-Feb-04'. Right now it is Thursday, March 11, 2004 here and Friday, March 12, 2004 in New Zealand. No matter, wday = 0 for either

   octave> strptime('11-Mar-04', "%e-%b-%y")

or

   octave> strptime('12-Mar-04', "%e-%b-%y")

Everyday is Sunday to strptime. It must be retired.


It does appears that you can always get the correct (local) time structure from the composite function localtime(mktime(strptime())). Thus

   octave> localtime(mktime(strptime('11-Mar-04', "%e-%b-%y")))

produces the correct

   ans =
   {
     hour = 0
     isdst = 0
     mday = 11
     min = 0
     mon = 2
     sec = 0
     usec = 0
     wday = 4
     yday = 70
     year = 104
     zone = EST
   }

whereas

   octave> strptime('11-Mar-04', "%e-%b-%y")

produces the impossible

   ans =
   {
     hour = 0
     isdst = 0
     mday = 11
     min = 0
     mon = 2
     sec = 0
     usec = 0
     wday = 0
     yday = 0
     year = 104
     zone =
   }


As you will notice strptime produces no time zone at all on my Octave, version 2.1.50.


Regards,

Vic


At 7:09 PM -0500 3/10/04, Paul Kienzle wrote:
 On Mar 10, 2004, at 11:45 AM, Vic Norton wrote:
Start with the date 23-Feb-04. That was a Monday. Do strptime to get a TM_STRUCT and then do strftime to that. This changes the day. Now 23-Feb-04 is Sunday.

It can if it is in a different time zone. E.g., start at 12:00AM on Monday, no time zone specified. Set zone to EST. If your time zone is CST, 12:00AM on Monday
 in EST is really 11:00PM on Monday in CST.

print out the full date and time, including time zone, on tm_struct1 and tm_struct2.

        strftime ("%r (%Z) %A %e %B %Y",tm)

 Paul Kienzle
 address@hidden



 -------------------------------------------------------------
 Octave is freely available under the terms of the GNU GPL.

 Octave's home on the web:  http://www.octave.org
 How to fund new projects:  http://www.octave.org/funding.html
 Subscription information:  http://www.octave.org/archive.html
 -------------------------------------------------------------

--
*------* http://www.ridehsta.com
|  Vic Norton      2002 CapoNord   HSTA 5992  DOD 43403
| (419)353-8399    1997 KLR650     STOC 037   AMA 594102
*------* http://vic.norton.name/moto



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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