Everyday Utilities

pendulum

A clock that never lies to you about timezones, even after months of daylight saving changes.

Install it: pip install pendulum

What does it do?

Pendulum is a drop-in upgrade for Python’s date and time handling that fixes one of the most notoriously error-prone areas of programming: timezones and daylight saving transitions. Every date it creates is timezone-aware by default, which sounds small but eliminates an entire category of bugs where a timestamp silently means the wrong thing depending on where the code runs. It offers the same kind of natural methods as Arrow, adding days, formatting nicely, comparing dates, but with a particular focus on correctness underneath. Developers who’ve been burned by an off-by-one-hour bug around a daylight saving switch tend to become loyal fans.

See it in action

This gets the current time in New York, calculates the date exactly one week from now, and prints a friendly description of how recent the current moment is.

import pendulum

now = pendulum.now("America/New_York")
next_week = now.add(days=7)
print(next_week.to_datetime_string())
print(now.diff_for_humans())

Why would a non-developer care?

Timezone bugs are some of the most quietly damaging errors in software, because they don’t crash anything, they just show the wrong time to some subset of users. A tool built specifically to make timezone correctness the default rather than something you have to remember matters more than it sounds like it should.

Real-world examples

It gets pulled into scheduling, logging, and reporting systems, where a wrong timestamp isn’t just annoying but genuinely costly, like a financial report timestamped in the wrong timezone. Its author built it explicitly frustrated with how many timezone footguns existed in Python’s standard library and in Arrow.

Who uses it

Developers building scheduling, logging, or financial systems where getting a timestamp’s timezone wrong would actually cause real problems.

How it compares to alternatives

Its closest rival is Arrow; Pendulum tends to be favored by developers who prioritize timezone correctness above all else, while Arrow is often seen as having a slightly gentler, more beginner-friendly API.

New to Python and want to actually try libraries like this yourself?

Find a beginner-friendly course

Related libraries