4

The following code print 2022-01-01 05:30:00-04:56. What's -04:56?

import pytz, datetime
tz = pytz.timezone("America/New_York")
t = datetime.datetime(2022, 1,1, 5, 30)
u = t.replace(tzinfo=tz)
print(u)

2022-01-01 05:30:00-04:56

In jupyter, u has the value of datetime.datetime(2022, 1, 1, 5, 30, tzinfo=<DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD>). What's DstTzInfo? And what's 19:04:00 STD?

ca9163d9
  • 27,283
  • 64
  • 210
  • 413
  • 1
    [Similar](https://stackoverflow.com/q/11473721/12671057)? – Kelly Bundy Jun 11 '22 at 00:01
  • 1
    Does this answer your question? [Time zone field in isoformat](https://stackoverflow.com/questions/26264897/time-zone-field-in-isoformat) – 0x263A Jun 11 '22 at 00:21
  • I find it to be weird and a bit distressing that the [answer referenced by @0x263A](https://stackoverflow.com/questions/26264897/time-zone-field-in-isoformat) also had a ` -04:56` offset at an example date in October, (which would be EST `-04:00` in the US]. But the ["equation of time"](https://en.wikipedia.org/wiki/Equation_of_time) says that the difference in directions should be in the opposite direction relative to 1 January, which is used here. Just tested code on 3.10.4 and am replicating results from that 2014 answer. – webelo Jun 11 '22 at 00:47

1 Answers1

2

(Delete previous answer)

My bad: I parsed datetime.datetime(2022, 1,1, 5, 30) as 30 May (I'm answering this on 10 June.). We're not in daylight savings time in January.

^ For me, this whole question is yet another reminder that I don't * really * understand time.

OP. will you please remove this as an accepted solution? (It will not allow me to delete an accepted solution.)

webelo
  • 1,646
  • 1
  • 14
  • 32