cf.dt

cf.dt(arg, month=1, day=1, hour=0, minute=0, second=0, microsecond=0, calendar='')[source]

Return a date-time object for a date and time according to a calendar.

See also

cf.dt_vector

Parameters
arg:

A multi-purpose argument that is one of:

  • An int specifying the calendar year, used in conjunction with the month, day, hour, minute, second and microsecond parameters.

  • A str specifying an ISO 8601-like date-time string (in which non-Gregorian calendar dates are allowed).

  • datetime.datetime or subclass `cftime.datetime (such as Datetime360Day). A new date-time object is returned for the given date-time.

calendar: str, optional

The calendar for the date-time. By default the Gregorian calendar is used.

Parameter example:

calendar='360_day'

Returns
(subclass of) cftime.datetime

The new date-time object.

Examples:

>>> d = cf.dt(2003)
>>> d
cftime.DatetimeGregorian(2003-01-01 00:00:00)
>>> print(d)
2003-01-01 00:00:00
>>> d = cf.dt(2003, 2, 30, calendar='360_day')
>>> d = cf.dt(2003, 2, 30, 0, 0, 0, calendar='360_day')
>>> d = cf.dt('2003-2-30', calendar='360_day')
>>> d = cf.dt('2003-2-30 0:0:0', calendar='360_day')
>>> d
cftime.Datetime360Day(2003:02:30 00:00:00)
>>> print(d)
2003-02-30 00:00:00
>>> d = cf.dt(2003, 4, 5, 12, 30, 15)
>>> d = cf.dt(year=2003, month=4, day=5, hour=12, minute=30, second=15)
>>> d = cf.dt('2003-04-05 12:30:15')
>>> d.year, d.month, d.day, d.hour, d.minute, d.second
(2003, 4, 5, 12, 30, 15)