Period.with_origin#

Period.with_origin(origin_date_time)[source]#

Return a Period derived from this one but with the origin set to the specified datetime.

The date/time offset and ordinal shift of this Period are discarded and recalculated such that for the resulting Period object the following are True:

>>> from datetime import datetime
>>> origin_date_time = datetime(2024, 1, 1)
>>> period = Period.of_days(7).with_origin(origin_date_time)
>>> period.ordinal(origin_date_time)
0
>>> period.is_aligned(origin_date_time)
True
Parameters:

origin_date_time (datetime) – The datetime to become ordinal 0, and the start of an interval

Return type:

Period

Returns:

A Period object