Why 2:30 AM can happen twice in one night, and why emojis break string lengths.
A timestamp like "Nov 3, 2:00 AM" is meaningless without a Timezone. In regions with Daylight Saving Time (DST), clocks roll back in Autumn. This means 1:59 AM is followed by 1:00 AM. The entire hour happens twice! If you schedule a job for 1:30 AM local time, it runs twice. Always store time in UTC (Coordinated Universal Time), which never jumps backwards.
Similarly, strings aren't just letters; they are bytes. A standard English letter is 1 byte, but an Emoji (like ) is 4 bytes. If you truncate a string by blindly slicing bytes (e.g., `bytes[0:2]`), you will chop an emoji in half, creating a corrupted string bug.
# BAD: Using local time
dt = datetime(2023, 11, 5, 1, 30)
# Is this the FIRST 1:30 AM or the SECOND 1:30 AM? Ambiguous!
# GOOD: Use UTC for storage and logic
dt = datetime.now(timezone.utc)
# UTC never observes DST. It is a strictly monotonic timeline.
# BAD: Slicing bytes directly
text = "Hi!".encode('utf-8')
truncated = text[0:4]
# Result: b'Hið' -> decoding this throws an Error!
# GOOD: Slicing Unicode Code Points (Characters)
text = "Hi!"
truncated = text[0:4] # "Hi!"
# The language handles the byte-length mapping internally.