Module: ICU::TimeFormatting

Defined in:
lib/ffi-icu/time_formatting.rb

Defined Under Namespace

Classes: BaseFormatter, DateTimeFormatter

Constant Summary collapse

TZ_MAP =
{
  :generic_location =>   'VVVV',# The generic location format.
                                #   Where that is unavailable, falls back to the long localized GMT format ("OOOO";
                                #   Note: Fallback is only necessary with a GMT-style Time Zone ID, like Etc/GMT-830.),
                                #   This is especially useful when presenting possible timezone choices for user selection,
                                #   since the naming is more uniform than the "v" format.
                                #   such as "United States Time (New York)", "Italy Time"
  :generic_long     =>  'vvvv', # The long generic non-location format.
                                #   Where that is unavailable, falls back to generic location format ("VVVV")., such as "Eastern Time".
  :generic_short    =>     'v', # The short generic non-location format.
                                #   Where that is unavailable, falls back to the generic location format ("VVVV"),
                                #   then the short localized GMT format as the final fallback., such as "ET".
  :specific_long    =>  'zzzz', # The long specific non-location format.
                                #   Where that is unavailable, falls back to the long localized GMT format ("OOOO").
  :specific_short   =>     'z', # The short specific non-location format.
                                #   Where that is unavailable, falls back to the short localized GMT format ("O").
  :basic            =>     'Z', # The ISO8601 basic format with hours, minutes and optional seconds fields.
                                #   The format is equivalent to RFC 822 zone format (when optional seconds field is absent).
                                #   This is equivalent to the "xxxx" specifier.
  :localized_long   =>  'ZZZZ', # The long localized GMT format. This is equivalent to the "OOOO" specifier, such as GMT-8:00
  :extended         => 'ZZZZZ', # The ISO8601 extended format with hours, minutes and optional seconds fields.
                                #   The ISO8601 UTC indicator "Z" is used when local time offset is 0.
                                #   This is equivalent to the "XXXXX" specifier, such as -08:00 -07:52:58
  :localized_short  =>    'O',  # The short localized GMT format, such as GMT-8
  :localized_longO  => 'OOOO',  # The long localized GMT format, such as GMT-08:00
  :tz_id_short      =>    'V',  # The short time zone ID. Where that is unavailable,
                                #   the special short time zone ID unk (Unknown Zone) is used.
                                #   Note: This specifier was originally used for a variant of the short specific non-location format,
                                #   but it was deprecated in the later version of this specification. In CLDR 23, the definition
                                #   of the specifier was changed to designate a short time zone ID, such as uslax
  :tz_id_long       =>   'VV',  # The long time zone ID, such as America/Los_Angeles
  :city_location    =>  'VVV',  # The exemplar city (location) for the time zone. Where that is unavailable,
                                #   the localized exemplar city name for the special zone Etc/Unknown is used as the fallback
                                #   (for example, "Unknown City"), such as Los Angeles
  # see: http://unicode.org/reports/tr35/tr35-dates.html#Date_Format_Patterns
}

Class Method Summary collapse

Class Method Details

.clear_default_optionsObject



46
47
48
# File 'lib/ffi-icu/time_formatting.rb', line 46

def self.clear_default_options
  @default_options.clear
end

.create(options = {}) ⇒ Object



42
43
44
# File 'lib/ffi-icu/time_formatting.rb', line 42

def self.create(options = {})
  DateTimeFormatter.new(@default_options.merge(options))
end

.format(dt, options = {}) ⇒ Object



54
55
56
# File 'lib/ffi-icu/time_formatting.rb', line 54

def self.format(dt, options = {})
  create(@default_options.merge(options)).format(dt)
end

.set_default_options(options) ⇒ Object



50
51
52
# File 'lib/ffi-icu/time_formatting.rb', line 50

def self.set_default_options(options)
  @default_options.merge!(options)
end