Error in Substract ? GetDays ?

Robin,

you are right: since 2008-03-30 we have daylight savings time.

If I change the test program to

import wx
v = wx.DateTimeFromDMY(31, 11, 2007)
v.SetHour(12)
for tag in range (1,32):
  b = wx.DateTimeFromDMY(tag, 2, 2008)
  b.SetHour(12)
  d = b.Subtract(v).GetDays()
  print b, d
for tag in range (1,31):
  b = wx.DateTimeFromDMY(tag, 3, 2008)
  b.SetHour(12)
  d = b.Subtract(v).GetDays()
  print b, d

I get this output:
...

Fri Mar 28 12:00:00 2008 88
Sat Mar 29 12:00:00 2008 89
Sun Mar 30 12:00:00 2008 89
Mon Mar 31 12:00:00 2008 90
Tue Apr 1 12:00:00 2008 91
Wed Apr 2 12:00:00 2008 92

...

Now 2008-03-30 is '89' (the same as 2008-03-29) but it is the day 90!

If I line 3 is a comment I get

...

Thu Mar 27 12:00:00 2008 87
Fri Mar 28 12:00:00 2008 88
Sat Mar 29 12:00:00 2008 89
Sun Mar 30 12:00:00 2008 90
Mon Mar 31 12:00:00 2008 91
Tue Apr 1 12:00:00 2008 92
Wed Apr 2 12:00:00 2008 93

...

These are correct day numbers.

Egon

Robin Dunn schrieb:

···

Egon Frerich wrote:

I wrote this little test program; it should find the day number in the year:

import wx
for tag in range (1,32):
    b = wx.DateTimeFromDMY(tag, 2, 2008)
    d = b.Subtract(wx.DateTimeFromDMY(31, 11, 2007)).GetDays()
    print b, d
for tag in range (1,31):
    b = wx.DateTimeFromDMY(tag, 3, 2008)
    d = b.Subtract(wx.DateTimeFromDMY(31, 11, 2007)).GetDays()
    print b, d

I get

...

Fri Mar 28 00:00:00 2008 88
Sat Mar 29 00:00:00 2008 89
Sun Mar 30 00:00:00 2008 90
Mon Mar 31 00:00:00 2008 90
Tue Apr 1 00:00:00 2008 91
Wed Apr 2 00:00:00 2008 92

...

The 2008-03-31 should be day 91 not 90 and so on.

What is the cause? Leap year 2008 ?

It probably has something to do with the switch to daylight savings time. Is that the day the switch was made in your locale? Does it make any difference if you set the time in the objects to noon instead of defaulting to midnight?