Suggestion for "jForms" "GetDateTimeDecode" lazarus / 43-Android ---------------------------------------------------------------------- ADiV · 2018-10-20 08:57 Hi guys, I created this "GetDateTimeDecode" function to be able to manipulate dates and times, if Mr. @jmpessoa likes it I could include it in the "jForm" class to complement the "GetDateTime" function already included in "androidwidget.pas". Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i //publicfunction  GetDateTimeDecode(                              var day : integer; var month : integer; var year : integer;                           var hours : integer; var minutes: integer; var seconds : integer ) : boolean; // ... function jForm.GetDateTimeDecode(                            var day : integer; var month : integer; var year : integer;                             var hours : integer; var minutes: integer; var seconds : integer ) : boolean;var strDateTime : string;begin result := false;  strDateTime := GetDateTime;  day := 0; month := 0; year := 0; hours := 0; minutes := 0; seconds := 0;  try   year  := strToInt( copy(strDateTime, 1, 4) );   month := strToInt( copy(strDateTime, 6, 2) );   day   := strToInt( copy(strDateTime, 9, 2) );   hours   := strToInt( copy(strDateTime, 12, 2) );   minutes := strToInt( copy(strDateTime, 15, 2) );   seconds := strToInt( copy(strDateTime, 18, 2) ); except   exit; end;  result := true; end; ---------------------------------------------------------------------- A.S. · 2018-10-20 10:11 Which format is used for strDateTime parameter? Why function from unit DateUtils cannot be used? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DateUtils.DecodeDateTime(StrToDateTime(strDateTime),   AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond) ---------------------------------------------------------------------- ADiV · 2018-10-20 10:56 Quote from: A.S. on October 20, 2018, 12:11:25 pmWhich format is used for strDateTime parameter? Why function from unit DateUtils cannot be used? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DateUtils.DecodeDateTime(StrToDateTime(strDateTime),   AYear, AMonth, ADay, AHour, AMinute, ASecond, AMilliSecond) This function is not compatible with "GetDateTime" of jForm since it uses the format 'yyyy-mm-dd hh:mm:ss' for example '2018-10-20 12:45:33' ---------------------------------------------------------------------- Thaddy · 2018-10-20 11:21 Quote from: TR3E on October 20, 2018, 12:56:12 pmThis function is not compatible with "GetDateTime" of jForm since it uses the format 'yyyy- mm-dd hh:mm:ss' for example '2018-10-20 12:45:33' Doesn't it contain an overload with TFormatsettings? Then it IS compatible. Also, the above is the logical format. I will have a look. ---------------------------------------------------------------------- yuriy_sydorov · 2018-10-20 11:22 Quote from: TR3E on October 20, 2018, 12:56:12 pmThis function is not compatible with "GetDateTime" of jForm since it uses the format 'yyyy- mm-dd hh:mm:ss' for example '2018-10-20 12:45:33' If you are using FPC 3.1+ add the clocale unit to your project, the date/time format in FPC should be correct for the current regional settings of the device. ---------------------------------------------------------------------- Thaddy · 2018-10-20 11:29 Quote from: yuriy_sydorov on October 20, 2018, 01:22:50 pmQuote from: TR3E on October 20, 2018, 12:56:12 pmThis function is not compatible with "GetDateTime" of jForm since it uses the format 'yyyy-mm-dd hh:mm:ss' for example '2018-10-20 12:45:33' If you are using FPC 3.1+ add the clocale unit to your project, the date/time format in FPC should be correct for the current regional settings of the device. Indeed, but I just saw dateutil needs some work regarding Tformatsettings overloads (sysutils is completely done). IMHO it should be fixed like that.