polyfemos.almanac.ordinal.Ordinal

class polyfemos.almanac.ordinal.Ordinal(*args, **kwargs)[source]

Bases: obspy.core.utcdatetime.UTCDateTime

A class for treating dates as years and days of the year, with a precicion of 1 day.

Public Methods

__init__(*args, **kwargs)[source]

If no arguments are given, returns the current date, at 12am UTC

see UTCDateTime for more information about the args and kwargs

getstr(sep='-')[source]
Parameters

sep (str, optional) – defaults to hyphen

Return type

str

Returns

A string representation of the date, year and the day of the year, separated with sep.

static range(starttime, endtime, step=1)[source]

A static method

Alternatively, starttime and endtime can be given as datatypes accepted by UTCDateTime constructor.

Parameters
  • starttime (Ordinal) –

  • endtime (Ordinal) –

  • step (int, optional) – defaults to 1, the step size of the date sequence in days.

Return type

generator

Returns

A generator yielding Ordinal dates between starttime and endtime, including both.

shiftdays(a)[source]

see __iadd__()

Parameters

a (int) –

Return type

Ordinal

Returns

till(endtime, step=1)[source]

See range() for more info.

Parameters
  • endtime (Ordinal) –

  • step (int, optional) – defaults to 1, the step size of the date sequence in days.

Return type

generator

Returns

A generator yielding Ordinal dates between self and endtime, including both.

static today()[source]

A static method

Return type

Ordinal

Returns

A current date at 12am UTC

utcdatetime()[source]
Return type

UTCDateTime

Returns

returns the current Ordinal instance as UTCDateTime

Special Methods

__format__(a)[source]

Adds a possibility to use python’s format function

>>> "{}".format(Ordinal)
Parameters

a

Return type

str

Returns

__iadd__(a)[source]

Adds a days to the current date

Parameters

a (int) –

Return type

Ordinal

Returns

__isub__(a)[source]

Substracts a days from the current date

Parameters

a (int) –

Return type

Ordinal

Returns