From 7105a05f22fca7af25b078c7534416f1821cf27b Mon Sep 17 00:00:00 2001 From: afine-gs Date: Thu, 3 Oct 2024 08:59:07 -0400 Subject: [PATCH] add addtional time formats (#3142) --- .../main/resources/core/pure/corefunctions/dateExtension.pure | 2 +- .../resources/core/pure/corefunctions/tests/date/testDate.pure | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/dateExtension.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/dateExtension.pure index 486b1972a4c..8c2c4510554 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/dateExtension.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/dateExtension.pure @@ -649,5 +649,5 @@ function meta::pure::functions::date::toEpochValue(d:Date[1], unit:DurationUnit[ function meta::pure::functions::date::validateDateTimeFormat(dateTimeFormat:String[1]):Boolean[1] { // Supported Formats : yyyy, yyyy-M, yyyy-MM, yyyy-MM-d, yyyy-M-d, yyyy-MM-dd, yyyy/mm/dd, yyyyMMdd, yyyyMd, yyMd, dd/MM/yyyy, MM/dd/yyyy, MM/dd/yyyy "at" hh:mma z, yyyy-MM-dd HH:mm:ss, yyyy-MM-dd h:mm:ssa, yyyy-MM-dd HH:mm:ss.SSS, yyyy-MM-dd HH:mm:ss.SSSX, yyyy-MM-dd HH:mm:ss.SSSZ, yyyy-MM-dd HH:mm:ss.SSS z, yyyy-MM-dd HH:mm:ss.SSSS z, yyyy-MM-dd"T"HH:mm:ss, yyyy-MM-dd"T"HH:mm:ssZ, yyyy-MM-dd"T"HH:mm:ss.SSS, yyyy-MM-dd"T"HH:mm:ss.SSSZ, yyyy-MM-dd"T"HH:mm:ss.SSSSZ, yy-MM-dd"T"HH:mm:ss."000000", , 'yyyy-MM-dd"T"HH:mm:ss."000000"X', [EST]yyyy-MM-dd HH:mm:ss.SSSZ, [CST]yyyy-MM-dd HH:mm:ss.SSS z, [CET]yyyy-MM-dd HH:mm:ss.SSSX, [EST]yyyy-MM-dd and other timezones - $dateTimeFormat->matches('(\\[[A-Z][A-Z]([ACDKLMNORSTUVW])?([DSWT])?([T])?\\])?(MM/dd/|dd/MM/)?(?:y{4}|y{2})(([-/])?[mM]{1,2}(([-/])?(d{1,2}) *((\"T\"|T)?(H{2}|h{1}):m{2}:s{2}.?((?:S{3,4} *[zZX]?|\"000000\"))?)?)?)? *(\"at\")? *(h{2}:m{2}a)? *[zZxX]?'); + $dateTimeFormat->matches('(\\[[A-Z][A-Z]([ACDKLMNORSTUVW])?([DSWT])?([T])?\\])?(MM/dd/|dd/MM/|MM-dd-|dd-MM-)?(?:y{4}|y{2})(([-/])?[mM]{1,2}(([-/])?(d{1,2}) *((\"T\"|T)?(H{2}|h{1}):m{2}:s{2}.?((?:S{3,4} *[zZX]?|\"000000\"))?)?)?)? *(\"at\")? *(h{2}:m{2}a)? *[zZxX]?'); } diff --git a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/date/testDate.pure b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/date/testDate.pure index db2e0e02420..6d739cef458 100644 --- a/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/date/testDate.pure +++ b/legend-engine-core/legend-engine-core-pure/legend-engine-pure-code-compiled-core/src/main/resources/core/pure/corefunctions/tests/date/testDate.pure @@ -21,7 +21,7 @@ function <> meta::pure::functions::date::tests::testSystemDefaultTime function <> meta::pure::functions::date::tests::testValidateDateTimeFormat():Boolean[1] { - let formats = ['yyyy', 'yyyy-M', 'yyyy-MM', 'yyyy-MM-d', 'yyyy-M-d', 'yyyy-MM-dd', 'yyyy/mm/dd', 'yyyyMMdd', 'yyyyMd', 'yyMd', 'dd/MM/yyyy', 'MM/dd/yyyy', 'MM/dd/yyyy "at" hh:mma z', 'yyyy-MM-dd HH:mm:ss', 'yyyy-MM-dd h:mm:ssa', 'yyyy-MM-dd HH:mm:ss.SSS', 'yyyy-MM-dd HH:mm:ss.SSSX', 'yyyy-MM-dd HH:mm:ss.SSSZ', 'yyyy-MM-dd HH:mm:ss.SSS z', 'yyyy-MM-dd HH:mm:ss.SSSS z', 'yyyy-MM-dd"T"HH:mm:ss', 'yyyy-MM-dd"T"HH:mm:ssZ', 'yyyy-MM-dd"T"HH:mm:ssZZ', 'yyyy-MM-dd"T"HH:mm:ss.SSS', 'yyyy-MM-dd"T"HH:mm:ss.SSSZ', 'yyyy-MM-dd"T"HH:mm:ss.SSSSZ', 'yy-MM-dd"T"HH:mm:ss."000000"', 'yyyy-MM-dd"T"HH:mm:ss."000000"X', '[EST]yyyy-MM-dd HH:mm:ss.SSSZ', '[CST]yyyy-MM-dd HH:mm:ss.SSS z', '[CET]yyyy-MM-dd HH:mm:ss.SSSX', '[EST]yyyy-MM-dd']; + let formats = ['yyyy', 'yyyy-M', 'yyyy-MM', 'yyyy-MM-d', 'yyyy-M-d', 'yyyy-MM-dd', 'yyyy/mm/dd', 'yyyyMMdd', 'yyyyMd', 'yyMd', 'dd/MM/yyyy', 'MM/dd/yyyy','MM-dd-yyyy','dd-MM-yyyy', 'MM/dd/yyyy "at" hh:mma z', 'yyyy-MM-dd HH:mm:ss', 'yyyy-MM-dd h:mm:ssa', 'yyyy-MM-dd HH:mm:ss.SSS', 'yyyy-MM-dd HH:mm:ss.SSSX', 'yyyy-MM-dd HH:mm:ss.SSSZ', 'yyyy-MM-dd HH:mm:ss.SSS z', 'yyyy-MM-dd HH:mm:ss.SSSS z', 'yyyy-MM-dd"T"HH:mm:ss', 'yyyy-MM-dd"T"HH:mm:ssZ', 'yyyy-MM-dd"T"HH:mm:ssZZ', 'yyyy-MM-dd"T"HH:mm:ss.SSS', 'yyyy-MM-dd"T"HH:mm:ss.SSSZ', 'yyyy-MM-dd"T"HH:mm:ss.SSSSZ', 'yy-MM-dd"T"HH:mm:ss."000000"', 'yyyy-MM-dd"T"HH:mm:ss."000000"X', '[EST]yyyy-MM-dd HH:mm:ss.SSSZ', '[CST]yyyy-MM-dd HH:mm:ss.SSS z', '[CET]yyyy-MM-dd HH:mm:ss.SSSX', '[EST]yyyy-MM-dd']; assert($formats->map(format | validateDateTimeFormat($format))->assertNotContains(false)); let invalidFormats = ['yyy', 'yyyyy-M', 'yyyy-MMM', 'yyyy-MM-ddd', 'dd/mm/yyyy', 'MM/ddyy', 'MM/dd/yyyy "at" hh:ma z', 'yyyy-MMM-dd HH:mm:ss', 'yyyy-MM-dd hh:mm:ssa', 'yyyy-MM-dd HH:mm:ss.SSZ', 'yyyy-MM-dd HH:mm:ss.SZ', 'yyyy-MM-dd"TT"HH:mm:ss', 'yyyy-MM-dd"T"HH:mm:sss.SSS', 'yyyy-MM-dd""HH:mm:ss.SSSZ', 'yyyy-MM-dd"T"HH:mm:ss.SSSSSZ', 'yy-MM-dd"T"HH:mm:ss."00"', '(EST)yyyy-MM-dd'];