Interface RegionInfoModel<AdditionalData>

Represents a model for region information, extending the basic region options and data model. It allows for managing regional settings and unit conversions.

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[];
    convert(value, from, to): string;
    setSelectedTimeFormat(id): void;
    setSelectedDateFormat(id): void;
    setSelectedUnitSystem(id): void;
    getDefaultUnitForMeasure(measure, unitSystem): string;
    getUnitMeasure: ((unit) => string);
    getDefaultUnitDecimalPlaces(measure, unitSystem, unit?): number;
}

Type Parameters

  • AdditionalData extends BaseRegionResponse = BaseRegionResponse

    Extends the base region response to include additional data as needed.

Hierarchy (view full)

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.

getUnitMeasure: ((unit) => string)

Retrieves the measure associated with a given unit.

Type declaration

    • (unit): string
    • Parameters

      • unit: string

        The unit for which to get the measure.

      Returns string

Returns

The measure associated with the specified unit.

Methods

  • Converts a value from one unit to another.

    Parameters

    • value: number

      The numerical value to convert.

    • from: UnitSource

      The unit source to convert from.

    • to: UnitSource

      The unit source to convert to.

    Returns string

    The converted value as a string.

  • 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.