Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76621
| Date | 2014-08-20 09:14 +1000 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: How to look up historical time zones by date and location |
| References | <53F2A8E2.9000804@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13178.1408490080.18130.python-list@python.org> (permalink) |
On 19Aug2014 09:31, luofeiyu <elearn2014@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@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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How to look up historical time zones by date and location Cameron Simpson <cs@zip.com.au> - 2014-08-20 09:14 +1000
csiph-web