Me: I live in Silicon Valley with my wife, child and cat. I have worked at Microsoft since I graduated from College, both in the Macintosh Business Unit on products such as Outlook Express, Entourage, IE, and Virtual PC and in Windows Live on Hotmail, Calendar and People. I am currently a Principal Lead Program Manager on the Windows Live Social Networking team. I basically manage a team of Program Managers responsible for delivering features to support our web and client applications. I've been blogging since 2001 and like to play around with .NET in my spare time working on projects such as dasBlog (the blog that powers this site) and Send to SmugMug (an application for uploading photos to SmugMug). I blog about a number of technology and productivity related topics.
Powered by: newtelligence dasBlog 2.3.9074.18820
Disclaimer The posts on this weblog are provided "AS IS" with no warranties, and confer no rights. The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2010, Omar Shahine
E-mail
Recently I found the answer to two very hard questions about bugs in dasBlog. They were kinda tricky to figure out, but also really interesting (bug 2 will be in a follow up post)
Bug 1: DateTime.ToString()
One of the classes in dasBlog that stores information like Comments, Trackbacks and Pingbacks determines it's filename like so:
public string FileName{ get { return DateUtc.ToString("yyyy-MM-dd") + ".dayextra.xml"; }}
Well a few weeks ago Scott Hanselman emailed me with some files with names like 1425-05-05.dayextra. Can you figure out why this is?
Well as I found out, DateTime always assumes Gregorian Calendar, so DateTime.ToString() will output a filename with a Culture.Invariant filename. Well what happened to Scott is that he got comment spammed by some one who's Windows Region was set to a Culture that uses the Hijri Calendar. So, 1425-05-05 is the equivalent of 2004-06-22.
The reason this happened was because this person happened to be the first person to leave a comment, and thus the file was created using the CultureInfo from their machine!
The fix was to do the following:
public string FileName{ get { // Use Invariant Culture, not host culture (or user override), // for date formats. IFormatProvider mmddFormat = new CultureInfo(String.Empty, false); // Ignore local DateFormatInfo (could say CCYY-DD-MM), // always use CCYY-MM-DD. return DateUtc.ToString("yyyy-MM-dd", mmddFormat) + ".dayfeedback.xml"; }}
DateTime stuff is very tricky and dasBlog has 4 different kinds of DateTime so it can get confusing.
In all these cases dasBlog must know how to convert back and forth between all these formats and preserving the window of time that equals a single Day (24 hours of time, in the server, author, or UTC timezone).