ts-time-format/DateTimeFormatter

Consumption

import DateTimeFormatter, {DateTimeCompiler, DATE_TIME_COMPILERS} from "ts-time-format/DateTimeFormatter";

Default export#

Hierarchy#

Description#

Formatter of LocalDateTime to a string. You may initialize a formatter explicitly by using of method, or implicitly by using ofPattern method. See DATE_TIME_COMPILERS for supported pattern characters. See parsePattern for general pattern writing guidelines.

Methods#

format (inherited from TemporalFormatter)#

(value: LocalDateTime, context?: any): string

value
Value to format.
context
Context object (see TemporalCompiler).
returns
Formatted string.
Formats value to a string as concatenation of write method call results on all components.

Static methods#

of#

(components: TemporalFormatComponent<LocalDateTime>[]): DateTimeFormatter

components
Ordered array of format components.
returns
Formatter.
Constructs a formatter explicitly by components.
ofPattern#

(pattern: string, compilers: Dictionary<DateTimeCompiler> = DATE_TIME_COMPILERS): DateTimeFormatter

pattern
Pattern string.
compilers
Dictionary from supported pattern characters to the respective compilers.
returns
Formatter.
Constructs a formatter implicitly by pattern. See parsePattern for details.

DateTimeCompiler#

Hierarchy#

Description#

TemporalCompiler for LocalDateTime.

Fields#

maxLength (inherited from TemporalCompiler)#

readonly maxLength: number

Maximum number of sequential characters supported in a pattern.

Methods#

compile (inherited from TemporalCompiler)#

(value: LocalDateTime, length: number, context: any = DEFAULT_TEMPORAL_CONTEXT): string

value
Value to compile.
length
Number of sequential characters used in a pattern.
context
Context object.
returns
Compiled string.
Compiles value to a string based on number of sequential characters specified in length and compiler-dependent context object which can be used, in particular, to specify language-specific textual strings.

DATE_TIME_COMPILERS#

DATE_TIME_COMPILERS: Dictionary<DateTimeCompiler>

Default dictionary from pattern character to the respective compiler. Union of interface-compatible adapters around DATE_COMPILERS and TIME_COMPILERS.