How to look up historical time zones by date and location
Cameron Simpson
cs at zip.com.au
Tue Aug 19 19:14:36 EDT 2014
On 19Aug2014 09:31, luofeiyu <elearn2014 at gmail.com> wrote:
>My dear friends here, all i want is get ` LMT+8:06:00` from the
>output of tz1 `<DstTzInfo 'Asia/Shanghai' LMT+8:06:00 STD>`
>
>Shall we get back to the main point?
That didn't seem to be your main point. You seemed to want to get Asia/Urumqi
time by either natural longituide or by Beijing Time, depending on context.
>If you are interested in it ,please say yes or no ,and how to do that ?
>
>import pytz,datetime
>tz1 = pytz.timezone('Asia/Shanghai')
>tz1
><DstTzInfo 'Asia/Shanghai' LMT+8:06:00 STD>
>>>> str(tz1)
>'Asia/Shanghai'
Ah, ok. The Python interperter prints repr(tz1), not str(tz1).
You could extract it from that string, but it would be better to get it from
the object attributes.
I don't have the pytz module to hand; there seems to be good documentation
here:
http://pytz.sourceforge.net/
including example code to get various specific pieces of information out of a
DstTzInfo object.
Please see if that helps you, and if not, come back.
Cheers,
Cameron Simpson <cs at zip.com.au>
Ignorance is preferable to error; and he is less remote from the truth
who believes nothing, than he who believes what is wrong.
- Thomas Jefferson
More information about the Python-list
mailing list