[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Time confusion?
From: |
John W. Eaton |
Subject: |
Time confusion? |
Date: |
Wed, 10 Mar 2004 23:23:00 -0600 |
On 10-Mar-2004, Vic Norton <address@hidden> wrote:
After seeing Paul's reply, I decided to take another look at this.
I'll reorder your post a bit so the output directly follows the input:
| date0 = '23-Feb-04'
| date0 = 23-Feb-04
| tm_struct1 = strptime(date0, "%e-%b-%y")
| tm_struct1 =
| {
| hour = 0
| isdst = 0
| mday = 23
| min = 0
| mon = 1
| sec = 0
| usec = 0
| wday = 0
| yday = 0
| year = 104
| zone =
| }
Here is what I see (using 2.1.53 on a Debian testing system):
octave:1> date0 = '23-Feb-04'
date0 = 23-Feb-04
octave:2> tm_struct1 = strptime(date0, "%e-%b-%y")
tm_struct1 =
{
hour = 0
isdst = 0
mday = 23
min = 0
mon = 1
sec = 0
usec = 0
wday = 1
yday = 53
year = 104
zone =
}
Note that my strptime fills in the wday and yday fields and yours did
not.
| date1 = strftime("%a, %e-%b-%y", tm_struct1)
| date1 = Sun, 23-Feb-04
I see
octave:3> date1 = strftime("%a, %e-%b-%y", tm_struct1)
date1 = Mon, 23-Feb-04
However, if I modify my time structure to be the same as yours, then I
obtain the same result that you see:
octave:5> tm_struct1.wday = 0;
octave:6> tm_struct1.yday = 0;
octave:7> date1 = strftime("%a, %e-%b-%y", tm_struct1)
date1 = Sun, 23-Feb-04
The key seems to be the setting of wday:
octave:9> tm_struct1.wday = 5;
octave:10> date1 = strftime("%a, %e-%b-%y", tm_struct1)
date1 = Fri, 23-Feb-04
Odd, but if this is a bug, then it is not really a bug in Octave,
since Octave just relies on the C library functions to do the right
thing.
So, why does the strptime function on your system not return wday == 1
for 23 Feb 2004?
jwe
-------------------------------------------------------------
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
-------------------------------------------------------------
Time confusion?,
John W. Eaton <=