TryVar2DateTime in u_dzVariantUtils only handles a varDate, a string and custom variant types. Measured with Delphi 12:
| Variant | Result |
|---|---|
| varDate 2026-10-14 | True |
| String '2026-10-14' | True |
| Double 46309.5 | False |
| Integer 46309 | False |
| String 'abc' | False |
| Null, Empty | False |
Two problems:
TDateTime, and Var2DateTimeEx and Var2DateTimeStr accept it, but TryVar2DateTime returns False.TryVar2Xxx functions raise EVariantConvertError (see [bugs:#63]).Fix: accept everything that converts to TDateTime, return False for Null and Empty, raise EVariantConvertError for a value that cannot be converted, and give it the same optional _ErrorHandling: TErrorHandlingEnum = ehRaiseException parameter as the other TryVar2Xxx functions.
Note: this changes the behaviour for its callers, TNullableDate.AssignVariant, TNullableDateTime.AssignVariant and TryFieldAsDate in u_dzDatasetHelpers.
Bug Reports: #63
Bug Reports: #68
Bug Reports: #69
Feature Requests: #31
Fixed in revision #2440