Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76574
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.065 |
| X-Spam-Evidence | '*H*': 0.87; '*S*': 0.00; 'output': 0.05; 'url:launchpad': 0.05; 'see.': 0.07; 'falls': 0.09; 'subject:How': 0.10; 'bug': 0.12; 'behavior:': 0.16; 'repr': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'trying': 0.19; '>>>': 0.22; 'import': 0.22; 'aug': 0.22; 'parse': 0.24; 'string,': 0.24; 'helpful': 0.24; 'mon,': 0.24; 'supported': 0.26; 'gets': 0.27; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'skip:p 30': 0.29; 'url:bugs': 0.29; 'said,': 0.30; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; '>>>>': 0.31; 'noted': 0.31; 'yourself.': 0.31; 'probably': 0.32; 'open': 0.33; 'subject:time': 0.33; 'could': 0.34; 'problem': 0.35; 'something': 0.35; 'case,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'entry': 0.36; 'clear': 0.37; 'somebody': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'obtain': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'future': 0.60; 'simply': 0.61; 'first': 0.61; 'back': 0.62; 'guarantee': 0.63; 'show': 0.63; 'more': 0.64; 'dear': 0.65; 'determine': 0.67; 'yes': 0.68; 'useful.': 0.68; 'fact,': 0.69; 'evaluate': 0.72; 'friends': 0.81; 'longitude': 0.84; 'subject:location': 0.84; ',please': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=U24W9syCEygbWinHOhzCyR2/X6uFo+ExtrkbElqMuKg=; b=v0U9f8D0ZuCp7KC7aGqA6J3J8Sc6YFAN3Sma5JYaEZsXnmV8FrUAsnaWVbmTBDQso4 bWytXQ8JofiKtSHFFTskfWdKCiBIytmtveHJMEv4BijQqi9H+cX6RuktjGKdDGL7XH0U y2u8+WelV8GKSJeKvA/PBAx00PftfrJcKM9piFD/rRNkCh8vLKfrXglUDC7PwaalvTEO g1e2U6E7nD0n/RjIhn7ijSA6LQPmOeQr6faGj03Rc+FguNZlSaOx8EM95bCyXYkVFDl7 ZRy/Gk1nK/WFAfYY/makrmuvQx+SkdLDzgdtqo/6yzK7RQFHY/zLn9DwfiuR1ah3mJX+ jbtg== |
| X-Received | by 10.70.137.98 with SMTP id qh2mr40426929pdb.61.1408465599718; Tue, 19 Aug 2014 09:26:39 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <53F2A8E2.9000804@gmail.com> |
| References | <53F14971.3010209@gmail.com> <85mwb24h9o.fsf@benfinney.id.au> <53F1875F.4020109@gmail.com> <CAPTjJmrxAox15ZKSNR5HtbFJSBukK7GwKH91itLid8cNE8Nvsg@mail.gmail.com> <53F1FBCC.6060406@gmail.com> <mailman.13107.1408384942.18130.python-list@python.org> <lstqar$pg5$2@reader1.panix.com> <53F2A197.3090401@gmail.com> <53F2A8E2.9000804@gmail.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Tue, 19 Aug 2014 10:25:58 -0600 |
| Subject | Re: How to look up historical time zones by date and location |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.13153.1408465604.18130.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1408465604 news.xs4all.nl 2839 [2001:888:2000:d::a6]:43751 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:76574 |
Show key headers only | View raw
On Mon, Aug 18, 2014 at 7:31 PM, 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?
>
> 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'
This is not a supported use case, so there's no good way to do it that
I can see. What gets printed when you evaluate tz1 is the result of
calling repr(), not str().
>>> repr(tz1)
"<DstTzInfo 'Asia/Shanghai' LMT+8:06:00 STD>"
If you just want the "LMT+8:06:00" as a string, you could call
repr(tz1) and then parse the result with a regex. But like I said,
this is not something that is supported by pytz. Somebody else noted
that the repr is simply showing the first historical entry for the
timezone in the database. Since the first entry is somewhat arbitrary,
not all time zones will show LMT like this, and there is no guarantee
that it won't change in some future update of pytz. In fact, there is
an open bug to fix this behavior:
https://bugs.launchpad.net/pytz/+bug/1319939
We might be able to be more helpful if you would be more clear about
what problem it is that you are trying to solve. Are you trying, for a
given point on the Earth, to determine what nautical time zone it
falls into, or some other "natural" time zone, or its LMT offset, or
something else? For any of those cases, I think the Olson database of
*legal* time zones is not going to be very useful. It would probably
be better to obtain the longitude and do the calculation yourself.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: How to look up historical time zones by date and location Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-18 11:53 -0600
Re: How to look up historical time zones by date and location pecore@pascolo.net - 2014-08-18 21:47 +0200
Re: How to look up historical time zones by date and location Grant Edwards <invalid@invalid.invalid> - 2014-08-18 21:14 +0000
Re: How to look up historical time zones by date and location luofeiyu <elearn2014@gmail.com> - 2014-08-19 09:31 +0800
Re: How to look up historical time zones by date and location luofeiyu <elearn2014@gmail.com> - 2014-08-19 09:00 +0800
Re: How to look up historical time zones by date and location Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-19 10:25 -0600
Re: How to look up historical time zones by date and location Denis McMahon <denismfmcmahon@gmail.com> - 2014-08-19 17:44 +0000
csiph-web