Skip to content

Instantly share code, notes, and snippets.

@greenlikeorange
Created May 26, 2015 11:53
Show Gist options
  • Save greenlikeorange/197ea1a9d5a22dd1850b to your computer and use it in GitHub Desktop.
Save greenlikeorange/197ea1a9d5a22dd1850b to your computer and use it in GitHub Desktop.
(3).day.ago
function definePropertiesOfObjects(objects, values){
for (var i = 0; i < objects.length; i++) {
Object.defineProperties(objects[i], values);
}
}
function defineProperty(){
Object.defineProperty.apply(null, arguements);
}
definePropertiesOfObjects([Number.prototype], {
week: {
get: function(){
this.__milliseconds = this * 1000 * 3600 * 24 * 7;
return this;
}
},
day: {
get: function(){
this.__milliseconds = this * 1000 * 3600 * 24;
return this;
}
},
ago: {
get: function(){
return new Date(Date.now() - this.__milliseconds);
}
},
next: {
get: function(){
return new Date(Date.now() + this.__milliseconds);
}
}
});
console.log((3).week.ago);
console.log((3).day.next);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment