Comparing version 0.1.3 to 0.1.4
@@ -12,2 +12,4 @@ /** | ||
var util = require('util'); | ||
var _tzCache = new TzCache(); // cached tzInfo() data and whether typesetting as GMT | ||
@@ -28,19 +30,22 @@ | ||
// Date is magic, and cannot inherit its prototype methods... so decorate it | ||
function GmtDate( dt ) { | ||
this.dt = dt; | ||
} | ||
GmtDate.prototype.getTime = function GmtDate_getTime() { return this.dt.getTime(); }; | ||
GmtDate.prototype.getFullYear = function GmtDate_getFullYear() { return this.dt.getUTCFullYear(); }; | ||
GmtDate.prototype.getMonth = function GmtDate_getMonth() { return this.dt.getUTCMonth(); }; | ||
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(); }; | ||
GmtDate.prototype.getMinutes = function GmtDate_getMinutes() { return this.dt.getUTCMinutes(); }; | ||
GmtDate.prototype.getSeconds = function GmtDate_getSeconds() { return this.dt.getUTCSeconds(); }; | ||
function gmdate( format, timestamp ) { | ||
var dt = _timestampToDt(timestamp); | ||
// do not alter the provided Date object, use a copy instead | ||
if (typeof timestamp === 'object') dt = new Date(dt.getTime()); | ||
dt.getFullYear = dt.getUTCFullYear; | ||
dt.getMonth = dt.getUTCMonth; | ||
dt.getDay = dt.getUTCDay; | ||
dt.getDate = dt.getUTCDate; | ||
dt.getHours = dt.getUTCHours; | ||
dt.getMinutes = dt.getUTCMinutes; | ||
dt.getSeconds = dt.getUTCSeconds; | ||
var currentlyGmt = _tzCache.isGmt(); | ||
_tzCache.forceGmt(true); | ||
var ret = phpdate(format, dt); | ||
var ret = phpdate(format, new GmtDate(dt)); | ||
_tzCache.forceGmt(currentlyGmt); | ||
@@ -53,2 +58,3 @@ | ||
return (typeof timestamp === 'number') ? new Date(timestamp) : timestamp ? timestamp : new Date(); | ||
// TODO: use process.hrtime() to capture microsecond timestamp, for 'u' format | ||
} | ||
@@ -55,0 +61,0 @@ |
{ | ||
"name": "arlib", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Andras' Utility Functions", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
61317
1336