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/. */
|
|
|
|
|
2018-03-19 03:23:05 +00:00
|
|
|
const make = require('../make')
|
|
|
|
const random = require('../random')
|
|
|
|
|
|
|
|
class datetime extends make {
|
|
|
|
static object () {
|
2017-06-26 18:43:25 +00:00
|
|
|
switch (random.number(2)) {
|
|
|
|
case 0:
|
|
|
|
return new Date(new Date().getTime() + random.number())
|
|
|
|
case 1:
|
|
|
|
return new Date(new Date().getTime() - random.number())
|
|
|
|
}
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static date () {
|
2017-09-13 02:13:50 +00:00
|
|
|
return this.object().toDateString()
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static time () {
|
2017-09-13 02:13:50 +00:00
|
|
|
return this.object().toTimeString()
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static iso () {
|
2017-09-13 02:13:50 +00:00
|
|
|
return this.object().toISOString()
|
2018-03-19 03:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static epoch () {
|
2017-11-27 16:53:48 +00:00
|
|
|
return Math.floor(this.object() / 1000)
|
2017-06-26 18:43:25 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-19 03:23:05 +00:00
|
|
|
|
|
|
|
module.exports = datetime
|