polyfemos.almanac.ordinal.Ordinal — polyfemos 0.3.29 documentation

# polyfemos.almanac.ordinal.Ordinal

class `polyfemos.almanac.ordinal.` `Ordinal`(*args, **kwargs)

  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)

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

    see `UTCDateTime` for more information about the `args` and `kwargs`

  `getstr`(sep='-')
    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)

    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)

    see `__iadd__()`

    Parameters

      a (int) –

    Return type

      `Ordinal`

    Returns

  `till`(endtime, step=1)

    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`()

    A static method

    Return type

      `Ordinal`

    Returns

      A current date at 12am UTC

  `utcdatetime`()
    Return type

      `UTCDateTime`

    Returns

      returns the current `Ordinal` instance as `UTCDateTime`

  Special Methods

  `__format__`(a)

    Adds a possibility to use python’s format function

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

    Parameters

      a –

    Return type

      str

    Returns

  `__iadd__`(a)

    Adds `a` days to the current date

    Parameters

      a (int) –

    Return type

      `Ordinal`

    Returns

  `__isub__`(a)

    Substracts `a` days from the current date

    Parameters

      a (int) –

    Return type

      `Ordinal`

    Returns