diff options
| -rw-r--r-- | weekschedule.cls | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/weekschedule.cls b/weekschedule.cls index abc35be..75925b3 100644 --- a/weekschedule.cls +++ b/weekschedule.cls @@ -135,10 +135,18 @@ % ============================================ % Internal time parsing % ============================================ -% Parse time to decimal (e.g., "9:30" -> 9.5) +% Parse time to decimal and round to nearest 15-minute interval +% (e.g., "9:04" -> 9.0, "9:14" -> 9.25) \def\@parsetime#1{\@@parsetime#1\@nil} \def\@@parsetime#1:#2\@nil{% - \pgfmathparse{#1 + #2/60}% + % Convert to total minutes + \pgfmathparse{#1 * 60 + #2}% + \pgfmathtruncatemacro{\@totalminutes}{\pgfmathresult}% + % Round to nearest 15 minutes + \pgfmathparse{round(\@totalminutes/15)*15}% + \pgfmathtruncatemacro{\@roundedminutes}{\pgfmathresult}% + % Convert back to decimal hours + \pgfmathparse{\@roundedminutes/60}% \edef\@parsedtime{\pgfmathresult}% } |