mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
1 line
10 KiB
JSON
1 line
10 KiB
JSON
{"ast":null,"code":"import toDate from \"../toDate/index.js\";\nimport isValid from \"../isValid/index.js\";\nimport addLeadingZeros from \"../_lib/addLeadingZeros/index.js\";\n/**\n * @name formatISO9075\n * @category Common Helpers\n * @summary Format the date according to the ISO 9075 standard (https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_get-format).\n *\n * @description\n * Return the formatted date string in ISO 9075 format. Options may be passed to control the parts and notations of the date.\n *\n * @param {Date|Number} date - the original date\n * @param {Object} [options] - an object with options.\n * @param {'extended'|'basic'} [options.format='extended'] - if 'basic', hide delimiters between date and time values.\n * @param {'complete'|'date'|'time'} [options.representation='complete'] - format date, time, or both.\n * @returns {String} the formatted date string\n * @throws {TypeError} 1 argument required\n * @throws {RangeError} `date` must not be Invalid Date\n * @throws {RangeError} `options.format` must be 'extended' or 'basic'\n * @throws {RangeError} `options.represenation` must be 'date', 'time' or 'complete'\n *\n * @example\n * // Represent 18 September 2019 in ISO 9075 format:\n * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52))\n * //=> '2019-09-18 19:00:52'\n *\n * @example\n * // Represent 18 September 2019 in ISO 9075, short format:\n * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })\n * //=> '20190918 190052'\n *\n * @example\n * // Represent 18 September 2019 in ISO 9075 format, date only:\n * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })\n * //=> '2019-09-18'\n *\n * @example\n * // Represent 18 September 2019 in ISO 9075 format, time only:\n * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })\n * //=> '19:00:52'\n */\n\nexport default function formatISO9075(dirtyDate, dirtyOptions) {\n if (arguments.length < 1) {\n throw new TypeError(\"1 argument required, but only \".concat(arguments.length, \" present\"));\n }\n var originalDate = toDate(dirtyDate);\n if (!isValid(originalDate)) {\n throw new RangeError('Invalid time value');\n }\n var options = dirtyOptions || {};\n var format = options.format == null ? 'extended' : String(options.format);\n var representation = options.representation == null ? 'complete' : String(options.representation);\n if (format !== 'extended' && format !== 'basic') {\n throw new RangeError(\"format must be 'extended' or 'basic'\");\n }\n if (representation !== 'date' && representation !== 'time' && representation !== 'complete') {\n throw new RangeError(\"representation must be 'date', 'time', or 'complete'\");\n }\n var result = '';\n var dateDelimiter = format === 'extended' ? '-' : '';\n var timeDelimiter = format === 'extended' ? ':' : ''; // Representation is either 'date' or 'complete'\n\n if (representation !== 'time') {\n var day = addLeadingZeros(originalDate.getDate(), 2);\n var month = addLeadingZeros(originalDate.getMonth() + 1, 2);\n var year = addLeadingZeros(originalDate.getFullYear(), 4); // yyyyMMdd or yyyy-MM-dd.\n\n result = \"\".concat(year).concat(dateDelimiter).concat(month).concat(dateDelimiter).concat(day);\n } // Representation is either 'time' or 'complete'\n\n if (representation !== 'date') {\n var hour = addLeadingZeros(originalDate.getHours(), 2);\n var minute = addLeadingZeros(originalDate.getMinutes(), 2);\n var second = addLeadingZeros(originalDate.getSeconds(), 2); // If there's also date, separate it with time with a space\n\n var separator = result === '' ? '' : ' '; // HHmmss or HH:mm:ss.\n\n result = \"\".concat(result).concat(separator).concat(hour).concat(timeDelimiter).concat(minute).concat(timeDelimiter).concat(second);\n }\n return result;\n}","map":{"version":3,"names":["toDate","isValid","addLeadingZeros","formatISO9075","dirtyDate","dirtyOptions","arguments","length","TypeError","concat","originalDate","RangeError","options","format","String","representation","result","dateDelimiter","timeDelimiter","day","getDate","month","getMonth","year","getFullYear","hour","getHours","minute","getMinutes","second","getSeconds","separator"],"sources":["C:/Users/eudes.inacio/GabineteDigital/gabinete-digital-fo/node_modules/date-fns/esm/formatISO9075/index.js"],"sourcesContent":["import toDate from \"../toDate/index.js\";\nimport isValid from \"../isValid/index.js\";\nimport addLeadingZeros from \"../_lib/addLeadingZeros/index.js\";\n/**\n * @name formatISO9075\n * @category Common Helpers\n * @summary Format the date according to the ISO 9075 standard (https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_get-format).\n *\n * @description\n * Return the formatted date string in ISO 9075 format. Options may be passed to control the parts and notations of the date.\n *\n * @param {Date|Number} date - the original date\n * @param {Object} [options] - an object with options.\n * @param {'extended'|'basic'} [options.format='extended'] - if 'basic', hide delimiters between date and time values.\n * @param {'complete'|'date'|'time'} [options.representation='complete'] - format date, time, or both.\n * @returns {String} the formatted date string\n * @throws {TypeError} 1 argument required\n * @throws {RangeError} `date` must not be Invalid Date\n * @throws {RangeError} `options.format` must be 'extended' or 'basic'\n * @throws {RangeError} `options.represenation` must be 'date', 'time' or 'complete'\n *\n * @example\n * // Represent 18 September 2019 in ISO 9075 format:\n * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52))\n * //=> '2019-09-18 19:00:52'\n *\n * @example\n * // Represent 18 September 2019 in ISO 9075, short format:\n * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { format: 'basic' })\n * //=> '20190918 190052'\n *\n * @example\n * // Represent 18 September 2019 in ISO 9075 format, date only:\n * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'date' })\n * //=> '2019-09-18'\n *\n * @example\n * // Represent 18 September 2019 in ISO 9075 format, time only:\n * const result = formatISO9075(new Date(2019, 8, 18, 19, 0, 52), { representation: 'time' })\n * //=> '19:00:52'\n */\n\nexport default function formatISO9075(dirtyDate, dirtyOptions) {\n if (arguments.length < 1) {\n throw new TypeError(\"1 argument required, but only \".concat(arguments.length, \" present\"));\n }\n\n var originalDate = toDate(dirtyDate);\n\n if (!isValid(originalDate)) {\n throw new RangeError('Invalid time value');\n }\n\n var options = dirtyOptions || {};\n var format = options.format == null ? 'extended' : String(options.format);\n var representation = options.representation == null ? 'complete' : String(options.representation);\n\n if (format !== 'extended' && format !== 'basic') {\n throw new RangeError(\"format must be 'extended' or 'basic'\");\n }\n\n if (representation !== 'date' && representation !== 'time' && representation !== 'complete') {\n throw new RangeError(\"representation must be 'date', 'time', or 'complete'\");\n }\n\n var result = '';\n var dateDelimiter = format === 'extended' ? '-' : '';\n var timeDelimiter = format === 'extended' ? ':' : ''; // Representation is either 'date' or 'complete'\n\n if (representation !== 'time') {\n var day = addLeadingZeros(originalDate.getDate(), 2);\n var month = addLeadingZeros(originalDate.getMonth() + 1, 2);\n var year = addLeadingZeros(originalDate.getFullYear(), 4); // yyyyMMdd or yyyy-MM-dd.\n\n result = \"\".concat(year).concat(dateDelimiter).concat(month).concat(dateDelimiter).concat(day);\n } // Representation is either 'time' or 'complete'\n\n\n if (representation !== 'date') {\n var hour = addLeadingZeros(originalDate.getHours(), 2);\n var minute = addLeadingZeros(originalDate.getMinutes(), 2);\n var second = addLeadingZeros(originalDate.getSeconds(), 2); // If there's also date, separate it with time with a space\n\n var separator = result === '' ? '' : ' '; // HHmmss or HH:mm:ss.\n\n result = \"\".concat(result).concat(separator).concat(hour).concat(timeDelimiter).concat(minute).concat(timeDelimiter).concat(second);\n }\n\n return result;\n}"],"mappings":"AAAA,OAAOA,MAAM,MAAM,oBAAoB;AACvC,OAAOC,OAAO,MAAM,qBAAqB;AACzC,OAAOC,eAAe,MAAM,kCAAkC;AAC9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,SAASC,aAAaA,CAACC,SAAS,EAAEC,YAAY,EAAE;EAC7D,IAAIC,SAAS,CAACC,MAAM,GAAG,CAAC,EAAE;IACxB,MAAM,IAAIC,SAAS,CAAC,gCAAgC,CAACC,MAAM,CAACH,SAAS,CAACC,MAAM,EAAE,UAAU,CAAC,CAAC;EAC5F;EAEA,IAAIG,YAAY,GAAGV,MAAM,CAACI,SAAS,CAAC;EAEpC,IAAI,CAACH,OAAO,CAACS,Y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