Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'syntax': 0.03; 'dst': 0.07; 'pretend': 0.07; 'python': 0.09; 'boundaries': 0.09; 'confuse': 0.09; 'corresponds': 0.09; 'postgres': 0.09; 'sane': 0.09; 'sep': 0.09; 'bit.': 0.16; 'clocks': 0.16; 'formats,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lie,': 0.16; 'offsets': 0.16; 'simple.': 0.16; 'sleeping': 0.16; 'subject:issue': 0.16; 'there...': 0.16; 'timezones': 0.16; 'utc': 0.16; 'utc.': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'written': 0.20; 'all,': 0.21; 'somebody': 0.23; "i've": 0.23; 'header:In-Reply- To:1': 0.25; 'am,': 0.27; 'rules': 0.27; 'easiest': 0.27; 'library.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'correct': 0.28; 'skip:( 20': 0.28; 'sensible': 0.29; 'defining': 0.33; 'handle': 0.33; 'to:addr:python-list': 0.33; 'everyone': 0.33; 'likely': 0.33; 'received:google.com': 0.34; 'open': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'add': 0.36; 'but': 0.36; 'correctly': 0.37; 'uses': 0.37; 'summer': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'things': 0.38; 'to:addr:python.org': 0.39; 'easily': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'most': 0.61; 'places': 0.61; "you'll": 0.62; 'back': 0.62; 'time,': 0.62; 'different': 0.63; 'more': 0.63; 'our': 0.65; 'decided': 0.65; 'else.': 0.65; 'winter': 0.65; 'forward': 0.66; 'hours': 0.66; 'finally': 0.66; 'hour': 0.69; 'as:': 0.75; 'yourself': 0.77; 'hand': 0.82; 'but!': 0.84; 'greece': 0.84; 'metaphor': 0.84; 'southern': 0.84; 'summer,': 0.84; 'thing,': 0.84; 'worms': 0.84; 'stamp': 0.91 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 :content-type; bh=DaTuf8vZPTUGEkjpAEHUaSBLHLhi7CRLxU8iI8lkqYw=; b=Cd2GRZ67F5+LbfgUPH4hwPecnAyI1NwO7kBu+zPa81J/gteGEhCtAIQZBPwkIs5QMP y0goe3y3f1jwb45J5AMlwUFG3wEwIqlp18jRO+V/l9Pc2a9yNAfzDQL697Ez7oTRweAf yU+kIYUr9OC/hXUzK1havgJ1674FLOXdsq7TOqrls5bYvbvYYTEiTd6i9f5fgpuayH5U jkJbz6pr/FITvaqR9twCxQOnjq1FCU1e/RpWudYMtzO6iXaN0p7PwzoCGwa/Cj3A7Hnk HH50vHblfcl/ps+E2iDbwc/Nklthfq/LmPbkTN2tdDFXJg0SmlVwG+qxUVVj3rib74iy QNmg== MIME-Version: 1.0 In-Reply-To: <5680604e-98e5-48c1-b5ac-9b837bc16770@googlegroups.com> References: <52847c35-388c-4758-b72d-1d1859b788a3@googlegroups.com> <8370412f-5176-45ff-87eb-72cbca5149d5@googlegroups.com> <5680604e-98e5-48c1-b5ac-9b837bc16770@googlegroups.com> Date: Mon, 17 Sep 2012 01:54:08 +1000 Subject: Re: datetime issue From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347810852 news.xs4all.nl 6959 [2001:888:2000:d::a6]:46322 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29323 On Mon, Sep 17, 2012 at 1:40 AM, wrote: > Cant it be written more easily as: > date = (datetime.datetime.utcnow(+2) > > i know this is not thhe correct syntax but it just needs a way to add GMT+2 hours since utc=gmt I've dithered about whether to open this can of worms or let sleeping dogs lie, and I finally decided to make some metaphor potpourri. Simple UTC offsets are not the same thing as local time. There are a variety of other considerations, but the main one is Daylight Robbery Time, where every government wants to put its own stamp on things by fiddling with the DST rules a bit. Most places will move their clocks an hour forward for summer and then back for winter. But! * Some places are sensible and don't have DST at all (eg Australia/Queensland, America/Arizona) * Northern hemisphere summer corresponds to southern hemisphere winter, and vice versa * Everyone has a different way of defining the boundaries of summer and winter * And just to confuse us all, Irish Standard Time is used in summer, and they *subtract* an hour for winter time! The only way to handle timezones correctly and keep yourself even marginally sane is to hand the job on to somebody else. I dodged the whole issue by letting our Postgres database handle everything for us (date/time formats, timezones, the lot), and having our internal systems all just work in UTC. You'll likely find it easiest to do the same thing with a Python library. Just don't try to pretend to yourself that Greece uses GMT+2, because it's not that simple. For one thing, it's currently summer there... ChrisA