Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76445 > unrolled thread

How can I get the timezone time of a location?

Started byluofeiyu <elearn2014@gmail.com>
First post2014-08-18 08:31 +0800
Last post2014-08-18 08:31 +0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  How can I get the timezone time of a location? luofeiyu <elearn2014@gmail.com> - 2014-08-18 08:31 +0800

#76445 — How can I get the timezone time of a location?

Fromluofeiyu <elearn2014@gmail.com>
Date2014-08-18 08:31 +0800
SubjectHow can I get the timezone time of a location?
Message-ID<mailman.13077.1408328818.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

The land area of China is 60-degree longitude from west to east. 
According to the demarcation of the world time zoning standard,
the land area of China lies between the eastern fifth to ninth time 
zones, there are 5 time zones in china in fact.
Currently, all the places in China have adopted the eastern eighth time 
zone for the sake of convenience. It is the so-called “/Beijing Time/”.

I knew there is a difference between localtime and timezone time.
Localtime: The official time in a local region (adjusted for location 
around the Earth); established by law or custom.
Timezone: Any of the 24 regions of the globe (loosely divided by 
longitude) throughout which the same standard time is used.
Timezone time : If location A is belong to timezone X, the time of 
timezone X is the location A 's timezone time.

For Urumqi,localtime is the time of east 8 timezone, but timezone time 
is the time of east 6 timezone.
How can I get the timezone time of urumqi with python code?

|from datetime import datetime, timedelta
from pytz import timezone
import pytz
tz = pytz.timezone('Asia/Urumqi')
dt= tz.localize(datetime(2002, 10, 27, 6, 0, 0))
fmt = '%Y-%m-%d %H:%M:%S %Z%z'
print(dt.strftime(fmt))
2002-10-27 06:00:00 CST+0800
|

It is a wrong answer,the timezone time is 2002-10-27 04:00:00 +0600 
.|2002-10-27 06:00:00 CST+0800| is the localtime for Urumiq(by law in 
china).

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web