octo-deno/lib/make/datetime.js

27 lines
871 B
JavaScript
Raw Normal View History

2017-06-26 18:43:25 +00:00
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
make.datetime = {
object: function () {
switch (random.number(2)) {
case 0:
return new Date(new Date().getTime() + random.number())
case 1:
return new Date(new Date().getTime() - random.number())
}
},
date: function () { // eslint-disable-line no-unused-vars
2017-09-13 02:13:50 +00:00
return this.object().toDateString()
2017-06-26 18:43:25 +00:00
},
time: function () { // eslint-disable-line no-unused-vars
2017-09-13 02:13:50 +00:00
return this.object().toTimeString()
2017-06-26 18:57:46 +00:00
},
iso: function () { // eslint-disable-line no-unused-vars
2017-09-13 02:13:50 +00:00
return this.object().toISOString()
2017-11-27 16:53:48 +00:00
},
epoch: function () { // eslint-disable-line no-unused-vars
return Math.floor(this.object() / 1000)
2017-06-26 18:43:25 +00:00
}
}