#1 2012-05-16 13:50:15

lele9
Member
Registered: 2011-10-28
Posts: 170

tsqltable, tdate and localization

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

#2 2012-05-16 15:16:50

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,274
Website

Re: tsqltable, tdate and localization

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.

Online

#3 2012-05-16 15:42:18

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: tsqltable, tdate and localization

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

#4 2012-05-16 17:03:13

Leander007
Member
From: Slovenia
Registered: 2011-04-29
Posts: 113

Re: tsqltable, tdate and localization

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

#5 2012-05-16 18:50:19

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,274
Website

Re: tsqltable, tdate and localization

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.

Online

#6 2012-05-17 07:21:44

lele9
Member
Registered: 2011-10-28
Posts: 170

Re: tsqltable, tdate and localization

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

#7 2012-05-17 10:04:59

Leander007
Member
From: Slovenia
Registered: 2011-04-29
Posts: 113

Re: tsqltable, tdate and localization

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

Board footer

Powered by FluxBB