MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / DateTimeFromISO8601

Function DateTimeFromISO8601

sourcecommon/utils.cpp:1925–1946  ·  view source on GitHub ↗

--------------------------------------------------------------------------- s = "yyyy[mm[dd[Thh[nn[ss[.zzzz]]]]]]"

Source from the content-addressed store, hash-verified

1923//---------------------------------------------------------------------------
1924// s = "yyyy[mm[dd[Thh[nn[ss[.zzzz]]]]]]"
1925TDateTime DateTimeFromISO8601(String s)
1926{
1927 int l = s.Length();
1928 unsigned short year, month=0, day=0;
1929 unsigned short hour=0, min=0, sec=0, msec=0;
1930
1931 if( l<4 )
1932 throw Exception(AnsiString("DateTimeFromISO8601(): �������� ���� �����: ") + s);
1933
1934 year = StrToInt(s.SubString(1,4));
1935 if( l>=6 ) month = StrToInt(s.SubString(5,2));
1936 if( l>=8 ) day = StrToInt(s.SubString(7,2));
1937 if( l>=11 )
1938 if( s[9]=='T' )
1939 {
1940 hour = StrToInt(s.SubString(10,2));
1941 if( l>=13 ) min = StrToInt(s.SubString(12,2));
1942 if( l>=15 ) sec = StrToInt(s.SubString(14,2));
1943 if( l>=20 ) if( s[16]=='.' ) msec = StrToInt(s.SubString(17,3));
1944 }
1945 return TDateTime(year, month, day) + TDateTime(hour, min, sec, msec);
1946}
1947//---------------------------------------------------------------------------
1948bool StringStartWith(String Str, String StartStr)
1949{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected