tdatetime

Conversion with StrToDateTime and TFormatSettings does not work

时光总嘲笑我的痴心妄想 提交于 2019-12-18 03:56:11
问题 This code should work in Delphi XE2, but it gives "not a valid date and time" error in StrtoDateTime conversion: procedure TForm2.Button1Click(Sender: TObject); var s: string; d: TDateTime; FmtStngs: TFormatSettings; begin GetLocaleFormatSettings(GetThreadLocale, FmtStngs); FmtStngs.DateSeparator := #32; FmtStngs.ShortDateFormat := 'dd mmm yyyy'; FmtStngs.TimeSeparator := ':'; FmtStngs.LongTimeFormat := 'hh:nn'; s := FormatDateTime('', Now, FmtStngs); d := StrToDateTime(s, FmtStngs); end; Any

Conversion with StrToDateTime and TFormatSettings does not work

天涯浪子 提交于 2019-12-18 03:56:06
问题 This code should work in Delphi XE2, but it gives "not a valid date and time" error in StrtoDateTime conversion: procedure TForm2.Button1Click(Sender: TObject); var s: string; d: TDateTime; FmtStngs: TFormatSettings; begin GetLocaleFormatSettings(GetThreadLocale, FmtStngs); FmtStngs.DateSeparator := #32; FmtStngs.ShortDateFormat := 'dd mmm yyyy'; FmtStngs.TimeSeparator := ':'; FmtStngs.LongTimeFormat := 'hh:nn'; s := FormatDateTime('', Now, FmtStngs); d := StrToDateTime(s, FmtStngs); end; Any

Calculate time between 2 TDateTime, with a twist

邮差的信 提交于 2019-12-11 14:09:43
问题 I need to find out how to get the time between 2 times, but only if it is within work hours(Stored in a database) This is what I got for now, but it is totally wrong. the total won't bee correct. int __fastcall Organisasjon::CalculateResponsetimeInOpeninghours(std::auto_ptr<DBCommand> cmd, long orgid, TDateTime starttimeIn, TDateTime endtimeIn) { int totalTimeInQueue = 0; String sIsWorkDay = ""; String s = "SELECT o.isworkday, o.workdate, o.workstarttime, o.workendtime " \ "FROM orgwdexcep o

Convert UTC string to TDatetime in Delphi

我是研究僧i 提交于 2019-12-06 02:03:45
问题 var tm : string; dt : tdatetime; tm := '2009-08-21T09:11:21Z'; dt := ? I know I can parse it manually but I wonder if there is any built-in function or Win32 API function to do this ? 回答1: I don't know why there are so many people shooting their mouth off when they don't know what they are talking about? I have to do this menial work; Is it a RAD tool? I sometimes find Delphi has a real superb architecture, though. procedure setISOtoDateTime(strDT: string); var // Delphi settings save vars

How can I distinguish TDateTime properties from Double properties with RTTI?

感情迁移 提交于 2019-12-05 13:21:50
问题 Using the RTTI system in Delphi 2010, is there any way to find out if a property is a TDateTime? It's currently treating it as a double whenever I call back asVariant and also if I check the property type. Is this due to the fact it can only see the base type? (TDateTime = double) 回答1: Try checking the Name property of the TRttiProperty.PropertyType I don't have Delphi 2010, but this works in XE. {$APPTYPE CONSOLE} uses SysUtils, Classes, Rtti; type TMyClass =class private FDate: TDateTime;

Convert UTC string to TDatetime in Delphi

强颜欢笑 提交于 2019-12-04 05:41:23
var tm : string; dt : tdatetime; tm := '2009-08-21T09:11:21Z'; dt := ? I know I can parse it manually but I wonder if there is any built-in function or Win32 API function to do this ? delphi_hangover I don't know why there are so many people shooting their mouth off when they don't know what they are talking about? I have to do this menial work; Is it a RAD tool? I sometimes find Delphi has a real superb architecture, though. procedure setISOtoDateTime(strDT: string); var // Delphi settings save vars ShortDF, ShortTF : string; TS, DS : char; // conversion vars dd, tt, ddtt: TDateTime; begin //

How can I distinguish TDateTime properties from Double properties with RTTI?

时光怂恿深爱的人放手 提交于 2019-12-03 22:41:33
Using the RTTI system in Delphi 2010, is there any way to find out if a property is a TDateTime? It's currently treating it as a double whenever I call back asVariant and also if I check the property type. Is this due to the fact it can only see the base type? (TDateTime = double) Try checking the Name property of the TRttiProperty.PropertyType I don't have Delphi 2010, but this works in XE. {$APPTYPE CONSOLE} uses SysUtils, Classes, Rtti; type TMyClass =class private FDate: TDateTime; FProp: Integer; FDate2: TDateTime; FDate1: TDateTime; public property Date1 : TDateTime read FDate1 Write

Checking two TDateTime variables

こ雲淡風輕ζ 提交于 2019-12-01 01:07:46
I am using C++ Builder and have the following question: I am wanting to detect if a date/time is later than another date/time, and by how much. Here is my current code: TDateTime testFirstDate("11/09/2012"); TDateTime testFirstTime("14:00"); TDateTime testSecondDate("12/09/2012"); TDateTime testSecondTime("16:00"); TDateTime testCombined1 = testFirstDate + testFirstTime; TDateTime testCombined2 = testSecondDate + testSecondTime; TDateTime testDateDifference = testSecondDate - testFirstDate; std::cout << testDateDifference; In the above example, the following gets printed out: 31/12/1899 The

Checking two TDateTime variables

微笑、不失礼 提交于 2019-11-30 21:12:05
问题 I am using C++ Builder and have the following question: I am wanting to detect if a date/time is later than another date/time, and by how much. Here is my current code: TDateTime testFirstDate("11/09/2012"); TDateTime testFirstTime("14:00"); TDateTime testSecondDate("12/09/2012"); TDateTime testSecondTime("16:00"); TDateTime testCombined1 = testFirstDate + testFirstTime; TDateTime testCombined2 = testSecondDate + testSecondTime; TDateTime testDateDifference = testSecondDate - testFirstDate;

Conversion with StrToDateTime and TFormatSettings does not work

老子叫甜甜 提交于 2019-11-29 03:19:57
This code should work in Delphi XE2, but it gives "not a valid date and time" error in StrtoDateTime conversion: procedure TForm2.Button1Click(Sender: TObject); var s: string; d: TDateTime; FmtStngs: TFormatSettings; begin GetLocaleFormatSettings(GetThreadLocale, FmtStngs); FmtStngs.DateSeparator := #32; FmtStngs.ShortDateFormat := 'dd mmm yyyy'; FmtStngs.TimeSeparator := ':'; FmtStngs.LongTimeFormat := 'hh:nn'; s := FormatDateTime('', Now, FmtStngs); d := StrToDateTime(s, FmtStngs); end; Any hints? If you want to convert some special DateTime-Formats you should better use VarToDateTime