/** * Date handling utilities. **/ Date.prototype.clone = function () { return new Date (this.getTime ()); } module.exports = { WDays: [ _('Sunday') ,_('Monday') ,_('Tuesday') ,_('Wednesday') ,_('Thursday') ,_('Friday') ,_('Saturday') ] ,AbrWDays: [ _('Su') ,_('Mo') ,_('Tu') ,_('We') ,_('Th') ,_('Fr') ,_('Sa') ] ,Months: [ _('January') ,_('February') ,_('March') ,_('April') ,_('May') ,_('June') ,_('July') ,_('August') ,_('September') ,_('October') ,_('November') ,_('December') ] ,AbrMonths: [ _('Jan') ,_('Feb') ,_('Mar') ,_('Apr') ,_('May') ,_('Jun') ,_('Jul') ,_('Ago') ,_('Sep') ,_('Oct') ,_('Nov') ,_('Dec') ] ,tokenD: _('%A, %B %e') ,regexp: new RegExp ('%[a-zA-Z]', 'g') ,pad: function (number) { if (number < 10) return '0'+ number.toString (); return number.toString (); } ,regexpFunc: function (d, token) { switch (token.charAt (1)) { // Minutes with 2 digits case 'M': return this.pad (d.getMinutes ()); // Hour with 2 digits in 24 hour format case 'H': return this.pad (d.getHours ()); // Complete time case 'T': return d.toLocaleTimeString (); // Complete week day name case 'A': return this.WDays[d.getDay ()]; // Abreviated week day name case 'a': return this.AbrWDays[d.getDay ()]; // Day of month with 2 digits case 'd': return this.pad (d.getDate ()); // Day of month case 'e': return d.getDate (); // Complete month name case 'B': return this.Months[d.getMonth ()]; // Abreviated month name case 'b': return this.AbrMonths[d.getMonth ()]; // Month number with 2 digits case 'm': return this.pad (d.getMonth () + 1); // Year with 4 digits case 'Y': return d.getFullYear (); // Complete date without year case 'D': return this.tokenD.replace (this.regexp, this.regexpFunc.bind (this, d)); } return token; } ,strftime: function (date, format) { if (!date) return ''; return format.replace (this.regexp, this.regexpFunc.bind (this, date)); } };