Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'attribute': 0.05; 'used.': 0.07; 'alter': 0.09; 'sep': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'sat,': 0.15; 'bind': 0.16; 'clause,': 0.16; 'doesnt': 0.16; 'sits': 0.16; 'skip:d 60': 0.16; 'subject:issue': 0.16; 'tighter': 0.16; '>>>': 0.18; 'equivalent': 0.20; 'import': 0.21; '"",': 0.22; 'work,': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header :In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(most': 0.27; 'skip:( 50': 0.29; 'file': 0.32; "skip:' 20": 0.32; 'traceback': 0.33; 'url:home': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'server': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'wanted': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'where': 0.40; 'between': 0.63; 'hours': 0.66; '8bit%:100': 0.70; '8bit%:92': 0.70; 'dennis': 0.91; 'skip:\xc3 10': 0.91 Newsgroups: comp.lang.python Date: Sun, 16 Sep 2012 01:25:30 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=94.68.84.56; posting-account=DYJQ-woAAACEPH85Au2BhUVfFTfSfVa4 References: <52847c35-388c-4758-b72d-1d1859b788a3@googlegroups.com> <8370412f-5176-45ff-87eb-72cbca5149d5@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 94.68.84.56 MIME-Version: 1.0 Subject: Re: datetime issue From: =?ISO-8859-7?B?zenq/Ovh7/Igyu/98eHy?= To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 91 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347783937 news.xs4all.nl 6916 [2001:888:2000:d::a6]:35651 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29296 =CE=A4=CE=B7 =CE=9A=CF=85=CF=81=CE=B9=CE=B1=CE=BA=CE=AE, 16 =CE=A3=CE=B5=CF= =80=CF=84=CE=B5=CE=BC=CE=B2=CF=81=CE=AF=CE=BF=CF=85 2012 8:53:57 =CF=80.=CE= =BC. UTC+3, =CE=BF =CF=87=CF=81=CE=AE=CF=83=CF=84=CE=B7=CF=82 Dennis Lee Bi= eber =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: > On Sat, 15 Sep 2012 22:15:38 -0700 (PDT), =C3=8D=C3=A9=C3=AA=C3=BC=C3=AB= =C3=A1=C3=AF=C3=B2 =C3=8A=C3=AF=C3=BD=C3=B1=C3=A1=C3=B2 >=20 > declaimed the following in >=20 > gmane.comp.python.general: >=20 >=20 >=20 >=20 >=20 > >=20 >=20 > > If i wanted to alter the following line, how would i write it? >=20 > >=20 >=20 > > date =3D datetime.datetime.now()+datetime.timedelta(hours=3D2).strftime= ( '%y-%m-%d %H:%M:%S') >=20 > >=20 >=20 > > But that doesnt work, >=20 >=20 >=20 > What did you expect? Object methods bind tighter than operators so >=20 > what you have is the equivalent of >=20 >=20 >=20 > dn =3D datetime.datetime.now() >=20 > dd =3D datetime.timedelta(hours=3D2).strftime(...) >=20 > date =3D dn + dd >=20 >=20 >=20 > Try >=20 >=20 >=20 > >>> import datetime >=20 > >>> date =3D datetime.datetime.now()+datetime.timedelta(hours=3D2).strfti= me( '%y-%m-%d %H:%M:%S') >=20 > Traceback (most recent call last): >=20 > File "", line 1, in >=20 > AttributeError: 'datetime.timedelta' object has no attribute 'strftime' >=20 > >>> date =3D (datetime.datetime.now()+datetime.timedelta(hours=3D2) ).str= ftime( '%y-%m-%d %H:%M:%S') >=20 > >>> date >=20 > '12-09-16 03:50:44' >=20 > >>>=20 >=20 >=20 >=20 > Note the ( ) wrapping the the + clause, with strftime() applied to >=20 > the result of that... >=20 > --=20 >=20 > Wulfraed Dennis Lee Bieber AF6VN >=20 > wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/ date =3D ( datetime.datetime.now() + datetime.timedelta(hours=3D8) ).strfti= me( '%y-%m-%d %H:%M:%S') but iam giving +8 hours which is the time difference between texas, us wher= e the server sits and Greece's time. cant we somehow tell it to use GMT+2 ? also it would be nice if datetime.datetime.now(GMT+2) can be used.