Improving Time Fields fractional seconds display
Posted: 24.11.2020, 20:18
Hi all!
I fixed some minor bugs recently in the time and datetime display for fractional seconds. I kept the code the same besides the fix, but it is a bit odd in the way that it works.
Case 1:
if your timeformat is "simple" (i.e. it ends with the fractional seconds), then they are concatenated to the end of the string and trailing zeros are not trimmed. e.g. 12:21:03.1230
Case 2:
If your timeformat is not simple (usually because it ends with an AM or PM indicator), then the current code puts the fractional time at the correct position, and then removes any trailing zeros. This causes a bit of an issue if the fractional time is zero, as the decimal character is not removed (so you can get a time that shows '12:21:03. AM' (note the '.')
My first thought was that the solution would just be not removing the trailing zeros, but it seems that Firebird doesn't actually tell you the current scale of a timestamp, so it's always 4, and that ends up looking a bit odd.
So I *think* the best solution is to always trim the trailing zeros on the fractional time including the decimal char. Any thoughts?
-Mark
I fixed some minor bugs recently in the time and datetime display for fractional seconds. I kept the code the same besides the fix, but it is a bit odd in the way that it works.
Case 1:
if your timeformat is "simple" (i.e. it ends with the fractional seconds), then they are concatenated to the end of the string and trailing zeros are not trimmed. e.g. 12:21:03.1230
Case 2:
If your timeformat is not simple (usually because it ends with an AM or PM indicator), then the current code puts the fractional time at the correct position, and then removes any trailing zeros. This causes a bit of an issue if the fractional time is zero, as the decimal character is not removed (so you can get a time that shows '12:21:03. AM' (note the '.')
My first thought was that the solution would just be not removing the trailing zeros, but it seems that Firebird doesn't actually tell you the current scale of a timestamp, so it's always 4, and that ends up looking a bit odd.
So I *think* the best solution is to always trim the trailing zeros on the fractional time including the decimal char. Any thoughts?
-Mark