Last active
October 29, 2025 07:04
-
-
Save gnacu/738b83896f3e8bd34038d195d1c22046 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #!/usr/bin/env node | |
| const userMeta = JSON.parse(process.env.READYUSER || "{}"); | |
| function readStdin(callback) { | |
| let data = ""; | |
| process.stdin.setEncoding("utf8"); | |
| process.stdin.on("data",(chunk) => { | |
| data += chunk; | |
| }); | |
| process.stdin.on("end",() => { | |
| callback(data); | |
| }); | |
| } | |
| function internationalDate(msgArgs) { | |
| const date = new Date(); | |
| const options = { | |
| weekday: "long", // "Monday" | |
| year: "numeric", // "2025" | |
| month: "long", // "September" | |
| day: "numeric", // 28 | |
| hour: "2-digit", | |
| minute: "2-digit", | |
| second: "2-digit", | |
| hour12: false // optional: 24-hour format | |
| }; | |
| var argParts = msgArgs.split(" "); | |
| var timeZone = argParts[0].trim(); | |
| if(!timeZone) | |
| timeZone = userMeta.timezone; | |
| options.timeZone = timeZone; | |
| try { | |
| const formatter = new Intl.DateTimeFormat("en-US", options); | |
| process.stdout.write(formatter.format(date)+" ("+timeZone+")"); | |
| } catch(e) { | |
| process.stdout.write("I don't recognize that timezone. Try 'region/city'."); | |
| } | |
| } | |
| readStdin((msgArgs) => { | |
| internationalDate(msgArgs); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment