time_zone.rb 553 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Setting::Validation::TimeZone < Setting::Validation::Base
  3. def run
  4. if value.blank?
  5. return result_failed(__('Time zone is required.'))
  6. end
  7. if !self.class.valid_timezone_identifier?(value)
  8. return result_failed(__('Given time zone is not valid.'))
  9. end
  10. result_success
  11. end
  12. def self.valid_timezone_identifier?(input)
  13. ActiveSupport::TimeZone.find_tzinfo input
  14. true
  15. rescue TZInfo::InvalidTimezoneIdentifier
  16. false
  17. end
  18. end