Second

when_exactly.Second dataclass

Bases: when_exactly.core.custom_interval.CustomInterval

Represents a single second.

A Second is a 1-second interval, the finest resolution supported by when-exactly. Seconds are numbered from 0 to 59.

Attributes:

Name Type Description
start when_exactly.core.moment.Moment

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

stop when_exactly.core.moment.Moment

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

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

next property

The next second.

previous property

The previous second.

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

Create a Second from year, month, day, hour, minute, and second.

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
second int

The second (0-59).

required

Returns:

Type Description
None

A Second interval.

__repr__()

Return the canonical string representation of the second.

__str__()

Return the ISO 8601 string representation of the second.

from_moment(moment) classmethod

Create a Second from a Moment.

Parameters:

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

The moment to extract the second from.

required

Returns:

Type Description
when_exactly._api.Second

The Second containing the moment.

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

minute()

Get the minute containing this second.

Returns:

Type Description
when_exactly._api.Minute

The Minute containing this second.

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