pjs.toLilianSeconds()

pjs.toLilianSeconds()

This API was added in version 7.17.0

This API is intended primarily for RPG to JavaScript code transformation scenarios, and provides a drop-in alternative to CEESECS.

For new code, it’s recommended to use standard JS Date methods and/or 3rd party Node.js libraries.

This API converts a date/time string into a number which represents the number of seconds since 14 October 1582. The value can be used for date arithmetic, such as to calculate the number of days between two dates.

An exception will be thrown for any error.

Parameters

  1. Date/time (string). A date/time string in the format given by the following parameter. Valid dates are in the range 15 October 1582 to 31 December 9999. Valid times are in the range 00:00:00 to 23:59:59.999.

  2. Date/time format (string). A string representing the format of the date/time string. Valid formats are:
    YYYY-MM-DD-HH.MI.SS
    YYYY-MM-DD-HH.MI.SS.9
    YYYY-MM-DD-HH.MI.SS.99
    YYYY-MM-DD-HH.MI.SS.999

  3. Seconds (field name) a numeric field name defined with pjs.define() that will receive the number of seconds.

Example

pjs.define("out_secs", { type: 'float', length: 8 }); pjs.toLilianSeconds('9999-12-31-23.59.59.999', 'YYYY-MM-DD-HH.MI.SS', out_secs); console.log(out_secs); // 265621679999.999