File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 261261 " Windows Filetime to UNIX Timestamp" ,
262262 " UNIX Timestamp to Windows Filetime" ,
263263 " Extract dates" ,
264+ " Generate Current Epoch" ,
264265 " Sleep"
265266 ]
266267 },
Original file line number Diff line number Diff line change 1+ /**
2+ * @author n1073645 [n1073645@gmail.com]
3+ * @copyright Crown Copyright 2020
4+ * @license Apache-2.0
5+ */
6+
7+ import Operation from "../Operation.mjs" ;
8+
9+ /**
10+ * GenerateCurrentEpoch operation
11+ */
12+ class GenerateCurrentEpoch extends Operation {
13+
14+ /**
15+ * GenerateCurrentEpoch constructor
16+ */
17+ constructor ( ) {
18+ super ( ) ;
19+
20+ this . name = "Generate Current Epoch" ;
21+ this . module = "Default" ;
22+ this . description = "Generates the current time(in seconds/milliseconds) since the UNIX epoch." ;
23+ this . infoURL = "https://wikipedia.org/wiki/Unix_time" ;
24+ this . inputType = "string" ;
25+ this . outputType = "string" ;
26+ this . args = [
27+ {
28+ name : "Granularity" ,
29+ type : "option" ,
30+ value : [ "Milliseconds" , "Seconds" ]
31+ }
32+ ] ;
33+ }
34+
35+ /**
36+ * @param {string } input
37+ * @param {Object[] } args
38+ * @returns {string }
39+ */
40+ run ( input , args ) {
41+ if ( args [ 0 ] === "Milliseconds" )
42+ return ( new Date ( ) ) . getTime ( ) . toString ( ) ;
43+ else
44+ return Math . round ( ( new Date ( ) ) . getTime ( ) / 1000 ) . toString ( ) ;
45+ }
46+
47+ }
48+
49+ export default GenerateCurrentEpoch ;
You can’t perform that action at this time.
0 commit comments