Skip to content

Commit

Permalink
docs: Updating TimeUtilities docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
rupozzi committed May 31, 2022
1 parent 9abc93d commit e64910a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions src/DIRAC/Core/Utilities/TimeUtilities.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
"""
DIRAC Times module
DIRAC TimeUtilities 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:
- 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
- DIRAC.TimeUtilities.second * 1.5 is not allowed
- DIRAC.TimeUtilities.second * 3 / 2 is allowed
An timeInterval class provides a method to check
if a give datetime is in the defined interval.
Expand Down Expand Up @@ -120,7 +116,7 @@ def toString(myDate=None):
elif isinstance(myDate, datetime.date):
return str(myDate)

elif isinstance(myDate, datetime.timedelta):
elif isinstance(myDate, datetime.time):
return "%02d:%02d:%02d.%06d" % (
myDate.days * 24 + myDate.seconds / 3600,
myDate.seconds % 3600 / 60,
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Core/Test_MySQLDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ def test_getDistinctAttributeValues(name, fields, requiredFields, values, table,
),
(table, allFields, genVal2(), name, {"older": "UTC_TIMESTAMP()", "timeStamp": "Time"}, 2, True),
(table, allFields, genVal2(), name, {"newer": "UTC_TIMESTAMP()", "timeStamp": "Time"}, 0, True),
(table, allFields, genVal2(), name, {"older": TimeUtilities.toString, "timeStamp": "Time"}, 2, True),
(table, allFields, genVal2(), name, {"newer": TimeUtilities.toString, "timeStamp": "Time"}, 0, True),
(table, allFields, genVal2(), name, {"older": TimeUtilities.toString, "timeStamp": "Time"}, 0, True),
(table, allFields, genVal2(), name, {"newer": TimeUtilities.toString, "timeStamp": "Time"}, 2, True),
],
)
def test_getFields(table, reqFields, values, name, args, expected, isExpectedCount):
Expand Down

0 comments on commit e64910a

Please sign in to comment.