Import the datetime
and timedelta
classes from the datetime
package without having to fully qualify their uses.
This commit is contained in:
14
gitfiti.py
14
gitfiti.py
@ -9,7 +9,7 @@ gitfiti
|
|||||||
noun : Carefully crafted graffiti in a github commit history calendar
|
noun : Carefully crafted graffiti in a github commit history calendar
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
from datetime import datetime, timedelta
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
@ -237,13 +237,13 @@ def multiplier(max_commits):
|
|||||||
def get_start_date():
|
def get_start_date():
|
||||||
"""returns a datetime object for the first sunday after one year ago today
|
"""returns a datetime object for the first sunday after one year ago today
|
||||||
at 12:00 noon"""
|
at 12:00 noon"""
|
||||||
d = datetime.datetime.today()
|
d = datetime.today()
|
||||||
date = datetime.datetime(d.year - 1, d.month, d.day, 12)
|
date = datetime(d.year - 1, d.month, d.day, 12)
|
||||||
weekday = datetime.datetime.weekday(date)
|
weekday = datetime.weekday(date)
|
||||||
|
|
||||||
while weekday < 6:
|
while weekday < 6:
|
||||||
date = date + datetime.timedelta(1)
|
date = date + timedelta(1)
|
||||||
weekday = datetime.datetime.weekday(date)
|
weekday = datetime.weekday(date)
|
||||||
|
|
||||||
return date
|
return date
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ def date_gen(start_date, offset=0):
|
|||||||
input. The offset is in weeks"""
|
input. The offset is in weeks"""
|
||||||
start = offset * 7
|
start = offset * 7
|
||||||
for i in itertools.count(start):
|
for i in itertools.count(start):
|
||||||
yield start_date + datetime.timedelta(i)
|
yield start_date + timedelta(i)
|
||||||
|
|
||||||
|
|
||||||
def values_in_date_order(image, multiplier=1):
|
def values_in_date_order(image, multiplier=1):
|
||||||
|
Reference in New Issue
Block a user