I'm working on something that involves parsing out a date from a string, so i'm using the datetime.strptime() function. I've noticed that this works correctly in python, but when i run it within a django environment it doesn't seem to work. Example, in python:
[EMAIL PROTECTED]:~/projects/mu_tools$ python Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from datetime import datetime >>> test_time = "Tue Sep 30 15:33:07 EDT" >>> test_format = "%a %b %d %H:%M:%S %Z" >>> datetime.strptime(test_time, test_format) datetime.datetime(1900, 9, 30, 15, 33, 7) >>> And in a django python shell: [EMAIL PROTECTED]:~/projects/mu_tools$ ./manage.py shell Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52) [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from datetime import datetime >>> test_time = "Tue Sep 30 15:33:07 EDT" >>> test_format = "%a %b %d %H:%M:%S %Z" >>> datetime.strptime(test_time, test_format) Traceback (most recent call last): File "<console>", line 1, in <module> File "/usr/lib/python2.5/_strptime.py", line 330, in strptime (data_string, format)) ValueError: time data did not match format: data=Tue Sep 30 15:33:07 EDT fmt=%a %b %d %H:%M:%S %Z After playing with different types of strings, the problem seems to be the timezone - if i leave the timezone out of the time string and the format string, it will parse correctly. However, I'm not sure why this would break in Django - presumably it's something to do with the timezone setting in settings.py? (this is django-1.0, btw) If anybody can point me in the right direction I'd really appreciate it. Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---