dist/@ajsf/core/esm2015/lib/shared/date.functions.js
/**
 *
 * @param date
 * @param options
 * return a date string which follows the JSON schema standard
 */
@param date
@param options
return a date string which follows the JSON schema standard
@param date @param options return a date string which follows the JSON schema standard
function dateToString(date, options = {}) {
    const dateFormat = options.dateFormat || 'YYYY-MM-DD';
    date = new Date(date || undefined);
    if (!date.getDate()) {
        return null;
    }
    const year = date.getFullYear().toString();
    const month = date.getMonth();
    const day = date.getDate();
    const dayOfWeek = date.getDay();
    return dateFormat
        .replace(/S/g, getOrdinal(day))
        .replace(/YYYY/g, year)
        .replace(/YY/g, year.slice(-2))
        .replace(/MMMM/g, longMonths[month])
        .replace(/MMM/g, shortMonths[month])
        .replace(/MM/g, ('0' + (month + 1)).slice(-2))
        .replace(/M/g, month + 1)
        .replace(/DDDD/g, longDays[dayOfWeek])
        .replace(/DDD/g, shortDays[dayOfWeek])
        .replace(/DD/g, ('0' + day).slice(-2))
        .replace(/D/g, day);
}
function dateToString ( date , options = { } ) { const dateFormat = options . dateFormat || 'YYYY-MM-DD' ; date = new Date ( date || undefined ) ; if ( ! date . getDate ( ) ) { return null ; } const year = date . getFullYear ( ) . toString ( ) ; const month = date . getMonth ( ) ; const day = date . getDate ( ) ; const dayOfWeek = date . getDay ( ) ; return dateFormat . replace ( / S / g , getOrdinal ( day ) ) . replace ( / YYYY / g , year ) . replace ( / YY / g , year . slice ( - 2 ) ) . replace ( / MMMM / g , longMonths [ month ] ) . replace ( / MMM / g , shortMonths [ month ] ) . replace ( / MM / g , ( '0' + ( month + 1 ) ) . slice ( - 2 ) ) . replace ( / M / g , month + 1 ) . replace ( / DDDD / g , longDays [ dayOfWeek ] ) . replace ( / DDD / g , shortDays [ dayOfWeek ] ) . replace ( / DD / g , ( '0' + day ) . slice ( - 2 ) ) . replace ( / D / g , day ) ; }
@param date
 @param options
 return a date string which follows the JSON schema standard
@param date @param options return a date string which follows the JSON schema standard
// TODO: Use options.locale to change default format and names // const locale = options.locale || 'en-US';