ts-time-format/OffsetFormatter
Consumption
import OffsetFormatter, {OffsetCompiler, OFFSET_COMPILERS, OFFSET_COMPILER, OFFSET_NZ_COMPILER} from "ts-time-format/OffsetFormatter";
Default export#
Hierarchy#
Description#
Formatter of
ZoneOffset to a string. You may initialize a formatter explicitly by using
of method,
or implicitly by using
ofPattern method. See
OFFSET_COMPILERS for supported pattern characters. See
parsePattern for general pattern writing guidelines.
Methods#
(value: ZoneOffset , 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#
(components: TemporalFormatComponent <ZoneOffset >[]): OffsetFormatter
components Ordered array of format components.
returns Formatter.
Constructs a formatter explicitly by components.
ofPattern#
(pattern: string, compilers: Dictionary<OffsetCompiler > = OFFSET_COMPILERS ): OffsetFormatter
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.
OffsetCompiler#
Hierarchy#
Description#
TemporalCompiler for
ZoneOffset .
Fields#
readonly maxLength: number
Maximum number of sequential characters supported in a pattern.
Methods#
(value: ZoneOffset , 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.
OFFSET_COMPILERS#
OFFSET_COMPILERS: Dictionary<OffsetCompiler >
Default dictionary from pattern character to the respective compiler:
OFFSET_COMPILER#
OFFSET_NZ_COMPILER#
OFFSET_NZ_COMPILER: OffsetCompiler
Depending on length:
Writes just the hour, such as "+01", unless the minute is non-zero in which case writes also the minute, such
as "+0130".
Writes the hour and minute, without a colon, such as "+0130".
Writes the hour and minute, with a colon, such as "+01:30".
Writes the hour and minute and optional second, without a colon, such as "+013015".
Writes the hour and minute and optional second, with a colon, such as "+01:30:15".
Default pattern character is "x".
© Copyright: Egor Nepomnyaschih