zulip_tools.py: Add `get_threshold_timestamp()` function.

Given `threshold_days` this function returns a timestamp corresponding
to the time before threshold number of days.
This commit is contained in:
Harshit Bansal 2017-08-19 23:43:44 +05:30 committed by Tim Abbott
parent 8954605726
commit e71f92b09e
1 changed files with 8 additions and 0 deletions

View File

@ -173,3 +173,11 @@ def get_recent_deployments(threshold_days):
if os.path.exists("/root/zulip"):
recent.add("/root/zulip")
return recent
def get_threshold_timestamp(threshold_days):
# type: (int) -> int
# Given number of days, this function returns timestamp corresponding
# to the time prior to given number of days.
threshold = datetime.datetime.now() - datetime.timedelta(days=threshold_days)
threshold_timestamp = int(time.mktime(threshold.utctimetuple()))
return threshold_timestamp