Usage
Typescript Import Format
//To import this namespace, use the format below.
import {IntlConverterUtils} from "ojs/ojconverterutils-i18n";
For additional information visit:
Methods
-
(static) dateToLocalIso(date) : {string}
-
Returns a local ISO string provided a Date object. This method can be used to convert a moment in time or a local ISO string into a local ISO string. It can also be used to convert any Date object into local ISO string.
Examples below are where the local (user's system) time zone is UTC-06:00
dateToLocalIso(new Date('2021-06-04T00:00:00-04:00')); -->'2021-06-03T22:00:00'
dateToLocalIso(new Date('2021-06-04T02:30:00Z')); -->'2021-06-03T20:30:00'
In this example the input ISO string is local, the output is the same:
dateToLocalIso(new Date('2021-06-04T02:30:00')); -->'2021-06-04T02:30:00'
In this example we just want to convert a Date object:
dateToLocalIso(new Date());
Parameters:
Name Type Description date
Date - Since:
- 0.7.0
Returns:
isoString
- Type
- string
-
(static) dateToLocalIsoDateString(date) : {string}
-
Returns the date only portion of a local ISO string provided a Date object. This method can be used to convert a moment in time ISO string into a local ISO string and get the date part of it. This method is useful if you are storing your dates as a moment in time and you want to use it in a date only component, like oj-input-date, that shows the date in the timezone of the user's local system.
Examples where local time zone offset is UTC-06:00
dateToLocalIsoDateString(new Date('2021-06-04T00:00:00-04:00')); -->'2021-06-03'
dateToLocalIsoDateString(new Date('2021-06-04T02:30:00Z')); -->'2021-06-03'
Parameters:
Name Type Description date
Date - Since:
- 12.0.0
Returns:
date portion only of the ISO String
- Type
- string
-
(static) getConverterInstance<T>(converterOption: string|Validation.RegisteredConverter|Converter<T>): Converter<T>|null
-
Given either an Object literal representing a 'converter' option (used in components) or a converter instance of type Converter, this method returns the converter instance. You can also pass in a string. In this case, it will return you an instance of a converter registered with that type.
Parameters:
Name Type Description converterOption
string | Object - Deprecated:
-
Since Description 8.0.0
Create a converter using its constructor.
- Since:
- 8.0.0
Returns:
converterInstance or null if a converter cannot be determined
- Type
- Object | null
-
(static) getInitials(firstName, lastName) : {string|undefined}
-
Returns a person's initials
Parameters:
Name Type Argument Description firstName
string <optional>
first name lastName
string <optional>
last name - Since:
- 4.0.0
Returns:
uppercase concatenation of first letter of first name and first letter of last name. There are the following special cases: - If the name is Arabic characters, it returns empty string. - If the name is Hindi characters, it returns the first letter of the first name. - If the name is Thai characters, it returns the first letter of the first name. - If the name is Korean characters, it returns the first name. - If the name is Japanese or Chinese characters, it returns the last name.
- Type
- string | undefined
-
(static) getLocalTimeZoneOffset(date) : {string}
-
Returns the timezone offset between UTC and the local time in Etc/GMT[+-]h syntax. The offset is positive if the local timezone is behind UTC and negative if it is ahead. The offset range is between Etc/GMT-14 and Etc/GMT+12 (UTC-12 and UTC+14)
Parameters:
Name Type Argument Description date
Date <optional>
If date is undefined, it returns the local timezone offset of the current date, otherwise it returns the local timezone offset at that given date. Returns:
- Type
- string
-
(static) isoToDate(isoString) : {Date}
-
Parses the isoString and returns a JavaScript Date object
Parameters:
Name Type Description isoString
string isoString to parse and to return Date of Returns:
the parsed JavaScript Date Object
- Type
- Date
-
(static) isoToLocalDate(isoString) : {Date}
-
Returns a local Date object from a local ISO string. This method is only meant to work with local ISO strings. If the input ISO string contain Z or offset, they will be ignored.
Parameters:
Name Type Description isoString
string an ISO 8601 string - Since:
- 0.7.0
Returns:
localDate
- Type
- Date