Symbol Methods
Symbol.iterator
Enables iteration over date components, allowing destructuring and array spreading.
Signature
*[Symbol.iterator](): IterableIterator<[string, number]>Return Type
IterableIterator<[string, number]> - Date components as key-value pairs
Behavior
- Yields all date components as
[property, value]pairs - Enables destructuring assignment and
for...ofloops - Compatible with array spread operator
Example
Symbol.toPrimitive
Provides primitive value conversion for mathematical operations and string interpolation.
Signature
[Symbol.toPrimitive](hint: string): string | numberParameters
hint: Conversion hint ('number'or'string')
Return Type
string | number - Primitive value
Behavior
numberhint: Returns timestamp for mathematical operationsstringhint: Returns ISO string based on instance origindefaulthint: Returns ISO string for string interpolation
Info
- This method is the basis for the
String()constructor and theString.prototype.toString()method whenhintis'string'.
Example
Symbol.replace
Enables Chronos instances to be used as search patterns in String.prototype.replace().
Signature
[Symbol.replace](string: string, replacement: string): stringParameters
string: The string to perform replacement onreplacement: The replacement string
Return Type
string - The modified string with replacements
Behavior
- Replaces date patterns in strings based on
Chronosinstance format - Handles different ISO string formats depending on instance origin
- Supports timezone-aware replacements
Example
Symbol.search
Enables Chronos instances to be used as search patterns in String.prototype.search().
Signature
[Symbol.search](string: string): numberParameters
string: The string to search within
Return Type
number - Index of the first match or -1 if not found
Behavior
- Searches for date patterns in strings
- Returns the position of the matched date pattern
- Handles different ISO formats based on instance origin
Example
Symbol.split
Enables Chronos instances to be used as separators in String.prototype.split().
Signature
[Symbol.split](string: string): string[]Parameters
string: The string to split
Return Type
string[] - Array of substrings
Behavior
- Splits strings using the
Chronosinstance's date pattern as delimiter - Handles different date formats based on instance origin
- Useful for parsing text containing date separators
Example
Symbol.match
Enables Chronos instances to be used as regex patterns in string matching operations.
Signature
[Symbol.match](string: string): RegExpMatchArray | nullParameters
string: The string to search for date patterns
Return Type
RegExpMatchArray | null - Match result or null if no match found
Behavior
- Supports fuzzy matching of various date and time formats
- Automatically handles both date-only and datetime patterns
- Flexible separator matching (hyphens, slashes, dots, or no separators)
Supported Formats
Date Formats:
2025-09-01(standard hyphenated)2025/09/01(slash separated)20250901(compact)
Time Formats:
13:26:00(colon separated)13.26.00(dot separated)132600(compact)
Separators:
T(ISO standard)- Space
- No separator
Example
Symbol.toStringTag
Customizes the default string description of the object.
Signature
get [Symbol.toStringTag](): stringReturn Type
string - String tag representation
Behavior
- Used by
Object.prototype.toString()method - Returns different ISO string formats based on instance origin
- Provides meaningful string representation for object inspection
Example
Symbol.isConcatSpreadable
Enables Chronos instances to be spread when used with array concatenation.
Signature
get [Symbol.isConcatSpreadable](): booleanReturn Type
boolean - Always returns true
Behavior
- Allows
Chronosobjects to be spread into arrays using spread operator - Enables array concatenation with
Chronosinstances - Returns key-value pairs for each date component when spread
Example
Notes
- Useful for extracting all date components into an array
- Enables functional programming patterns with date data
- Compatible with array methods like
map,filter, andreduce
Last updated: Fri, Jun 19, 2026 06:06:59PM (UTC)
