From 3a172adb84bf06e7a71cab1e32213b184464671a Mon Sep 17 00:00:00 2001 From: Sergey Bogdanov Date: Mon, 17 Jan 2022 12:07:54 +0000 Subject: [PATCH] Fix day lag Signed-off-by: Sergey Bogdanov --- diary.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/diary.rb b/diary.rb index 83be077..80bcde4 100644 --- a/diary.rb +++ b/diary.rb @@ -64,6 +64,8 @@ class DbTime @time.to_time.localtime.strftime("%Y-%m-%d %H:%M:%S") elsif @time.is_a? DateTime and @time.mjd > 0 @time.new_offset(@@offset).strftime("%Y-%m-%d %H:%M:%S") + elsif @time.class == Time + @time.to_time.localtime.strftime("%Y-%m-%d %H:%M:%S") else "" end @@ -135,7 +137,10 @@ class DiaryPerson @records += 1 # We assume that 20:00 is the rough time people submit the diary - @lag += (created - (ddate + Rational(20, 24))) + tlag = (created -((Time.strptime(ddate.to_s + " 00:00:00", "%Y-%m-%d %H:%M:%S")) + 20*60*60))/60/60/24 + if tlag > 0 + @lag += tlag + end week_day_name = Date::ABBR_DAYNAMES[ddate.wday] @week[week_day_name][:hours] += hours.to_i