r89236 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89235‎ | r89236 | r89237 >
Date:22:50, 31 May 2011
Author:rfaulk
Status:deferred
Tags:
Comment:
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) (history)

Diff [purge]

Index: trunk/fundraiser-statistics/fundraiser-scripts/classes/TimestampProcessor.py
@@ -45,8 +45,28 @@
4646 import math
4747 import Fundraiser_Tools.classes.Helper as mh
4848
 49+"""
 50+ Get timestamps for interval
4951
 52+ INPUT:
 53+ start_time_obj - a datetime object indicating the start of the interval
5054 """
 55+def timestamps_for_interval(start_time_obj, timestamp_format, **kwargs):
 56+
 57+ for key in kwargs:
 58+
 59+ if key == 'minutes':
 60+ end_time_obj = start_time_obj + datetime.timedelta(minutes=kwargs[key])
 61+ elif key == 'hours':
 62+ end_time_obj = start_time_obj + datetime.timedelta(hours=kwargs[key])
 63+
 64+ start_timestamp = timestamp_from_obj(start_time_obj, timestamp_format, 3)
 65+ end_timestamp = timestamp_from_obj(end_time_obj, timestamp_format, 3)
 66+
 67+ return [start_timestamp, end_timestamp]
 68+
 69+
 70+"""
5171
5272 Takes a list of timestamps as input and converts it to a set of days, hours, or minutes counting back from 0
5373

Status & tagging log