Ассошиэйтед Пресс RSS дата
Я пытаюсь разобрать RSS-канал Associated Press, и дата действительно сбивает меня с толку. Вот пример одного элемента в ленте:
<entry>
<id>urn:publicid:ap.org:Hosted2Syndication:b7f6d88749d341aa9a30e15dcb983b41</id>
<title type="text">9/11 defendants ignore judge at Guantanamo hearing</title>
<summary type="text">GUANTANAMO BAY NAVAL BASE, Cuba (AP) — They knelt in prayer, ignored the judge and wouldn't listen to Arabic translations as they confronted nearly 3,000 counts of murder. The self-proclaimed mastermind of the Sept. 11 attacks and four co-defendants defiantly disrupted an arraignment that dragged into Saturday night in the opening act of the long-stalled effort to prosecute them in a military court.</summary>
<published>2012-05-05T22:38:59-04:00</published>
<updated>2012-05-05T20:28:08-04:00</updated>
<author />
<link rel="alternate" type="text/html" title="AP Article" href="http://hosted2.ap.org/APDEFAULT/3d281c11a96b4ad082fe88aa0db04305/Article_2012-05-05-Guantanamo-Sept%2011%20Trial/id-b7f6d88749d341aa9a30e15dcb983b41" />
<content type="xhtml"></content>
</entry>
Итак, опубликованная дата: 2012-05-05T22:38:59-04:00
Если вы просматриваете этот элемент в своем браузере, дата отображается как: May. 5, 2012 8:28 PM ET
Когда я конвертирую это в дату в коде, однако:
DateTime date;
DateTime.TryParse("2012-05-05T22:38:59-04:00", out date);
Это выходит как: 5/5/2012 10:38:59 PM
Я не знаю, почему отображаемая дата на сайте отличается на 2 часа.
Вероятно, вы можете увидеть разницу с любым элементом в текущем фиде:
http://hosted2.ap.org/atom/APDEFAULT/3d281c11a96b4ad082fe88aa0db04305
1 ответ
Вы правильно видите <updated>2012-05-05T20:28:08-04:00</updated>
дата / время в статье, когда вы загружаете фактическую историю как May. 5, 2012 8:28 PM ET
20:28:08 (GMT-4) == 8:28 PM (ET)
Ваш код C# в порядке, но вам нужно будет спросить AP, почему статья была обновлена в последний раз за два часа до того, как она была действительно опубликована.