From be2110fb7fc6255bbc921a0a79acf7b565f3090d Mon Sep 17 00:00:00 2001 From: Li Yuxiao Date: Thu, 28 Mar 2024 21:33:51 +0800 Subject: [PATCH] Add a real clock for time. only applicable to one day events. --- ical2org.awk | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ical2org.awk b/ical2org.awk index 022ce8f..1021bfb 100755 --- a/ical2org.awk +++ b/ical2org.awk @@ -439,9 +439,28 @@ BEGIN { if (date2 != "") { # Fake some logbook entries so we can generate a clock report + hours1 = substr(date1, length(date1)-4, 2) + minutes1 = substr(date1, length(date1)-1, 2) + + # Extract hours and minutes for date2 + hours2 = substr(date2, length(date2)-4, 2) + minutes2 = substr(date2, length(date2)-1, 2) + + # Calculate differences + hdif = hours2 - hours1 + mdif = minutes2 - minutes1 + + if (mdif < 0) { + mdif += 60 + hdif -= 1 + } + dtime = sprintf("%d:%02d", hdif, mdif) + print " :LOGBOOK:" - print " CLOCK: [" date1 "]--[" date2 "] => " "0:00" + print " CLOCK: [" date1 "]--[" date2 "] => " dtime print " :END" + + } if (!condense) print "<" date ">"