python compare datetimes with different timezones

I'm implementing feature with scheduled publishing of object. User chooses the time to publish and i created a cron task to run every minute and check if it's the time to publish.

Users are from different timezones.

So i need to compare two datetimes:

>>user_chosen_time
datetime.datetime(2012, 12, 4, 14, 0, tzinfo=tzinfo(120))
>>curdate=datetime.datetime.now()
datetime.datetime(2012, 12, 4, 18, 4, 20, 17340)
>>user_chosen_time==curdate
*** TypeError: can't compare offset-naive and offset-aware datetimes

Sorry for rather stupid question but i need to discuss this. Thanks


http://pytz.sourceforge.net/ is where you want to look when you want to eliminate the timezone differencies :)

edit: just found this post on SO that may give you a lot more informations on your problem

链接地址: http://www.djcxy.com/p/11552.html

上一篇: 使用Phonegap显示和导航大型自定义地图

下一篇: python比较日期时间与不同的时区