From 398d2ac68cdab6dd68944f187de5c5f39e97ef6d Mon Sep 17 00:00:00 2001 From: Dominique Mikes Date: Fri, 3 Apr 2020 10:45:20 +0200 Subject: [PATCH] Changed the TDateTime detection part. Now date and time, with optional fractional seconds and time zone (e.g., 2008-08-30T01:45:36 or 2008-08-30T01:45:36.123Z) are detected. --- Pkg.Json.Mapper.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Pkg.Json.Mapper.pas b/Pkg.Json.Mapper.pas index 641e6fc..6d89f54 100644 --- a/Pkg.Json.Mapper.pas +++ b/Pkg.Json.Mapper.pas @@ -441,7 +441,7 @@ function TPkgJsonMapper.GetJsonType(AJsonValue: TJsonValue): TJsonType; if AJsonValue is TJSONString then begin LJsonString := (AJsonValue as TJSONString); - if TRegEx.IsMatch(LJsonString.Value, '^([0-9]{4})-?(1[0-2]|0[1-9])-?(3[01]|0[1-9]|[12][0-9])(T| )(2[0-3]|[01][0-9]):?([0-5][0-9]):?([0-5][0-9])$') then + if TRegEx.IsMatch(LJsonString.Value, '^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\.[0-9]+)?(Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?$') then result := jtDateTime else if TRegEx.IsMatch(LJsonString.Value, '^([0-9]{4})(-?)(1[0-2]|0[1-9])\2(3[01]|0[1-9]|[12][0-9])$') then