Skip to content

Timezone handling #27

@ez-plugins

Description

@ez-plugins

Problem

Currently countdowns/announcements start relative to the server/process start time. For recurring announcements (for example, "announce every 2 hours") you must start the timer at the correct clock boundary and keep the process running. This is inconvenient and error-prone.

Use case

  • I want the plugin to announce every 2 hours on the clock (e.g., 00:00, 02:00, 04:00...) regardless of when the server or bot was started.
  • The schedule should be timezone-aware (e.g., align to the nearest timezone or a configured timezone per guild/server).

Proposed feature

Add an option for recurring timers to align to real-world clock intervals and to specify a timezone. Example configuration options:

  • align_to_clock: boolean (default: false) - if true, align repeats to clock boundaries
  • align_interval: string (e.g., "2h", "1d", or cron expression) - the interval to align to
  • timezone: string (IANA timezone, e.g., "America/New_York") - the timezone to use for alignment; if omitted use server local or guild setting

Behavior examples

  • interval: 2h, align_to_clock: true, timezone: "UTC"
    -> announcements at 00:00, 02:00, 04:00 UTC regardless of start time
  • interval: 1d, align_to_clock: true, timezone: "Europe/London"
    -> announcements at 00:00 Europe/London each day

Acceptance criteria

  • New option(s) available in configuration and/or command API to enable clock-aligned schedules and set timezone.
  • Timers persist and re-calculate next run across process restarts.
  • Handles DST changes correctly for named timezones.
  • Backwards compatible: default behavior remains the current relative countdown.
  • Documentation and examples added to README.

Implementation notes / suggestions

  • Use a cron-like schedule parser or support both an interval+alignment flag and cron expressions.
  • Use a timezone-aware library (e.g., luxon or moment-timezone) to compute next run times and handle DST.
  • Persist schedule state so restart/resume works without manual intervention.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions