Python Arrow library is not handling DST properly - Stack Overflow

My understanding of shift method was it will take care of DST. However when testing for 10 hours shift

My understanding of shift method was it will take care of DST. However when testing for 10 hours shift on 2025-03-08T18:30:00 with US/Central as tzinfo, the expected output should be 2025-03-09T05:30:00-05:00 but I am getting 2025-03-09T04:30:00-05:00. Fyi, DST changes on March 9, 2025. At 2 a.m


# Step 1: Create a timezone-aware datetime using Arrow
start = arrow.get("2025-03-08T18:30:00").format('YYYY-MM-DDTHH:mm:ss')  # starting datetime
start_tz = arrow.get(start).replace(tzinfo='US/Central')  # Set the timezone to US/Central

# Step 2: Shift by 10 hours
shifted = start_tz.shift(hours=10)

# Step 3: Print the result
print(shifted)  # Should print: 2025-03-09T05:30:00-05:00 (after DST transition) but getting <Arrow [2025-03-09T04:30:00-05:00]>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744809199a4594964.html

相关推荐

  • Python Arrow library is not handling DST properly - Stack Overflow

    My understanding of shift method was it will take care of DST. However when testing for 10 hours shift

    2天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信