X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FTimestamp.py;h=9f382ece6a3f79192e4138909c45f8a061dcf10a;hb=refs%2Fheads%2Fremove-xmlrpc;hp=1b1f9ad7600d06fb34b15e9b4f60892f2837ac2f;hpb=fe81b2c91b436b1882f63023413c7f51b29538ed;p=plcapi.git diff --git a/PLC/Timestamp.py b/PLC/Timestamp.py index 1b1f9ad..9f382ec 100644 --- a/PLC/Timestamp.py +++ b/PLC/Timestamp.py @@ -1,10 +1,5 @@ # # Utilities to handle timestamps / durations from/to integers and strings -# -# $Id$ -# $URL$ -# - # # datetime.{datetime,timedelta} are powerful tools, but these objects are not # natively marshalled over xmlrpc @@ -19,7 +14,7 @@ from PLC.Parameter import Parameter, Mixed # a dummy class mostly used as a namespace class Timestamp: - + debug=False # debug=True @@ -36,8 +31,8 @@ class Timestamp: "%Y-%m-%d %H:%M UTC", ] - # for timestamps we usually accept either an int, or an ISO string, - # the datetime.datetime stuff can in general be used locally, + # for timestamps we usually accept either an int, or an ISO string, + # the datetime.datetime stuff can in general be used locally, # but not sure it can be marshalled over xmlrpc though @staticmethod @@ -49,17 +44,17 @@ class Timestamp: @staticmethod def sql_validate (input, timezone=False, check_future = False): """ - Validates the specified GMT timestamp, returns a + Validates the specified GMT timestamp, returns a standardized string suitable for SQL input. Input may be a number (seconds since UNIX epoch back in 1970, - or a string (in one of the supported input formats). + or a string (in one of the supported input formats). - If timezone is True, the resulting string contains + If timezone is True, the resulting string contains timezone information, which is hard-wired as 'UTC' - + If check_future is True, raises an exception if timestamp is in - the past. + the past. Returns a GMT timestamp string suitable to feed SQL. """ @@ -108,7 +103,7 @@ class Timestamp: Translates input timestamp as a unix timestamp. Input may be a number (seconds since UNIX epoch, i.e., 1970-01-01 - 00:00:00 GMT), a string (in one of the supported input formats above). + 00:00:00 GMT), a string (in one of the supported input formats above). """ if Timestamp.debug: print 'cast_long, in:',input,