DIRAC Times module Support for basic Date and Time operations based on system datetime module.
It provides common interface to UTC timestamps, converter to string types and back.
The following datetime classes are used in the returned objects:
dateTime = datetime.datetime
date = datetime.date
time = datetime.timedelta
Useful timedelta constant are also provided to define time intervals.
Notice: datetime.timedelta objects allow multiplication and division by interger but not by float. Thus:
DIRAC.Times.second * 1.5 is not allowed
DIRAC.Times.second * 3 / 2 is allowed
An timeInterval class provides a method to check if a give datetime is in the defined interval.
Return current UTC date, as datetime.date object if a _dateTimeType is pass as argument its associated date is returned
Return current UTC datetime, as datetime.datetime object
Get date from seconds since 2K
Get datetime object from epoch
Convert date/time/datetime String back to appropriated objects
The format of the string it is assume to be that returned by toString method. See notice on toString method On Error, return None
Decorator to measure the function call time
Return current UTC time, as datetime.time object if a _dateTimeType is pass as argument its associated time is returned
- class DIRAC.Core.Utilities.Time.timeInterval(initialDateTime, intervalTimeDelta)
Simple class to define a timeInterval object able to check if a given dateTime is inside
- __init__(initialDateTime, intervalTimeDelta)
Initialization method, it requires the initial dateTime and the timedelta that define the limits. The upper limit is not included thus it is [begin,end) If not properly initialized an error flag is set, and subsequent calls to any method will return None
Function to be used as a decorator for timing other functions/methods
Get seconds, with microsecond precission, since 2K
Get seconds since epoch
Get milliseconds since epoch
Convert to String if argument type is neither _dateTimeType, _dateType, nor _timeType the current dateTime converted to String is returned instead
- Notice: datetime.timedelta are converted to strings using the format:
[day] days [hour]:[min]:[sec]:[microsec] where hour, min, sec, microsec are always positive integers, and day carries the sign.
- To keep internal consistency we are using:
[hour]:[min]:[sec]:[microsec] where min, sec, microsec are always positive integers and hour carries the sign.