Skip to content
This repository has been archived by the owner on Mar 24, 2021. It is now read-only.

Commit

Permalink
Hour produce an hourly range
Browse files Browse the repository at this point in the history
  • Loading branch information
phss committed Oct 18, 2013
1 parent 71bfe39 commit 568485b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backdrop/core/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def __init__(self):
self.name = "hour"
self._delta = timedelta(hours=1)

def _is_boundary(self, timestamp):
return self.valid_start_at(timestamp)

def start(self, timestamp):
return timestamp.replace(minute=0, second=0, microsecond=0)

Expand Down
10 changes: 10 additions & 0 deletions tests/core/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,13 @@ def test_that_returns_the_end_of_the_current_hour(self):

assert_that(end, is_(d(2013, 10, 4, 11, 0, 0)))

def test_that_a_range_of_five_hours_gives_us_five_data_points(self):
range = HOUR.range(d_tz(2013, 4, 3, 12), d_tz(2013, 4, 3, 17))

assert_that(list(range), contains(
(d_tz(2013, 4, 3, 12), d_tz(2013, 4, 3, 13)),
(d_tz(2013, 4, 3, 13), d_tz(2013, 4, 3, 14)),
(d_tz(2013, 4, 3, 14), d_tz(2013, 4, 3, 15)),
(d_tz(2013, 4, 3, 15), d_tz(2013, 4, 3, 16)),
(d_tz(2013, 4, 3, 16), d_tz(2013, 4, 3, 17))
))

0 comments on commit 568485b

Please sign in to comment.