Fix more DST problems with the schedule display

This commit is contained in:
prpr 2024-03-28 19:17:35 +00:00
parent 95c9471b51
commit bb64837e79
3 changed files with 17 additions and 9 deletions

View File

@ -78,7 +78,7 @@ puts "
<tr>
<th class=hour></th>
"
set t [clock seconds]
set t [midnight]
set firstday [clock format $t -format {%Y%m%d}]
set daymap {}
loop i 0 8 {
@ -87,7 +87,7 @@ loop i 0 8 {
set day [clock format $t -format {%Y%m%d}]
set daymap($day) $i
set dayrmap($i) $day
incr t 86400
set t [midnight_local $($t+93600)]
}
puts "
</tr>

View File

@ -320,8 +320,7 @@ proc render_timeline {usedhours} {
# Midnight today.
set day [midnight]
set gday [clock scan "[clock format [clock seconds] -format {%Y %m %d}] 00:00:00" \
-format {%Y %m %d %T} -gmt 1]
set gday [midnight_gmt $day]
set elength [llength $events]
set eindex 0

View File

@ -12,12 +12,21 @@ proc lremove {var val} {
set v [lsearch -all -inline -not -exact $v $val]
}
# Returns the epoch time for midnight on the specified epoch date
proc midnight_gmt {t} {
set dt [clock format $t -format {%F}]
return [clock scan "$dt 00:00:00" -format {%F %T} -gmt 1]
}
# Returns the epoch time for midnight on the specified epoch date, accounting for local timezone
proc midnight_local {t} {
set dt [clock format $t -format {%F}]
return [clock scan "$dt 00:00:00" -format {%F %T}]
}
# Returns the epoch time for midnight today, accounting for local timezone
proc midnight {} {{today ""}} {
if {$today eq ""} {
set today [clock format [clock seconds] -format "%Y %m %d"]
}
return [clock scan "$today 00:00:00" -format "%Y %m %d %T"]
proc midnight {} {
return [midnight_local [clock seconds]]
}
# Base-64 according to RFC 4648