MCPcopy Create free account
hub / github.com/microsoft/SandDance / timeUnits

Function timeUnits

docs/app/js/sanddance-app.js:111184–111196  ·  view source on GitHub ↗
(units)

Source from the content-addressed store, hash-verified

111182];
111183const UNITS = TIME_UNITS.reduce((o, u, i)=>(o[u] = 1 + i, o), {});
111184function timeUnits(units) {
111185 const u = (0, _vegaUtil.array)(units).slice(), m = {}; // check validity
111186 if (!u.length) (0, _vegaUtil.error)("Missing time unit.");
111187 u.forEach((unit)=>{
111188 if ((0, _vegaUtil.hasOwnProperty)(UNITS, unit)) m[unit] = 1;
111189 else (0, _vegaUtil.error)("Invalid time unit: ".concat(unit, "."));
111190 });
111191 const numTypes = (m[WEEK] || m[DAY] ? 1 : 0) + (m[QUARTER] || m[MONTH] || m[DATE] ? 1 : 0) + (m[DAYOFYEAR] ? 1 : 0);
111192 if (numTypes > 1) (0, _vegaUtil.error)("Incompatible time units: ".concat(units));
111193 // ensure proper sort order
111194 u.sort((a, b)=>UNITS[a] - UNITS[b]);
111195 return u;
111196}
111197const defaultSpecifiers = {
111198 [YEAR]: "%Y ",
111199 [QUARTER]: "Q%q ",

Callers 1

timeUnitSpecifierFunction · 0.70

Calls 1

forEachMethod · 0.45

Tested by

no test coverage detected