pjs.toLilianDate()

pjs.toLilianDate()

  • 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 CEEDAYS.

  • For new code, it is recommended to use standard JavaScript Date methods and/or third-party Node.js libraries.

Description

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

Parameters

  1. Date (string) - A date string in the format given by the following parameter. Valid dates are in the range 15 October 1582 to 31 December 9999.

  2. Date format (string) - A string representing the format of the date string. Valid formats are DD/MM/YY, DDMMYY, MM/DD/YY, MMDDYY, YY/MM/DD, YYMMDD, MM/DD/YYYY, MMDDYYYY, DD.MM.YYYY, DDMMYYYY, YYYY-MM-DD, and YYYYMMDD.

  3. Days (field name) - A numeric field name defined with pjs.define() that will receive the number of days.

Return Value

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

Exception Handling

An exception is thrown for any error.

Example

The date string and the format string must be the same length.

pjs.define("out_date", { type: 'integer', length: 10, decimals: 0 }); pjs.toLilianDate("1988-05-16", 'YYYY-MM-DD', out_date); console.log(out_date); // 148138

Related Pages