Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news.astraweb.com!border5.newsrouter.astraweb.com!not-for-mail From: Ben Finney Newsgroups: comp.lang.python Subject: Re: utcnow References: X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney Date: Mon, 17 Sep 2012 14:48:09 +1000 Message-ID: <87vcfdl0fq.fsf@benfinney.id.au> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Cancel-Lock: sha1:wghYrNqedgVFEn8T0NNh8s9kmb4= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Lines: 30 Organization: Unlimited download news at news.astraweb.com NNTP-Posting-Host: e7a40bf2.news.astraweb.com X-Trace: DXC=1>^?XA6En1m=3UWcM[dT7dL?0kYOcDh@j7^o:UA4R?ce7hYWEOcT^fg]G;2>V^?kWcbEW9A[5UK?eNZ[SL`C\KgchIN4:cNSV writes: > Hello is there a better way of writing this: > > date = ( datetime.datetime.utcnow() + datetime.timedelta(hours=3) > ).strftime( '%y-%m-%d %H:%M:%S') > > something like: > > date = datetime.datetime.utcnow(hours=3).strftime( '%y-%m-%d %H:%M:%S') > > i prefer it if it could be written as this. Break long complicated statements into simpler statements. You might need to get used to naming your intermediate results. now = datetime.datetime.utcnow() later = now + datetime.timedelta(hours=3) timestamp_text = later.strftime("%Y-%m-%d %H:%M:%S") > Also what about dayligh savings time? What about it? What has your reading of the ‘datetime’ module documentation taught you? -- \ “Don't worry about people stealing your ideas. If your ideas | `\ are any good, you'll have to ram them down people's throats.” | _o__) —Howard Aiken | Ben Finney