File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
src/main/java/io/github/techstreet/dfscript/script/action Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 4444import java .io .IOException ;
4545import java .nio .file .Files ;
4646import java .nio .file .Path ;
47+ import java .text .SimpleDateFormat ;
4748import java .util .*;
4849import java .util .function .Consumer ;
4950import java .util .regex .Pattern ;
@@ -1881,7 +1882,21 @@ public enum ScriptActionType {
18811882 result = input .repeat (times );
18821883
18831884 ctx .context ().setVariable (ctx .variable ("Result" ).name (), new ScriptTextValue (result ));
1884- }));
1885+ })),
1886+
1887+ FORMAT_TIME (builder -> builder .name ("Format Timestamp" )
1888+ .description ("Turns a timestamp (ms) into human readable time." )
1889+ .icon (Items .CLOCK )
1890+ .arg ("Result" , ScriptActionArgumentType .VARIABLE )
1891+ .arg ("Timestamp" , ScriptActionArgumentType .NUMBER )
1892+ .arg ("Format" , ScriptActionArgumentType .TEXT )
1893+ .category (ScriptActionCategory .TEXTS )
1894+ .action (ctx -> {
1895+ Date date = new Date ((long ) ctx .value ("Timestamp" ).asNumber ());
1896+ SimpleDateFormat format = new SimpleDateFormat (ctx .value ("Format" ).asText ());
1897+
1898+ ctx .context ().setVariable (ctx .variable ("Result" ).name (), new ScriptTextValue (format .format (date )));
1899+ }));
18851900
18861901 private Consumer <ScriptActionContext > action = (ctx ) -> {
18871902 };
You can’t perform that action at this time.
0 commit comments