diff --git a/docs/user-guide/configuration.md b/docs/user-guide/configuration.md index fbccd93..4a49e5b 100644 --- a/docs/user-guide/configuration.md +++ b/docs/user-guide/configuration.md @@ -247,6 +247,7 @@ stop_on_restart = false date_format = %Y.%m.%d time_format = %H:%M:%S%z week_start = monday +day_start_hour = 0 log_current = false pager = true report_current = false diff --git a/watson/cli.py b/watson/cli.py index 31b5887..da26f4f 100644 --- a/watson/cli.py +++ b/watson/cli.py @@ -1088,7 +1088,8 @@ def log(watson, current, reverse, from_, to, projects, tags, ignore_projects, if reverse is None: reverse = watson.config.getboolean('options', 'reverse_log', True) - span = watson.frames.span(from_, to) + day_start_hour = watson.config.getint('options', 'day_start_hour', 0) + span = watson.frames.span(from_, to, day_start_hour) filtered_frames = watson.frames.filter( projects=projects or None, tags=tags or None, ignore_projects=ignore_projects or None, diff --git a/watson/frames.py b/watson/frames.py index 0e51157..a195de5 100644 --- a/watson/frames.py +++ b/watson/frames.py @@ -61,10 +61,10 @@ def __gte__(self, other): class Span(object): - def __init__(self, start, stop, timeframe='day'): - self.timeframe = timeframe - self.start = start.floor(self.timeframe) - self.stop = stop.ceil(self.timeframe) + def __init__(self, start, stop, shift_hours): + timeframe = 'day' + self.start = start.floor(timeframe).shift(hours=shift_hours) + self.stop = stop.ceil(timeframe).shift(hours=shift_hours) def overlaps(self, frame): return frame.start <= self.stop and frame.stop >= self.start @@ -183,5 +183,5 @@ def filter( stop = span.stop if frame.stop > span.stop else frame.stop yield frame._replace(start=start, stop=stop) - def span(self, start, stop): - return Span(start, stop) + def span(self, start, stop, shift_hours): + return Span(start, stop, shift_hours) diff --git a/watson/watson.py b/watson/watson.py index 3f39be2..beb4f66 100644 --- a/watson/watson.py +++ b/watson/watson.py @@ -551,7 +551,8 @@ def report(self, from_, to, current=None, projects=None, tags=None, self.frames.add(cur['project'], cur['start'], arrow.utcnow(), cur['tags'], id="current") - span = self.frames.span(from_, to) + day_start_hour = self.config.getint('options', 'day_start_hour', 0) + span = self.frames.span(from_, to, day_start_hour) frames_by_project = sorted_groupby( self.frames.filter(