Skip to content

Commit

Permalink
faster gmdate using getSeconds
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasq committed Mar 2, 2020
1 parent c5d5ca5 commit 66ee67b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/phpdate.js
Expand Up @@ -225,8 +225,11 @@ function configure( config ) {
GmtDate.prototype.getDay = function GmtDate_getDay() { return this.dt.getUTCDay(); };
GmtDate.prototype.getDate = function GmtDate_getDate() { return this.dt.getUTCDate(); };
GmtDate.prototype.getHours = function GmtDate_getHours() { return this.dt.getUTCHours(); };
// note: GmtDate is 2x slower than Date, because UTC access methods are 6x slower.
// note: if the tz offset coincides in hours, is 10% faster to use getMinutes()
GmtDate.prototype.getMinutes = function GmtDate_getMinutes() { return this.dt.getUTCMinutes(); };
GmtDate.prototype.getSeconds = function GmtDate_getSeconds() { return this.dt.getUTCSeconds(); };
// note: all timezones are aligned on minute boundaries, use the faster method
GmtDate.prototype.getSeconds = function GmtDate_getSeconds() { return this.dt.getSeconds(); };

var _resultCacheGmt = new ResultCacheRing();
function gmdate( format, timestamp ) {
Expand Down

0 comments on commit 66ee67b

Please sign in to comment.