Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread 1.02B1 - FormatSettings
Wed, Jun 12 2013 10:12 AMPermanent Link

Christian Kaufmann

Some issues are solved now, but I still can't use it as expected:

* Setting a ShortTimeFormat causes problems. I need "HH:mm" and
"HH:mm:ss". Both of these gives an error.

* There is still no simple way to set the format strings to the
regional settings of the computer. "Globalize" is a library for that
but it's Javascript. Did anybody solve this problem already? Otherwise
I'll have to build something on my own.

cu Christian
Wed, Jun 12 2013 1:46 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Christian,

<< * Setting a ShortTimeFormat causes problems. I need "HH:mm" and
"HH:mm:ss". Both of these gives an error. >>

Update the SetShortTimeFormat method in the WebCore unit with the following
code:

procedure TFormatSettings.SetShortTimeFormat(const Value: String);
var
  TempComps: TStringsArray;
  TempHour: String;
  TempAMPM: String;
  I: Integer;
begin
  if (Value <> FShortTimeFormat) then
     begin
     TempComps:=ParseShortTime(Value,True);
     ValidateShortTimeComp(Value,TempComps[0]);
     TempHour:=TempComps[0];
     ValidateShortTimeComp(Value,TempComps[1]);
     ValidateShortTimeComp(Value,TempComps[2]);
     TempAMPM:='';
     for I:=3 downto 1 do
        begin
        if (TempComps[I]=FULL_AMPM_FORMAT) then
           begin
           TempAMPM:=TempComps[I];
           Break;
           end;
        end;
     if (TempHour[1]=HOUR12_FORMAT_CHAR) then
        ValidateShortTimeComp(Value,TempAMPM)
     else if (TempAMPM <> '') then
        Error(Value,Translate('ERR_DATETIME_TOOMANYCOMPS',[GetTimeName]));
     FShortTimeFormat:=Value;
     FShortTimeFormatComps:=TempComps;
     end;
end;

<< * There is still no simple way to set the format strings to the regional
settings of the computer. "Globalize" is a library for that but it's
Javascript. >>

That's not what Globalize does, at least as far as I know.  There's really
no way to reliably detect the regional settings of the OS from a browser, at
least not across all browsers.

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jun 13 2013 2:07 AMPermanent Link

Christian Kaufmann

>Update the SetShortTimeFormat method in the WebCore unit with the following
>code:

It works fine for "HH:mm:ss" now, but not for "HH:mm", probably
because you expect three time components.


><< * There is still no simple way to set the format strings to the regional
>settings of the computer. "Globalize" is a library for that but it's
>Javascript. >>
>
>That's not what Globalize does, at least as far as I know.  There's really
>no way to reliably detect the regional settings of the OS from a browser, at
>least not across all browsers.

I looked at the code and for "CultureInfo" it loads time and date
formats and translations based on the language.

I think for now, this is the best solution. And is important to use
the full language because Swiss french and Canadian french use
different date formats:

fr-ch  : dd.MM.yyyy
fr-ca :  yyyy/MM/dd

In my case I either do it localy or I send the formats back from my
server application, based on the language or even customized based on
logged in user.

cu Christian
Fri, Jun 14 2013 2:18 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Christian,

<< It works fine for "HH:mm:ss" now, but not for "HH:mm", probably because
you expect three time components. >>

I'll check it out.

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Image