Merge datetime with time class
This commit is contained in:
parent
a869409853
commit
19a2f21259
4 changed files with 27 additions and 41 deletions
|
@ -1,35 +0,0 @@
|
|||
/* 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/. */
|
||||
|
||||
const make = require('../make')
|
||||
const random = require('../random')
|
||||
|
||||
class datetime extends make {
|
||||
static object () {
|
||||
switch (random.number(2)) {
|
||||
case 0:
|
||||
return new Date(new Date().getTime() + random.number())
|
||||
case 1:
|
||||
return new Date(new Date().getTime() - random.number())
|
||||
}
|
||||
}
|
||||
|
||||
static date () {
|
||||
return this.object().toDateString()
|
||||
}
|
||||
|
||||
static time () {
|
||||
return this.object().toTimeString()
|
||||
}
|
||||
|
||||
static iso () {
|
||||
return this.object().toISOString()
|
||||
}
|
||||
|
||||
static epoch () {
|
||||
return Math.floor(this.object() / 1000)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = datetime
|
|
@ -27,10 +27,6 @@ class make {
|
|||
return require('./crypto')
|
||||
}
|
||||
|
||||
static get datetime () {
|
||||
return require('./datetime')
|
||||
}
|
||||
|
||||
static get files () {
|
||||
return require('./files')
|
||||
}
|
||||
|
|
|
@ -12,8 +12,33 @@ class time extends make {
|
|||
])
|
||||
}
|
||||
|
||||
static datetime () {
|
||||
switch (random.number(2)) {
|
||||
case 0:
|
||||
return new Date(new Date().getTime() + random.number())
|
||||
case 1:
|
||||
return new Date(new Date().getTime() - random.number())
|
||||
}
|
||||
}
|
||||
|
||||
static date () {
|
||||
return time.datetime().toDateString()
|
||||
}
|
||||
|
||||
static time () {
|
||||
return time.datetime().toTimeString()
|
||||
}
|
||||
|
||||
static iso () {
|
||||
return time.datetime().toISOString()
|
||||
}
|
||||
|
||||
static epoch () {
|
||||
return Math.floor(time.object() / 1000)
|
||||
}
|
||||
|
||||
static any () {
|
||||
return make.number.any() + this.unit()
|
||||
return make.number.any() + time.unit()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@mozillasecurity/octo",
|
||||
"version": "1.0.9",
|
||||
"version": "1.0.10",
|
||||
"description": "",
|
||||
"keywords": [
|
||||
"fuzzing",
|
||||
|
|
Loading…
Reference in a new issue