UNPKG

@khatastroffik/react-text-renderer-components

Version:

a zero-dependencies component library providing (pure) text rendering for common and custom data/field types.

58 lines (47 loc) 2.81 kB
var $b8f6b02ccb3471cd$exports = require("./CacheManager.5cf53329.js"); var $d05063a33f9bc032$exports = require("./AbstractRenderer.51d1084a.js"); function $parcel$export(e, n, v, s) { Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); } $parcel$export(module.exports, "defaultQuarterFormatOptions", () => $07d061ed55bcfdb2$export$2aa57f48c574b918); $parcel$export(module.exports, "defaultYearFormatOptions", () => $07d061ed55bcfdb2$export$b49af7dca2ba7431); $parcel$export(module.exports, "QuarterRenderer", () => $07d061ed55bcfdb2$export$d734a8582745b47a); $parcel$export(module.exports, "calcQuarter", () => $07d061ed55bcfdb2$export$91ca22384d33e8); const $07d061ed55bcfdb2$export$2aa57f48c574b918 = { minimumIntegerDigits: 1 }; const $07d061ed55bcfdb2$export$b49af7dca2ba7431 = { year: "numeric" }; const $07d061ed55bcfdb2$var$_QuarterFormatterCache = {}; const $07d061ed55bcfdb2$var$_YearFormatterCache = {}; class $07d061ed55bcfdb2$export$d734a8582745b47a extends (0, $d05063a33f9bc032$exports.AbstractRenderer) { getFormatedText() { if (this.value) { const quarterFormatter = (0, $b8f6b02ccb3471cd$exports.getFromCache)($07d061ed55bcfdb2$var$_QuarterFormatterCache, Intl.NumberFormat, undefined, $07d061ed55bcfdb2$export$2aa57f48c574b918); const yearFormatter = (0, $b8f6b02ccb3471cd$exports.getFromCache)($07d061ed55bcfdb2$var$_YearFormatterCache, Intl.DateTimeFormat, undefined, $07d061ed55bcfdb2$export$b49af7dca2ba7431); return quarterFormatter.format($07d061ed55bcfdb2$export$91ca22384d33e8(this.value)) + (this.props.displayYear ? "/" + yearFormatter.format(this.value) : ""); } else return ""; } } function $07d061ed55bcfdb2$export$91ca22384d33e8(inputDate) { // getMonth() --> value range is 0..11 return Math.floor(1 + inputDate.getMonth() / 3); } /** FOR FUTURE DEVELOPMENT ******************************************* var date = new Date(); ops = {year: "numeric"}; // Default calendar const manually = new Intl.DateTimeFormat('en-GB', ops).format(new Date())); // Islamic calendar console.log(new Intl.DateTimeFormat('en-GB-u-ca-islamic', ops).format(new Date())); // Japanese Imperial calendar console.log(new Intl.DateTimeFormat('en-GB-u-ca-japanese', ops).format(new Date())); // Ethiopic calendar console.log(new Intl.DateTimeFormat('en-GB-u-ca-ethiopic', ops).format(new Date())); // Traditional Hebrew calendar console.log(new Intl.DateTimeFormat('en-GB-u-ca-hebrew', ops).format(new Date())); // Indian calendar console.log(new Intl.DateTimeFormat('en-GB-u-ca-indian', ops).format(new Date())); see also: https://stackoverflow.com/a/75602964 *********************************************************************/ //# sourceMappingURL=QuarterRenderer.c0ce4e70.js.map