mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
removed a chrome/node/nw date hack... still not final
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f627483322
commit
8982365b03
@ -60,13 +60,23 @@ if(typeof(process) != 'undefined'){
|
|||||||
|
|
||||||
// NOTE: jli is patching the Date object and with two separate
|
// NOTE: jli is patching the Date object and with two separate
|
||||||
// instances we'll need to sync things up...
|
// instances we'll need to sync things up...
|
||||||
// XXX HACK...
|
// XXX HACK: if node and chrome Date implementations ever
|
||||||
global.Date !== window.Date
|
// significantly diverge this will break things + this is
|
||||||
&& global.Date = window.Date
|
// a potential data leak between contexts...
|
||||||
|
//global.Date = window.Date
|
||||||
|
|
||||||
|
// XXX this is less of a hack but it is still an implicit
|
||||||
|
patchDate(global.Date)
|
||||||
|
patchDate(window.Date)
|
||||||
|
|
||||||
// node...
|
// node...
|
||||||
} else {
|
} else {
|
||||||
ImageGridFeatures.runtime = 'node'
|
ImageGridFeatures.runtime = 'node'
|
||||||
|
|
||||||
|
// XXX patch Date...
|
||||||
|
// XXX this will not work directly as we will need to explicitly
|
||||||
|
// require jli...
|
||||||
|
//patchDate(global.Date)
|
||||||
}
|
}
|
||||||
|
|
||||||
// browser...
|
// browser...
|
||||||
|
|||||||
@ -1055,7 +1055,12 @@ var cancelAnimationFrame = (window.cancelRequestAnimationFrame
|
|||||||
|| clearTimeout)
|
|| clearTimeout)
|
||||||
|
|
||||||
|
|
||||||
Date.prototype.toShortDate = function(){
|
// NOTE: repatching a date should not lead to any side effects as this
|
||||||
|
// does not add any state...
|
||||||
|
function patchDate(date){
|
||||||
|
date = date || Date
|
||||||
|
|
||||||
|
date.prototype.toShortDate = function(){
|
||||||
var y = this.getFullYear()
|
var y = this.getFullYear()
|
||||||
var M = this.getMonth()+1
|
var M = this.getMonth()+1
|
||||||
M = M < 10 ? '0'+M : M
|
M = M < 10 ? '0'+M : M
|
||||||
@ -1069,8 +1074,8 @@ Date.prototype.toShortDate = function(){
|
|||||||
s = s < 10 ? '0'+s : s
|
s = s < 10 ? '0'+s : s
|
||||||
|
|
||||||
return ''+y+'-'+M+'-'+D+' '+H+':'+m+':'+s
|
return ''+y+'-'+M+'-'+D+' '+H+':'+m+':'+s
|
||||||
}
|
}
|
||||||
Date.prototype.getTimeStamp = function(no_seconds){
|
date.prototype.getTimeStamp = function(no_seconds){
|
||||||
var y = this.getFullYear()
|
var y = this.getFullYear()
|
||||||
var M = this.getMonth()+1
|
var M = this.getMonth()+1
|
||||||
M = M < 10 ? '0'+M : M
|
M = M < 10 ? '0'+M : M
|
||||||
@ -1084,8 +1089,8 @@ Date.prototype.getTimeStamp = function(no_seconds){
|
|||||||
s = s < 10 ? '0'+s : s
|
s = s < 10 ? '0'+s : s
|
||||||
|
|
||||||
return ''+y+M+D+H+m+s
|
return ''+y+M+D+H+m+s
|
||||||
}
|
}
|
||||||
Date.prototype.setTimeStamp = function(ts){
|
date.prototype.setTimeStamp = function(ts){
|
||||||
ts = ts.replace(/[^0-9]*/g, '')
|
ts = ts.replace(/[^0-9]*/g, '')
|
||||||
this.setFullYear(ts.slice(0, 4))
|
this.setFullYear(ts.slice(0, 4))
|
||||||
this.setMonth(ts.slice(4, 6)*1-1)
|
this.setMonth(ts.slice(4, 6)*1-1)
|
||||||
@ -1094,15 +1099,15 @@ Date.prototype.setTimeStamp = function(ts){
|
|||||||
this.setMinutes(ts.slice(10, 12))
|
this.setMinutes(ts.slice(10, 12))
|
||||||
this.setSeconds(ts.slice(12, 14))
|
this.setSeconds(ts.slice(12, 14))
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
Date.timeStamp = function(){
|
date.timeStamp = function(){
|
||||||
return (new Date()).getTimeStamp()
|
return (new this()).getTimeStamp()
|
||||||
}
|
}
|
||||||
Date.fromTimeStamp = function(ts){
|
date.fromTimeStamp = function(ts){
|
||||||
return (new Date()).setTimeStamp(ts)
|
return (new this()).setTimeStamp(ts)
|
||||||
}
|
}
|
||||||
// convert string time period to milliseconds...
|
// convert string time period to milliseconds...
|
||||||
Date.str2ms = function(str, dfl){
|
date.str2ms = function(str, dfl){
|
||||||
dfl = dfl || 'ms'
|
dfl = dfl || 'ms'
|
||||||
|
|
||||||
if(typeof(str) == typeof(123)){
|
if(typeof(str) == typeof(123)){
|
||||||
@ -1125,7 +1130,12 @@ Date.str2ms = function(str, dfl){
|
|||||||
: null
|
: null
|
||||||
|
|
||||||
return c ? val * c : NaN
|
return c ? val * c : NaN
|
||||||
|
}
|
||||||
|
|
||||||
|
return date
|
||||||
}
|
}
|
||||||
|
// patch the root date...
|
||||||
|
patchDate()
|
||||||
|
|
||||||
|
|
||||||
function logCalls(func, logger){
|
function logCalls(func, logger){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user