MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / addFormatToken

Function addFormatToken

tests/test_code/js/moment/moment.js:458–481  ·  view source on GitHub ↗
(token, padded, ordinal, callback)

Source from the content-addressed store, hash-verified

456 // ordinal: 'Mo'
457 // callback: function () { this.month() + 1 }
458 function addFormatToken(token, padded, ordinal, callback) {
459 var func = callback;
460 if (typeof callback === 'string') {
461 func = function () {
462 return this[callback]();
463 };
464 }
465 if (token) {
466 formatTokenFunctions[token] = func;
467 }
468 if (padded) {
469 formatTokenFunctions[padded[0]] = function () {
470 return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
471 };
472 }
473 if (ordinal) {
474 formatTokenFunctions[ordinal] = function () {
475 return this.localeData().ordinal(
476 func.apply(this, arguments),
477 token
478 );
479 };
480 }
481 }
482
483 function removeFormattingTokens(input) {
484 if (input.match(/\[[\s\S]/)) {

Callers 4

moment.jsFile · 0.85
meridiemFunction · 0.85
offsetFunction · 0.85
addWeekYearFormatTokenFunction · 0.85

Calls 2

zeroFillFunction · 0.85
applyMethod · 0.80

Tested by

no test coverage detected