View Issue Details

IDProjectCategoryView StatusLast Update
0037974pas2jsrtlpublic2020-11-05 09:55
Reporterlxpbuaa Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Fixed in Versiontrunk 
Summary0037974: TryRFC3339ToDateTime raise Error
DescriptionHi,
With the datetime D='2020-10-24 10:00',
    var S := FormatDateTime(yyyy-mm-dd"T"hh:nn:ss, D). //S is '2020-10-24T10:00', it doesn't contain seconds.
TryRFC3339ToDateTime(S) will raise a error,
In TryRFC3339ToDateTime:
    lH:=StrToIntDef(Copy(AValue,P[ppHour],2),-1);
    lMi:=StrToIntDef(Copy(AValue,P[ppMinute],2),-1);
    lS:=StrToIntDef(Copy(AValue,P[ppSec],2),-1);
    It is required that these hour, minute and second cannot be empty. I suggest changing the param - 1 to 0, or modifing the function FormatDateTime to include seconds.
Thanks!
TagsNo tags attached.
Fixed in Revision918
Attached Files

Activities

Michael Van Canneyt

2020-11-05 09:55

administrator   ~0126751

I can't reproduce the part with formatdatetime, I always get the ending 0.
---
program scratch;

{$mode objfpc}

uses
  browserconsole, JS, SysUtils, DateUtils, web, rtti;

var
  S : String;
  D : TDateTime;
begin
   D:=Date+EncodeTime(10,00,00,00);
   S := FormatDateTime('yyyy-mm-dd"T"hh:nn:ss', D);
   Writeln(s);
   D:=RFC3339ToDateTime(S);
   S := FormatDateTime('yyyy-mm-dd"T"hh:nn:ss', D);
   Writeln(s);
end.
---
Produces always the same output:
---
2020-11-05T10:00:00
2020-11-05T10:00:00
---
But I made sure the TryRFC3339 is more robust, the seconds can be skipped.

Issue History

Date Modified Username Field Change
2020-10-23 18:22 lxpbuaa New Issue
2020-10-23 22:52 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-10-23 22:52 Michael Van Canneyt Status new => assigned
2020-11-05 09:55 Michael Van Canneyt Status assigned => resolved
2020-11-05 09:55 Michael Van Canneyt Resolution open => fixed
2020-11-05 09:55 Michael Van Canneyt Fixed in Version => trunk
2020-11-05 09:55 Michael Van Canneyt Fixed in Revision => 918
2020-11-05 09:55 Michael Van Canneyt Note Added: 0126751