UNPKG

carbonjs

Version:

Javascript date library alternative to Moment.js with the same modern API

1 lines 603 B
"use strict";const t=require("../constants"),e=require("../utils"),r=["th","st","nd","rd"];module.exports=(s=>{s._en.ordinal=(t=>{const e=t%100;return`[${t}${r[(e-20)%10]||r[e]||r[0]}]`});const o=s.prototype,a=o.format;o.format=function(r=t.FORMAT_DEFAULT){const s=r.replace(/Q|Do|X|x|kk?|S/g,t=>{switch(t){case"Q":return Math.ceil((this._month+1)/3);case"Do":return this._locale.ordinal(this._day);case"k":case"kk":return e.padStart(`${0===this._hours?24:this._hours}`,"k"===t?1:2,"0");case"X":return Math.floor(this._date.getTime()/1e3);default:return this._date.getTime()}});return a.call(this,s)}});