Class: DateColumn

DateColumn(name, formatopt, descriptionopt)

Date column supporting custom formatting (default "%d%m%Y") and null/zero-padding. Parses raw date strings into UTC Date objects.

Constructor

new DateColumn(name, formatopt, descriptionopt)

Creates an instance of DateColumn.
Parameters:
Name Type Attributes Default Description
name string Column name.
format string <optional>
"%d%m%Y" Date format pattern.
description string | null <optional>
null Column description.
Source:
Example
const col = new DateColumn('birth_date', '%d%m%Y', 'Birth Date');
col.toValue('21072026'); // Date object (UTC: 2026-07-21T00:00:00.000Z)

Extends

Classes

DateColumn

Members

assertionType :string

Type descriptor for error assertions.
Type:
  • string
Overrides:
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
Overrides:
Source:

name :string

Name of the column.
Type:
  • string
Overrides:
Source:

requiredFormatNumElements :number

Expected specifier count.
Type:
  • number
Overrides:
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