1 |
- {"ast":null,"code":"import toDate from \"../toDate/index.js\";\nimport isValid from \"../isValid/index.js\";\nimport addLeadingZeros from \"../_lib/addLeadingZeros/index.js\";\nimport toInteger from \"../_lib/toInteger/index.js\";\n/**\n * @name formatRFC3339\n * @category Common Helpers\n * @summary Format the date according to the RFC 3339 standard (https://tools.ietf.org/html/rfc3339#section-5.6).\n *\n * @description\n * Return the formatted date string in RFC 3339 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 {0|1|2|3} [options.fractionDigits=0] - number of digits after the decimal point after seconds\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.fractionDigits` must be between 0 and 3\n *\n * @example\n * // Represent 18 September 2019 in RFC 3339 format:\n * const result = formatRFC3339(new Date(2019, 8, 18, 19, 0, 52))\n * //=> '2019-09-18T19:00:52Z'\n *\n * @example\n * // Represent 18 September 2019 in RFC 3339 format, 2 digits of second fraction:\n * const result = formatRFC3339(new Date(2019, 8, 18, 19, 0, 52, 234), { fractionDigits: 2 })\n * //=> '2019-09-18T19:00:52.23Z'\n *\n * @example\n * // Represent 18 September 2019 in RFC 3339 format, 3 digits of second fraction\n * const result = formatRFC3339(new Date(2019, 8, 18, 19, 0, 52, 234), { fractionDigits: 3 })\n * //=> '2019-09-18T19:00:52.234Z'\n */\nexport default function formatRFC3339(dirtyDate, options) {\n var _options$fractionDigi;\n if (arguments.length < 1) {\n throw new TypeError(\"1 arguments 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 fractionDigits = Number((_options$fractionDigi = options === null || options === void 0 ? void 0 : options.fractionDigits) !== null && _options$fractionDigi !== void 0 ? _options$fractionDigi : 0);\n\n // Test if fractionDigits is between 0 and 3 _and_ is not NaN\n if (!(fractionDigits >= 0 && fractionDigits <= 3)) {\n throw new RangeError('fractionDigits must be between 0 and 3 inclusively');\n }\n var day = addLeadingZeros(originalDate.getDate(), 2);\n var month = addLeadingZeros(originalDate.getMonth() + 1, 2);\n var year = originalDate.getFullYear();\n var hour = addLeadingZeros(originalDate.getHours(), 2);\n var minute = addLeadingZeros(originalDate.getMinutes(), 2);\n var second = addLeadingZeros(originalDate.getSeconds(), 2);\n var fractionalSecond = '';\n if (fractionDigits > 0) {\n var milliseconds = originalDate.getMilliseconds();\n var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, fractionDigits - 3));\n fractionalSecond = '.' + addLeadingZeros(fractionalSeconds, fractionDigits);\n }\n var offset = '';\n var tzOffset = originalDate.getTimezoneOffset();\n if (tzOffset !== 0) {\n var absoluteOffset = Math.abs(tzOffset);\n var hourOffset = addLeadingZeros(toInteger(absoluteOffset / 60), 2);\n var minuteOffset = addLeadingZeros(absoluteOffset % 60, 2);\n // If less than 0, the sign is +, because it is ahead of time.\n var sign = tzOffset < 0 ? '+' : '-';\n offset = \"\".concat(sign).concat(hourOffset, \":\").concat(minuteOffset);\n } else {\n offset = 'Z';\n }\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day, \"T\").concat(hour, \":\").concat(minute, \":\").concat(second).concat(fractionalSecond).concat(offset);\n}","map":{"version":3,"names":["toDate","isValid","addLeadingZeros","toInteger","formatRFC3339","dirtyDate","options","_options$fractionDigi","arguments","length","TypeError","concat","originalDate","RangeError","fractionDigits","Number","day","getDate","month","getMonth","year","getFullYear","hour","getHours","minute","getMinutes","second","getSeconds","fractionalSecond","milliseconds","getMilliseconds","fractionalSeconds","Math","floor","pow","offset","tzOffset","getTimezoneOffset","absoluteOffset","abs","hourOffset","minuteOffset","sign"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/date-fns/esm/formatRFC3339/index.js"],"sourcesContent":["import toDate from \"../toDate/index.js\";\nimport isValid from \"../isValid/index.js\";\nimport addLeadingZeros from \"../_lib/addLeadingZeros/index.js\";\nimport toInteger from \"../_lib/toInteger/index.js\";\n/**\n * @name formatRFC3339\n * @category Common Helpers\n * @summary Format the date according to the RFC 3339 standard (https://tools.ietf.org/html/rfc3339#section-5.6).\n *\n * @description\n * Return the formatted date string in RFC 3339 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 {0|1|2|3} [options.fractionDigits=0] - number of digits after the decimal point after seconds\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.fractionDigits` must be between 0 and 3\n *\n * @example\n * // Represent 18 September 2019 in RFC 3339 format:\n * const result = formatRFC3339(new Date(2019, 8, 18, 19, 0, 52))\n * //=> '2019-09-18T19:00:52Z'\n *\n * @example\n * // Represent 18 September 2019 in RFC 3339 format, 2 digits of second fraction:\n * const result = formatRFC3339(new Date(2019, 8, 18, 19, 0, 52, 234), { fractionDigits: 2 })\n * //=> '2019-09-18T19:00:52.23Z'\n *\n * @example\n * // Represent 18 September 2019 in RFC 3339 format, 3 digits of second fraction\n * const result = formatRFC3339(new Date(2019, 8, 18, 19, 0, 52, 234), { fractionDigits: 3 })\n * //=> '2019-09-18T19:00:52.234Z'\n */\nexport default function formatRFC3339(dirtyDate, options) {\n var _options$fractionDigi;\n if (arguments.length < 1) {\n throw new TypeError(\"1 arguments 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 fractionDigits = Number((_options$fractionDigi = options === null || options === void 0 ? void 0 : options.fractionDigits) !== null && _options$fractionDigi !== void 0 ? _options$fractionDigi : 0);\n\n // Test if fractionDigits is between 0 and 3 _and_ is not NaN\n if (!(fractionDigits >= 0 && fractionDigits <= 3)) {\n throw new RangeError('fractionDigits must be between 0 and 3 inclusively');\n }\n var day = addLeadingZeros(originalDate.getDate(), 2);\n var month = addLeadingZeros(originalDate.getMonth() + 1, 2);\n var year = originalDate.getFullYear();\n var hour = addLeadingZeros(originalDate.getHours(), 2);\n var minute = addLeadingZeros(originalDate.getMinutes(), 2);\n var second = addLeadingZeros(originalDate.getSeconds(), 2);\n var fractionalSecond = '';\n if (fractionDigits > 0) {\n var milliseconds = originalDate.getMilliseconds();\n var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, fractionDigits - 3));\n fractionalSecond = '.' + addLeadingZeros(fractionalSeconds, fractionDigits);\n }\n var offset = '';\n var tzOffset = originalDate.getTimezoneOffset();\n if (tzOffset !== 0) {\n var absoluteOffset = Math.abs(tzOffset);\n var hourOffset = addLeadingZeros(toInteger(absoluteOffset / 60), 2);\n var minuteOffset = addLeadingZeros(absoluteOffset % 60, 2);\n // If less than 0, the sign is +, because it is ahead of time.\n var sign = tzOffset < 0 ? '+' : '-';\n offset = \"\".concat(sign).concat(hourOffset, \":\").concat(minuteOffset);\n } else {\n offset = 'Z';\n }\n return \"\".concat(year, \"-\").concat(month, \"-\").concat(day, \"T\").concat(hour, \":\").concat(minute, \":\").concat(second).concat(fractionalSecond).concat(offset);\n}"],"mappings":"AAAA,OAAOA,MAAM,MAAM,oBAAoB;AACvC,OAAOC,OAAO,MAAM,qBAAqB;AACzC,OAAOC,eAAe,MAAM,kCAAkC;AAC9D,OAAOC,SAAS,MAAM,4BAA4B;AAClD;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,eAAe,SAASC,aAAaA,CAACC,SAAS,EAAEC,OAAO,EAAE;EACxD,IAAIC,qBAAqB;EACzB,IAAIC,SAAS,CAACC,MAAM,GAAG,CAAC,EAAE;IACxB,MAAM,IAAIC,SAAS,CAAC,iCAAiC,CAACC,MAAM,CAACH,SAAS,CAACC,MAAM,EAAE,UAAU,CAAC,CAAC;EAC7F;EACA,IAAIG,YAAY,GAAGZ,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