File tree 2 files changed +50
-0
lines changed
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 267
267
" Windows Filetime to UNIX Timestamp" ,
268
268
" UNIX Timestamp to Windows Filetime" ,
269
269
" Extract dates" ,
270
+ " Generate Current Epoch" ,
270
271
" Sleep"
271
272
]
272
273
},
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @author n1073645 [[email protected] ]
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