Why does Python return a negative timezone value?

Viewed 1693

For time.timezone, the Python documentation says:

The offset of the local (non-DST) timezone, in seconds west of UTC (negative in most of Western Europe, positive in the US, zero in the UK).

Does anybody know why it returns a negative value for most of Western Europe? These countries are in a positive offset, and not in a negative one.

Example: Brussels is in UTC+1 timezone...

2 Answers

I think, it will be helpful to somebody if I am elaborating this. Because:

import time
time.timezone

is definitely confusing.

If your timezone is UTC+10, then time.timezone => -36000. ie; (10hrs * 60mnts * 60 secs).
If your timezone is UTC-10, then time.timezone => +36000. ie; (10hrs * 60mnts * 60 secs).
You will not be having any doubt about 36000. But doubt will be about the sign. Why you get the sign inversely?

Why?
In time module, Python following unix standard of time and timezone formats. In unix they are following the above standard.

The concept is given below:
UNIX developer believed that
utc time =(should be equal to)= localtime + timezone
ie: If your local time is 21, and time.timezone is -10, then utc time = 21 + (-10) = 11

But, you know that time.time() returning utc time in python time module. This timestamp is actually retrieved from bios.
So, if time.time() is 11 (this will be actually timestamp),
and if, time.timezone is -10 then this implies two things:

  1. utc time => 11
  2. and timezone => -10
    We know that, utc_time = local_time + timezone
    So, local_time = utc_time - timezone => 11 - (-10) = 21
Related