Browse Source

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

Ahmad Kholid 3 years ago
parent
commit
3072a77eb7
1 changed files with 4 additions and 4 deletions
  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;
   },