Android, Interesting

Google Calendar Subtle Duration Bug

Sometimes it is the most subtle and simple bugs that can really get under your skin and annoy you like nothing else. Recently I was dealing with data that I get sync from Google Calendear and I used RFC2445 and RFC5545 to get the specification for a ‘Duration’. Durations are important because according to the spec a VEVENT must have either a DTEND or a DURATION. Therefore I need to be able to parse durations when dealing with data that I get back from Google. The RFC’s define the duration as:

       dur-value  = (["+"] / "-") "P" (dur-date / dur-time / dur-week)

       dur-date   = dur-day [dur-time]
       dur-time   = "T" (dur-hour / dur-minute / dur-second)
       dur-week   = 1*DIGIT "W"
       dur-hour   = 1*DIGIT "H" [dur-minute]
       dur-minute = 1*DIGIT "M" [dur-second]
       dur-second = 1*DIGIT "S"
       dur-day    = 1*DIGIT "D"

But Google Calendar does not follow that pattern…Google Calendar events have a subtle difference:

       dur-value  = (["+"] / "-") "P" (dur-date / dur-time / dur-week)

       dur-date   = dur-day "T" [dur-time]
       dur-time   = (dur-hour / dur-minute / dur-second)
       dur-week   = 1*DIGIT "W"
       dur-hour   = 1*DIGIT "H" [dur-minute]
       dur-minute = 1*DIGIT "M" [dur-second]
       dur-second = 1*DIGIT "S"
       dur-day    = 1*DIGIT "D"

You probably did not even notice it but the ‘T’ character has moved. This caused my parser (generated with JavaCC) to fail and was an annoying problem to debug. It has also forced me to write many annoying test cases to make sure that I can easily ascertain if Google is doing the right thing in the future.

Just so that you know, this means that it generates incorrect periods. So Google Calendar generates a period that looks like this “P300S” whereas it should generate a valid period like this “PT300S”.

Advertisements
Interesting

Original LotR (Lord of the Rings) Funny Gifs

I’m taking a break from my usual programming posts to instead save an important part of internet history in an easy to discover place: this blog. If you are here then you probably know about the “One does not simply X” meme. But where did it all begin? I do not know who the original authors are but I do remember that sometime around 2008 (IIRC) I came across four gifs in a row that made me rofl. I must have watched them a million times all in this particular order that I liked. I never found out who the authors are but they are completely awesome and it is my hope that they will contact me or claim ownership eventually; the internet would like to thank them. The order that I like watching them in are:

  • One does not simply walk into Mordor
  • What about a Catapult (Part 1)
  • What about a Catapult (Part 2)
  • LotR: The Short Version

And without any more talking, here they are, in that order (If you want to download them all then I have a Zip file in Google Drive that you can download):

(Click on any of the images to open them in a new tab/window and play from the start)

One does not simply walk into Mordor

What about a Catapult (Part 1):

What about a Catapult (Part 2):

LotR: The Short Version

And that is all of them. I hope you enjoyed this post. Take the reference to the author on the last gif with a grain of salt. When I saw the original I do not remember it having any attribution so I will have to verify that they are in-fact the authors.