@khatastroffik/react-text-renderer-components
Version:
a zero-dependencies component library providing (pure) text rendering for common and custom data/field types.
50 lines (41 loc) • 2.58 kB
JavaScript
import {getFromCache as $e916fd7cd7eb5385$export$2c00c4d94d5391c0} from "./CacheManager.00afa454.js";
import {AbstractRenderer as $fdhqi$AbstractRenderer} from "./AbstractRenderer.78c11f00.js";
const $40952d5935c36b84$export$2aa57f48c574b918 = {
minimumIntegerDigits: 1
};
const $40952d5935c36b84$export$b49af7dca2ba7431 = {
year: "numeric"
};
const $40952d5935c36b84$var$_QuarterFormatterCache = {};
const $40952d5935c36b84$var$_YearFormatterCache = {};
class $40952d5935c36b84$export$d734a8582745b47a extends (0, $fdhqi$AbstractRenderer) {
getFormatedText() {
if (this.value) {
const quarterFormatter = (0, $e916fd7cd7eb5385$export$2c00c4d94d5391c0)($40952d5935c36b84$var$_QuarterFormatterCache, Intl.NumberFormat, undefined, $40952d5935c36b84$export$2aa57f48c574b918);
const yearFormatter = (0, $e916fd7cd7eb5385$export$2c00c4d94d5391c0)($40952d5935c36b84$var$_YearFormatterCache, Intl.DateTimeFormat, undefined, $40952d5935c36b84$export$b49af7dca2ba7431);
return quarterFormatter.format($40952d5935c36b84$export$91ca22384d33e8(this.value)) + (this.props.displayYear ? "/" + yearFormatter.format(this.value) : "");
} else return "";
}
}
function $40952d5935c36b84$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
*********************************************************************/
export {$40952d5935c36b84$export$2aa57f48c574b918 as defaultQuarterFormatOptions, $40952d5935c36b84$export$b49af7dca2ba7431 as defaultYearFormatOptions, $40952d5935c36b84$export$d734a8582745b47a as QuarterRenderer, $40952d5935c36b84$export$91ca22384d33e8 as calcQuarter};
//# sourceMappingURL=QuarterRenderer.3fff2ac5.js.map