Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'detect': 0.07; 'alter': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tismer': 0.09; 'subject:question': 0.10; 'python': 0.11; 'thread': 0.14; 'grounds': 0.16; 'possible?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'language': 0.16; 'wrote:': 0.18; 'thanks.': 0.20; 'written': 0.21; '>>>': 0.22; 'programming': 0.22; 'header:User-Agent:1': 0.23; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'wondering': 0.29; 'leave': 0.29; 'statement': 0.30; "i'm": 0.30; 'calculated': 0.31; 'go.': 0.31; 'but': 0.35; 'there': 0.35; "i'll": 0.36; 'wrong': 0.37; 'christian': 0.38; 'to:addr:python- list': 0.38; 'ability': 0.39; 'itself': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'even': 0.60; 'manually': 0.60; 'world.': 0.61; 'saving': 0.69; '8bit%:92': 0.71; '8bit%:100': 0.72; 'saw': 0.77; 'suspicion': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: datetime question Date: Fri, 08 Nov 2013 22:18:46 +0000 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: host-78-147-18-11.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 In-Reply-To: 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1383949147 news.xs4all.nl 15997 [2001:888:2000:d::a6]:56678 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:58874 On 08/11/2013 22:01, Νίκος Αλεξόπουλος wrote: > Στις 8/11/2013 11:29 μμ, ο/η Mark Lawrence έγραψε: >> On 08/11/2013 21:11, Νίκος Αλεξόπουλος wrote: >>> Is there someway to write the following line even better with the >>> ability to detect daylight saving time by itself so i don't have to >>> alter the line manually when time changes? >>> >>> lastvisit = ( datetime.utcnow() + timedelta(hours=2) ).strftime( >>> '%y-%m-%d %H:%M:%S' ) # MySQL datetime format >>> >>> Thanks. >> >> http://stackoverflow.com/questions/19774709/use-python-to-find-out-if-a-timezone-currently-in-daylight-savings-time >> > > I saw the link and i'm wondering if it can be written in 1-liner. > Don't get me wrong but i had the lastvisit calculated on 1 statement and > i want to retain it this way. > > Is it possible? Yes, but I'll leave you to work out how to do it, on the grounds that I have a very, very strong suspicion about the way this thread is going to go. -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence