2

I have searched on internet but unable to find this answer for this specific question.

This question is different from others because we don't know whether parsing string contains EST, PST at compile time. I am parsing RSS Feed's for a lot of sites and expecting pub date of some RSS in this format I want to parse this kind of format

Wed, 02 Oct 2002 08:00:00 EST

The problem is that i can not parse EST, PST etc when they come on run time.

The only solution left is to use a switch like this

so when PST comes at the end of string, i use forexample

 string TimeZone="";
 string LastThreeChar=raw.substring(raw.length-4,3);
 switch(LastTHreeChar)
  {
     case 'PST':
     TimeZone= "Pacific Standard Time";
     break;
   }
  TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(TimeZone);

Kindly help me.

Charlie
  • 4,827
  • 2
  • 31
  • 55
  • 3
    What do you want to do with ambiguous abbreviations? EST can mean various different things, IIRC. – Jon Skeet Nov 16 '15 at 10:58
  • so what should i do to parse this string. @JonSkeet – Charlie Nov 16 '15 at 11:05
  • You should ask yourself how you want to handle those ambiguities... – Jon Skeet Nov 16 '15 at 11:09
  • There must be some way i can determine rss feed belongs to specific time zone more than abbreviations. xml is following some standards. – Charlie Nov 16 '15 at 11:17
  • Yes, the RSS feed will be following standards - but they're bad standards, basically. (It was an appalling choice of date format, IMO.) I suspect you'll have to make assumptions about what is meant in any given case. See the duplicate question. – Jon Skeet Nov 16 '15 at 11:18
  • thank you, it helped me @JonSkeet – Charlie Nov 16 '15 at 11:27

0 Answers0