Day

when_exactly.Day dataclass

Bases: when_exactly.core.custom_interval.CustomInterval

Represents a single day, from midnight to midnight.

A Day spans from 00:00:00 to 00:00:00 the next day (exclusive).

Attributes:

Name Type Description
start when_exactly.core.moment.Moment

The moment at midnight starting the day (inclusive).

stop when_exactly.core.moment.Moment

The moment at midnight ending the day (exclusive).

Example
>>> import when_exactly as wnx
>>> day = wnx.Day(2025, 1, 15)
>>> day
Day(2025, 1, 15)
>>> str(day)
'2025-01-15'
>>> day.next
Day(2025, 1, 16)
>>> day.month
Month(2025, 1)

month cached property

The month containing this day.

next property

The next day.

ordinal_day cached property

This day as an OrdinalDay.

week cached property

The ISO week containing this day.

weekday cached property

This day as a Weekday.

hour(hour)

Get a specific hour of the day.

Parameters:

Name Type Description Default
hour int

The hour (0-23).

required

Returns:

Type Description
when_exactly._api.Hour

The Hour for the specified hour.

Example
>>> import when_exactly as wnx
>>> day = wnx.Day(2025, 1, 15)
>>> day.hour(14)
Hour(2025, 1, 15, 14)