Add custom Timezone to `TZInfo::Timezone`

575 Views Asked by At

My Rails application validates timezones (and finds offsets) by using the list of timezone names in TZInfo::Timezone.all_identifiers.

I am able to pull up timezones that have an :00 GMT offset without problems:

irb(main):008:0> TZInfo::Timezone.get("Etc/GMT+1")
=> #<TZInfo::DataTimezone: Etc/GMT+1>

But when attempting to pull up Etc/ timezones with a :30 offset, I receive the following runtime exception:

irb(main):012:0> TZInfo::Timezone.get("Etc/GMT+5:30")
Traceback (most recent call last):
        1: from (irb):12
TZInfo::InvalidTimezoneIdentifier (Invalid identifier)

I am specifically looking for Indian/Delhi or Etc/GMT+5:30.

How do I add a custom timezone name / offset to the list of sources in the tzinfo gem?

0

There are 0 best solutions below