Closed moppi79 closed 4 months ago
GetValue()
behaves as intended:
"Directly returns the internal representation of wxDateTime object as the number of milliseconds (positive or negative) since the Unix/C epoch."
You can convert from milliseconds to second via x.GetData().GetValue()/1000.0
You can also use GetTicks()
to get seconds:
https://docs.wxwidgets.org/3.2/classwx_date_time.html#a99263946a9a2ece83421411081c02378
Be aware that the valid range of ticks is much less, though. Usually you can't rely on ticks as they are only valid between 1970 and 2038. If your date control allows values outside, use wxDateTime or Python datetime.
Thanks, Dietmar. Yes, this is working as designed as noted by Dietmar.
Thx for the answer
Operating system: Windows 10 wxPython version & source: Pypi Python version & source: 4.2.1
Description of the problem:
The Orginal Value from .GetDate().GetValue() is to long, it has milli-Seconds on Python sends OS error
Here is Example:
[...]1704927600000
[...]print (datetime.datetime.fromtimestamp(self.calendar_ctrl_1.GetDate().GetValue()).strftime('%Y,%m,%d')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [...]OSError: [Errno 22] Invalid argument
When i short the int it is working:
[...] 1704927600
[...]2024,01,11
Greetings