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’s recommended to use standard JS Date methods and/or 3rd party Node.js libraries.

This API converts a date string into a number which represents the number of days 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 (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
    YYYYMMDD

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

Example

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