Explorar el Código

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

Ahmad Kholid hace 3 años
padre
commit
3072a77eb7
Se han modificado 1 ficheros con 4 adiciones y 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;
   },