Last post Jun 15, 2008 09:39 AM by MrMox
Jun 14, 2008 09:53 AM|MrMox|LINK
I'm having a small problem with date formatting.
I'm reading a date from a master XML file. The date string is localized in Danish (say, "23 Maj 2007"). I then convert the date to RFC822 format for use in an RSS feed.
Here is the relevant part of the code (C#):
string dateString = objXrd.ReadString();
DateTime dt = DateTime.Parse(dateString, new CultureInfo("da-DK"));
objXwr.WriteElementString("pubDate",dt.ToString("R", new CultureInfo("da-DK")));
The DateTime.Parse reads the "23 Maj 2007" correctly and converts it to DateTime format.
But when I write the string to the RSS XML file in RFC822 format, the output is not "Onsdag, 23 Maj 2007, 02:00:00" as I would expect but "Wednesday, 23 May 2007 02:00:00".
What am I doing wrong?
Jun 14, 2008 09:24 PM|vcsjones|LINK
The "R" format parameter will always return days and months in English. That's part of the RFC standard.
Jun 15, 2008 09:39 AM|MrMox|LINK
Thanks for the info. That's kind of what I suspected.
I checked some other local feeds (newspapers etc.) with the IE7 RSS reader and they also display the date in English, so apparently that's not a big issue.
Now, wouldn't it have been neat if the RSS reader could use the <language> tag in the RSS feed to convert the date to a localized version...