Class: TimeColumn

TimeColumn(name, formatopt, descriptionopt)

Time column supporting custom formatting (default "%H%M") and null/zero-padding. Parses raw time strings into UTC Date objects.

Constructor

new TimeColumn(name, formatopt, descriptionopt)

Creates an instance of TimeColumn.
Parameters:
Name Type Attributes Default Description
name string Column name.
format string <optional>
"%H%M" Time format pattern.
description string | null <optional>
null Column description.
Source:
Example
const col = new TimeColumn('opening_time', '%H%M', 'Opening Time');
col.toValue('1430'); // Date object (UTC: 2000-01-01T14:30:00.000Z)

Extends

Classes

TimeColumn

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