cf.Datetime¶
-
class
cf.Datetime(year, month=1, day=1, hour=0, minute=0, second=0, microsecond=0, dayofwk=-1, dayofyr=1)[source]¶ Bases:
objectA date-time object which supports CF calendars.
Any date and time valid in any CF calendar is allowed.
In many situations, it may be used interchangeably with a built-in
datetime.datetimeobject. For example:>>> import datetime >>> d = cf.Datetime(2004, 2, 30) >>> d > datetime.datetime(2004, 2, 1) True
Attributes
Attribute Description yearThe year of the date monthThe month of the year of the date dayThe day of the month of the date hourThe hour of the day of the date minuteThe minute of the hour of the date secondThe second of the minute of the date microsecondThe microsecond of the second of the date See also
Initialization
Parameters: - year : int
The year.
- month, day, hour, minute, second, microsecond : ints, optional
The month of the year, the day of the month and time of the day. month and day default to 1 and hour; minute, second and microsecond default to 0.
Examples: >>> cf.Datetime(2003) <CF Datetime: 2003-01-01 00:00:00> >>> d = cf.Datetime(2003, 2, 30) >>> d = cf.Datetime(2003, 2, 30, 0) >>> d = cf.Datetime(2003, 2, 30, 0, 0) >>> d = cf.Datetime(2003, 2, 30, 0, 0, 0) >>> d = cf.Datetime(2003, 4, 5, 12, 30, 15) >>> d = cf.Datetime(year=2003, month=4, day=5, hour=12, minute=30, second=15) >>> d.year, d.month, d.day, d.hour, d.minute, d.second (2003, 4, 5, 12, 30, 15) >>> d.timetuple() (2003, 4, 5, 12, 30, 15, -1, 1)