From 789943fc3cbef7c060b7033e52c28600326dd684 Mon Sep 17 00:00:00 2001 From: Roland Hedberg Date: Tue, 28 Sep 2010 13:35:06 +0200 Subject: [PATCH] needed new function --- src/saml2/time_util.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/saml2/time_util.py b/src/saml2/time_util.py index 5a6040a..f9f8f25 100644 --- a/src/saml2/time_util.py +++ b/src/saml2/time_util.py @@ -234,6 +234,20 @@ def a_while_ago(days=0, seconds=0, microseconds=0, milliseconds=0, # --------------------------------------------------------------------------- +def shift_time(dtime, shift): + """ Adds/deletes an integer amount of seconds from a datetime specification + + :param dtime: The datatime specification + :param shift: The wanted time shift (+/-) + :return: A shifted datatime specification + """ + tstruct = dtime.timetuple() + tfl = time.mktime(tstruct) + tfl += shift + return datetime.utcfromtimestamp(tfl) + +# --------------------------------------------------------------------------- + def str_to_time(timestr): if not timestr: return 0