ZFormatSettings issues related to separators
Posted: 15.05.2021, 20:52
The ZFormatSettings unit and how it works is very nice. There is an issue, however, because while you can set various formats, you can't set the date or time separators, and so if they get changed from the regional defaults the library routines used for conversions won't work. For example if my regional date separator is '/', and I set ZConn.FormatSettings.EditTimestampFormatSettings.Format := 'YYYY-MM-DD HH:NN:SS'; then TZAbstractTimestampFormatSettings.TryStrToTimestamp won't work (just picking one example.)
To solve it I added time and date separator checking and setting to all of the various "SetFormat" methods. This works well for date and time, but not for timestamps. However I also added them to SetDateformat and SetTimeFormat of the TZAbstractTimestampFormatSettings object and so as long as you set them the correct separators will be used. I also had to add the DateFormat and TimeFormat properties to TZEditTimestampFormatSettings.
So that fixes things, or at least allows them to work properly, but I'm guessing a more elegant solution could be found. Currently TimestampFormats keep their "full format" in LongDateFormat, maybe that should be removed and set date and time formats for timestamps individually?
Thanks
- Mark
To solve it I added time and date separator checking and setting to all of the various "SetFormat" methods. This works well for date and time, but not for timestamps. However I also added them to SetDateformat and SetTimeFormat of the TZAbstractTimestampFormatSettings object and so as long as you set them the correct separators will be used. I also had to add the DateFormat and TimeFormat properties to TZEditTimestampFormatSettings.
So that fixes things, or at least allows them to work properly, but I'm guessing a more elegant solution could be found. Currently TimestampFormats keep their "full format" in LongDateFormat, maybe that should be removed and set date and time formats for timestamps individually?
Thanks
- Mark