Example
import pytz
b=pytz.timezone('Europe/Rome')
c=pytz.timezone('Europe/Berlin')
These two timezones have different names but represent the same thing, however
Is there any way to see that b is in reality equal to c?
The concrete problem is that I have to convert the timezone of a pandas data frame, but only if this zone is different than let's say c. The original timezone might be b and in this case I do not want to convert as it would be a lost of time to convert b into c (since they represent the same time zones at the end....)
Thanks for any help.
Update: changed 'CET' into 'Europe/Rome' to make sure that the timezones are the same in the example, using the feedback from an answer
But correct version would be: if lastMonthAllowed. year > lastUserUploadMonth. year or (lastMonthAllowed. year == lastUserUploadMonth.
The parameter pytz. timezone allows us to specify the timezone information as a string. We can pass in any available timezone and will get the current date time of that timezone, and it will also print the offset with respect to the UTC. i.e., the difference between UTC timezone(+00:00) and the specified time zone.
They do not represent the same thing.
"CET"
is always UTC+01:00
"Europe/Berlin"
alternates between CET (UTC+01:00) in the winter, and CEST (UTC+02:00) in the summer.
See also:
With regards to the edit, Europe/Rome
is a distinct time zone. It is not the same as Europe/Berlin
, nor Europe/Zurich
, nor Europe/Amsterdam
. At least not for their entire histories.
If you compare their definitions (using the links in the prior paragraph), you'll see that these each aligned to the "EU" rule for CET/CEST at some point in their past. Rome and Berlin since 1980, Zurich since 1981, and Amsterdam since 1977. Before those dates, they differed significantly. Other time zones have different rules as well.
If you're interested in the history of these zones, I suggest reading through the europe file in the TZ data. The comments alone are quite interesting.
On the other hand, if you are only working with modern dates, where all zones are following the same rules and offsets, then you could consider these substitutable - at least as long as they don't change in the future.
Also, there are some time zones that are just aliases and are completely interchangeable. In the TZ data, they're called "links". For example, you can see here that Europe/Vatican
and Europe/San_Marino
are both linked to Europe/Rome
, and are therefore equivalent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With