Add a utility class that clones and adds a timestamp field (by default 'date') to any given object passed as argument

This commit is contained in:
Tissevert 2020-01-13 18:03:31 +01:00
parent abba380f3f
commit 2fc3ba8308

13
js/Time.js Normal file
View file

@ -0,0 +1,13 @@
return {
timestamp: timestamp
};
function timestamp(o, field) {
var field = field || 'date';
var clone = {};
for(var key in o) {
clone[key] = o[key];
}
clone[field] = Date.now();
return clone;
}