summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Schlaeger <cs@taskjuggler.org>2020-09-07 21:11:35 +0200
committerGitHub <noreply@github.com>2020-09-07 21:11:35 +0200
commitb32ead4e94082dc1dd2e97cbab2e022949e19079 (patch)
tree238e802811950f9b4dc67cb1867acfb14024a466 /lib
parent94e706d3cac058559e3ddee78b437d39f73e773b (diff)
parent114366863b001af51cd599ef62989feb3af15119 (diff)
downloadpostrunner-master.zip
Merge pull request #23 from nospam3335/topic/prefix_daily_timesHEADmaster
Make daily command indicate date of sleep events
Diffstat (limited to 'lib')
-rw-r--r--lib/postrunner/MonitoringStatistics.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/postrunner/MonitoringStatistics.rb b/lib/postrunner/MonitoringStatistics.rb
index fb8daea..3bfb9fc 100644
--- a/lib/postrunner/MonitoringStatistics.rb
+++ b/lib/postrunner/MonitoringStatistics.rb
@@ -115,6 +115,10 @@ module PostRunner
t.localtime(utc_offset).strftime('%H:%M')
end
+ def prefix_for_time(t, a)
+ a.window_start_time.strftime('%Y-%m-%d') == t.strftime('%Y-%m-%d') ? ' ' : '+'
+ end
+
def daily_sleep_cycle_table(analyzer)
ti = FlexiTable.new
ti.head
@@ -129,8 +133,8 @@ module PostRunner
if last_to_time && c.from_time > last_to_time
# We have a gap in the sleep cycles.
ti.cell('Wake')
- cell_right_aligned(ti, time_as_hm(last_to_time, utc_offset))
- cell_right_aligned(ti, time_as_hm(c.from_time, utc_offset))
+ cell_right_aligned(ti, prefix_for_time(last_to_time, analyzer) + time_as_hm(last_to_time, utc_offset))
+ cell_right_aligned(ti, prefix_for_time(c.from_time, analyzer) + time_as_hm(c.from_time, utc_offset))
cell_right_aligned(ti, "(#{secsToHM(c.from_time - last_to_time)})")
ti.cell('')
ti.cell('')
@@ -139,8 +143,8 @@ module PostRunner
end
ti.cell((idx + 1).to_s, format)
- ti.cell(c.from_time.localtime(utc_offset).strftime('%H:%M'), format)
- ti.cell(c.to_time.localtime(utc_offset).strftime('%H:%M'), format)
+ ti.cell(prefix_for_time(c.from_time.localtime(utc_offset), analyzer) + c.from_time.localtime(utc_offset).strftime('%H:%M'), format)
+ ti.cell(prefix_for_time(c.to_time.localtime(utc_offset), analyzer) + c.to_time.localtime(utc_offset).strftime('%H:%M'), format)
duration = c.to_time - c.from_time
totals[:duration] += duration