美联社RSS日期

本文关键字:日期 RSS 美联社 | 更新日期: 2023-09-27 18:33:15

我正在尝试解析美联社RSS提要,日期真的让我感到困惑。 以下是 Feed 中一个项目的示例:

<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 小时。

您可能会看到与当前 Feed 中的任何项目的差异:

http://hosted2.ap.org/atom/APDEFAULT/3d281c11a96b4ad082fe88aa0db04305

美联社RSS日期

当您将实际故事加载为May. 5, 2012 8:28 PM ET时,您会正确地看到文章中<updated>2012-05-05T20:28:08-04:00</updated>日期/时间

20:28:08 (GMT-4) == 8:28 PM (ET)

您的 C# 代码很好,但您必须询问 AP 为什么文章在实际发布前两个小时最后一次更新。