From 037d319a2f61ba3af47b6a48b20cabf038ad6030 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 7 Mar 2025 11:11:28 +0100 Subject: [PATCH] Lua `date` useful library --- plugs/core/Library/Std/Date.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 plugs/core/Library/Std/Date.md diff --git a/plugs/core/Library/Std/Date.md b/plugs/core/Library/Std/Date.md new file mode 100644 index 00000000..e7682bd2 --- /dev/null +++ b/plugs/core/Library/Std/Date.md @@ -0,0 +1,33 @@ +#meta + +Date and time APIs + +```space-lua +-- priority: 10 + +local DAY_SECONDS = 60 * 60 * 24 + +date = { + date_format = "%Y-%m-%d", + time_format = "%H:%M:%S", +} + +function date.today() + return os.date(date.date_format) +end + +function date.tomorrow() + return os.date(date.date_format, os.time() + DAY_SECONDS) +end + +function date.yesterday() + return os.date(date.date_format, os.time() - DAY_SECONDS) +end + +function date.time() + return os.date(date.time_format) +end +``` + +# Examples +Today: ${date.today()} and ${date.time()} \ No newline at end of file