Timezone filter icon

Timezone filter

Times that are always right, for everyone. The Timezone filter rewrites date/times inserted with its companion editor plugin (tiny_timezone) into each viewer's own timezone: a teacher in London writes "the webinar starts at 14:00" and a student in Sydney reads it as 23:00 local time, automatically. The original timestamp and source timezone travel inside the page markup, so the conversion is exact across daylight-saving boundaries and safe to repeat. If the filter is ever disabled, readers still see the full original date with its timezone — nothing breaks. The display format is configurable site-wide.
Price option: Free

Supports Moodle 5.0-5.2 See all versions
Latest release: 3 days ago
Installations: 5
Downloads (last 90 days): 6

Frankenstyle name: filter_timezone
Filters

Description

The Timezone filter (filter_timezone) solves a constant nuisance in multi-timezone courses: an announced time is only correct for readers in the author's timezone. Together with the tiny_timezone editor plugin, which lets authors insert a date/time picked in their own timezone, this text filter makes every such time display correctly for every reader. 

When a page is rendered, the filter finds the spans tiny_timezone inserted — each carries the exact Unix timestamp and the author's IANA timezone — and replaces the visible text with the same moment expressed in the viewing user's timezone, formatted with a site-configurable language-pack format string and labelled with the viewer's timezone name. Conversions use Moodle's own core_date and userdate() machinery, so daylight saving and half-hour offsets are handled exactly.

The filter is deliberately conservative and secure. It only rewrites spans whose content is exactly what the editor plugin wrote — anything an author typed around or inside the span is never discarded — and the replacement span is rebuilt from validated attributes only, so no attacker-controlled markup is ever reflected to other users. Disabled or uninstalled, pages degrade gracefully to the original text with its source timezone. Requires Moodle 5.0+; ships with PHPUnit tests and CI for Moodle 5.0–5.2.

Contributors

Awards

Privacy friendly
Automated testing support