From ecac3c04cdad0073c7c6ced9fe2fd00fac832e54 Mon Sep 17 00:00:00 2001 From: Andrew Judd Date: Tue, 27 Jun 2023 08:51:00 -0400 Subject: [PATCH] feat(timestamp): timestamp to date Adding in a feature to convert a timestamp into a date --- Boop/Boop/scripts/TimestampToDate.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Boop/Boop/scripts/TimestampToDate.js diff --git a/Boop/Boop/scripts/TimestampToDate.js b/Boop/Boop/scripts/TimestampToDate.js new file mode 100644 index 00000000..ccf38adf --- /dev/null +++ b/Boop/Boop/scripts/TimestampToDate.js @@ -0,0 +1,21 @@ +/** + { + "api":1, + "name":"Timestamp to Date", + "description":"Converts a Unix timestamp to a date.", + "author":"Andrew Judd", + "icon":"watch", + "tags":"date,time,calendar,unix,timestamp" + } +**/ + +function main(input) { + + let parsedDate = new Date(+input.text * 1000) + + if (isNaN(parsedDate)) { + input.postError("Invalid Date") + } else { + input.text = parsedDate + } +}