Loading topic
datetime module has three core types for calendar values: date, time, and datetime. Every other tool in the module, including time zones, builds on them. This chapter shows how to create each type, read its parts, and combine or modify them.3 min readdate, time, and datetime types from the previous chapter. It also assumes you are comfortable with basic Python arithmetic and exceptions.2 min readdatetime objects and use timedelta, and that you know what UTC and an offset such as +02:00 are. Time zone names come in a later chapter. Here the zones are UTC and fixed offsets.3 min readtimedelta. Here you will use the two simplest kinds of time zone in the standard library: UTC and a fixed offset.3 min readdatetime and timedelta types, and the difference between naive and aware datetimes. You should also know what UTC is. Here you will get the current time safely and convert between datetimes and POSIX timestamps.3 min readdate, datetime and timedelta types, the difference between naive and aware datetimes, and how to attach a ZoneInfo. It covers converting between datetimes and text.2 min readtimezone.utc and fixed offsets. A fixed offset such as UTC-05:00 cannot describe a place like New York, because New York changes its offset during the year. zoneinfo, added in Python 3.9, fills t3 min readZoneInfo. It also assumes you know that a naive datetime has no tzinfo and an aware one does. Here you will learn how astimezone moves a moment between zones, and which mistakes make the result wrong.2 min readZoneInfo to a datetime and convert it with astimezone. You also need to know the difference between naive and aware datetimes.3 min readtimedelta, aware datetimes, ZoneInfo, and astimezone. It covers what happens when you add a duration to a datetime in a zone that changes its clock.3 min readZoneInfo and call astimezone. It explains where the zone rules behind ZoneInfo("America/New_York") come from, and what to do when they are missing.3 min readdatetime, timedelta, ZoneInfo, and astimezone, and that you understand naive versus aware datetimes. It collects them into rules you can apply to real programs.3 min read