UNPKG

@rodewitsch/carbone

Version:

Fast, Simple and Powerful report generator. Injects JSON and produces PDF, DOCX, XLSX, ODT, PPTX, ODS, ...!

137 lines 5.8 kB
/** * Format dates. It takes an output date pattern as an argument. Date patterns are available on [this section](#date-formats). * It is possible to change the timezone through the option `options.timezone` and the lang through `options.lang`. * List of timezones: [https://en.wikipedia.org/wiki/List_of_tz_database_time_zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). * * @version 3.0.0 updated * * @exampleContext {"lang":"en", "timezone":"Europe/Paris"} * @example ["20160131", "L"] * @example ["20160131", "LL"] * @example ["20160131", "LLLL"] * @example ["20160131", "dddd"] * * @exampleContext {"lang":"fr", "timezone":"Europe/Paris"} * @example ["2017-05-10T15:57:23.769561+03:00", "LLLL"] * @example ["2017-05-10 15:57:23.769561+03:00", "LLLL"] * @example ["20160131", "LLLL"] * @example ["20160131", "dddd"] * * @exampleContext {"lang":"fr", "timezone":"Europe/Paris"} * @example ["20160131", "dddd", "YYYYMMDD"] * @example [1410715640, "LLLL", "X" ] * * @exampleContext {"lang":"fr", "timezone": "Asia/Singapore"} * @example ["20160131", "dddd", "YYYYMMDD"] * @example [1410715640, "LLLL", "X" ] * * @param {String|Number} d date to format * @param {String} patternOut output format * @param {String} patternIn [optional] input format, "ISO 8601" by default * @return {String} return formatted date */ export function formatD(d: string | number, patternOut: string, patternIn: string): string; /** * Format dates * * @deprecated * @version 1.0.0 deprecated * * @exampleContext {"lang":"en", "timezone":"Europe/Paris"} * @example ["20160131", "YYYYMMDD", "L"] * @example ["20160131", "YYYYMMDD", "LL"] * @example ["20160131", "YYYYMMDD", "LLLL"] * @example ["20160131", "YYYYMMDD", "dddd"] * @example [1410715640, "X", "LLLL"] * * @exampleContext {"lang":"fr", "timezone":"Europe/Paris"} * @example ["20160131", "YYYYMMDD", "LLLL"] * @example ["20160131", "YYYYMMDD", "dddd"] * * @param {String|Number} d date to format * @param {String} patternIn input format * @param {String} patternOut output format * @return {String} return formatted date */ export function convDate(d: string | number, patternIn: string, patternOut: string): string; /** * * Add a time to a date. Available units: day, week, month, quarter, year, hour, minute, second and millisecond. * Units are case insensitive, and support plural and short forms. * * @version 3.0.0 new * * @exampleContext {"lang":"fr", "timezone":"Europe/Paris"} * @example ["2017-05-10T15:57:23.769561+03:00", "3", "day"] * @example ["2017-05-10 15:57:23.769561+03:00", "3", "month"] * @example ["20160131", "3", "day"] * @example ["20160131", "3", "month"] * @example ["31-2016-01", "3", "month", "DD-YYYY-MM"] * * @param {String|Number} d input date * @param {Number} amount The amount * @param {String} unit The unit * @param {String} patternIn [optional] input format, ISO8601 by default * @return {Date} return a date, which can be formatted with formatD, or manipulated with other formatters */ export function addD(d: string | number, amount: number, unit: string, patternIn: string): Date; /** * * Subtract a time to a date. Available units: day, week, month, quarter, year, hour, minute, second and millisecond. * Units are case insensitive, and support plural and short forms. * * @version 3.0.0 new * * @exampleContext {"lang":"fr", "timezone":"Europe/Paris"} * @example ["2017-05-10T15:57:23.769561+03:00", "3", "day"] * @example ["2017-05-10 15:57:23.769561+03:00", "3", "month"] * @example ["20160131", "3", "day"] * @example ["20160131", "3", "month"] * @example ["31-2016-01", "3", "month", "DD-YYYY-MM"] * * @param {String|Number} d input date * @param {Number} amount The amount * @param {String} unit The unit * @param {String} patternIn [optional] input format, ISO8601 by default * @return {Date} return a date, which can be formatted with formatD, or manipulated with other formatters */ export function subD(d: string | number, amount: number, unit: string, patternIn: string): Date; /** * * Create a date and set it to the start of a unit of time. * * @version 3.0.0 new * * @exampleContext {"lang":"fr", "timezone":"Europe/Paris"} * @example ["2017-05-10T15:57:23.769561+03:00", "day"] * @example ["2017-05-10 15:57:23.769561+03:00", "month"] * @example ["20160131", "day"] * @example ["20160131", "month"] * @example ["31-2016-01", "month", "DD-YYYY-MM"] * * @param {String|Number} d input date * @param {String} unit The unit * @param {String} patternIn [optional] input format, ISO8601 by default * @return {Date} return a date, which can be formatted with formatD, or manipulated with other formatters */ export function startOfD(d: string | number, unit: string, patternIn: string): Date; /** * * Create a date and set it to the end of a unit of time. * * @version 3.0.0 new * * @exampleContext {"lang":"fr", "timezone":"Europe/Paris"} * @example ["2017-05-10T15:57:23.769561+03:00", "day"] * @example ["2017-05-10 15:57:23.769561+03:00", "month"] * @example ["20160131", "day"] * @example ["20160131", "month"] * @example ["31-2016-01", "month", "DD-YYYY-MM"] * * @param {String|Number} d input date * @param {String} unit The unit * @param {String} patternIn [optional] input format, ISO8601 by default * @return {Date} return a date, which can be formatted with formatD, or manipulated with other formatters */ export function endOfD(d: string | number, unit: string, patternIn: string): Date; //# sourceMappingURL=date.d.ts.map