Constructor
new DateTimeColumn(name, formatopt, descriptionopt, requiredFormatNumElementsopt)
Creates an instance of DateTimeColumn.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
name |
string | Column name. | ||
format |
string |
<optional> |
"%d%m%Y%H%M" | Date format string using Python strftime patterns. |
description |
string | null |
<optional> |
null | Column description. |
requiredFormatNumElements |
number |
<optional> |
5 | Number of format specifiers required. |
- Source:
Throws:
-
-
If name or format is not a string.
- Type
- TypeError
-
-
-
If name or format is blank, or format specifier count does not match requirement.
- Type
- Error
-
Example
const col = new DateTimeColumn('created_at', '%d%m%Y%H%M', 'Creation Timestamp');
col.toValue('210720261640'); // Date object (UTC: 2026-07-21T16:40:00.000Z)
Extends
Classes
Members
assertionType :string
Type descriptor for error assertions.
Type:
- string
- Source:
description :string
Description of the column.
Type:
- string
- Overrides:
- Source:
end :number
1-indexed end position of the column within a row line.
Type:
- number
- Overrides:
- Source:
format :string
Date format pattern.
Type:
- string
- Source:
name :string
Name of the column.
Type:
- string
- Overrides:
- Source:
requiredFormatNumElements :number
Expected specifier count.
Type:
- number
- Source:
size :number
Character width of the column.
Type:
- number
- Overrides:
- Source:
start :number|null
1-indexed start position of the column within a row line.
Type:
- number | null
- Overrides:
- Source:
Methods
toStr(value) → {string}
Serializes a Date object into a formatted fixed-width string.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Date | null | Date object to format. Null/undefined serializes to zero string. |
- Overrides:
- Source:
Throws:
-
If value is not a valid Date instance.
- Type
- TypeError
Returns:
Formatted fixed-width string.
- Type
- string
toValue(slice) → {Date|null}
Converts raw string slice from file into a UTC Date object.
Parameters:
| Name | Type | Description |
|---|---|---|
slice |
string | Raw fixed-width date-time string. |
- Overrides:
- Source:
Throws:
-
If slice does not match date-time format.
- Type
- Error
Returns:
Parsed Date object or null if zero-filled string.
- Type
- Date | null
validateToStrSize(value) → {string}
Validates that a formatted string representation matches the required column size.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
string | The formatted string to validate. |
- Overrides:
- Source:
Throws:
-
If formatted string length does not equal column size.
- Type
- Error
Returns:
The validated string.
- Type
- string