Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom start date #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions gitfiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,14 @@ def calculate_multiplier(max_commits):
return m


def get_start_date():
"""returns a datetime object for the first sunday after one year ago today
at 12:00 noon"""
def get_default_date():
"""returns a datetime object from one year ago, at 12:00 noon"""
today = datetime.today()
date = datetime(today.year - 1, today.month, today.day, 12)
weekday = datetime.weekday(date)

while weekday < 6:
date = date + timedelta(1)
weekday = datetime.weekday(date)

return date
return datetime(today.year - 1, today.month, today.day, 12)

def calculate_next_sunday(date):
"""returns a datetime object for the first sunday after the input date"""
return date + timedelta(6 - datetime.weekday(date))

def generate_next_dates(start_date, offset=0):
"""generator that returns the next date, requires a datetime object as
Expand Down Expand Up @@ -406,7 +401,15 @@ def main():
except:
image = IMAGES[image_name_fallback]

start_date = get_start_date()
print('Enter the origin date (blank to start today, one year ago)')
try:
input_date = datetime.strptime(
request_user_input('yyyy-mm-dd: '),
'%Y-%m-%d')
except ValueError:
input_date = get_default_date()
start_date = calculate_next_sunday(input_date)

fake_it_multiplier = m * match

if not ghe:
Expand Down