From 123a76c491511e85f3dbb382adeff7206fb73ccc Mon Sep 17 00:00:00 2001 From: CF Mitrah Date: Tue, 16 Mar 2021 19:18:31 +0530 Subject: [PATCH 1/2] Resolved the conflicts and added "epochms" mask --- .../functions/displayFormatting/DateTimeFormat.java | 10 ++++++++++ core/src/main/java/resource/fld/core-cfml.fld | 1 + 2 files changed, 11 insertions(+) diff --git a/core/src/main/java/lucee/runtime/functions/displayFormatting/DateTimeFormat.java b/core/src/main/java/lucee/runtime/functions/displayFormatting/DateTimeFormat.java index 0b854f6dc4..ddf93519f7 100644 --- a/core/src/main/java/lucee/runtime/functions/displayFormatting/DateTimeFormat.java +++ b/core/src/main/java/lucee/runtime/functions/displayFormatting/DateTimeFormat.java @@ -92,6 +92,16 @@ public static String invoke(DateTime datetime, String mask, Locale locale, TimeZ else if ("long".equalsIgnoreCase(mask)) format = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.LONG, java.text.DateFormat.LONG, locale); else if ("full".equalsIgnoreCase(mask)) format = java.text.DateFormat.getDateTimeInstance(java.text.DateFormat.FULL, java.text.DateFormat.FULL, locale); else if ("iso8601".equalsIgnoreCase(mask) || "iso".equalsIgnoreCase(mask)) format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); + else if ("epoch".equalsIgnoreCase(mask)) { + String gettime = String.valueOf(datetime.getTime() / 1000); + String epoch = gettime.toString(); + return epoch; + } + else if ("epochms".equalsIgnoreCase(mask)) { + String gettime = String.valueOf(datetime.getTime()); + String epoch = gettime.toString(); + return epoch; + } else { SimpleDateFormat sdf; format = sdf = new SimpleDateFormat(convertMask(mask), locale); diff --git a/core/src/main/java/resource/fld/core-cfml.fld b/core/src/main/java/resource/fld/core-cfml.fld index 935489bbad..4f25ba9098 100755 --- a/core/src/main/java/resource/fld/core-cfml.fld +++ b/core/src/main/java/resource/fld/core-cfml.fld @@ -451,6 +451,7 @@ The following masks can be used to format the full date and time and may not be - long: medium followed by three-letter time zone; i.e. "mmmm d, yyyy h:nn:ss tt zzz" - full: equivalent to "dddd, mmmm d, yyyy h:nn:ss tt zz" - ISO8601/ISO: equivalent to "yyyy-mm-dd'T'HH:nn:ssXXX" +- epoch: Total seconds of a given date (Example:1567517664) The function follows Java date time mask. For details, see the section Date and Time Patterns at http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html From 81495cd3f44ab4fdb8acdba8c7f5794fe435a454 Mon Sep 17 00:00:00 2001 From: CF Mitrah Date: Wed, 7 Apr 2021 11:55:43 +0530 Subject: [PATCH 2/2] Added epochms details in .fld file --- core/src/main/java/resource/fld/core-cfml.fld | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/java/resource/fld/core-cfml.fld b/core/src/main/java/resource/fld/core-cfml.fld index 4f25ba9098..e0257a3faf 100755 --- a/core/src/main/java/resource/fld/core-cfml.fld +++ b/core/src/main/java/resource/fld/core-cfml.fld @@ -452,6 +452,7 @@ The following masks can be used to format the full date and time and may not be - full: equivalent to "dddd, mmmm d, yyyy h:nn:ss tt zz" - ISO8601/ISO: equivalent to "yyyy-mm-dd'T'HH:nn:ssXXX" - epoch: Total seconds of a given date (Example:1567517664) +- epochms: Total millseconds of a given date (Example:1567517664000) The function follows Java date time mask. For details, see the section Date and Time Patterns at http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html