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 is recommended to use standard JavaScript Date methods and/or third-party Node.js libraries.

Description

The pjs.toLilianSeconds() API converts a date/time string into a number that represents the number of seconds since 14 October 1582. The value can be used for date arithmetic, such as calculating the number of seconds between two date/time values.

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, and 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, and 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.

Return Value

None. The field named in the third parameter receives the number of seconds.

Exception Handling

An exception is thrown for any error.

Example

The date/time string and the format string must be the same length, so a value that includes three fractional second digits requires the YYYY-MM-DD-HH.MI.SS.999 format.

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

Related Pages