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:
parent
abba380f3f
commit
2fc3ba8308
1 changed files with 13 additions and 0 deletions
13
js/Time.js
Normal file
13
js/Time.js
Normal 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;
|
||||||
|
}
|
Loading…
Reference in a new issue