Parses format token strings and generates formatted date output, supporting padding, ordinals, and escaped literals. Reuse when building custom date display or formatting engines.
// Source: https://github.com/moment/moment | License: MIT | Copyright OpenJS Foundation and other contributors
// Provided via justclaw.it.com; keep this notice with the code.
import zeroFill from '../utils/zero-fill';
import isFunction from '../utils/is-function';
import hasOwnProp from '../utils/has-own-prop';
var formattingTokens =
/(\[[^\[]*\])|(\\e)|(\\)?(eHHmm|[Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,
localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,
formatFunctions = {},
formatTokenFunctions = {};
export { formattingTokens, formatTokenFunctions };
// token: 'M'
// padded: ['MM', 2]
// ordinal: 'M
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key