On Mon, Jul 27, 2015 at 12:15 PM, Nikolaus Rath <nikol...@rath.org> wrote:

> On Jul 27 2015, Lennart Regebro <rege...@gmail.com> wrote:
> > That you add one hour to it, and the datetime moves forward one hour
> > in actual time? That's doable, but during certain circumstance this
> > may mean that you go from 1AM to 1AM, or from 1AM to 3AM.
> >
> > Or do you expect that adding one hour will increase the hour count
> > with one, ie that the "wall time" increases with one hour? This may
> > actually leave you with a datetime that does not exist, so that is not
> > something you can consistently do.
>
> Apologies for asking yet another dumb question about this, but I have
> the impression that a lot of other people are struggling with the basics
> here too.
>

I believe your questions are addressed to Lennart, but let me offer
my answer to the first:

>
> Can you tell us which of the two operations datetime currently
> implements?


The first one, but not as directly as one might wish.  (I think the
situation
is similar to that of pytz's normalize(), but I am not an expert on pytz.)

>>> t = datetime(2014,11,2,5,tzinfo=timezone.utc).astimezone()
>>> t.strftime("%D %T%z %Z")
'11/02/14 01:00:00-0400 EDT'
>>> (t+timedelta(hours=1)).astimezone().strftime("%D %T%z %Z")
'11/02/14 01:00:00-0500 EST'
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to