iris.time

Time handling.

In this module:

A PartialDateTime object specifies values for some subset of the calendar/time fields (year, month, hour, etc.) for comparing with datetime.datetime-like instances.

Comparisons are defined against any other class with all of the attributes: year, month, day, hour, minute, and second. Notably, this includes datetime.datetime and cftime.datetime. Comparison also extends to the microsecond attribute for classes, such as datetime.datetime, which define it.

A PartialDateTime object is not limited to any particular calendar, so no restriction is placed on the range of values allowed in its component fields. Thus, it is perfectly legitimate to create an instance as: PartialDateTime(month=2, day=30).

class iris.time.PartialDateTime(year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None)[source]

Allows partial comparisons against datetime-like objects.

Args:

  • year (int):

  • month (int):

  • day (int):

  • hour (int):

  • minute (int):

  • second (int):

  • microsecond (int):

For example, to select any days of the year after the 3rd of April:

>>> from iris.time import PartialDateTime
>>> import datetime
>>> pdt = PartialDateTime(month=4, day=3)
>>> datetime.datetime(2014, 4, 1) > pdt
False
>>> datetime.datetime(2014, 4, 5) > pdt
True
>>> datetime.datetime(2014, 5, 1) > pdt
True
>>> datetime.datetime(2015, 2, 1) > pdt
False
day

The day number as an integer, or None.

hour

The hour number as an integer, or None.

microsecond

The microsecond number as an integer, or None.

minute

The minute number as an integer, or None.

month

The month number as an integer, or None.

second

The second number as an integer, or None.

timetuple = None
year

The year number as an integer, or None.