punchcard: shift midnight alignment

This commit is contained in:
Frédéric Péters 2020-07-31 19:49:47 +02:00
parent b1784a694a
commit 01a3c60ceb
1 changed files with 9 additions and 2 deletions

View File

@ -16,11 +16,18 @@ class Command(GraphCommand):
if options.get('committime'):
datetime_var = 'commit_datetime'
def hour_shift(x):
x = x - 4
if x < 0:
x += 24
return x
for commit in self.get_events(options):
coords = (getattr(commit, datetime_var).weekday(), getattr(commit, datetime_var).hour)
coords = (getattr(commit, datetime_var).weekday(), hour_shift(getattr(commit, datetime_var).hour))
infos[coords] = infos[coords] + 1
draw_punchcard(infos)
draw_punchcard(infos,
ax2_ticks=list(range(4, 24)) + list(range(4)))
self.plot(options)
# https://stackoverflow.com/a/14850998