Minute

when_exactly.Minute dataclass

Bases: when_exactly.core.custom_interval.CustomInterval

Represents a single minute, from :00 to :01 the next minute.

A Minute is a 60-second interval. Minutes are numbered from 0 to 59.

Attributes:

Name Type Description
start when_exactly.core.moment.Moment

The moment at the start of the minute (inclusive).

stop when_exactly.core.moment.Moment

The moment at the start of the next minute (exclusive).

Example
>>> import when_exactly as wnx
>>> minute = wnx.Minute(2020, 1, 1, 0, 0)
>>> minute
Minute(2020, 1, 1, 0, 0)
>>> str(minute)
'2020-01-01T00:00'
>>> minute.next
Minute(2020, 1, 1, 0, 1)
>>> minute.second(30)
Second(2020, 1, 1, 0, 0, 30)
>>> len(list(minute.seconds()))
60

next property

The next minute.

previous property

The previous minute.

__init__(year, month, day, hour, minute)

Create a Minute from year, month, day, hour, and minute.

Parameters:

Name Type Description Default
year int

The year.

required
month int

The month (1-12).

required
day int

The day of month.

required
hour int

The hour (0-23).

required
minute int

The minute (0-59).

required

Returns:

Type Description
None

A Minute interval.

__repr__()

Return the canonical string representation of the minute.

__str__()

Return the ISO 8601 string representation of the minute.

from_moment(moment) classmethod

Create a Minute from a Moment.

Parameters:

Name Type Description Default
moment when_exactly.core.moment.Moment

The moment to extract the minute from.

required

Returns:

Type Description
when_exactly._api.Minute

The Minute containing the moment.

Example
>>> import when_exactly as wnx
>>> moment = wnx.Moment(2020, 1, 1, 15, 30, 45)
>>> wnx.Minute.from_moment(moment)
Minute(2020, 1, 1, 15, 30)

second(second)

Get a specific second of the minute.

Parameters:

Name Type Description Default
second int

The second (0-59).

required

Returns:

Type Description
when_exactly._api.Second

The Second for the specified second.

Example
>>> import when_exactly as wnx
>>> minute = wnx.Minute(2020, 1, 1, 0, 0)
>>> minute.second(30)
Second(2020, 1, 1, 0, 0, 30)

seconds()

Generate all 60 seconds in this minute.

Returns:

Type Description
typing.Iterable[when_exactly._api.Second]

An iterable of Second objects from :00 to :59.

Example
>>> import when_exactly as wnx
>>> minute = wnx.Minute(2020, 1, 1, 0, 0)
>>> seconds = list(minute.seconds())
>>> len(seconds)
60
>>> seconds[0]
Second(2020, 1, 1, 0, 0, 0)