formats.js (876B)
1import { formattingTokens } from '../format/format'; 2 3export var defaultLongDateFormat = { 4 LTS: 'h:mm:ss A', 5 LT: 'h:mm A', 6 L: 'MM/DD/YYYY', 7 LL: 'MMMM D, YYYY', 8 LLL: 'MMMM D, YYYY h:mm A', 9 LLLL: 'dddd, MMMM D, YYYY h:mm A', 10}; 11 12export function longDateFormat(key) { 13 var format = this._longDateFormat[key], 14 formatUpper = this._longDateFormat[key.toUpperCase()]; 15 16 if (format || !formatUpper) { 17 return format; 18 } 19 20 this._longDateFormat[key] = formatUpper 21 .match(formattingTokens) 22 .map(function (tok) { 23 if ( 24 tok === 'MMMM' || 25 tok === 'MM' || 26 tok === 'DD' || 27 tok === 'dddd' 28 ) { 29 return tok.slice(1); 30 } 31 return tok; 32 }) 33 .join(''); 34 35 return this._longDateFormat[key]; 36}