Skip to content

Agenda Extension timezone issue + 24hr time being forced #138

@tannerkovach

Description

@tannerkovach

There needs to be settings to control these things. My Sunday events were being displayed for Monday (it was saying Today Sunday was Monday), and also using 24hr time despite my desktop shell/system using 12hr time. Didn't feel like waiting for a fix so got an LLM to help fix the issue on my end (just a band-aid fix), but might be useful for anyone else having the same issue.


File: ~/.local/share/vicinae/extensions/store.vicinae.agenda/upcoming-events.js

Issue

Event times displayed 8 hours off (e.g., 9:00 AM showed as 1:00 AM) due to local time being stored as UTC internally by node-ical/rrule.

Changes

1. 12-hour time format

Occurrences: 3

- hour12:!1
+ hour12:!0

Changes time display from 24-hour to 12-hour format.


2. Date grouping - use local date instead of ISO date

- M=new Date(O.start).toISOString().split("T")[0]
+ M=((d)=>(d.getFullYear()+"-"+String(d.getMonth()+1).padStart(2,"0")+"-"+String(d.getDate()).padStart(2,"0")))(new Date(O.start))

Groups events by local date rather than UTC date, preventing events from appearing under the wrong day.


3. Section title date parsing

- ln=r=>{let i=new Date(r)
+ ln=r=>{let i=((s)=>{let[y,m,d]=s.split("-").map(Number);return new Date(y,m-1,d)})(r)

Parses the date string as local time components instead of letting new Date() interpret it (which can cause timezone shifts).


4. Time display functions - force UTC timezone

Occurrences: 2 (start time and end time functions)

Start time (Me function):

- Me=(r,i)=>i?"":r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0})
+ Me=(r,i)=>i?"":r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0,timeZone:"UTC"})

End time (mn function):

- mn=(r,i)=>i?void 0:r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0})
+ mn=(r,i)=>i?void 0:r.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!0,timeZone:"UTC"})

Since node-ical/rrule stores local time values as UTC timestamps, displaying with timeZone:"UTC" shows the intended local time.


Root Cause

The node-ical library (or rrule) stores event times with the local time value in the UTC position. For example, a 9:00 AM PST event gets stored as 09:00 UTC instead of 17:00 UTC. By forcing display in UTC, we retrieve the original local time value.

Affected Timezone

Tested with US/Pacific (PST, -0800). The fix should work for any timezone as it addresses the underlying storage issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions