Commit 2bc04131 authored by Thomas Lotze's avatar Thomas Lotze
Browse files

re #2: add filters for start and end date, fallback to month

parent f55ef92c
from calendar import monthrange
from datetime import date
from gitlabtime.fetch import fetch
from import report
from import report_csv
......@@ -19,6 +21,14 @@ import click
help='Filter for month (yyyy-mm)',
help='Filter for start date (yyyy-mm-dd)',
help='Filter for end date (yyyy-mm-dd)',
help='Filter for project name',
......@@ -31,9 +41,18 @@ import click
help='path to CSV output file',
def cli(url, token, month, project, username, csv):
def cli(url, token, month, start, end, project, username, csv):
if month:
first = month + '-01'
if not start:
start = first
if not end:
first = date.fromisoformat(first)
_, last = monthrange(first.year, first.month)
end = '{}-{}'.format(month, last)
filter = dict(
......@@ -39,7 +39,10 @@ def fetch_project(project, filter):
for author, date, seconds in fetch_times(item):
if filter['username'] not in (author, None):
if not date.startswith(filter['month'] or ''):
if (filter['start'] or '') > date:
if (filter['end'] or '9999-99-99') < date:
entries[author, date] += seconds
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment