Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64953 > unrolled thread
| Started by | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| First post | 2014-01-29 14:21 -0800 |
| Last post | 2014-01-29 14:21 -0800 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: UTC "timezone" causing brain explosions Ethan Furman <ethan@stoneleaf.us> - 2014-01-29 14:21 -0800
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2014-01-29 14:21 -0800 |
| Subject | Re: UTC "timezone" causing brain explosions |
| Message-ID | <mailman.6099.1391035371.18130.python-list@python.org> |
On 01/29/2014 01:52 PM, Skip Montanaro wrote:
> Following up on my earlier note about UTC v. GMT, I am having some
> trouble grokking attempts to convert a datetime into UTC.
>
> Okay, let's see what GMT does for us:
>
>>>> GMT = pytz.timezone("GMT")
>>>> u = GMT.normalize(s)
>>>> u
> datetime.datetime(2014, 1, 29, 21, 39, 35, 263666, tzinfo=<StaticTzInfo 'GMT'>)
>>>> u.hour
> 21
>
> That looks correct, but I don't understand why I don't get hour==21
> out of the UTC.normalize call. It's like it's a no-op.
Having not examined the code, I can't tell you why UTC is different. I can say that .astimezone seems to work in all cases:
--> GMT
<StaticTzInfo 'GMT'>
--> UTC
<UTC>
--> LOCAL_TZ = pytz.timezone("America/Los_Angeles")
--> now = datetime.datetime.now()
--> s = LOCAL_TZ.localize(now)
--> s
datetime.datetime(2014, 1, 29, 14, 9, 56, 494967, tzinfo=<DstTzInfo 'America/Los_Angeles' PST-1 day, 16:00:00 STD>)
--> s.astimezone(UTC)
datetime.datetime(2014, 1, 29, 22, 9, 56, 494967, tzinfo=<UTC>)
--> s.astimezone(GMT)
datetime.datetime(2014, 1, 29, 22, 9, 56, 494967, tzinfo=<StaticTzInfo 'GMT'>)
--
~Ethan~
Back to top | Article view | comp.lang.python
csiph-web