Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug summary
I have a very curious problem withnum2date
which I am not able to understand where it comes from. It seems that when running a code snippet (which is working as expected in a conda environment) within a container on a specific machine with time zone EET,num2date
introduces a 2-hour offset from UTC associated to the time zone. The weird fact is that the time seems to be the same for both machines, so I do not understand where such extra two hours is applied. it is interesting also since thedate2num
works fine...
Unfortunately this is partially reproducible since this is happening within a singularity container that I cannot share easily. I am wondering if such potential issues with time zones are known to show up inside containers.
It might be a feature that I am not aware but I cannot understand how to control this.
Code for reproduction
fromdatetimeimportdatetime,timezoneimportmatplotlib.datesasmdatesimporttimeprint("Time:",time.strftime("%Y-%m-%d %H:%M:%S",time.localtime()))print("System timezone according to time module:",time.tzname)original=datetime(1989,1,1,tzinfo=timezone.utc)num=mdates.date2num(original)converted=mdates.num2date(num,tz=timezone.utc)print("Epoch:",mdates.get_epoch())print("Original datetime: ",original)print("Converted to num: ",num)print("Back to datetime: ",converted)
Actual outcome
On the container
Time: 2025-06-03 19:30:19System timezone according to time module: ('EET', 'EEST')Epoch: 1970-01-01T00:00:00Original datetime: 1989-01-01 00:00:00+00:00Converted to num: 6940.0Back to datetime: 1988-12-31 22:00:00+00:00
Expected outcome
On the conda envrionment:
Time: 2025-06-03 19:30:23System timezone according to time module: ('EET', 'EEST')Epoch: 1970-01-01T00:00:00Original datetime: 1989-01-01 00:00:00+00:00Converted to num: 6940.0Back to datetime: 1989-01-01 00:00:00+00:00
Additional information
Running matplotlib 3.10.3
Operating system
unix
Matplotlib Version
matplotlib 3.10.3
Matplotlib Backend
agg
Python version
3.12
Jupyter version
No response
Installation
conda