You are not logged in.
Pages: 1
Hi there,
I have a tsqlrecord with a tdate property (not tdatetime, i need just the date) and when i fill tsqltable in a tadvstringgrid the tdate property isn't formatted as date.
I see that in the function expandstring (i think this is the name, i haven't the sourcecode now) miss the tdate formatting code, there is just tdatetime formatting code. I think is easy to add but my question is "why there isn't?"
Another question.
How can i Localize format of tdatetime in tsqltable?
Thanks,
Emanuele.
Offline
The "date only" format does not exist by itself in mORMot DB layers.
It is a global sftDateTime format.
But if the value does not have any time within, it should be displayed only as date.
Do you use SQLite3i18n unit?
In this case, this expected behavior was not implemented.
I've modified the source code so that SQLite3i18n Iso2S() - i.e. overriden i18nDateText global function pointer - will handle a date-only or time-only supplied value as expected.
See http://synopse.info/fossil/info/5aa2c35b43
The default implementation in SQLite3Commons (if SQLite3i18n unit is used nowwhere in the application) was already corrected, AFAIK.
Offline
thanks ab,
now work as expected but, i always see date in english format. i would like in italian. Or i would like to change the format.
for expample:
now i see "Sep, 25 1983".
i would like to see "25/09/1983" in short format or "25 settembre 1983" in long format.
how can i do?
thanks,
Emanuele.
Offline
As already said you should assign i18nDateText global function with your implementation. If you use SQLite3i18n unit then this is relevant for you (extracted commented code from source):
/// format string used to convert a date value to a text
// - the expected format is the one used by the FormatDateTime() function
// - the current system format, depending on the current language, is used,
// then overriden by a DateFmt= entry in the .msg file content
DateFmt: string;
/// format string used to convert a time value to a text
// - the expected format is the one used by the FormatDateTime() function
// - the current system format, depending on the current language, is used,
// then overriden by a TimeFmt= entry in the .msg file content
TimeFmt: string;
/// format string used to convert a date and time value to a text
// - the expected format is the one used by the FormatDateTime() function
// - the current system format, depending on the current language, is used,
// then overriden by a DateTimeFmt= entry in the .msg file content
DateTimeFmt: string;
Last edited by Leander007 (2012-05-16 17:04:44)
"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal
Offline
You have to set the language, as expected by SQLite3i18n unit, if you use it.
By default, this is English.
And it will set automatically the i18nDateText global function as expected.
So there is nothing to set: it is already done.
Offline
hi ab,
actually i don't use SQLite3i18n unit.
the only way to have formatted date as expected is to use SQLite3i18n?
thanks,
Emanuele.
Offline
1. If you use "real localization" (e.g. multi language support), then you should follow the localization rules (resourcestrings...) and use SQLite3i18n unit and proper functions from it. Then you have many possibilities to set the current language and the regular formating (windows regional settings) will be used automatically (as already said by Arnaud), if you don't provide other option.
2. If you don't use "real localization", but hard coded one, then you may use TSQLTable.ExpandAsString function (which is used e.g. by TSQLTableToGrid), which in turn uses i18nDateText function. And to this function (which is in SynCommons unit) you can assign your custom implementation.
In 1. case assignment of i18nDateText is already done behind the scene, you must just set the current language, so usage of e.g. TSQLTableToGrid will be already in localized form.
Last edited by Leander007 (2012-05-17 10:12:45)
"Uncertainty in science: There no doubt exist natural laws, but once this fine reason of ours was corrupted, it corrupted everything.", Blaise Pascal
Offline
Pages: 1