<p>我肯定会看一眼,解决你的问题需要遵循几个步骤。</p>
<p>首先需要分析字符串。很好地使用了Delorean<a href="http://delorean.readthedocs.org/en/latest/quickstart.html#strings-and-parsing" rel="noreferrer">parse</a>方法。</p>
<pre><code>>>> from delorean import parse
>>> d = parse("Wed, 20 Feb 2013 03:51:39 +0000")
>>> d
Delorean(datetime=2013-02-20 03:51:39+00:00, timezone=UTC)
</code></pre>
<p>一旦在Delorean对象中解析了日期时间,就可以简单地转换为EST</p>
<pre><code>>>> d = d.shift('US/Eastern')
>>> d
Delorean(datetime=2013-02-19 22:51:39-05:00, timezone=US/Eastern)
</code></pre>
<p>尽管毫无意义。你从来不用它来回答你的问题,但和德洛林在一起很容易。</p>
<p>那么你现在在东部时间</p>
<p>从delorean进口delorean</p>
<pre><code>>>> d1 = Delorean(timezone="US/Eastern")
>>> d1
Delorean(datetime=2013-02-21 00:35:56.405256-05:00, timezone=US/Eastern)
</code></pre>
<p>现在开始<a href="http://delorean.readthedocs.org/en/latest/quickstart.html#truncation" rel="noreferrer">truncation</a>步骤。</p>
<pre><code>>>> d.truncate('day')
Delorean(datetime=2013-02-21 00:00:00-05:00, timezone=US/Eastern)
</code></pre>
<p>执行上述简单的转换到UTC。</p>
<p>现在结束一天。</p>
<pre><code>d = d.next_day(1) # move to the next day
</code></pre>
<p>再往后移一秒钟。图书馆需要的东西我会更新的。只需通过使用<code>datetime</code>属性从<code>Delorean</code>示例中获取datetime。</p>
<pre><code>d.datetime - timedelta(seconds=1)
datetime.datetime(2013, 2, 21, 23, 59, 59, tzinfo=<DstTzInfo 'US/Eastern' EST-1 day, 19:00:00 STD>)
</code></pre>
<p>祝你好运,但是这个库应该只处理日期时间操作:)</p>