This project has moved. For the latest updates, please go here.

How to programatically set pubDate property?

Topics: User Forum
Feb 6, 2007 at 6:39 PM
Is there is way to programatically set pubDate property, so that when i create a rss item the appropriate date is shown in the rss reader?
Feb 7, 2007 at 2:47 PM

markovuksanovic wrote:
Is there is way to programatically set pubDate property, so that when i create a rss item the appropriate date is shown in the rss reader?


I figured it out,... the date and time need to be in the RFC822 format...

Here's the code i used to transform the DateTime format to RFC822:

private enum DayOfTheWeek
{
Mon = 1,
Tue,
Wen,
Thu,
Fri,
Sat,
Sun
}

private enum Month
{
Jan = 1,
Feb,
Mar,
Apr,
May,
Jun,
Jul,
Aug,
Sep,
Oct,
Nov,
Dec
}

private string TransformToRFC822(DateTime dateTime)
{
string dateTimeRFC822="";

switch (dateTime.Day)
{
case 1:
dateTimeRFC822 += DayOfTheWeek.Mon;
break;
case 2:
dateTimeRFC822 += DayOfTheWeek.Tue;
break;
case 3:
dateTimeRFC822 += DayOfTheWeek.Wen;
break;
case 4:
dateTimeRFC822 += DayOfTheWeek.Thu;
break;
case 5:
dateTimeRFC822 += DayOfTheWeek.Fri;
break;
case 6:
dateTimeRFC822 += DayOfTheWeek.Sat;
break;
case 7:
dateTimeRFC822 += DayOfTheWeek.Sun;
break;
}

dateTimeRFC822 += ", " + dateTime.Day.ToString()+" ";

switch (dateTime.Month)
{
case 1:
dateTimeRFC822 += Month.Jan;
break;
case 2:
dateTimeRFC822 += Month.Feb;
break;
case 3:
dateTimeRFC822 += Month.Mar;
break;
case 4:
dateTimeRFC822 += Month.Apr;
break;
case 5:
dateTimeRFC822 += Month.May;
break;
case 6:
dateTimeRFC822 += Month.Jun;
break;
case 7:
dateTimeRFC822 += Month.Jul;
break;
case 8:
dateTimeRFC822 += Month.Aug;
break;
case 9:
dateTimeRFC822 += Month.Sep;
break;
case 10:
dateTimeRFC822 += Month.Oct;
break;
case 11:
dateTimeRFC822 += Month.Nov;
break;
case 12:
dateTimeRFC822 += Month.Dec;
break;
}

dateTimeRFC822 += " " + dateTime.Year + " " + dateTime.TimeOfDay + " UT";

return dateTimeRFC822;
}
Coordinator
Apr 23, 2007 at 10:40 PM
This discussion has been copied to Work Item 9810. You may wish to continue further discussion there.
Coordinator
May 6, 2007 at 5:28 AM
Full RFC822 compatibility is included in the 2.0 release
May 6, 2007 at 9:03 AM
Where can the new version (2.0) be downloaded ?