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

Function newFormat

docs/tests/v2/es6/js/sanddance.js:82272–82296  ·  view source on GitHub ↗
(specifier, formats)

Source from the content-addressed store, hash-verified

82270 utcFormats.c = newFormat(locale_dateTime, utcFormats);
82271
82272 function newFormat(specifier, formats) {
82273 return function (date) {
82274 var string = [],
82275 i = -1,
82276 j = 0,
82277 n = specifier.length,
82278 c,
82279 pad,
82280 format;
82281 if (!(date instanceof Date)) date = new Date(+date);
82282
82283 while (++i < n) {
82284 if (specifier.charCodeAt(i) === 37) {
82285 string.push(specifier.slice(j, i));
82286 if ((pad = pads[c = specifier.charAt(++i)]) != null) c = specifier.charAt(++i);else pad = c === "e" ? " " : "0";
82287 if (format = formats[c]) c = format(date, pad);
82288 string.push(c);
82289 j = i + 1;
82290 }
82291 }
82292
82293 string.push(specifier.slice(j, i));
82294 return string.join("");
82295 };
82296 }
82297
82298 function newParse(specifier, Z) {
82299 return function (string) {

Callers 2

formatLocaleFunction · 0.70
formatPrefixFunction · 0.70

Calls 3

formatFunction · 0.70
maxMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected