Skip to content

Commit 92a8da6

Browse files
committed
heatmap: fix date wrapping
1 parent 8576717 commit 92a8da6

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

heatmap/heatmap.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ def slice_columns(columns, low_freq, high_freq):
110110
stop_col = sum(f<=args.high_freq for f in columns)
111111
return start_col, stop_col-1
112112

113+
def parse_time(t):
114+
return datetime.datetime.strptime(t, '%Y-%m-%d %H:%M:%S')
115+
113116
freqs = set()
114117
f_cache = set()
115118
times = set()
@@ -148,8 +151,8 @@ def slice_columns(columns, low_freq, high_freq):
148151
max_z = max(max_z, max(zs))
149152

150153
if start is None:
151-
start = datetime.datetime.strptime(line[0] + ' ' + line[1], '%Y-%m-%d %H:%M:%S')
152-
stop = datetime.datetime.strptime(line[0] + ' ' + line[1], '%Y-%m-%d %H:%M:%S')
154+
start = parse_time(line[0] + ' ' + line[1])
155+
stop = parse_time(line[0] + ' ' + line[1])
153156

154157
freqs = list(sorted(list(freqs)))
155158
times = list(sorted(list(times)))
@@ -216,7 +219,7 @@ def rgb3(z):
216219
draw.text((x, y), s, font=font, fill='white')
217220

218221
duration = stop - start
219-
duration = duration.seconds
222+
duration = duration.days * 24*60*60 + duration.seconds + 30
220223
pixel_height = duration / len(times)
221224
hours = int(duration / 3600)
222225
minutes = int((duration - 3600*hours) / 60)

0 commit comments

Comments
 (0)