Hi,

I wonder if anyone can help....

I am struggling to understand the representation of timedelta when used in 
conjunction with astimezone. 

Given the code below, in a python interactive interpreter, I am trying to 
calculate a resultant datetime an hour earlier from a UTC datetime....

```bash
    >>> dt = datetime(2021, 8, 22, 23, 59, 31, tzinfo=timezone.utc)
    >>> hour_before=dt.astimezone(timezone(-timedelta(seconds=3600)))
    >>> hour_before
    datetime.datetime(2021, 8, 22, 22, 59, 31, 
tzinfo=datetime.timezone(datetime.timedelta(days=-1, seconds=82800)))
```

I cannot understand why the resultant datetime.timedelta is days=-1, 
seconds=82800 (23 hours) .

Why is it not an hour earlier as seconds=-3600? Why is days = -1 when the 
resultant calculated date is the same, year, day, month??
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to