Explorar o código

feat: add "timestamp" format in `$date` function

Ahmad Kholid %!s(int64=3) %!d(string=hai) anos
pai
achega
3072a77eb7
Modificáronse 1 ficheiros con 4 adicións e 4 borrados
  1. 4 4
      src/utils/reference-data/mustache-replacer.js

+ 4 - 4
src/utils/reference-data/mustache-replacer.js

@@ -25,10 +25,10 @@ export const functions = {
     const isValidDate = date instanceof Date && !isNaN(date);
     const dayjsDate = dayjs(isValidDate ? date : Date.now());
 
-    const result =
-      dateFormat === 'relative'
-        ? dayjsDate.fromNow()
-        : dayjsDate.format(dateFormat);
+    let result = dayjsDate.format(dateFormat);
+
+    if (dateFormat === 'relative') result = dayjsDate.fromNow();
+    else if (dateFormat === 'timestamp') result = dayjsDate.valueOf();
 
     return result;
   },