Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25054
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'dst': 0.07; 'indicated': 0.07; 'determines': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'zero.': 0.09; '12))': 0.16; 'message- id:@dough.gmane.org': 0.16; 'need:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'utc': 0.16; 'switched': 0.17; 'thanks,': 0.18; 'python?': 0.20; 'hours,': 0.22; 'produces': 0.22; 'references': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'subject:skip:d 10': 0.27; 'correct': 0.28; 'header:X-Complaints-To:1': 0.28; 'hour.': 0.29; 'maybe': 0.29; 'year,': 0.30; 'to:addr:python-list': 0.33; 'equal': 0.33; 'version': 0.34; 'there': 0.35; 'received:org': 0.36; 'except': 0.36; 'should': 0.36; 'hours.': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'help': 0.40; 'think': 0.40; 'days': 0.60; 'skip:u 10': 0.60; 'different': 0.63; 'times': 0.63; 'date,': 0.65; 'hour': 0.69; 'day': 0.73; 'received:89': 0.86; 'outcome': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Damjan <gdamjan@gmail.com> |
| Subject | Re: Confusing datetime.datetime |
| Date | Sun, 08 Jul 2012 23:49:39 +0200 |
| References | <jt4766$og9$1@dough.gmane.org> <mailman.1843.1341528901.4697.python-list@python.org> <4ff71557$0$6974$e4fe514c@news2.news.xs4all.nl> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | 89.205.110.217 |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120616 Thunderbird/13.0.1 |
| In-Reply-To | <4ff71557$0$6974$e4fe514c@news2.news.xs4all.nl> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1928.1341784133.4697.python-list@python.org> (permalink) |
| Lines | 33 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1341784133 news.xs4all.nl 6925 [2001:888:2000:d::a6]:42741 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:25054 |
Show key headers only | View raw
> Because x1 and x2 have different time zones. > > The tzinfo field in x2 is equal to TZ and has a UTC offset of 1 hour. > The tzinfo field in x1 contains the DST version of that timezone, > with a UTC offset of 2 hours, because Skopje is currently on DST. > > I think you want: > > x2 = TZ.localize(datetime(x1.year, x1.month, x1.day)) > > That produces a datetime with the year, month and day set as indicated > and tzinfo set to the correct UTC offset for that date, at 00:00 hours. > > Or maybe you need: > > x2 = TZ.localize(datetime(x1.year, x1.month, x1.day, 12)) > x2 = x2.replace(hour=0) > > That determines whether DST should be on at noon, and then resets the > hour field to zero. This produces the same outcome as the one liner, > except on days when DST is switched on or off. Thanks, I think this will help me. Although these issues seem very much underdocumented in the datetime documentation. Are there any good references of using good times in Python? -- damjan
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: Confusing datetime.datetime Damjan <gdamjan@gmail.com> - 2012-07-06 00:55 +0200
Re: Confusing datetime.datetime Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-06 01:28 +0000
Re: Confusing datetime.datetime Damjan <gdamjan@gmail.com> - 2012-07-06 04:05 +0200
Re: Confusing datetime.datetime Hans Mulder <hansmu@xs4all.nl> - 2012-07-06 18:41 +0200
Re: Confusing datetime.datetime Damjan <gdamjan@gmail.com> - 2012-07-08 23:49 +0200
csiph-web