aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-02-03 00:03:43 +0100
committerRobin Jarry <robin@jarry.cc>2023-02-20 14:48:42 +0100
commit70f99085d73b3bfc9b3338c52e6df7bebc7651c7 (patch)
tree40918277a9e09c28c9492b0837a992e2d3824080
parent24f91b0277a1034f731aaf00c3e1f894c5ad27c1 (diff)
downloadaerc-70f99085d73b3bfc9b3338c52e6df7bebc7651c7.tar.gz
templates: add now function
This allows to get the current local time. Signed-off-by: Robin Jarry <robin@jarry.cc> Acked-by: Moritz Poldrack <moritz@poldrack.dev>
-rw-r--r--doc/aerc-templates.7.scd8
-rw-r--r--lib/templates/functions.go1
2 files changed, 9 insertions, 0 deletions
diff --git a/doc/aerc-templates.7.scd b/doc/aerc-templates.7.scd
index c7bb0d1f..71042835 100644
--- a/doc/aerc-templates.7.scd
+++ b/doc/aerc-templates.7.scd
@@ -290,6 +290,14 @@ aerc provides the following additional functions:
{{.DateAutoFormat .OriginalDate.Local}}
```
+*now*
+ Return the current date as a golang time.Time object that can be
+ formated with *dateFormat*.
+
+ ```
+ {{dateFormat now "Mon Jan 2 15:04:05 -0700 MST 2006"}}
+ ```
+
*humanReadable*
Return the human readable form of an integer value.
diff --git a/lib/templates/functions.go b/lib/templates/functions.go
index 5d2f1928..0b0a4546 100644
--- a/lib/templates/functions.go
+++ b/lib/templates/functions.go
@@ -250,6 +250,7 @@ var templateFuncs = template.FuncMap{
"quote": quote,
"wrapText": wrapText,
"wrap": wrap,
+ "now": time.Now,
"dateFormat": time.Time.Format,
"toLocal": toLocal,
"exec": cmd,