Class: DateHandler

DateHandler()

Class for dealing with times and dates.

Constructor

new DateHandler()

Source:

Methods

(static) createUniqueTimestamp(ts, storage) → {number}

Makes sure that a given timestamp is not already used (unique). If it is already in use, we add iteratively one second to it until it is unique.
Parameters:
Name Type Description
ts number The original timestamp.
storage Storage A storage object for accessing the data.
Source:
Returns:
A unique timestamp generated from the original timestamp.
Type
number

(static) dateToTimestamp(day, month, year) → {number}

Creates a timestamp out of a given day, month and year.
Parameters:
Name Type Description
day string The day of the date.
month string The month of the date.
year string The year of the date.
Source:
Returns:
The corresponding timestamp for the given date.
Type
number

(static) getCurrentTimestamp() → {number}

Returns a timestamp for the current time.
Source:
Returns:
A timestamp of the current date in seconds.
Type
number

(static) lessEqualDate(d1, d2) → {bool}

Checks whether d1 <= d2, i.e., whether d2 is the same day as d1 or d2 comes after d1 (only day, month, year are relevant, the actual time of the day is neglected).
Parameters:
Name Type Description
d1 Date The first date.
d2 Date The second date.
Source:
Returns:
True if d1 <= d2 (in terms of day, month, year), else false.
Type
bool

(static) stepInterval(startDate, oldDate, interval)

Increments a given date by a given interval.
Parameters:
Name Type Description
startDate number The original date where the transaction started. Necessary to keep the original day.
oldDate number The date to increment as a timestamp in seconds.
interval number The interval, in form of one of the following: 0 => one week (7 days), 1 => four weeks (28 days), 2 => one month, 3 => two months, 4 => three months (quarterly), 5 => six months (biannual), 6 => one year (annual)
Source:

(static) stepIntervalDays(oldDate, interval) → {number}

Increments a given date according to a given interval.
Parameters:
Name Type Description
oldDate number The date to increment as a timestamp in seconds.
interval number The interval: Can be either 0 for one week or 1 for four weeks.
Source:
Returns:
The new data as a timestamp in seconds.
Type
number

(static) stepIntervalMonths(startDate, oldDate, interval) → {number}

Increments a given date according to a given interval.
Parameters:
Name Type Description
startDate number The original date where the transaction started. Necessary to keep the original day.
oldDate number The date to increment as a timestamp in seconds.
interval number The interval: Can be either 2 for one month, 3 for two months, 4 for three moths, 5 for six months or 6 for one year.
Source:
Returns:
The new data as a timestamp in seconds.
Type
number

(static) strDateToFilename(date) → {string}

Creates a filename for a given date in string format. Input format: dd.mm.yyyy, output format: mm.yyyy.json
Parameters:
Name Type Description
date string The date which should be reversed.
Source:
Returns:
The filename for the given date in mm.yyyy.json format.
Type
string

(static) timestampToFilename(ts) → {string}

Creates a filename for a given timestamp. Input: Timestamp in seconds, output format: mm.yyyy.json
Parameters:
Name Type Description
ts number The timestamp for which we want to obtain the filename.
Source:
Returns:
The filename for the given timestamp in mm.yyyy.json format.
Type
string

(static) timestampToString(ts) → {string}

Converts a timestamp in seconds into a date in string format.
Parameters:
Name Type Description
ts number The timestamp (in seconds) which we want to convert.
Source:
Returns:
The formatted date (dd.mm.yyyy).
Type
string