1 line
8.4 KiB
Plaintext
1 line
8.4 KiB
Plaintext
{"version":3,"file":"NcDateTime-DshRFtUU-DhtBMvqa.chunk.mjs","sources":["../node_modules/@nextcloud/vue/dist/chunks/NcDateTime-DshRFtUU.mjs"],"sourcesContent":["import { ref, unref, computed, watch, onMounted, onUnmounted } from \"vue\";\nimport { getCanonicalLocale, getLanguage } from \"@nextcloud/l10n\";\nimport { r as register, l as t2, a as t } from \"./_l10n-DQgzdF9S.mjs\";\nimport { n as normalizeComponent } from \"./_plugin-vue2_normalizer-DU4iP6Vu.mjs\";\nregister(t2);\nconst FEW_SECONDS_AGO = {\n long: t(\"a few seconds ago\"),\n short: t(\"seconds ago\"),\n // FOR TRANSLATORS: Shorter version of 'a few seconds ago'\n narrow: t(\"sec. ago\")\n // FOR TRANSLATORS: If possible in your language an even shorter version of 'a few seconds ago'\n};\nfunction useFormatDateTime(timestamp = Date.now(), opts = {}) {\n const currentTime = ref(Date.now());\n let intervalId;\n const options = ref({\n format: {\n timeStyle: \"medium\",\n dateStyle: \"short\"\n },\n relativeTime: \"long\",\n ignoreSeconds: false,\n ...unref(opts)\n });\n const wrappedOptions = computed(() => ({ ...unref(opts), ...options.value }));\n const date = computed(() => new Date(unref(timestamp)));\n const formattedFullTime = computed(() => {\n const formatter = new Intl.DateTimeFormat(getCanonicalLocale(), wrappedOptions.value.format);\n return formatter.format(date.value);\n });\n const formattedTime = computed(() => {\n if (wrappedOptions.value.relativeTime !== false) {\n const formatter = new Intl.RelativeTimeFormat(getLanguage(), { numeric: \"auto\", style: wrappedOptions.value.relativeTime });\n const diff = date.value.getTime() - currentTime.value;\n const seconds = diff / 1e3;\n if (Math.abs(seconds) < 59.5) {\n if (wrappedOptions.value.ignoreSeconds) {\n return FEW_SECONDS_AGO[wrappedOptions.value.relativeTime];\n } else {\n return formatter.format(Math.round(seconds), \"second\");\n }\n }\n const minutes = seconds / 60;\n if (Math.abs(minutes) <= 59) {\n return formatter.format(Math.round(minutes), \"minute\");\n }\n const hours = minutes / 60;\n if (Math.abs(hours) < 23.5) {\n return formatter.format(Math.round(hours), \"hour\");\n }\n const days = hours / 24;\n if (Math.abs(days) < 6.5) {\n return formatter.format(Math.round(days), \"day\");\n }\n if (Math.abs(days) < 27.5) {\n const weeks = days / 7;\n return formatter.format(Math.round(weeks), \"week\");\n }\n const months = days / 30;\n if (Math.abs(months) < 11.5) {\n return formatter.format(Math.round(months), \"month\");\n }\n return formatter.format(Math.round(days / 365), \"year\");\n }\n return formattedFullTime.value;\n });\n watch([wrappedOptions], () => {\n window.clearInterval(intervalId);\n intervalId = void 0;\n if (wrappedOptions.value.relativeTime) {\n intervalId = window.setInterval(() => {\n currentTime.value = Date.now();\n }, 1e3);\n }\n });\n onMounted(() => {\n if (wrappedOptions.value.relativeTime !== false) {\n intervalId = window.setInterval(() => {\n currentTime.value = Date.now();\n }, 1e3);\n }\n });\n onUnmounted(() => {\n window.clearInterval(intervalId);\n });\n return {\n formattedTime,\n formattedFullTime,\n options\n };\n}\nconst _sfc_main = {\n name: \"NcDateTime\",\n props: {\n /**\n * The timestamp to display, either an unix timestamp (in milliseconds) or a Date object\n */\n timestamp: {\n type: [Date, Number],\n required: true\n },\n /**\n * The format used for displaying, or if relative time is used the format used for the title (optional)\n *\n * @type {Intl.DateTimeFormatOptions}\n */\n format: {\n type: Object,\n default: () => ({ timeStyle: \"medium\", dateStyle: \"short\" })\n },\n /**\n * Wether to display the timestamp as time from now (optional)\n *\n * - `false`: Disable relative time\n * - `'long'`: Long text, like *2 seconds ago* (default)\n * - `'short'`: Short text, like *2 sec. ago*\n * - `'narrow'`: Even shorter text (same as `'short'` on some languages)\n */\n relativeTime: {\n type: [Boolean, String],\n default: \"long\",\n validator: (v) => v === false || [\"long\", \"short\", \"narrow\"].includes(v)\n },\n /**\n * Ignore seconds when displaying the relative time and just show `a few seconds ago`\n */\n ignoreSeconds: {\n type: Boolean,\n default: false\n }\n },\n setup(props) {\n const timestamp = computed(() => props.timestamp);\n const { formattedTime, formattedFullTime } = useFormatDateTime(timestamp, props);\n return {\n formattedTime,\n formattedFullTime\n };\n }\n};\nvar _sfc_render = function render() {\n var _vm = this, _c = _vm._self._c;\n return _c(\"span\", { staticClass: \"nc-datetime\", attrs: { \"data-timestamp\": _vm.timestamp, \"title\": _vm.formattedFullTime }, domProps: { \"textContent\": _vm._s(_vm.formattedTime) } });\n};\nvar _sfc_staticRenderFns = [];\nvar __component__ = /* @__PURE__ */ normalizeComponent(\n _sfc_main,\n _sfc_render,\n _sfc_staticRenderFns,\n false,\n null,\n null\n);\nconst NcDateTime = __component__.exports;\nexport {\n NcDateTime as N,\n useFormatDateTime as u\n};\n//# sourceMappingURL=NcDateTime-DshRFtUU.mjs.map\n"],"names":["register","t2","FEW_SECONDS_AGO","t","useFormatDateTime","timestamp","opts","currentTime","ref","intervalId","options","unref","wrappedOptions","computed","date","formattedFullTime","getCanonicalLocale","formattedTime","formatter","getLanguage","seconds","minutes","hours","days","weeks","months","watch","onMounted","onUnmounted","_sfc_main","v","props","_sfc_render","_vm","_c","_sfc_staticRenderFns","__component__","normalizeComponent","NcDateTime"],"mappings":"2KAIAA,EAASC,CAAE,EACX,MAAMC,EAAkB,CACtB,KAAMC,EAAE,mBAAmB,EAC3B,MAAOA,EAAE,aAAa,EAEtB,OAAQA,EAAE,UAAU,CAEtB,EACA,SAASC,EAAkBC,EAAY,KAAK,IAAG,EAAIC,EAAO,CAAA,EAAI,CAC5D,MAAMC,EAAcC,EAAI,KAAK,IAAG,CAAE,EAClC,IAAIC,EACJ,MAAMC,EAAUF,EAAI,CAClB,OAAQ,CACN,UAAW,SACX,UAAW,OACZ,EACD,aAAc,OACd,cAAe,GACf,GAAGG,EAAML,CAAI,CACjB,CAAG,EACKM,EAAiBC,EAAS,KAAO,CAAE,GAAGF,EAAML,CAAI,EAAG,GAAGI,EAAQ,KAAK,EAAG,EACtEI,EAAOD,EAAS,IAAM,IAAI,KAAKF,EAAMN,CAAS,CAAC,CAAC,EAChDU,EAAoBF,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