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
1 changed files with 13 additions and 0 deletions

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;
}