@cubejs-client/core
Advanced tools
+1743
| 'use strict'; | ||
| Object.defineProperty(exports, '__esModule', { value: true }); | ||
| require('core-js/modules/es.array.includes.js'); | ||
| require('core-js/modules/es.date.to-string.js'); | ||
| require('core-js/modules/es.number.is-nan.js'); | ||
| require('core-js/modules/es.object.to-string.js'); | ||
| require('core-js/modules/es.parse-float.js'); | ||
| require('core-js/modules/es.regexp.to-string.js'); | ||
| require('core-js/modules/es.string.starts-with.js'); | ||
| require('core-js/modules/es.array.concat.js'); | ||
| require('core-js/modules/es.array.filter.js'); | ||
| require('core-js/modules/es.array.find.js'); | ||
| require('core-js/modules/es.array.map.js'); | ||
| require('core-js/modules/es.object.create.js'); | ||
| function _defineProperty(e, r, t) { | ||
| return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { | ||
| value: t, | ||
| enumerable: !0, | ||
| configurable: !0, | ||
| writable: !0 | ||
| }) : e[r] = t, e; | ||
| } | ||
| function ownKeys(e, r) { | ||
| var t = Object.keys(e); | ||
| if (Object.getOwnPropertySymbols) { | ||
| var o = Object.getOwnPropertySymbols(e); | ||
| r && (o = o.filter(function (r) { | ||
| return Object.getOwnPropertyDescriptor(e, r).enumerable; | ||
| })), t.push.apply(t, o); | ||
| } | ||
| return t; | ||
| } | ||
| function _objectSpread2(e) { | ||
| for (var r = 1; r < arguments.length; r++) { | ||
| var t = null != arguments[r] ? arguments[r] : {}; | ||
| r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { | ||
| _defineProperty(e, r, t[r]); | ||
| }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { | ||
| Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); | ||
| }); | ||
| } | ||
| return e; | ||
| } | ||
| function _toPrimitive(t, r) { | ||
| if ("object" != typeof t || !t) return t; | ||
| var e = t[Symbol.toPrimitive]; | ||
| if (void 0 !== e) { | ||
| var i = e.call(t, r || "default"); | ||
| if ("object" != typeof i) return i; | ||
| throw new TypeError("@@toPrimitive must return a primitive value."); | ||
| } | ||
| return ("string" === r ? String : Number)(t); | ||
| } | ||
| function _toPropertyKey(t) { | ||
| var i = _toPrimitive(t, "string"); | ||
| return "symbol" == typeof i ? i : i + ""; | ||
| } | ||
| function _typeof(o) { | ||
| "@babel/helpers - typeof"; | ||
| return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { | ||
| return typeof o; | ||
| } : function (o) { | ||
| return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; | ||
| }, _typeof(o); | ||
| } | ||
| function formatDecimal(x) { | ||
| return Math.abs(x = Math.round(x)) >= 1e21 | ||
| ? x.toLocaleString("en").replace(/,/g, "") | ||
| : x.toString(10); | ||
| } | ||
| // Computes the decimal coefficient and exponent of the specified number x with | ||
| // significant digits p, where x is positive and p is in [1, 21] or undefined. | ||
| // For example, formatDecimalParts(1.23) returns ["123", 0]. | ||
| function formatDecimalParts(x, p) { | ||
| if (!isFinite(x) || x === 0) return null; // NaN, ±Infinity, ±0 | ||
| var i = (x = p ? x.toExponential(p - 1) : x.toExponential()).indexOf("e"), coefficient = x.slice(0, i); | ||
| // The string returned by toExponential either has the form \d\.\d+e[-+]\d+ | ||
| // (e.g., 1.2e+3) or the form \de[-+]\d+ (e.g., 1e+3). | ||
| return [ | ||
| coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient, | ||
| +x.slice(i + 1) | ||
| ]; | ||
| } | ||
| function exponent(x) { | ||
| return x = formatDecimalParts(Math.abs(x)), x ? x[1] : NaN; | ||
| } | ||
| function formatGroup(grouping, thousands) { | ||
| return function(value, width) { | ||
| var i = value.length, | ||
| t = [], | ||
| j = 0, | ||
| g = grouping[0], | ||
| length = 0; | ||
| while (i > 0 && g > 0) { | ||
| if (length + g + 1 > width) g = Math.max(1, width - length); | ||
| t.push(value.substring(i -= g, i + g)); | ||
| if ((length += g + 1) > width) break; | ||
| g = grouping[j = (j + 1) % grouping.length]; | ||
| } | ||
| return t.reverse().join(thousands); | ||
| }; | ||
| } | ||
| function formatNumerals(numerals) { | ||
| return function(value) { | ||
| return value.replace(/[0-9]/g, function(i) { | ||
| return numerals[+i]; | ||
| }); | ||
| }; | ||
| } | ||
| // [[fill]align][sign][symbol][0][width][,][.precision][~][type] | ||
| var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i; | ||
| function formatSpecifier(specifier) { | ||
| if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); | ||
| var match; | ||
| return new FormatSpecifier({ | ||
| fill: match[1], | ||
| align: match[2], | ||
| sign: match[3], | ||
| symbol: match[4], | ||
| zero: match[5], | ||
| width: match[6], | ||
| comma: match[7], | ||
| precision: match[8] && match[8].slice(1), | ||
| trim: match[9], | ||
| type: match[10] | ||
| }); | ||
| } | ||
| formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof | ||
| function FormatSpecifier(specifier) { | ||
| this.fill = specifier.fill === undefined ? " " : specifier.fill + ""; | ||
| this.align = specifier.align === undefined ? ">" : specifier.align + ""; | ||
| this.sign = specifier.sign === undefined ? "-" : specifier.sign + ""; | ||
| this.symbol = specifier.symbol === undefined ? "" : specifier.symbol + ""; | ||
| this.zero = !!specifier.zero; | ||
| this.width = specifier.width === undefined ? undefined : +specifier.width; | ||
| this.comma = !!specifier.comma; | ||
| this.precision = specifier.precision === undefined ? undefined : +specifier.precision; | ||
| this.trim = !!specifier.trim; | ||
| this.type = specifier.type === undefined ? "" : specifier.type + ""; | ||
| } | ||
| FormatSpecifier.prototype.toString = function() { | ||
| return this.fill | ||
| + this.align | ||
| + this.sign | ||
| + this.symbol | ||
| + (this.zero ? "0" : "") | ||
| + (this.width === undefined ? "" : Math.max(1, this.width | 0)) | ||
| + (this.comma ? "," : "") | ||
| + (this.precision === undefined ? "" : "." + Math.max(0, this.precision | 0)) | ||
| + (this.trim ? "~" : "") | ||
| + this.type; | ||
| }; | ||
| // Trims insignificant zeros, e.g., replaces 1.2000k with 1.2k. | ||
| function formatTrim(s) { | ||
| out: for (var n = s.length, i = 1, i0 = -1, i1; i < n; ++i) { | ||
| switch (s[i]) { | ||
| case ".": i0 = i1 = i; break; | ||
| case "0": if (i0 === 0) i0 = i; i1 = i; break; | ||
| default: if (!+s[i]) break out; if (i0 > 0) i0 = 0; break; | ||
| } | ||
| } | ||
| return i0 > 0 ? s.slice(0, i0) + s.slice(i1 + 1) : s; | ||
| } | ||
| var prefixExponent; | ||
| function formatPrefixAuto(x, p) { | ||
| var d = formatDecimalParts(x, p); | ||
| if (!d) return prefixExponent = undefined, x.toPrecision(p); | ||
| var coefficient = d[0], | ||
| exponent = d[1], | ||
| i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, | ||
| n = coefficient.length; | ||
| return i === n ? coefficient | ||
| : i > n ? coefficient + new Array(i - n + 1).join("0") | ||
| : i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i) | ||
| : "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y! | ||
| } | ||
| function formatRounded(x, p) { | ||
| var d = formatDecimalParts(x, p); | ||
| if (!d) return x + ""; | ||
| var coefficient = d[0], | ||
| exponent = d[1]; | ||
| return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient | ||
| : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) | ||
| : coefficient + new Array(exponent - coefficient.length + 2).join("0"); | ||
| } | ||
| var formatTypes = { | ||
| "%": (x, p) => (x * 100).toFixed(p), | ||
| "b": (x) => Math.round(x).toString(2), | ||
| "c": (x) => x + "", | ||
| "d": formatDecimal, | ||
| "e": (x, p) => x.toExponential(p), | ||
| "f": (x, p) => x.toFixed(p), | ||
| "g": (x, p) => x.toPrecision(p), | ||
| "o": (x) => Math.round(x).toString(8), | ||
| "p": (x, p) => formatRounded(x * 100, p), | ||
| "r": formatRounded, | ||
| "s": formatPrefixAuto, | ||
| "X": (x) => Math.round(x).toString(16).toUpperCase(), | ||
| "x": (x) => Math.round(x).toString(16) | ||
| }; | ||
| function identity(x) { | ||
| return x; | ||
| } | ||
| var map = Array.prototype.map, | ||
| prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"]; | ||
| function formatLocale$1(locale) { | ||
| var group = locale.grouping === undefined || locale.thousands === undefined ? identity : formatGroup(map.call(locale.grouping, Number), locale.thousands + ""), | ||
| currencyPrefix = locale.currency === undefined ? "" : locale.currency[0] + "", | ||
| currencySuffix = locale.currency === undefined ? "" : locale.currency[1] + "", | ||
| decimal = locale.decimal === undefined ? "." : locale.decimal + "", | ||
| numerals = locale.numerals === undefined ? identity : formatNumerals(map.call(locale.numerals, String)), | ||
| percent = locale.percent === undefined ? "%" : locale.percent + "", | ||
| minus = locale.minus === undefined ? "−" : locale.minus + "", | ||
| nan = locale.nan === undefined ? "NaN" : locale.nan + ""; | ||
| function newFormat(specifier, options) { | ||
| specifier = formatSpecifier(specifier); | ||
| var fill = specifier.fill, | ||
| align = specifier.align, | ||
| sign = specifier.sign, | ||
| symbol = specifier.symbol, | ||
| zero = specifier.zero, | ||
| width = specifier.width, | ||
| comma = specifier.comma, | ||
| precision = specifier.precision, | ||
| trim = specifier.trim, | ||
| type = specifier.type; | ||
| // The "n" type is an alias for ",g". | ||
| if (type === "n") comma = true, type = "g"; | ||
| // The "" type, and any invalid type, is an alias for ".12~g". | ||
| else if (!formatTypes[type]) precision === undefined && (precision = 12), trim = true, type = "g"; | ||
| // If zero fill is specified, padding goes after sign and before digits. | ||
| if (zero || (fill === "0" && align === "=")) zero = true, fill = "0", align = "="; | ||
| // Compute the prefix and suffix. | ||
| // For SI-prefix, the suffix is lazily computed. | ||
| var prefix = (options && options.prefix !== undefined ? options.prefix : "") + (symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : ""), | ||
| suffix = (symbol === "$" ? currencySuffix : /[%p]/.test(type) ? percent : "") + (options && options.suffix !== undefined ? options.suffix : ""); | ||
| // What format function should we use? | ||
| // Is this an integer type? | ||
| // Can this type generate exponential notation? | ||
| var formatType = formatTypes[type], | ||
| maybeSuffix = /[defgprs%]/.test(type); | ||
| // Set the default precision if not specified, | ||
| // or clamp the specified precision to the supported range. | ||
| // For significant precision, it must be in [1, 21]. | ||
| // For fixed precision, it must be in [0, 20]. | ||
| precision = precision === undefined ? 6 | ||
| : /[gprs]/.test(type) ? Math.max(1, Math.min(21, precision)) | ||
| : Math.max(0, Math.min(20, precision)); | ||
| function format(value) { | ||
| var valuePrefix = prefix, | ||
| valueSuffix = suffix, | ||
| i, n, c; | ||
| if (type === "c") { | ||
| valueSuffix = formatType(value) + valueSuffix; | ||
| value = ""; | ||
| } else { | ||
| value = +value; | ||
| // Determine the sign. -0 is not less than 0, but 1 / -0 is! | ||
| var valueNegative = value < 0 || 1 / value < 0; | ||
| // Perform the initial formatting. | ||
| value = isNaN(value) ? nan : formatType(Math.abs(value), precision); | ||
| // Trim insignificant zeros. | ||
| if (trim) value = formatTrim(value); | ||
| // If a negative value rounds to zero after formatting, and no explicit positive sign is requested, hide the sign. | ||
| if (valueNegative && +value === 0 && sign !== "+") valueNegative = false; | ||
| // Compute the prefix and suffix. | ||
| valuePrefix = (valueNegative ? (sign === "(" ? sign : minus) : sign === "-" || sign === "(" ? "" : sign) + valuePrefix; | ||
| valueSuffix = (type === "s" && !isNaN(value) && prefixExponent !== undefined ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign === "(" ? ")" : ""); | ||
| // Break the formatted value into the integer “value” part that can be | ||
| // grouped, and fractional or exponential “suffix” part that is not. | ||
| if (maybeSuffix) { | ||
| i = -1, n = value.length; | ||
| while (++i < n) { | ||
| if (c = value.charCodeAt(i), 48 > c || c > 57) { | ||
| valueSuffix = (c === 46 ? decimal + value.slice(i + 1) : value.slice(i)) + valueSuffix; | ||
| value = value.slice(0, i); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| // If the fill character is not "0", grouping is applied before padding. | ||
| if (comma && !zero) value = group(value, Infinity); | ||
| // Compute the padding. | ||
| var length = valuePrefix.length + value.length + valueSuffix.length, | ||
| padding = length < width ? new Array(width - length + 1).join(fill) : ""; | ||
| // If the fill character is "0", grouping is applied after padding. | ||
| if (comma && zero) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = ""; | ||
| // Reconstruct the final output based on the desired alignment. | ||
| switch (align) { | ||
| case "<": value = valuePrefix + value + valueSuffix + padding; break; | ||
| case "=": value = valuePrefix + padding + value + valueSuffix; break; | ||
| case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break; | ||
| default: value = padding + valuePrefix + value + valueSuffix; break; | ||
| } | ||
| return numerals(value); | ||
| } | ||
| format.toString = function() { | ||
| return specifier + ""; | ||
| }; | ||
| return format; | ||
| } | ||
| function formatPrefix(specifier, value) { | ||
| var e = Math.max(-8, Math.min(8, Math.floor(exponent(value) / 3))) * 3, | ||
| k = Math.pow(10, -e), | ||
| f = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier), {suffix: prefixes[8 + e / 3]}); | ||
| return function(value) { | ||
| return f(k * value); | ||
| }; | ||
| } | ||
| return { | ||
| format: newFormat, | ||
| formatPrefix: formatPrefix | ||
| }; | ||
| } | ||
| var locale$1; | ||
| var format; | ||
| defaultLocale$1({ | ||
| thousands: ",", | ||
| grouping: [3], | ||
| currency: ["$", ""] | ||
| }); | ||
| function defaultLocale$1(definition) { | ||
| locale$1 = formatLocale$1(definition); | ||
| format = locale$1.format; | ||
| locale$1.formatPrefix; | ||
| return locale$1; | ||
| } | ||
| const t0 = new Date, t1 = new Date; | ||
| function timeInterval(floori, offseti, count, field) { | ||
| function interval(date) { | ||
| return floori(date = arguments.length === 0 ? new Date : new Date(+date)), date; | ||
| } | ||
| interval.floor = (date) => { | ||
| return floori(date = new Date(+date)), date; | ||
| }; | ||
| interval.ceil = (date) => { | ||
| return floori(date = new Date(date - 1)), offseti(date, 1), floori(date), date; | ||
| }; | ||
| interval.round = (date) => { | ||
| const d0 = interval(date), d1 = interval.ceil(date); | ||
| return date - d0 < d1 - date ? d0 : d1; | ||
| }; | ||
| interval.offset = (date, step) => { | ||
| return offseti(date = new Date(+date), step == null ? 1 : Math.floor(step)), date; | ||
| }; | ||
| interval.range = (start, stop, step) => { | ||
| const range = []; | ||
| start = interval.ceil(start); | ||
| step = step == null ? 1 : Math.floor(step); | ||
| if (!(start < stop) || !(step > 0)) return range; // also handles Invalid Date | ||
| let previous; | ||
| do range.push(previous = new Date(+start)), offseti(start, step), floori(start); | ||
| while (previous < start && start < stop); | ||
| return range; | ||
| }; | ||
| interval.filter = (test) => { | ||
| return timeInterval((date) => { | ||
| if (date >= date) while (floori(date), !test(date)) date.setTime(date - 1); | ||
| }, (date, step) => { | ||
| if (date >= date) { | ||
| if (step < 0) while (++step <= 0) { | ||
| while (offseti(date, -1), !test(date)) {} // eslint-disable-line no-empty | ||
| } else while (--step >= 0) { | ||
| while (offseti(date, +1), !test(date)) {} // eslint-disable-line no-empty | ||
| } | ||
| } | ||
| }); | ||
| }; | ||
| if (count) { | ||
| interval.count = (start, end) => { | ||
| t0.setTime(+start), t1.setTime(+end); | ||
| floori(t0), floori(t1); | ||
| return Math.floor(count(t0, t1)); | ||
| }; | ||
| interval.every = (step) => { | ||
| step = Math.floor(step); | ||
| return !isFinite(step) || !(step > 0) ? null | ||
| : !(step > 1) ? interval | ||
| : interval.filter(field | ||
| ? (d) => field(d) % step === 0 | ||
| : (d) => interval.count(0, d) % step === 0); | ||
| }; | ||
| } | ||
| return interval; | ||
| } | ||
| const durationSecond = 1000; | ||
| const durationMinute = durationSecond * 60; | ||
| const durationHour = durationMinute * 60; | ||
| const durationDay = durationHour * 24; | ||
| const durationWeek = durationDay * 7; | ||
| const timeDay = timeInterval( | ||
| date => date.setHours(0, 0, 0, 0), | ||
| (date, step) => date.setDate(date.getDate() + step), | ||
| (start, end) => (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationDay, | ||
| date => date.getDate() - 1 | ||
| ); | ||
| timeDay.range; | ||
| const utcDay = timeInterval((date) => { | ||
| date.setUTCHours(0, 0, 0, 0); | ||
| }, (date, step) => { | ||
| date.setUTCDate(date.getUTCDate() + step); | ||
| }, (start, end) => { | ||
| return (end - start) / durationDay; | ||
| }, (date) => { | ||
| return date.getUTCDate() - 1; | ||
| }); | ||
| utcDay.range; | ||
| const unixDay = timeInterval((date) => { | ||
| date.setUTCHours(0, 0, 0, 0); | ||
| }, (date, step) => { | ||
| date.setUTCDate(date.getUTCDate() + step); | ||
| }, (start, end) => { | ||
| return (end - start) / durationDay; | ||
| }, (date) => { | ||
| return Math.floor(date / durationDay); | ||
| }); | ||
| unixDay.range; | ||
| function timeWeekday(i) { | ||
| return timeInterval((date) => { | ||
| date.setDate(date.getDate() - (date.getDay() + 7 - i) % 7); | ||
| date.setHours(0, 0, 0, 0); | ||
| }, (date, step) => { | ||
| date.setDate(date.getDate() + step * 7); | ||
| }, (start, end) => { | ||
| return (end - start - (end.getTimezoneOffset() - start.getTimezoneOffset()) * durationMinute) / durationWeek; | ||
| }); | ||
| } | ||
| const timeSunday = timeWeekday(0); | ||
| const timeMonday = timeWeekday(1); | ||
| const timeTuesday = timeWeekday(2); | ||
| const timeWednesday = timeWeekday(3); | ||
| const timeThursday = timeWeekday(4); | ||
| const timeFriday = timeWeekday(5); | ||
| const timeSaturday = timeWeekday(6); | ||
| timeSunday.range; | ||
| timeMonday.range; | ||
| timeTuesday.range; | ||
| timeWednesday.range; | ||
| timeThursday.range; | ||
| timeFriday.range; | ||
| timeSaturday.range; | ||
| function utcWeekday(i) { | ||
| return timeInterval((date) => { | ||
| date.setUTCDate(date.getUTCDate() - (date.getUTCDay() + 7 - i) % 7); | ||
| date.setUTCHours(0, 0, 0, 0); | ||
| }, (date, step) => { | ||
| date.setUTCDate(date.getUTCDate() + step * 7); | ||
| }, (start, end) => { | ||
| return (end - start) / durationWeek; | ||
| }); | ||
| } | ||
| const utcSunday = utcWeekday(0); | ||
| const utcMonday = utcWeekday(1); | ||
| const utcTuesday = utcWeekday(2); | ||
| const utcWednesday = utcWeekday(3); | ||
| const utcThursday = utcWeekday(4); | ||
| const utcFriday = utcWeekday(5); | ||
| const utcSaturday = utcWeekday(6); | ||
| utcSunday.range; | ||
| utcMonday.range; | ||
| utcTuesday.range; | ||
| utcWednesday.range; | ||
| utcThursday.range; | ||
| utcFriday.range; | ||
| utcSaturday.range; | ||
| const timeYear = timeInterval((date) => { | ||
| date.setMonth(0, 1); | ||
| date.setHours(0, 0, 0, 0); | ||
| }, (date, step) => { | ||
| date.setFullYear(date.getFullYear() + step); | ||
| }, (start, end) => { | ||
| return end.getFullYear() - start.getFullYear(); | ||
| }, (date) => { | ||
| return date.getFullYear(); | ||
| }); | ||
| // An optimized implementation for this simple case. | ||
| timeYear.every = (k) => { | ||
| return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => { | ||
| date.setFullYear(Math.floor(date.getFullYear() / k) * k); | ||
| date.setMonth(0, 1); | ||
| date.setHours(0, 0, 0, 0); | ||
| }, (date, step) => { | ||
| date.setFullYear(date.getFullYear() + step * k); | ||
| }); | ||
| }; | ||
| timeYear.range; | ||
| const utcYear = timeInterval((date) => { | ||
| date.setUTCMonth(0, 1); | ||
| date.setUTCHours(0, 0, 0, 0); | ||
| }, (date, step) => { | ||
| date.setUTCFullYear(date.getUTCFullYear() + step); | ||
| }, (start, end) => { | ||
| return end.getUTCFullYear() - start.getUTCFullYear(); | ||
| }, (date) => { | ||
| return date.getUTCFullYear(); | ||
| }); | ||
| // An optimized implementation for this simple case. | ||
| utcYear.every = (k) => { | ||
| return !isFinite(k = Math.floor(k)) || !(k > 0) ? null : timeInterval((date) => { | ||
| date.setUTCFullYear(Math.floor(date.getUTCFullYear() / k) * k); | ||
| date.setUTCMonth(0, 1); | ||
| date.setUTCHours(0, 0, 0, 0); | ||
| }, (date, step) => { | ||
| date.setUTCFullYear(date.getUTCFullYear() + step * k); | ||
| }); | ||
| }; | ||
| utcYear.range; | ||
| function localDate(d) { | ||
| if (0 <= d.y && d.y < 100) { | ||
| var date = new Date(-1, d.m, d.d, d.H, d.M, d.S, d.L); | ||
| date.setFullYear(d.y); | ||
| return date; | ||
| } | ||
| return new Date(d.y, d.m, d.d, d.H, d.M, d.S, d.L); | ||
| } | ||
| function utcDate(d) { | ||
| if (0 <= d.y && d.y < 100) { | ||
| var date = new Date(Date.UTC(-1, d.m, d.d, d.H, d.M, d.S, d.L)); | ||
| date.setUTCFullYear(d.y); | ||
| return date; | ||
| } | ||
| return new Date(Date.UTC(d.y, d.m, d.d, d.H, d.M, d.S, d.L)); | ||
| } | ||
| function newDate(y, m, d) { | ||
| return {y: y, m: m, d: d, H: 0, M: 0, S: 0, L: 0}; | ||
| } | ||
| function formatLocale(locale) { | ||
| var locale_dateTime = locale.dateTime, | ||
| locale_date = locale.date, | ||
| locale_time = locale.time, | ||
| locale_periods = locale.periods, | ||
| locale_weekdays = locale.days, | ||
| locale_shortWeekdays = locale.shortDays, | ||
| locale_months = locale.months, | ||
| locale_shortMonths = locale.shortMonths; | ||
| var periodRe = formatRe(locale_periods), | ||
| periodLookup = formatLookup(locale_periods), | ||
| weekdayRe = formatRe(locale_weekdays), | ||
| weekdayLookup = formatLookup(locale_weekdays), | ||
| shortWeekdayRe = formatRe(locale_shortWeekdays), | ||
| shortWeekdayLookup = formatLookup(locale_shortWeekdays), | ||
| monthRe = formatRe(locale_months), | ||
| monthLookup = formatLookup(locale_months), | ||
| shortMonthRe = formatRe(locale_shortMonths), | ||
| shortMonthLookup = formatLookup(locale_shortMonths); | ||
| var formats = { | ||
| "a": formatShortWeekday, | ||
| "A": formatWeekday, | ||
| "b": formatShortMonth, | ||
| "B": formatMonth, | ||
| "c": null, | ||
| "d": formatDayOfMonth, | ||
| "e": formatDayOfMonth, | ||
| "f": formatMicroseconds, | ||
| "g": formatYearISO, | ||
| "G": formatFullYearISO, | ||
| "H": formatHour24, | ||
| "I": formatHour12, | ||
| "j": formatDayOfYear, | ||
| "L": formatMilliseconds, | ||
| "m": formatMonthNumber, | ||
| "M": formatMinutes, | ||
| "p": formatPeriod, | ||
| "q": formatQuarter, | ||
| "Q": formatUnixTimestamp, | ||
| "s": formatUnixTimestampSeconds, | ||
| "S": formatSeconds, | ||
| "u": formatWeekdayNumberMonday, | ||
| "U": formatWeekNumberSunday, | ||
| "V": formatWeekNumberISO, | ||
| "w": formatWeekdayNumberSunday, | ||
| "W": formatWeekNumberMonday, | ||
| "x": null, | ||
| "X": null, | ||
| "y": formatYear, | ||
| "Y": formatFullYear, | ||
| "Z": formatZone, | ||
| "%": formatLiteralPercent | ||
| }; | ||
| var utcFormats = { | ||
| "a": formatUTCShortWeekday, | ||
| "A": formatUTCWeekday, | ||
| "b": formatUTCShortMonth, | ||
| "B": formatUTCMonth, | ||
| "c": null, | ||
| "d": formatUTCDayOfMonth, | ||
| "e": formatUTCDayOfMonth, | ||
| "f": formatUTCMicroseconds, | ||
| "g": formatUTCYearISO, | ||
| "G": formatUTCFullYearISO, | ||
| "H": formatUTCHour24, | ||
| "I": formatUTCHour12, | ||
| "j": formatUTCDayOfYear, | ||
| "L": formatUTCMilliseconds, | ||
| "m": formatUTCMonthNumber, | ||
| "M": formatUTCMinutes, | ||
| "p": formatUTCPeriod, | ||
| "q": formatUTCQuarter, | ||
| "Q": formatUnixTimestamp, | ||
| "s": formatUnixTimestampSeconds, | ||
| "S": formatUTCSeconds, | ||
| "u": formatUTCWeekdayNumberMonday, | ||
| "U": formatUTCWeekNumberSunday, | ||
| "V": formatUTCWeekNumberISO, | ||
| "w": formatUTCWeekdayNumberSunday, | ||
| "W": formatUTCWeekNumberMonday, | ||
| "x": null, | ||
| "X": null, | ||
| "y": formatUTCYear, | ||
| "Y": formatUTCFullYear, | ||
| "Z": formatUTCZone, | ||
| "%": formatLiteralPercent | ||
| }; | ||
| var parses = { | ||
| "a": parseShortWeekday, | ||
| "A": parseWeekday, | ||
| "b": parseShortMonth, | ||
| "B": parseMonth, | ||
| "c": parseLocaleDateTime, | ||
| "d": parseDayOfMonth, | ||
| "e": parseDayOfMonth, | ||
| "f": parseMicroseconds, | ||
| "g": parseYear, | ||
| "G": parseFullYear, | ||
| "H": parseHour24, | ||
| "I": parseHour24, | ||
| "j": parseDayOfYear, | ||
| "L": parseMilliseconds, | ||
| "m": parseMonthNumber, | ||
| "M": parseMinutes, | ||
| "p": parsePeriod, | ||
| "q": parseQuarter, | ||
| "Q": parseUnixTimestamp, | ||
| "s": parseUnixTimestampSeconds, | ||
| "S": parseSeconds, | ||
| "u": parseWeekdayNumberMonday, | ||
| "U": parseWeekNumberSunday, | ||
| "V": parseWeekNumberISO, | ||
| "w": parseWeekdayNumberSunday, | ||
| "W": parseWeekNumberMonday, | ||
| "x": parseLocaleDate, | ||
| "X": parseLocaleTime, | ||
| "y": parseYear, | ||
| "Y": parseFullYear, | ||
| "Z": parseZone, | ||
| "%": parseLiteralPercent | ||
| }; | ||
| // These recursive directive definitions must be deferred. | ||
| formats.x = newFormat(locale_date, formats); | ||
| formats.X = newFormat(locale_time, formats); | ||
| formats.c = newFormat(locale_dateTime, formats); | ||
| utcFormats.x = newFormat(locale_date, utcFormats); | ||
| utcFormats.X = newFormat(locale_time, utcFormats); | ||
| utcFormats.c = newFormat(locale_dateTime, utcFormats); | ||
| function newFormat(specifier, formats) { | ||
| return function(date) { | ||
| var string = [], | ||
| i = -1, | ||
| j = 0, | ||
| n = specifier.length, | ||
| c, | ||
| pad, | ||
| format; | ||
| if (!(date instanceof Date)) date = new Date(+date); | ||
| while (++i < n) { | ||
| if (specifier.charCodeAt(i) === 37) { | ||
| string.push(specifier.slice(j, i)); | ||
| if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i); | ||
| else pad = c === "e" ? " " : "0"; | ||
| if (format = formats[c]) c = format(date, pad); | ||
| string.push(c); | ||
| j = i + 1; | ||
| } | ||
| } | ||
| string.push(specifier.slice(j, i)); | ||
| return string.join(""); | ||
| }; | ||
| } | ||
| function newParse(specifier, Z) { | ||
| return function(string) { | ||
| var d = newDate(1900, undefined, 1), | ||
| i = parseSpecifier(d, specifier, string += "", 0), | ||
| week, day; | ||
| if (i != string.length) return null; | ||
| // If a UNIX timestamp is specified, return it. | ||
| if ("Q" in d) return new Date(d.Q); | ||
| if ("s" in d) return new Date(d.s * 1000 + ("L" in d ? d.L : 0)); | ||
| // If this is utcParse, never use the local timezone. | ||
| if (Z && !("Z" in d)) d.Z = 0; | ||
| // The am-pm flag is 0 for AM, and 1 for PM. | ||
| if ("p" in d) d.H = d.H % 12 + d.p * 12; | ||
| // If the month was not specified, inherit from the quarter. | ||
| if (d.m === undefined) d.m = "q" in d ? d.q : 0; | ||
| // Convert day-of-week and week-of-year to day-of-year. | ||
| if ("V" in d) { | ||
| if (d.V < 1 || d.V > 53) return null; | ||
| if (!("w" in d)) d.w = 1; | ||
| if ("Z" in d) { | ||
| week = utcDate(newDate(d.y, 0, 1)), day = week.getUTCDay(); | ||
| week = day > 4 || day === 0 ? utcMonday.ceil(week) : utcMonday(week); | ||
| week = utcDay.offset(week, (d.V - 1) * 7); | ||
| d.y = week.getUTCFullYear(); | ||
| d.m = week.getUTCMonth(); | ||
| d.d = week.getUTCDate() + (d.w + 6) % 7; | ||
| } else { | ||
| week = localDate(newDate(d.y, 0, 1)), day = week.getDay(); | ||
| week = day > 4 || day === 0 ? timeMonday.ceil(week) : timeMonday(week); | ||
| week = timeDay.offset(week, (d.V - 1) * 7); | ||
| d.y = week.getFullYear(); | ||
| d.m = week.getMonth(); | ||
| d.d = week.getDate() + (d.w + 6) % 7; | ||
| } | ||
| } else if ("W" in d || "U" in d) { | ||
| if (!("w" in d)) d.w = "u" in d ? d.u % 7 : "W" in d ? 1 : 0; | ||
| day = "Z" in d ? utcDate(newDate(d.y, 0, 1)).getUTCDay() : localDate(newDate(d.y, 0, 1)).getDay(); | ||
| d.m = 0; | ||
| d.d = "W" in d ? (d.w + 6) % 7 + d.W * 7 - (day + 5) % 7 : d.w + d.U * 7 - (day + 6) % 7; | ||
| } | ||
| // If a time zone is specified, all fields are interpreted as UTC and then | ||
| // offset according to the specified time zone. | ||
| if ("Z" in d) { | ||
| d.H += d.Z / 100 | 0; | ||
| d.M += d.Z % 100; | ||
| return utcDate(d); | ||
| } | ||
| // Otherwise, all fields are in local time. | ||
| return localDate(d); | ||
| }; | ||
| } | ||
| function parseSpecifier(d, specifier, string, j) { | ||
| var i = 0, | ||
| n = specifier.length, | ||
| m = string.length, | ||
| c, | ||
| parse; | ||
| while (i < n) { | ||
| if (j >= m) return -1; | ||
| c = specifier.charCodeAt(i++); | ||
| if (c === 37) { | ||
| c = specifier.charAt(i++); | ||
| parse = parses[c in pads ? specifier.charAt(i++) : c]; | ||
| if (!parse || ((j = parse(d, string, j)) < 0)) return -1; | ||
| } else if (c != string.charCodeAt(j++)) { | ||
| return -1; | ||
| } | ||
| } | ||
| return j; | ||
| } | ||
| function parsePeriod(d, string, i) { | ||
| var n = periodRe.exec(string.slice(i)); | ||
| return n ? (d.p = periodLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; | ||
| } | ||
| function parseShortWeekday(d, string, i) { | ||
| var n = shortWeekdayRe.exec(string.slice(i)); | ||
| return n ? (d.w = shortWeekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; | ||
| } | ||
| function parseWeekday(d, string, i) { | ||
| var n = weekdayRe.exec(string.slice(i)); | ||
| return n ? (d.w = weekdayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; | ||
| } | ||
| function parseShortMonth(d, string, i) { | ||
| var n = shortMonthRe.exec(string.slice(i)); | ||
| return n ? (d.m = shortMonthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; | ||
| } | ||
| function parseMonth(d, string, i) { | ||
| var n = monthRe.exec(string.slice(i)); | ||
| return n ? (d.m = monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; | ||
| } | ||
| function parseLocaleDateTime(d, string, i) { | ||
| return parseSpecifier(d, locale_dateTime, string, i); | ||
| } | ||
| function parseLocaleDate(d, string, i) { | ||
| return parseSpecifier(d, locale_date, string, i); | ||
| } | ||
| function parseLocaleTime(d, string, i) { | ||
| return parseSpecifier(d, locale_time, string, i); | ||
| } | ||
| function formatShortWeekday(d) { | ||
| return locale_shortWeekdays[d.getDay()]; | ||
| } | ||
| function formatWeekday(d) { | ||
| return locale_weekdays[d.getDay()]; | ||
| } | ||
| function formatShortMonth(d) { | ||
| return locale_shortMonths[d.getMonth()]; | ||
| } | ||
| function formatMonth(d) { | ||
| return locale_months[d.getMonth()]; | ||
| } | ||
| function formatPeriod(d) { | ||
| return locale_periods[+(d.getHours() >= 12)]; | ||
| } | ||
| function formatQuarter(d) { | ||
| return 1 + ~~(d.getMonth() / 3); | ||
| } | ||
| function formatUTCShortWeekday(d) { | ||
| return locale_shortWeekdays[d.getUTCDay()]; | ||
| } | ||
| function formatUTCWeekday(d) { | ||
| return locale_weekdays[d.getUTCDay()]; | ||
| } | ||
| function formatUTCShortMonth(d) { | ||
| return locale_shortMonths[d.getUTCMonth()]; | ||
| } | ||
| function formatUTCMonth(d) { | ||
| return locale_months[d.getUTCMonth()]; | ||
| } | ||
| function formatUTCPeriod(d) { | ||
| return locale_periods[+(d.getUTCHours() >= 12)]; | ||
| } | ||
| function formatUTCQuarter(d) { | ||
| return 1 + ~~(d.getUTCMonth() / 3); | ||
| } | ||
| return { | ||
| format: function(specifier) { | ||
| var f = newFormat(specifier += "", formats); | ||
| f.toString = function() { return specifier; }; | ||
| return f; | ||
| }, | ||
| parse: function(specifier) { | ||
| var p = newParse(specifier += "", false); | ||
| p.toString = function() { return specifier; }; | ||
| return p; | ||
| }, | ||
| utcFormat: function(specifier) { | ||
| var f = newFormat(specifier += "", utcFormats); | ||
| f.toString = function() { return specifier; }; | ||
| return f; | ||
| }, | ||
| utcParse: function(specifier) { | ||
| var p = newParse(specifier += "", true); | ||
| p.toString = function() { return specifier; }; | ||
| return p; | ||
| } | ||
| }; | ||
| } | ||
| var pads = {"-": "", "_": " ", "0": "0"}, | ||
| numberRe = /^\s*\d+/, // note: ignores next directive | ||
| percentRe = /^%/, | ||
| requoteRe = /[\\^$*+?|[\]().{}]/g; | ||
| function pad(value, fill, width) { | ||
| var sign = value < 0 ? "-" : "", | ||
| string = (sign ? -value : value) + "", | ||
| length = string.length; | ||
| return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); | ||
| } | ||
| function requote(s) { | ||
| return s.replace(requoteRe, "\\$&"); | ||
| } | ||
| function formatRe(names) { | ||
| return new RegExp("^(?:" + names.map(requote).join("|") + ")", "i"); | ||
| } | ||
| function formatLookup(names) { | ||
| return new Map(names.map((name, i) => [name.toLowerCase(), i])); | ||
| } | ||
| function parseWeekdayNumberSunday(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 1)); | ||
| return n ? (d.w = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseWeekdayNumberMonday(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 1)); | ||
| return n ? (d.u = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseWeekNumberSunday(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 2)); | ||
| return n ? (d.U = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseWeekNumberISO(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 2)); | ||
| return n ? (d.V = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseWeekNumberMonday(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 2)); | ||
| return n ? (d.W = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseFullYear(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 4)); | ||
| return n ? (d.y = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseYear(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 2)); | ||
| return n ? (d.y = +n[0] + (+n[0] > 68 ? 1900 : 2000), i + n[0].length) : -1; | ||
| } | ||
| function parseZone(d, string, i) { | ||
| var n = /^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(string.slice(i, i + 6)); | ||
| return n ? (d.Z = n[1] ? 0 : -(n[2] + (n[3] || "00")), i + n[0].length) : -1; | ||
| } | ||
| function parseQuarter(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 1)); | ||
| return n ? (d.q = n[0] * 3 - 3, i + n[0].length) : -1; | ||
| } | ||
| function parseMonthNumber(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 2)); | ||
| return n ? (d.m = n[0] - 1, i + n[0].length) : -1; | ||
| } | ||
| function parseDayOfMonth(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 2)); | ||
| return n ? (d.d = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseDayOfYear(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 3)); | ||
| return n ? (d.m = 0, d.d = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseHour24(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 2)); | ||
| return n ? (d.H = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseMinutes(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 2)); | ||
| return n ? (d.M = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseSeconds(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 2)); | ||
| return n ? (d.S = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseMilliseconds(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 3)); | ||
| return n ? (d.L = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseMicroseconds(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i, i + 6)); | ||
| return n ? (d.L = Math.floor(n[0] / 1000), i + n[0].length) : -1; | ||
| } | ||
| function parseLiteralPercent(d, string, i) { | ||
| var n = percentRe.exec(string.slice(i, i + 1)); | ||
| return n ? i + n[0].length : -1; | ||
| } | ||
| function parseUnixTimestamp(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i)); | ||
| return n ? (d.Q = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function parseUnixTimestampSeconds(d, string, i) { | ||
| var n = numberRe.exec(string.slice(i)); | ||
| return n ? (d.s = +n[0], i + n[0].length) : -1; | ||
| } | ||
| function formatDayOfMonth(d, p) { | ||
| return pad(d.getDate(), p, 2); | ||
| } | ||
| function formatHour24(d, p) { | ||
| return pad(d.getHours(), p, 2); | ||
| } | ||
| function formatHour12(d, p) { | ||
| return pad(d.getHours() % 12 || 12, p, 2); | ||
| } | ||
| function formatDayOfYear(d, p) { | ||
| return pad(1 + timeDay.count(timeYear(d), d), p, 3); | ||
| } | ||
| function formatMilliseconds(d, p) { | ||
| return pad(d.getMilliseconds(), p, 3); | ||
| } | ||
| function formatMicroseconds(d, p) { | ||
| return formatMilliseconds(d, p) + "000"; | ||
| } | ||
| function formatMonthNumber(d, p) { | ||
| return pad(d.getMonth() + 1, p, 2); | ||
| } | ||
| function formatMinutes(d, p) { | ||
| return pad(d.getMinutes(), p, 2); | ||
| } | ||
| function formatSeconds(d, p) { | ||
| return pad(d.getSeconds(), p, 2); | ||
| } | ||
| function formatWeekdayNumberMonday(d) { | ||
| var day = d.getDay(); | ||
| return day === 0 ? 7 : day; | ||
| } | ||
| function formatWeekNumberSunday(d, p) { | ||
| return pad(timeSunday.count(timeYear(d) - 1, d), p, 2); | ||
| } | ||
| function dISO(d) { | ||
| var day = d.getDay(); | ||
| return (day >= 4 || day === 0) ? timeThursday(d) : timeThursday.ceil(d); | ||
| } | ||
| function formatWeekNumberISO(d, p) { | ||
| d = dISO(d); | ||
| return pad(timeThursday.count(timeYear(d), d) + (timeYear(d).getDay() === 4), p, 2); | ||
| } | ||
| function formatWeekdayNumberSunday(d) { | ||
| return d.getDay(); | ||
| } | ||
| function formatWeekNumberMonday(d, p) { | ||
| return pad(timeMonday.count(timeYear(d) - 1, d), p, 2); | ||
| } | ||
| function formatYear(d, p) { | ||
| return pad(d.getFullYear() % 100, p, 2); | ||
| } | ||
| function formatYearISO(d, p) { | ||
| d = dISO(d); | ||
| return pad(d.getFullYear() % 100, p, 2); | ||
| } | ||
| function formatFullYear(d, p) { | ||
| return pad(d.getFullYear() % 10000, p, 4); | ||
| } | ||
| function formatFullYearISO(d, p) { | ||
| var day = d.getDay(); | ||
| d = (day >= 4 || day === 0) ? timeThursday(d) : timeThursday.ceil(d); | ||
| return pad(d.getFullYear() % 10000, p, 4); | ||
| } | ||
| function formatZone(d) { | ||
| var z = d.getTimezoneOffset(); | ||
| return (z > 0 ? "-" : (z *= -1, "+")) | ||
| + pad(z / 60 | 0, "0", 2) | ||
| + pad(z % 60, "0", 2); | ||
| } | ||
| function formatUTCDayOfMonth(d, p) { | ||
| return pad(d.getUTCDate(), p, 2); | ||
| } | ||
| function formatUTCHour24(d, p) { | ||
| return pad(d.getUTCHours(), p, 2); | ||
| } | ||
| function formatUTCHour12(d, p) { | ||
| return pad(d.getUTCHours() % 12 || 12, p, 2); | ||
| } | ||
| function formatUTCDayOfYear(d, p) { | ||
| return pad(1 + utcDay.count(utcYear(d), d), p, 3); | ||
| } | ||
| function formatUTCMilliseconds(d, p) { | ||
| return pad(d.getUTCMilliseconds(), p, 3); | ||
| } | ||
| function formatUTCMicroseconds(d, p) { | ||
| return formatUTCMilliseconds(d, p) + "000"; | ||
| } | ||
| function formatUTCMonthNumber(d, p) { | ||
| return pad(d.getUTCMonth() + 1, p, 2); | ||
| } | ||
| function formatUTCMinutes(d, p) { | ||
| return pad(d.getUTCMinutes(), p, 2); | ||
| } | ||
| function formatUTCSeconds(d, p) { | ||
| return pad(d.getUTCSeconds(), p, 2); | ||
| } | ||
| function formatUTCWeekdayNumberMonday(d) { | ||
| var dow = d.getUTCDay(); | ||
| return dow === 0 ? 7 : dow; | ||
| } | ||
| function formatUTCWeekNumberSunday(d, p) { | ||
| return pad(utcSunday.count(utcYear(d) - 1, d), p, 2); | ||
| } | ||
| function UTCdISO(d) { | ||
| var day = d.getUTCDay(); | ||
| return (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); | ||
| } | ||
| function formatUTCWeekNumberISO(d, p) { | ||
| d = UTCdISO(d); | ||
| return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2); | ||
| } | ||
| function formatUTCWeekdayNumberSunday(d) { | ||
| return d.getUTCDay(); | ||
| } | ||
| function formatUTCWeekNumberMonday(d, p) { | ||
| return pad(utcMonday.count(utcYear(d) - 1, d), p, 2); | ||
| } | ||
| function formatUTCYear(d, p) { | ||
| return pad(d.getUTCFullYear() % 100, p, 2); | ||
| } | ||
| function formatUTCYearISO(d, p) { | ||
| d = UTCdISO(d); | ||
| return pad(d.getUTCFullYear() % 100, p, 2); | ||
| } | ||
| function formatUTCFullYear(d, p) { | ||
| return pad(d.getUTCFullYear() % 10000, p, 4); | ||
| } | ||
| function formatUTCFullYearISO(d, p) { | ||
| var day = d.getUTCDay(); | ||
| d = (day >= 4 || day === 0) ? utcThursday(d) : utcThursday.ceil(d); | ||
| return pad(d.getUTCFullYear() % 10000, p, 4); | ||
| } | ||
| function formatUTCZone() { | ||
| return "+0000"; | ||
| } | ||
| function formatLiteralPercent() { | ||
| return "%"; | ||
| } | ||
| function formatUnixTimestamp(d) { | ||
| return +d; | ||
| } | ||
| function formatUnixTimestampSeconds(d) { | ||
| return Math.floor(+d / 1000); | ||
| } | ||
| var locale; | ||
| var timeFormat; | ||
| defaultLocale({ | ||
| dateTime: "%x, %X", | ||
| date: "%-m/%-d/%Y", | ||
| time: "%-I:%M:%S %p", | ||
| periods: ["AM", "PM"], | ||
| days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], | ||
| shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], | ||
| months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], | ||
| shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] | ||
| }); | ||
| function defaultLocale(definition) { | ||
| locale = formatLocale(definition); | ||
| timeFormat = locale.format; | ||
| locale.parse; | ||
| locale.utcFormat; | ||
| locale.utcParse; | ||
| return locale; | ||
| } | ||
| // Pre-built d3 locale definitions for the most popular locales. | ||
| // Used as a fallback when Intl is unavailable (e.g. some edge runtimes). | ||
| var formatD3NumericLocale = { | ||
| 'en-US': { | ||
| decimal: '.', | ||
| thousands: ',', | ||
| grouping: [3] | ||
| }, | ||
| 'en-GB': { | ||
| decimal: '.', | ||
| thousands: ',', | ||
| grouping: [3] | ||
| }, | ||
| 'zh-CN': { | ||
| decimal: '.', | ||
| thousands: ',', | ||
| grouping: [3] | ||
| }, | ||
| 'es-ES': { | ||
| decimal: ',', | ||
| thousands: '.', | ||
| grouping: [3] | ||
| }, | ||
| 'es-MX': { | ||
| decimal: '.', | ||
| thousands: ',', | ||
| grouping: [3] | ||
| }, | ||
| 'de-DE': { | ||
| decimal: ',', | ||
| thousands: '.', | ||
| grouping: [3] | ||
| }, | ||
| 'ja-JP': { | ||
| decimal: '.', | ||
| thousands: ',', | ||
| grouping: [3] | ||
| }, | ||
| 'fr-FR': { | ||
| decimal: ',', | ||
| thousands: "\xA0", | ||
| grouping: [3], | ||
| percent: "\u202F%" | ||
| }, | ||
| 'pt-BR': { | ||
| decimal: ',', | ||
| thousands: '.', | ||
| grouping: [3] | ||
| }, | ||
| 'ko-KR': { | ||
| decimal: '.', | ||
| thousands: ',', | ||
| grouping: [3] | ||
| }, | ||
| 'it-IT': { | ||
| decimal: ',', | ||
| thousands: '.', | ||
| grouping: [3] | ||
| }, | ||
| 'nl-NL': { | ||
| decimal: ',', | ||
| thousands: '.', | ||
| grouping: [3] | ||
| }, | ||
| 'ru-RU': { | ||
| decimal: ',', | ||
| thousands: "\xA0", | ||
| grouping: [3] | ||
| } | ||
| }; | ||
| var currencySymbols = { | ||
| USD: '$', | ||
| EUR: '€', | ||
| GBP: '£', | ||
| JPY: '¥', | ||
| CNY: '¥', | ||
| KRW: '₩', | ||
| INR: '₹', | ||
| RUB: '₽' | ||
| }; | ||
| function getCurrencyOverride(locale, currencyCode) { | ||
| try { | ||
| var _currencyParts$find$v, _currencyParts$find, _currencyParts$find2; | ||
| var cf = new Intl.NumberFormat(locale, { | ||
| style: 'currency', | ||
| currency: currencyCode | ||
| }); | ||
| var currencyParts = cf.formatToParts(1); | ||
| var currencySymbol = (_currencyParts$find$v = (_currencyParts$find = currencyParts.find(function (p) { | ||
| return p.type === 'currency'; | ||
| })) === null || _currencyParts$find === void 0 ? void 0 : _currencyParts$find.value) !== null && _currencyParts$find$v !== void 0 ? _currencyParts$find$v : currencyCode; | ||
| var firstMeaningfulType = (_currencyParts$find2 = currencyParts.find(function (p) { | ||
| return !['literal', 'nan'].includes(p.type); | ||
| })) === null || _currencyParts$find2 === void 0 ? void 0 : _currencyParts$find2.type; | ||
| var symbolIsPrefix = firstMeaningfulType === 'currency'; | ||
| return symbolIsPrefix ? [currencySymbol, ''] : ['', currencySymbol]; | ||
| } catch (_unused) { | ||
| var _currencySymbols$curr; | ||
| var symbol = (_currencySymbols$curr = currencySymbols[currencyCode]) !== null && _currencySymbols$curr !== void 0 ? _currencySymbols$curr : currencyCode; | ||
| return [symbol, '']; | ||
| } | ||
| } | ||
| function deriveGrouping(locale) { | ||
| // en-US → "1,234,567,890" → sizes [1,3,3,3] → [3] | ||
| // en-IN → "1,23,45,67,890" → sizes [1,2,2,2,3] → [3,2] | ||
| var sizes = new Intl.NumberFormat(locale).formatToParts(1234567890).filter(function (p) { | ||
| return p.type === 'integer'; | ||
| }).map(function (p) { | ||
| return p.value.length; | ||
| }); | ||
| if (sizes.length <= 1) { | ||
| return [3]; | ||
| } | ||
| // d3 repeats the last array element for all remaining groups, | ||
| // so we only need the two rightmost (least-significant) group sizes. | ||
| var first = sizes[sizes.length - 1]; | ||
| var second = sizes[sizes.length - 2]; | ||
| return first === second ? [first] : [first, second]; | ||
| } | ||
| function getD3NumericLocaleFromIntl(locale) { | ||
| var currencyCode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'USD'; | ||
| var nf = new Intl.NumberFormat(locale); | ||
| var numParts = nf.formatToParts(1234567.89); | ||
| var find = function find(type) { | ||
| var _numParts$find$value, _numParts$find; | ||
| return (_numParts$find$value = (_numParts$find = numParts.find(function (p) { | ||
| return p.type === type; | ||
| })) === null || _numParts$find === void 0 ? void 0 : _numParts$find.value) !== null && _numParts$find$value !== void 0 ? _numParts$find$value : ''; | ||
| }; | ||
| return { | ||
| decimal: find('decimal') || '.', | ||
| thousands: find('group') || ',', | ||
| grouping: deriveGrouping(locale), | ||
| currency: getCurrencyOverride(locale, currencyCode) | ||
| }; | ||
| } | ||
| var localeCache = Object.create(null); | ||
| function getD3NumericLocale(locale) { | ||
| var currencyCode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'USD'; | ||
| var key = "".concat(locale, ":").concat(currencyCode); | ||
| if (localeCache[key]) { | ||
| return localeCache[key]; | ||
| } | ||
| var definition; | ||
| if (formatD3NumericLocale[locale]) { | ||
| definition = _objectSpread2(_objectSpread2({}, formatD3NumericLocale[locale]), {}, { | ||
| currency: getCurrencyOverride(locale, currencyCode) | ||
| }); | ||
| } else { | ||
| try { | ||
| definition = getD3NumericLocaleFromIntl(locale, currencyCode); | ||
| } catch (e) { | ||
| console.warn('Failed to generate d3 local via Intl, failing back to en-US', e); | ||
| definition = _objectSpread2(_objectSpread2({}, formatD3NumericLocale['en-US']), {}, { | ||
| currency: getCurrencyOverride(locale, currencyCode) | ||
| }); | ||
| } | ||
| } | ||
| localeCache[key] = formatLocale$1(definition); | ||
| return localeCache[key]; | ||
| } | ||
| // Default d3-format specifiers — aligned with the named _2 formats | ||
| // (number_2, currency_2, percent_2) in NAMED_NUMERIC_FORMATS below. | ||
| // The `~` modifier trims insignificant trailing zeros so values like 1234 | ||
| // render as "1,234" rather than "1,234.00". | ||
| var DEFAULT_NUMBER_FORMAT = ',.2~f'; | ||
| var DEFAULT_CURRENCY_FORMAT = '$,.2~f'; | ||
| var DEFAULT_PERCENT_FORMAT = '.2~%'; | ||
| var DEFAULT_ID_FORMAT = '.0f'; | ||
| // Predefined named numeric formats and their d3-format specifiers. | ||
| // Mirrors NAMED_NUMERIC_FORMATS in @cubejs-backend/schema-compiler — keep in sync. | ||
| // Bare names ('number', 'percent', 'currency') keep their existing API contract | ||
| // and are routed through the explicit cases below; only the _N suffixed variants | ||
| // (and bare 'abbr', 'accounting', 'decimal') are resolved through this map. | ||
| var NAMED_NUMERIC_FORMATS = { | ||
| number_0: ',.0f', | ||
| number_1: ',.1~f', | ||
| number_2: ',.2~f', | ||
| number_3: ',.3~f', | ||
| number_4: ',.4~f', | ||
| number_5: ',.5~f', | ||
| number_6: ',.6~f', | ||
| percent_0: '.0%', | ||
| percent_1: '.1~%', | ||
| percent_2: '.2~%', | ||
| percent_3: '.3~%', | ||
| percent_4: '.4~%', | ||
| percent_5: '.5~%', | ||
| percent_6: '.6~%', | ||
| currency_0: '$,.0f', | ||
| currency_1: '$,.1~f', | ||
| currency_2: '$,.2~f', | ||
| currency_3: '$,.3~f', | ||
| currency_4: '$,.4~f', | ||
| currency_5: '$,.5~f', | ||
| currency_6: '$,.6~f', | ||
| decimal: ',.2~f', | ||
| decimal_0: ',.0f', | ||
| decimal_1: ',.1~f', | ||
| decimal_2: ',.2~f', | ||
| decimal_3: ',.3~f', | ||
| decimal_4: ',.4~f', | ||
| decimal_5: ',.5~f', | ||
| decimal_6: ',.6~f', | ||
| abbr: '.2~s', | ||
| abbr_0: '.0~s', | ||
| abbr_1: '.1~s', | ||
| abbr_2: '.2~s', | ||
| abbr_3: '.3~s', | ||
| abbr_4: '.4~s', | ||
| abbr_5: '.5~s', | ||
| abbr_6: '.6~s', | ||
| accounting: '(,.2~f', | ||
| accounting_0: '(,.0f', | ||
| accounting_1: '(,.1~f', | ||
| accounting_2: '(,.2~f', | ||
| accounting_3: '(,.3~f', | ||
| accounting_4: '(,.4~f', | ||
| accounting_5: '(,.5~f', | ||
| accounting_6: '(,.6~f' | ||
| }; | ||
| function detectLocale() { | ||
| try { | ||
| return new Intl.NumberFormat().resolvedOptions().locale; | ||
| } catch (e) { | ||
| console.warn('Failed to detect locale', e); | ||
| return 'en-US'; | ||
| } | ||
| } | ||
| var currentLocale = detectLocale(); | ||
| var DEFAULT_DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'; | ||
| var DEFAULT_DATE_FORMAT = '%Y-%m-%d'; | ||
| var DEFAULT_DATE_WEEK_FORMAT = '%Y-%m-%d W%V'; | ||
| var DEFAULT_DATE_MONTH_FORMAT = '%Y %b'; | ||
| var DEFAULT_DATE_QUARTER_FORMAT = '%Y-Q%q'; | ||
| var DEFAULT_DATE_YEAR_FORMAT = '%Y'; | ||
| function getFormatByGrain(grain) { | ||
| // Grains that should show date and time (sub-day granularities) | ||
| var dateTimeGrains = ['second', 'minute', 'hour']; | ||
| // Grains that should show date only (day and above granularities) | ||
| var dateOnlyGrains = ['day', 'week', 'month', 'quarter', 'year']; | ||
| if (grain === 'day') { | ||
| return DEFAULT_DATE_FORMAT; | ||
| } | ||
| if (grain === 'week') { | ||
| return DEFAULT_DATE_WEEK_FORMAT; | ||
| } | ||
| if (grain === 'month') { | ||
| return DEFAULT_DATE_MONTH_FORMAT; | ||
| } | ||
| if (grain === 'quarter') { | ||
| return DEFAULT_DATE_QUARTER_FORMAT; | ||
| } | ||
| if (grain === 'year') { | ||
| return DEFAULT_DATE_YEAR_FORMAT; | ||
| } | ||
| if (!grain || dateTimeGrains.includes(grain)) { | ||
| return DEFAULT_DATETIME_FORMAT; | ||
| } | ||
| if (dateOnlyGrains.includes(grain)) { | ||
| return DEFAULT_DATE_FORMAT; | ||
| } | ||
| // Fallback to datetime for unknown grains | ||
| return DEFAULT_DATETIME_FORMAT; | ||
| } | ||
| function formatDateByGranularity(value, granularity) { | ||
| var date = value instanceof Date ? value : new Date(value); | ||
| if (Number.isNaN(date.getTime())) { | ||
| return 'Invalid date'; | ||
| } | ||
| return timeFormat(getFormatByGrain(granularity))(date); | ||
| } | ||
| function parseNumber(value) { | ||
| if (value === null || value === undefined) { | ||
| return 0; | ||
| } | ||
| return parseFloat(value); | ||
| } | ||
| function formatBoolean(value) { | ||
| if (typeof value === 'boolean') { | ||
| return value.toString(); | ||
| } | ||
| if (typeof value === 'number') { | ||
| return Boolean(value).toString(); | ||
| } | ||
| // Some SQL drivers return booleans as '0'/'1' or 'true'/'false' strings, It's incorrect behaivour in Cube, | ||
| // but let's format it as boolean for backward compatibility. | ||
| if (value === '0' || value === 'false') { | ||
| return 'false'; | ||
| } | ||
| if (value === '1' || value === 'true') { | ||
| return 'true'; | ||
| } | ||
| return String(value); | ||
| } | ||
| function getFormat(member) { | ||
| var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, | ||
| _ref$locale = _ref.locale, | ||
| locale = _ref$locale === void 0 ? currentLocale : _ref$locale; | ||
| var type = member.type, | ||
| format$1 = member.format, | ||
| _member$currency = member.currency, | ||
| currency = _member$currency === void 0 ? 'USD' : _member$currency, | ||
| granularity = member.granularity; | ||
| if (type === 'boolean') { | ||
| return { | ||
| formatString: null, | ||
| formatFunc: formatBoolean | ||
| }; | ||
| } | ||
| if (format$1 && _typeof(format$1) === 'object') { | ||
| if (format$1.type === 'custom-numeric') { | ||
| return { | ||
| formatString: format$1.value, | ||
| formatFunc: function formatFunc(value) { | ||
| return format(format$1.value)(parseNumber(value)); | ||
| } | ||
| }; | ||
| } | ||
| if (format$1.type === 'custom-time') { | ||
| return { | ||
| formatString: format$1.value, | ||
| formatFunc: function formatFunc(value) { | ||
| var date = new Date(value); | ||
| return Number.isNaN(date.getTime()) ? 'Invalid date' : timeFormat(format$1.value)(date); | ||
| } | ||
| }; | ||
| } | ||
| // { type: 'link', label: string } — return value as string | ||
| return { | ||
| formatString: null, | ||
| formatFunc: function formatFunc(value) { | ||
| return String(value); | ||
| } | ||
| }; | ||
| } | ||
| if (typeof format$1 === 'string') { | ||
| switch (format$1) { | ||
| case 'currency': | ||
| return { | ||
| formatString: DEFAULT_CURRENCY_FORMAT, | ||
| formatFunc: function formatFunc(value) { | ||
| return getD3NumericLocale(locale, currency).format(DEFAULT_CURRENCY_FORMAT)(parseNumber(value)); | ||
| } | ||
| }; | ||
| case 'percent': | ||
| return { | ||
| formatString: DEFAULT_PERCENT_FORMAT, | ||
| formatFunc: function formatFunc(value) { | ||
| return getD3NumericLocale(locale).format(DEFAULT_PERCENT_FORMAT)(parseNumber(value)); | ||
| } | ||
| }; | ||
| case 'number': | ||
| return { | ||
| formatString: DEFAULT_NUMBER_FORMAT, | ||
| formatFunc: function formatFunc(value) { | ||
| return getD3NumericLocale(locale).format(DEFAULT_NUMBER_FORMAT)(parseNumber(value)); | ||
| } | ||
| }; | ||
| case 'id': | ||
| return { | ||
| formatString: DEFAULT_ID_FORMAT, | ||
| formatFunc: function formatFunc(value) { | ||
| return format(DEFAULT_ID_FORMAT)(parseNumber(value)); | ||
| } | ||
| }; | ||
| case 'imageUrl': | ||
| case 'link': | ||
| return { | ||
| formatString: null, | ||
| formatFunc: function formatFunc(value) { | ||
| return String(value); | ||
| } | ||
| }; | ||
| default: | ||
| { | ||
| var specifier = NAMED_NUMERIC_FORMATS[format$1]; | ||
| if (specifier) { | ||
| var localeFormatter = format$1.startsWith('currency') ? getD3NumericLocale(locale, currency).format(specifier) : getD3NumericLocale(locale).format(specifier); | ||
| return { | ||
| formatString: specifier, | ||
| formatFunc: function formatFunc(value) { | ||
| return localeFormatter(parseNumber(value)); | ||
| } | ||
| }; | ||
| } | ||
| return { | ||
| formatString: null, | ||
| formatFunc: function formatFunc(value) { | ||
| return String(value); | ||
| } | ||
| }; | ||
| } | ||
| } | ||
| } | ||
| // No explicit format — infer from type | ||
| if (type === 'time') { | ||
| return { | ||
| formatString: getFormatByGrain(granularity), | ||
| formatFunc: function formatFunc(value) { | ||
| return formatDateByGranularity(value, granularity); | ||
| } | ||
| }; | ||
| } | ||
| if (type === 'number') { | ||
| return { | ||
| formatString: DEFAULT_NUMBER_FORMAT, | ||
| formatFunc: function formatFunc(value) { | ||
| return getD3NumericLocale(locale, currency).format(DEFAULT_NUMBER_FORMAT)(parseNumber(value)); | ||
| } | ||
| }; | ||
| } | ||
| return { | ||
| formatString: null, | ||
| formatFunc: function formatFunc(value) { | ||
| return String(value); | ||
| } | ||
| }; | ||
| } | ||
| function formatValue(value, options) { | ||
| var _options$emptyPlaceho = options.emptyPlaceholder, | ||
| emptyPlaceholder = _options$emptyPlaceho === void 0 ? '∅' : _options$emptyPlaceho; | ||
| if (value === null || value === undefined) { | ||
| return emptyPlaceholder; | ||
| } | ||
| return getFormat(options, { | ||
| locale: options.locale | ||
| }).formatFunc(value); | ||
| } | ||
| exports.formatDateByGranularity = formatDateByGranularity; | ||
| exports.formatValue = formatValue; | ||
| exports.getFormat = getFormat; | ||
| //# sourceMappingURL=format.cjs.map |
Sorry, the diff of this file is too big to display
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/format.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAsElF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAOnG;AAUD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,eAAe,CAAC;IACtB,MAAM,CAAC,EAAE,eAAe,GAAG,aAAa,CAAC;IACzC,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yHAAyH;IACzH,WA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AAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;CACpC,CAAC;AAwBF,wBAAgB,SAAS,CACvB,MAAM,EAAE,iBAAiB,EACzB,EAAE,MAAsB,EAAE,GAAE,gBAAqB,GAChD,eAAe,CAsFjB;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CAQR"} |
+66
-2
@@ -5,3 +5,3 @@ import { format as d3Format } from 'd3-format'; | ||
| // Default d3-format specifiers — aligned with the named _2 formats | ||
| // (number_2, currency_2, percent_2) in named-numeric-formats.ts. | ||
| // (number_2, currency_2, percent_2) in NAMED_NUMERIC_FORMATS below. | ||
| // The `~` modifier trims insignificant trailing zeros so values like 1234 | ||
@@ -13,2 +13,54 @@ // render as "1,234" rather than "1,234.00". | ||
| const DEFAULT_ID_FORMAT = '.0f'; | ||
| // Predefined named numeric formats and their d3-format specifiers. | ||
| // Mirrors NAMED_NUMERIC_FORMATS in @cubejs-backend/schema-compiler — keep in sync. | ||
| // Bare names ('number', 'percent', 'currency') keep their existing API contract | ||
| // and are routed through the explicit cases below; only the _N suffixed variants | ||
| // (and bare 'abbr', 'accounting', 'decimal') are resolved through this map. | ||
| const NAMED_NUMERIC_FORMATS = { | ||
| number_0: ',.0f', | ||
| number_1: ',.1~f', | ||
| number_2: ',.2~f', | ||
| number_3: ',.3~f', | ||
| number_4: ',.4~f', | ||
| number_5: ',.5~f', | ||
| number_6: ',.6~f', | ||
| percent_0: '.0%', | ||
| percent_1: '.1~%', | ||
| percent_2: '.2~%', | ||
| percent_3: '.3~%', | ||
| percent_4: '.4~%', | ||
| percent_5: '.5~%', | ||
| percent_6: '.6~%', | ||
| currency_0: '$,.0f', | ||
| currency_1: '$,.1~f', | ||
| currency_2: '$,.2~f', | ||
| currency_3: '$,.3~f', | ||
| currency_4: '$,.4~f', | ||
| currency_5: '$,.5~f', | ||
| currency_6: '$,.6~f', | ||
| decimal: ',.2~f', | ||
| decimal_0: ',.0f', | ||
| decimal_1: ',.1~f', | ||
| decimal_2: ',.2~f', | ||
| decimal_3: ',.3~f', | ||
| decimal_4: ',.4~f', | ||
| decimal_5: ',.5~f', | ||
| decimal_6: ',.6~f', | ||
| abbr: '.2~s', | ||
| abbr_0: '.0~s', | ||
| abbr_1: '.1~s', | ||
| abbr_2: '.2~s', | ||
| abbr_3: '.3~s', | ||
| abbr_4: '.4~s', | ||
| abbr_5: '.5~s', | ||
| abbr_6: '.6~s', | ||
| accounting: '(,.2~f', | ||
| accounting_0: '(,.0f', | ||
| accounting_1: '(,.1~f', | ||
| accounting_2: '(,.2~f', | ||
| accounting_3: '(,.3~f', | ||
| accounting_4: '(,.4~f', | ||
| accounting_5: '(,.5~f', | ||
| accounting_6: '(,.6~f', | ||
| }; | ||
| function detectLocale() { | ||
@@ -137,4 +189,16 @@ try { | ||
| case 'link': | ||
| default: | ||
| return { formatString: null, formatFunc: (value) => String(value) }; | ||
| default: { | ||
| const specifier = NAMED_NUMERIC_FORMATS[format]; | ||
| if (specifier) { | ||
| const localeFormatter = format.startsWith('currency') | ||
| ? getD3NumericLocale(locale, currency).format(specifier) | ||
| : getD3NumericLocale(locale).format(specifier); | ||
| return { | ||
| formatString: specifier, | ||
| formatFunc: (value) => localeFormatter(parseNumber(value)), | ||
| }; | ||
| } | ||
| return { formatString: null, formatFunc: (value) => String(value) }; | ||
| } | ||
| } | ||
@@ -141,0 +205,0 @@ } |
@@ -34,7 +34,9 @@ import Meta from './Meta.js'; | ||
| }; | ||
| export type DimensionFormat = 'percent' | 'currency' | 'number' | 'imageUrl' | 'id' | 'link' | DimensionLinkFormat | DimensionCustomTimeFormat | CustomNumericFormat; | ||
| export type MeasureFormat = 'percent' | 'currency' | 'number' | CustomNumericFormat; | ||
| type FormatDescriptionBaseName = 'number' | 'percent' | 'currency' | 'abbr' | 'accounting'; | ||
| type FormatDescriptionPrecision = 0 | 1 | 2 | 3 | 4 | 5 | 6; | ||
| type FormatDescriptionName = 'custom' | 'id' | FormatDescriptionBaseName | `${FormatDescriptionBaseName}_${FormatDescriptionPrecision}`; | ||
| type NamedNumericPrecision = 0 | 1 | 2 | 3 | 4 | 5 | 6; | ||
| type NamedNumericFormatName = `number_${NamedNumericPrecision}` | `percent_${NamedNumericPrecision}` | `currency_${NamedNumericPrecision}` | `decimal_${NamedNumericPrecision}` | `abbr_${NamedNumericPrecision}` | `accounting_${NamedNumericPrecision}` | 'decimal' | 'abbr' | 'accounting'; | ||
| export type DimensionFormat = 'percent' | 'currency' | 'number' | 'imageUrl' | 'id' | 'link' | NamedNumericFormatName | DimensionLinkFormat | DimensionCustomTimeFormat | CustomNumericFormat; | ||
| export type MeasureFormat = 'percent' | 'currency' | 'number' | NamedNumericFormatName | CustomNumericFormat; | ||
| export type FormatDescription = { | ||
@@ -41,0 +43,0 @@ /** Predefined format name (e.g., 'percent_2', 'currency_1') or a base name like 'number' */ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAEjD,MAAM,MAAM,iBAAiB,GAAG;IAAE,CAAC,GA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GAAG,CAAC;AAEpC,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE7E,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,IAAI,CAAC;IACX,kBAAkB,CAAC,EAAE,wBAAwB,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,yBAAyB,EAAE,OAAO,CAAC;IACnC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,kBAAkB,CAAC,EAAE,wBAAwB,GAAG,IAAI,CAAC;CACtD,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,cAAc,GAAG,aAAa,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,SAAS,GAAG,eAAe,GAAG,wBAAwB,GAAG,iBAAiB,GAAG,UAAU,CAAC"} |
@@ -20,2 +20,24 @@ import { describe, it, expect } from 'vitest'; | ||
| }); | ||
| it('format: currency_N with precision', () => { | ||
| expect(formatValue(1234.56, { type: 'number', format: 'currency_0', currency: 'JPY' })).toBe('¥1,235'); | ||
| expect(formatValue(1234.56, { type: 'number', format: 'currency_1', currency: 'EUR' })).toBe('€1,234.6'); | ||
| expect(formatValue(1234.56, { type: 'number', format: 'currency_2', currency: 'GBP' })).toBe('£1,234.56'); | ||
| expect(formatValue(1234, { type: 'number', format: 'currency_2', currency: 'USD' })).toBe('$1,234'); | ||
| }); | ||
| it('format: number_N / percent_N with precision', () => { | ||
| expect(formatValue(1234.56, { type: 'number', format: 'number_0' })).toBe('1,235'); | ||
| expect(formatValue(1234.56, { type: 'number', format: 'number_3' })).toBe('1,234.56'); | ||
| expect(formatValue(0.1234, { type: 'number', format: 'percent_1' })).toBe('12.3%'); | ||
| expect(formatValue(0.1234, { type: 'number', format: 'percent_3' })).toBe('12.34%'); | ||
| }); | ||
| it('format: abbr / accounting / decimal', () => { | ||
| expect(formatValue(1500, { type: 'number', format: 'abbr' })).toBe('1.5k'); | ||
| expect(formatValue(123456, { type: 'number', format: 'abbr_1' })).toBe('100k'); | ||
| expect(formatValue(123456, { type: 'number', format: 'abbr_2' })).toBe('120k'); | ||
| expect(formatValue(123456, { type: 'number', format: 'abbr_3' })).toBe('123k'); | ||
| expect(formatValue(-1234.56, { type: 'number', format: 'accounting' })).toBe('(1,234.56)'); | ||
| expect(formatValue(-1234.56, { type: 'number', format: 'accounting_0' })).toBe('(1,235)'); | ||
| expect(formatValue(1234.56, { type: 'number', format: 'decimal' })).toBe('1,234.56'); | ||
| expect(formatValue(1234.56, { type: 'number', format: 'decimal_0' })).toBe('1,235'); | ||
| }); | ||
| it('format: percent', () => { | ||
@@ -79,2 +101,31 @@ expect(formatValue(0.1234, { type: 'number', format: 'percent' })).toBe('12.34%'); | ||
| }); | ||
| it('named currency_N formats apply locale grouping/decimal and currency code', () => { | ||
| expect(formatValue(1234.56, { type: 'number', format: 'currency_0', currency: 'EUR', locale: 'nl-NL' })).toBe('€1.235'); | ||
| expect(formatValue(1234.56, { type: 'number', format: 'currency_1', currency: 'EUR', locale: 'nl-NL' })).toBe('€1.234,6'); | ||
| expect(formatValue(1234.56, { type: 'number', format: 'currency_2', currency: 'EUR', locale: 'nl-NL' })).toBe('€1.234,56'); | ||
| expect(formatValue(1234.56, { type: 'number', format: 'currency_2', currency: 'USD', locale: 'nl-NL' })).toBe('US$1.234,56'); | ||
| // de-DE puts the currency symbol after the amount | ||
| expect(formatValue(1234567.89, { type: 'number', format: 'currency_2', currency: 'EUR', locale: 'de-DE' })).toBe('1.234.567,89€'); | ||
| expect(formatValue(1234.56, { type: 'number', format: 'currency_0', currency: 'EUR', locale: 'de-DE' })).toBe('1.235€'); | ||
| // fr-FR uses NBSP as thousands separator and suffixes the currency | ||
| expect(formatValue(1234567.89, { type: 'number', format: 'currency_2', currency: 'EUR', locale: 'fr-FR' })).toBe('1 234 567,89€'); | ||
| // en-IN keeps non-uniform grouping for named formats too | ||
| expect(formatValue(1234567.89, { type: 'number', format: 'currency_2', currency: 'INR', locale: 'en-IN' })).toBe('₹12,34,567.89'); | ||
| expect(formatValue(1234567.89, { type: 'number', format: 'currency_0', currency: 'INR', locale: 'en-IN' })).toBe('₹12,34,568'); | ||
| // ja-JP yields the full-width yen sign via Intl | ||
| expect(formatValue(1234.56, { type: 'number', format: 'currency_0', currency: 'JPY', locale: 'ja-JP' })).toBe('¥1,235'); | ||
| }); | ||
| it('named number_N / percent_N / decimal_N formats follow locale separators', () => { | ||
| expect(formatValue(1234567.89, { type: 'number', format: 'number_2', locale: 'nl-NL' })).toBe('1.234.567,89'); | ||
| expect(formatValue(1234.56, { type: 'number', format: 'number_0', locale: 'nl-NL' })).toBe('1.235'); | ||
| expect(formatValue(0.1234, { type: 'number', format: 'percent_1', locale: 'nl-NL' })).toBe('12,3%'); | ||
| expect(formatValue(0.1234, { type: 'number', format: 'percent_2', locale: 'de-DE' })).toBe('12,34%'); | ||
| // fr-FR overrides the percent sign with a thin-NBSP prefix | ||
| expect(formatValue(0.1234, { type: 'number', format: 'percent_1', locale: 'fr-FR' })).toBe('12,3 %'); | ||
| expect(formatValue(1234.56789, { type: 'number', format: 'decimal_3', locale: 'de-DE' })).toBe('1.234,568'); | ||
| }); | ||
| it('named accounting_N / abbr_N formats follow locale separators', () => { | ||
| expect(formatValue(-1234.56, { type: 'number', format: 'accounting_2', locale: 'de-DE' })).toBe('(1.234,56)'); | ||
| expect(formatValue(1500000, { type: 'number', format: 'abbr_2', locale: 'nl-NL' })).toBe('1,5M'); | ||
| }); | ||
| it('invalid date input returns Invalid date', () => { | ||
@@ -81,0 +132,0 @@ expect(formatValue('not-a-date', { type: 'time' })).toBe('Invalid date'); |
+5
-4
| { | ||
| "name": "@cubejs-client/core", | ||
| "version": "1.6.41", | ||
| "version": "1.6.42", | ||
| "engines": {}, | ||
@@ -24,3 +24,4 @@ "type": "module", | ||
| "types": "./dist/src/format.d.ts", | ||
| "import": "./dist/src/format.js" | ||
| "import": "./dist/src/format.js", | ||
| "require": "./dist/format.cjs" | ||
| } | ||
@@ -60,3 +61,3 @@ }, | ||
| "devDependencies": { | ||
| "@cubejs-backend/linter": "1.6.41", | ||
| "@cubejs-backend/linter": "1.6.42", | ||
| "@types/d3-format": "^3", | ||
@@ -73,3 +74,3 @@ "@types/d3-time-format": "^4", | ||
| }, | ||
| "gitHead": "e121f662d703c35053e3867fa6fd1910389e7331" | ||
| "gitHead": "bc42af723927870e925f863c9db7f52ac4dcab40" | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1504928
13.88%103
1.98%22012
12.87%