-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'EPOCH' of https://github.com/n1073645/CyberChef into n1…
…073645-EPOCH
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* @author n1073645 [[email protected]] | ||
* @copyright Crown Copyright 2020 | ||
* @license Apache-2.0 | ||
*/ | ||
|
||
import Operation from "../Operation.mjs"; | ||
|
||
/** | ||
* GenerateCurrentEpoch operation | ||
*/ | ||
class GenerateCurrentEpoch extends Operation { | ||
|
||
/** | ||
* GenerateCurrentEpoch constructor | ||
*/ | ||
constructor() { | ||
super(); | ||
|
||
this.name = "Generate Current Epoch"; | ||
this.module = "Default"; | ||
this.description = "Generates the current time(in seconds/milliseconds) since the UNIX epoch."; | ||
this.infoURL = "https://wikipedia.org/wiki/Unix_time"; | ||
this.inputType = "string"; | ||
this.outputType = "string"; | ||
this.args = [ | ||
{ | ||
name: "Granularity", | ||
type: "option", | ||
value: ["Milliseconds", "Seconds"] | ||
} | ||
]; | ||
} | ||
|
||
/** | ||
* @param {string} input | ||
* @param {Object[]} args | ||
* @returns {string} | ||
*/ | ||
run(input, args) { | ||
if (args[0] === "Milliseconds") | ||
return (new Date()).getTime().toString(); | ||
else | ||
return Math.round((new Date()).getTime() / 1000).toString(); | ||
} | ||
|
||
} | ||
|
||
export default GenerateCurrentEpoch; |