http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89236
Revision: 89236
Author: rfaulk
Date: 2011-05-31 22:50:20 +0000 (Tue, 31 May 2011)
Log Message:
-----------
added 'timestamps_for_interval' method which produces timestamps over an
interval given a python datetime object and interval length
Modified Paths:
--------------
trunk/fundraiser-statistics/fundraiser-scripts/classes/TimestampProcessor.py
Modified:
trunk/fundraiser-statistics/fundraiser-scripts/classes/TimestampProcessor.py
===================================================================
---
trunk/fundraiser-statistics/fundraiser-scripts/classes/TimestampProcessor.py
2011-05-31 22:49:11 UTC (rev 89235)
+++
trunk/fundraiser-statistics/fundraiser-scripts/classes/TimestampProcessor.py
2011-05-31 22:50:20 UTC (rev 89236)
@@ -45,8 +45,28 @@
import math
import Fundraiser_Tools.classes.Helper as mh
+"""
+ Get timestamps for interval
+ INPUT:
+ start_time_obj - a datetime object indicating the start of the
interval
"""
+def timestamps_for_interval(start_time_obj, timestamp_format, **kwargs):
+
+ for key in kwargs:
+
+ if key == 'minutes':
+ end_time_obj = start_time_obj +
datetime.timedelta(minutes=kwargs[key])
+ elif key == 'hours':
+ end_time_obj = start_time_obj +
datetime.timedelta(hours=kwargs[key])
+
+ start_timestamp = timestamp_from_obj(start_time_obj, timestamp_format,
3)
+ end_timestamp = timestamp_from_obj(end_time_obj, timestamp_format, 3)
+
+ return [start_timestamp, end_timestamp]
+
+
+"""
Takes a list of timestamps as input and converts it to a set of days,
hours, or minutes counting back from 0
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs