iris.time#
Time handling.
- class iris.time.PartialDateTime(year=None, month=None, day=None, hour=None, minute=None, second=None, microsecond=None)[source]#
Bases:
object
Allow partial comparisons against datetime-like objects.
A
PartialDateTime
object specifies values for some subset of the calendar/time fields (year, month, hour, etc.) for comparing withdatetime.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
andcftime.datetime
. Comparison also extends to the microsecond attribute for classes, such asdatetime.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).Allow partial comparisons against datetime-like objects.
- Parameters:
year (int) – The year number as an integer, or None.
month (int) – The month number as an integer, or None.
day (int) – The day number as an integer, or None.
hour (int) – The hour number as an integer, or None.
minute (int) – The minute number as an integer, or None.
second (int) – The second number as an integer, or None.
microsecond (int) – The microsecond number as an integer, or None.
Examples
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#
- hour#
- microsecond#
- minute#
- month#
- second#
- timetuple = None#
A dummy value provided as a workaround to allow comparisons with
datetime.datetime
. See https://bugs.python.org/issue8005. NB. It doesn’t even matter what this value is.
- year#