Interface RegionInfoModel<AdditionalData>

Region Info Model - Comprehensive regional localization and unit conversion system for KOS applications.

This singleton model provides centralized management of regional settings including time formats, date formats, unit systems, time zones, and intelligent unit conversion. Essential for building internationally-aware applications that adapt to local preferences and measurement standards.

Key Features

  • Time & Date Formatting - Configurable 12/24-hour time and various date order formats
  • Unit System Management - Complete metric/imperial conversion with precision control
  • Time Zone Support - Full time zone management with regional associations
  • Dynamic Configuration - Live updates through KOS configuration system
  • Type Safety - Generic support for additional regional data
  • Singleton Pattern - Single instance manages all regional settings

Unit Conversion System

The model provides intelligent unit conversion between different measurement systems:

  • Automatic scaling - Handles complex conversions with proper scaling factors
  • Precision control - Configurable decimal places per unit type
  • Family validation - Prevents invalid conversions (e.g., length to weight)
  • Default unit resolution - Automatic selection of appropriate units per system

Example: Basic Usage

const regionModel = RegionInfo.instance().build();

// Unit conversion and regional settings
const celsius = regionModel.convert(72, { unit: 'fahrenheit' }, { unit: 'celsius' });
console.log(regionModel.selectedCountry); // 'us'

Use Declared Type

See

interface RegionInfoModel<AdditionalData> {
    id: string;
    defaultUnitSystem: string;
    selectedUnitSystem: string;
    selectedTimeFormat: string;
    selectedDateFormat: string;
    selectedDateOrder: string;
    selectedCountry: string;
    selectedTimeZone: string;
    selectedRegion: RegionsResponse<AdditionalData>;
    is12HourTimeFormat: boolean;
    availableRegions: string[];
    regionId: string;
    timeZones: string[];
    allTimeZones: string[];
    timeFormatOptions: TimeFormatOptions[];
    dateFormatOptions: DateFormatOptions[];
    unitSystemOptions: UnitSystemOptions[];
    setSelectedTimeFormat(id): void;
    setSelectedDateFormat(id): void;
    setSelectedUnitSystem(id): void;
    getDefaultUnitForMeasure(measure, unitSystem): string;
    getDefaultUnitDecimalPlaces(measure, unitSystem, unit?): number;
}

Type Parameters

  • AdditionalData extends BaseRegionResponse = BaseRegionResponse

    Extends BaseRegionResponse for custom regional data requirements

Hierarchy (view full)

Methods

  • Sets the selected time format.

    Parameters

    • id: string

      The identifier of the time format to select.

    Returns void

  • Sets the selected date format.

    Parameters

    • id: string

      The identifier of the date format to select.

    Returns void

  • Sets the selected unit system.

    Parameters

    • id: string

      The identifier of the unit system to select.

    Returns void

  • Retrieves the default unit for a given measure in a specified unit system.

    Parameters

    • measure: string

      The measure for which to get the default unit.

    • unitSystem: string

      The unit system in which to find the default unit.

    Returns string

    The default unit for the specified measure and system.

  • Retrieves the default number of decimal places for a unit in a given measure and system.

    Parameters

    • measure: string

      The measure to consider.

    • unitSystem: string

      The unit system in which the unit is defined.

    • Optional unit: string

      Optional specific unit to consider.

    Returns number

    The number of decimal places for the unit.

Properties

id: string

Unique identifier for the region model instance.

defaultUnitSystem: string

The default unit system (e.g., metric or imperial) for the region.

selectedUnitSystem: string

The currently selected unit system.

selectedTimeFormat: string

The currently selected time format as a string.

selectedDateFormat: string

The currently selected date format as a string.

selectedDateOrder: string

The order of date elements (e.g., day/month/year) for the selected format.

selectedCountry: string

The currently selected country.

selectedTimeZone: string

The currently selected time zone.

selectedRegion: RegionsResponse<AdditionalData>

The detailed information of the selected region, extended with additional data. The type of additional data is determined by the generic parameter AdditionalData.

is12HourTimeFormat: boolean

Flag indicating if the 12-hour time format (AM/PM) is used.

availableRegions: string[]

An array of available regions as strings.

regionId: string

Identifier of the region.

timeZones: string[]

An array of available time zones as strings.

allTimeZones: string[]

An array of all available time zones as strings.

timeFormatOptions: TimeFormatOptions[]

Time format options available for selection.

dateFormatOptions: DateFormatOptions[]

Date format options available for selection.

unitSystemOptions: UnitSystemOptions[]

Unit system options available for selection.