Skip to main content

timespan_with_local_time

Given a timespan, format it in the given timezone, translating to the user's local time if it isn't the same. Automatically removes duplicate verbiage in the middle (e.g. day of week, time zone, etc.)

Parameters

format (String)

A time formatting string, like the one the built-in Liquid "date" filter uses (see http://strftime.net for examples). We recommend including "%Z" in this string in order to have an explicit time zone specifier.

input (ScheduledValue::TimespanDrop)

A timespan

timezone_name (String)

An IANA timezone name to use for the default format. If not given, this filter will try to use the convention's local timezone (if one exists).

Returns (String)

Examples

Formatting a timespan using an explicit time zone, while the user is in that zone
{{ convention.timespan
| timespan_with_local_time: "%A, %B %e from %l:%M%P %Z", "America/New_York" }} =>
"Saturday, July 11 from 10:00am to 11:59pm EDT"
Formatting a time using an explicit time zone, while the user is not in that zone
{{ convention.timespan
| timespan_with_local_time: "%A, %B %e from %l:%M%P %Z", "America/New_York" }} =>
"Saturday, July 11 from 10:00am to 11:59pm EDT (7:00am to 8:59pm PDT)"
Using the convention's time zone implicitly
{{ convention.timespan | timespan_with_local_time: "%A, %B %e from %l:%M%P %Z" }} =>
"Saturday, July 11 from 10:00am to 11:59pm EDT"