Re: Converting from local DST to UTC
On Wed, Apr 22, 2009 at 2:42 AM, vickywrote: > > Hi, > > I am new in django. I need to update events from my website to > outlook, Google, yahoo calendars. I have implemented some code from > vObject which download ".ics" file which is OK for outlook. I don't > know how to update event in Google and yahoo calendar. > > Please help me. > You'd be better off asking for help in forums for those tools (Google and yahoo calendar). How to update events for them has nothing to do with Django. Karen --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Converting from local DST to UTC
On Apr 15, 10:04 pm, Jamiewrote: > On Apr 14, 9:34 pm, Brian Neal wrote: > > > This is how I am doing it (I'm also integrating with Google Calendar): > > > tz = pytz.timezone(tz_name) # create timezone > > local = tz.localize(d) # make naive datetime localized > > zulu = local.astimezone(FixedOffset(0)) # convert to UTC > > s = zulu.strftime('%Y-%m-%dT%H:%M:%S.000Z') > > tz.localize() did the trick. > > I was using naive_datetime.replace(tzinfo = tz) to convert from naive > to a localized time. Once I changed that to tz.localize > (naive_datetime), it worked perfectly. > > Thanks for the help! Hi, I am new in django. I need to update events from my website to outlook, Google, yahoo calendars. I have implemented some code from vObject which download ".ics" file which is OK for outlook. I don't know how to update event in Google and yahoo calendar. Please help me. --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Converting from local DST to UTC
On Apr 14, 9:34 pm, Brian Nealwrote: > This is how I am doing it (I'm also integrating with Google Calendar): > tz = pytz.timezone(tz_name) # create timezone > local = tz.localize(d) # make naive datetime localized > zulu = local.astimezone(FixedOffset(0)) # convert to UTC > s = zulu.strftime('%Y-%m-%dT%H:%M:%S.000Z') tz.localize() did the trick. I was using naive_datetime.replace(tzinfo = tz) to convert from naive to a localized time. Once I changed that to tz.localize (naive_datetime), it worked perfectly. Thanks for the help! --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Converting from local DST to UTC
On Apr 14, 7:26 pm, Jamiewrote: > I am working on an app that will export a calendar event to Google > Calendar. Google Calendar requires that event datetimes be in UTC > format. I can make the conversion from local (America/New_York) to UTC > using pytz, but the time is off by an hour due to daylight savings > time (Python thinks the offset is -0500 rather than -0400) so all of > my exported events are off as a result. pytz does adjust for daylight savings time, that is one of its primary jobs. > > I'm first taking the naive datetime stored by Django and adding the > local timezone pulled from settings.py then using astimezone(pytz.utc) > to make the conversion to UTC. I'm not sure how to adjust for DST, > especially since all the events will be in the future and DST will > have to be calculated for each of them. Try using 'US/Eastern' instead of 'America/New_York'. It might be different. This is how I am doing it (I'm also integrating with Google Calendar): from django.utils.tzinfo import FixedOffset d = datetime.datetime.now() tz_name = 'US/Eastern' # or whatever tz = pytz.timezone(tz_name) # create timezone local = tz.localize(d) # make naive datetime localized zulu = local.astimezone(FixedOffset(0)) # convert to UTC s = zulu.strftime('%Y-%m-%dT%H:%M:%S.000Z') I think I probably could have used pytz.utc instead of FixedOffset(0). It's the same idea. But at least now this thread has Django content. :-) Hope that helps, BN --~--~-~--~~~---~--~~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---