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


Groups > comp.lang.python > #76463

Re: How can I get the timezone time of a location?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <kwpolska@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status UNSURE 0.247
X-Spam-Level **
X-Spam-Evidence '*H*': 0.52; '*S*': 0.02; 'adopted': 0.09; 'currently,': 0.09; 'sake': 0.09; 'solution,': 0.09; 'used.': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; '(via': 0.16; '0))': 0.16; 'code?': 0.16; 'wrote:': 0.18; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '&gt;': 0.26; 'somewhere': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'message- id:@mail.gmail.com': 0.30; 'that.': 0.31; 'lies': 0.31; 'so- called': 0.31; 'subject:time': 0.33; 'subject:the': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'belong': 0.36; 'east': 0.36; 'subject:?': 0.36; 'throughout': 0.37; 'wrong': 0.37; 'area': 0.37; 'others.': 0.38; 'skip:& 20': 0.39; 'subject:can': 0.39; 'skip:p 20': 0.39; 'according': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'easy': 0.60; 'manually': 0.60; 'most': 0.60; 'august': 0.61; 'from:charset:utf-8': 0.61; 'places': 0.64; 'land': 0.65; 'skip:\xe2 10': 0.65; 'to:addr:gmail.com': 0.65; 'world': 0.66; 'between': 0.67; 'eastern': 0.68; 'registers': 0.68; 'legal': 0.71; '8bit%:43': 0.74; 'subject:get': 0.81; 'east.': 0.84; 'fact.': 0.84; 'longitude': 0.84; 'solar': 0.84; 'standards.': 0.84; 'subject:location': 0.84; 'divided': 0.91; 'ninth': 0.91; 'regions': 0.93; 'china': 0.97
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=RWKJWSMyyZHMYU5z6Y6s+8Cm1S55b63m28tXyC0Hlws=; b=Yxy53iQJ++8nfWcIw6dOQubxRoJrdPJE3vuean87ZwVTdMViA6zLQDxi3dpEDcm0Ak Wd22ONhzGQW4ba8O9eqwCW/dRn3gzjHLQX2J8uv4ng2kDNLMu9CCHlGrj3w+yLWsU9Et PWGq8SdZCtVyouaCVVoSQZtcAnVzlbWgf13JeIgjmm7WCJYEqtsvEc+4nKOxt9MSlc3O fAz2olhYmxOEBDwTo4Riwc6mOBiuK8fNc+39UxphAxd76cLI2LrJZme3esJDYU33Zee7 TBT0LwBnejmjs3fYV0UCVRriZjghnJDuSNv11Z6EVJZv48jIt3KRsNYt2PG+XiPSm6VK oHWw==
MIME-Version 1.0
X-Received by 10.43.70.205 with SMTP id yh13mr34683739icb.44.1408345522014; Mon, 18 Aug 2014 00:05:22 -0700 (PDT)
In-Reply-To <53F14971.3010209@gmail.com>
References <53F14971.3010209@gmail.com>
Date Mon, 18 Aug 2014 09:05:21 +0200
Subject Re: How can I get the timezone time of a location?
From Chris “Kwpolska” Warrick <kwpolska@gmail.com>
To luofeiyu <elearn2014@gmail.com>
Content-Type multipart/alternative; boundary=bcaec51b201d8f8ecb0500e1fe73
X-Mailman-Approved-At Mon, 18 Aug 2014 11:02:26 +0200
Cc python-list@python.org
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.13091.1408352548.18130.python-list@python.org> (permalink)
Lines 101
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1408352548 news.xs4all.nl 2907 [2001:888:2000:d::a6]:40918
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76463

Show key headers only | View raw


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

On 18 August 2014 04:28 "luofeiyu" <elearn2014@gmail.com> wrote:
>
> 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.

There is also solar time, which is defined as 12:00 = zenith.

> 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).

You can't use the Olson tz database (via pytz) for that. The database
registers legal time and not any of the others. Most people don't really
care about the other time standards. AFAIK there is no easy solution, you'd
have to calculate it manually from the longitude, which you'd have to find
somewhere (online?)
-- 
Chris “Kwpolska” Warrick <http://chriswarrick.com/>
Sent from my SGS3.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: How can I get the timezone time of a location? Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2014-08-18 09:05 +0200

csiph-web