From cannonball at inbox.lv Wed Nov 2 19:59:23 2011 From: cannonball at inbox.lv (Andrej) Date: Wed, 02 Nov 2011 20:59:23 +0200 Subject: [icalendar-dev] Daylight saving time bug Message-ID: <1320260363.4eb1930bf15bf@mail.inbox.lv> > hi there > >I've also encoutered the daylight saving time bug. I think we could fix this by using the >following patch > >--- prop.py >+++ (clipboard) >@@ -309,7 +309,7 @@ > > def ical(self): > if self.dt.tzinfo: >- utc_time = self.dt - self.dt.tzinfo.utcoffset(self.dt) >+ utc_time = self.dt - self.dt.tzinfo.utcoffset(datetime.now()) > return utc_time.strftime("%Y%m%dT%H%M%SZ") > return self.dt.strftime("%Y%m%dT%H%M%S") > >i found the bug by trying the following in a python shell: > >>>> l=LocalTimezone(datetime.datetime(2011, 12, 23, 13,30)) >>>> l >CET >>>> date=datetime.datetime(2011, 12, 23, 13,30) >>>> date.replace(tzinfo=l) >datetime.datetime(2011, 12, 23, 13, 30, tzinfo=CET) >>>> l.utcoffset(datetime.datetime.now()) >datetime.timedelta(0, 7200) >>>> l.utcoffset(date) >datetime.timedelta(0, 3600) >>>> datetime.datetime.now() >datetime.datetime(2011, 8, 22, 10, 14, 40, 272260) > >utcoffset respects the date and knows when to use daylight saving time. therefore we >should use the actual date when evaluating the utcoffset > >marc Correct me if I'm wrong, using datetime.now() works correctly only when creating events for the current time zone? For example I have an event at 8:00 every monday for a year. Today I create the iCalendar file for the whole year in advance. When the time zone changes datetime.now() (today) is still used for offset calculation, which is wrong? cannonball From mail at ck.org.ua Fri Nov 4 21:53:40 2011 From: mail at ck.org.ua (Sergii Kauk) Date: Fri, 4 Nov 2011 21:53:40 +0100 Subject: [icalendar-dev] Date format usage bug In-Reply-To: References: Message-ID: Hello! I tried to add an ical feed from a website that uses the library to Google Calendar and didn't work. So I decided to figure out what's wrong with the feed and put it through the validator which said that there was a problem with the date format. Even though DATE-TIME format was used (the default one), it was specified that the value is in the DATE format with ";VALUE=DATE" expression. For example: DTEND;VALUE=DATE:20110710T220000 DTSTAMP;VALUE=DATE:20110624T170640 DTSTART;VALUE=DATE:20110708T180000 I've made some tests and found out that isinstance() function was used to check the format of the field and when it checks a 'datetime' variable against 'date' type it returns True: dt = datetime(2011, 7, 9) isinstance(dt, datetime.date) = True So even when DATE-TIME format is used in the code you'll get an explicit declaration of DATE format in the feed. To fix that we should additionally check if the value is in the DATE-TIME format: if isinstance(dt, date) and not isinstance(dt, datetime) A temporary workaround for the code that uses icalendar library would be for example: event.set('dtstart', prop.vDatetime(datetime(2011,7,9,12,0)).ical(), encode=0) I'm attaching a patch file with the solution. I did a few tests and got the right results when specifying different date formats. Regards, Sergii Kauk -------------- next part -------------- A non-text attachment was scrubbed... Name: prop.py.patch Type: application/octet-stream Size: 433 bytes Desc: not available Url : http://codespeak.net/pipermail/icalendar-dev/attachments/20111104/c77c8304/attachment.obj From mail at ck.org.ua Fri Nov 11 18:50:58 2011 From: mail at ck.org.ua (Sergii Kauk) Date: Fri, 11 Nov 2011 18:50:58 +0100 Subject: [icalendar-dev] Date format usage bug In-Reply-To: <4EBD5F24.1020000@ieee.org> References: <4EBD5F24.1020000@ieee.org> Message-ID: Yes, it is the same issue. Actually, I encountered it a few month ago but back then my message was bounced off and I didn't notice it. Thanks! On Fri, Nov 11, 2011 at 18:45, Joe Sapp wrote: > This looks like issue #9 in the github issue tracker [1]. I think this has > also been reported on this mailing list a few times in the past few years. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://codespeak.net/pipermail/icalendar-dev/attachments/20111111/4a63bdf8/attachment.htm From sappj at ieee.org Fri Nov 11 18:45:08 2011 From: sappj at ieee.org (Joe Sapp) Date: Fri, 11 Nov 2011 12:45:08 -0500 Subject: [icalendar-dev] Date format usage bug In-Reply-To: References: Message-ID: <4EBD5F24.1020000@ieee.org> This looks like issue #9 in the github issue tracker [1]. I think this has also been reported on this mailing list a few times in the past few years. -- Joe [1] https://github.com/collective/icalendar/pull/9 On 11/04/2011 04:53 PM, Sergii Kauk wrote: > Hello! > > I tried to add an ical feed from a website that uses the library to > Google Calendar and didn't work. So I decided to figure out what's > wrong with the feed and put it through the validator which said that > there was a problem with the date format. Even though DATE-TIME format was > used (the default one), it was specified that the value is in the DATE > format with ";VALUE=DATE" expression. > For example: > > DTEND;VALUE=DATE:20110710T220000 > DTSTAMP;VALUE=DATE:20110624T170640 > DTSTART;VALUE=DATE:20110708T180000 > > I've made some tests and found out that isinstance() function was used > to check the format of the field and when it checks a 'datetime' > variable against 'date' type it returns True: > > dt = datetime(2011, 7, 9) > isinstance(dt, datetime.date) = True > > So even when DATE-TIME format is used in the code you'll get an > explicit declaration of DATE format in the feed. To fix that we should > additionally check if the value is in the DATE-TIME format: > > if isinstance(dt, date) and not isinstance(dt, datetime) > > A temporary workaround for the code that uses icalendar library would > be for example: > > event.set('dtstart', prop.vDatetime(datetime(2011,7,9,12,0)).ical(), encode=0) > > I'm attaching a patch file with the solution. I did a few tests and > got the right results when specifying different date formats. > > Regards, > > Sergii Kauk > > > > _______________________________________________ > icalendar-dev mailing list > icalendar-dev at codespeak.net > http://codespeak.net/mailman/listinfo/icalendar-dev