different time tuple format

Maksim Kasimov kasimov at i.com.ua
Wed Jun 8 10:33:40 CEST 2005


seems like it is not a platform specific,
i think to solve the problem i need put settings in order (in php it is php.ini file) thus i'll have a portable code.
i've check the following code on my various servers, and it gives me different results:

import time
time.tzname
time.daylight
time.strptime("2005-06-07 15:07:12", "%Y-%m-%d %H:%M:%S")
time.strptime("2005-06-07 15:07:12 EEST", "%Y-%m-%d %H:%M:%S %Z")




Python 2.3.3 (#1, Feb 28 2004, 20:35:22)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
 >>> import time
 >>> time.tzname
('EET', 'EEST')
 >>> time.daylight
1
 >>> time.strptime("2005-06-07 15:07:12", "%Y-%m-%d %H:%M:%S")
(2005, 6, 7, 15, 7, 12, 1, 158, -1)
 >>> time.strptime("2005-06-07 15:07:12 EEST", "%Y-%m-%d %H:%M:%S %Z")
(2005, 6, 7, 15, 7, 12, 1, 158, 1)



Python 2.2.3 (#1, Oct 22 2004, 03:10:44)
[GCC 2.95.4 20020320 [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
 >>> import time
 >>> time.tzname
('EET', 'EEST')
 >>> time.daylight
1
 >>> time.strptime("2005-06-07 15:07:12", "%Y-%m-%d %H:%M:%S")
(2005, 6, 7, 15, 7, 12, 6, 1, 0)
 >>> time.strptime("2005-06-07 15:07:12 EEST", "%Y-%m-%d %H:%M:%S %Z")
(2005, 6, 7, 15, 7, 12, 6, 1, 1)



wittempj at hotmail.com wrote:
> In your case it is the EEST, as this is the DST timezone (see again:
> http://docs.python.org/lib/module-time.html)
> 
> ** martin at ubuntu:~ $ python
> ** Python 2.4.1 (#2, Mar 30 2005, 21:51:10)
> ** [GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2)] on linux2
> ** Type "help", "copyright", "credits" or "license" for more
> information.
> ** >>> import time
> ** >>> print time.tzname
> ** ('CET', 'CEST')
> ** >>> time.strptime("2005-06-07 15:07:12 CET", "%Y-%m-%d %H:%M:%S %Z")
> ** (2005, 6, 7, 15, 7, 12, 1, 158, 0)
> ** >>> time.strptime("2005-06-07 15:07:12 CEST", "%Y-%m-%d %H:%M:%S
> %Z")
> ** (2005, 6, 7, 15, 7, 12, 1, 158, 1)
> ** >>>
> 


-- 
Best regards,
Maksim Kasimov
mailto: kasimov at i.com.ua



More information about the Python-list mailing list