quoslibero
Version:
FusionCharts JavaScript charting framework
1 lines • 558 B
JavaScript
import pads from'./pads.js';const PERCENT_CHAR_CODE=37,isNil=a=>null===a||'undefined'==typeof a;class TimeFormatter{constructor(a,b){this._specifier=a,this._formats=b}format(a){var b,d,e,f=[],g=-1,h=0,k=this._specifier,l=k.length;for(a instanceof Date||(a=new Date(+a));++g<l;)k.charCodeAt(g)===PERCENT_CHAR_CODE&&(f.push(k.slice(h,g)),b=k.charAt(++g),d=pads[b],isNil(d)?d='e'===b?' ':'0':b=k.charAt(++g),e=this._formats[b],e&&(b=e(a,d)),f.push(b),h=g+1);return f.push(k.slice(h,g)),f.join('')}toString(){return this._specifier}}export default TimeFormatter;