Is there a way to check whether a Delphi TDateTime
variable has valid contents without trapping exceptions on conversions?
I have written an application that has to parse through hundreds of huge files written as raw Delphi records that contain a TDateTime
field. Occasionally I get a record where the contents has a TDateTime
value like 2.0927117954e+262
which gives a Floating point invalid Operation
exception when passed to conversion routines. I know I can simply trap the exception but this is such a nuisance when debugging as the debugger keeps stopping and I want to keep it enabled in case of other errors.
If your issue is the debugger stopping, you can fix that in the IDE of later Delphi versions. Set two breakpoints before and after the line where the exception will occur. E.g. in Delphi 2007, right-click on the margin red dot for the first BP, choose BreakPoint properties/Advanced/Ignore subsequent exceptions. On the second BP, 'Handle subsequent exceptions'