wx.DateTime and DST

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

wx.DateTime and DST

Peter Milliken-2
I live in Australia - that's in the Southern Hemisphere for those who might not be aware :-) I am not being facetious here, I lived in a country (in the Northern Hemisphere) for 2.5 years where people kept asking me which part of England Australia was in - I won't mention the countries name, I made some good friends while I lived there and would like to protect the innocent. 


I'm just trying to work out how to get the current time and have that time reflect the fact that DST is in force at this moment in time - for Sydney, Australia. 


I'm not sure if I am dealing with a bug (probably not) or just not understanding the API correctly or maybe there is something I must do with the Timezone? - although I am not sure what. But I suspect the source of my problem might have something to do with the timezone not being set/detected by the wx.DateTime library?

I am running on a Windows 10 computer system. It shows the correct date/time for Sydney AEDT (Australian Eastern Daylight Time), so I know that the computer OS is correctly set up. I am running Python 3.7 and wxPython 4.0.3.

If I call wx.DateTime.Now() the call returns the date/time without DST applied i.e. the time returned is 1hr ahead of "real" time (DST time). This seems to be the problem area - the Timezone doesn't seem to have been taken into account? I'm running my program from file explorer as I intend it to be eventually distributed as a Windows application. I can't see anything obvious in the wx.DateTime API to read and set the timezone?

I looked at API functions like IsDST(), GetBeginDST() and GetEndDST(), but they seem to have been provided to the convenience of performing queries about a specific date/time and are not helpful in my situation - although the fact that GetEndDST() returns 11th Apr, 2018 and not April 2019 i.e. my DST period is Nov, 2018 - Mar/Apr, 2019 makes me think the timezone is the issue.

Thanks in advance for any answers to this puzzle :-)

Peter



--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.DateTime and DST

john fabiani`

If the computer you are using is reporting the time correctly then I suspect that os.times() will report the correct time too.  Therefore, I'd use the windows OS to handle the time issue.

Johnf


On 12/12/2018 07:55 PM, Peter Milliken wrote:
I live in Australia - that's in the Southern Hemisphere for those who might not be aware :-) I am not being facetious here, I lived in a country (in the Northern Hemisphere) for 2.5 years where people kept asking me which part of England Australia was in - I won't mention the countries name, I made some good friends while I lived there and would like to protect the innocent. 


I'm just trying to work out how to get the current time and have that time reflect the fact that DST is in force at this moment in time - for Sydney, Australia. 


I'm not sure if I am dealing with a bug (probably not) or just not understanding the API correctly or maybe there is something I must do with the Timezone? - although I am not sure what. But I suspect the source of my problem might have something to do with the timezone not being set/detected by the wx.DateTime library?

I am running on a Windows 10 computer system. It shows the correct date/time for Sydney AEDT (Australian Eastern Daylight Time), so I know that the computer OS is correctly set up. I am running Python 3.7 and wxPython 4.0.3.

If I call wx.DateTime.Now() the call returns the date/time without DST applied i.e. the time returned is 1hr ahead of "real" time (DST time). This seems to be the problem area - the Timezone doesn't seem to have been taken into account? I'm running my program from file explorer as I intend it to be eventually distributed as a Windows application. I can't see anything obvious in the wx.DateTime API to read and set the timezone?

I looked at API functions like IsDST(), GetBeginDST() and GetEndDST(), but they seem to have been provided to the convenience of performing queries about a specific date/time and are not helpful in my situation - although the fact that GetEndDST() returns 11th Apr, 2018 and not April 2019 i.e. my DST period is Nov, 2018 - Mar/Apr, 2019 makes me think the timezone is the issue.

Thanks in advance for any answers to this puzzle :-)

Peter



--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.DateTime and DST

Tim Roberts
In reply to this post by Peter Milliken-2
Peter Milliken wrote:
>
> I'm not sure if I am dealing with a bug (probably not) or just not
> understanding the API correctly or maybe there is something I must do
> with the Timezone? - although I am not sure what. But I suspect the
> source of my problem might have something to do with the timezone not
> being set/detected by the wx.DateTime library?

wx.DateTime doesn't do any setting or detecting.  It calls time() and
localtime() in the C standard library.  It's very difficult for me to
understand how it could be going wrong if time() and localtime() are
doing the right thing.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: wx.DateTime and DST

Adi Redzic
Tim what os platform are you using? Win or unix type? 

Check out 

There are some different ways a timezone can be set on different os platforms.

I think this can be a issue when using os.time() 

tor. 13. des. 2018 kl. 22:52 skrev Tim Roberts <[hidden email]>:
Peter Milliken wrote:
>
> I'm not sure if I am dealing with a bug (probably not) or just not
> understanding the API correctly or maybe there is something I must do
> with the Timezone? - although I am not sure what. But I suspect the
> source of my problem might have something to do with the timezone not
> being set/detected by the wx.DateTime library?

wx.DateTime doesn't do any setting or detecting.  It calls time() and
localtime() in the C standard library.  It's very difficult for me to
understand how it could be going wrong if time() and localtime() are
doing the right thing.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
--
Adi Redzic

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.DateTime and DST

Tim Roberts
Adi Redzic wrote:
>
> Tim what os platform are you using? Win or unix type?

I looked in the wxWidgets source code.  The wxDateTime is not OS-specific.


> There are some different ways a timezone can be set on different os
> platforms.

Perhaps, but I'm pretty sure the original poster was not trying to do
anything tricky.  He has his timezone set, and somehow it is being
interpreted incorrectly.


> I think this can be a issue when using os.time()

I'm not talking about os.time().  I'm talking about the C runtime
library's time() and localtime().  If C apps are getting the right
offset, then wxDateTime should be getting the right offset.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.


--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: wx.DateTime and DST

Chris Barker - NOAA Federal
Daylight savings time is an f-omg nightmare.

I’ve had issues with wx’s implementation in the past.

You may want to try python datetime and pytz— I think they are at
least more maintained and hacksble.

Good luck!

CHB

Sent from my iPhone

> On Dec 13, 2018, at 5:27 PM, Tim Roberts <[hidden email]> wrote:
>
> Adi Redzic wrote:
>>
>> Tim what os platform are you using? Win or unix type?
>
> I looked in the wxWidgets source code.  The wxDateTime is not OS-specific.
>
>
>> There are some different ways a timezone can be set on different os platforms.
>
> Perhaps, but I'm pretty sure the original poster was not trying to do anything tricky.  He has his timezone set, and somehow it is being interpreted incorrectly.
>
>
>> I think this can be a issue when using os.time()
>
> I'm not talking about os.time().  I'm talking about the C runtime library's time() and localtime().  If C apps are getting the right offset, then wxDateTime should be getting the right offset.
>
> --
> Tim Roberts, [hidden email]
> Providenza & Boekelheide, Inc.
>
>
> --
> You received this message because you are subscribed to the Google Groups "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.