Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread TFormatSettings
Fri, May 10 2013 7:34 AMPermanent Link

Christian Kaufmann

Hi,

I tried to setup the object based on the selected language.

The arrays (LongDayNames, LongMonthNames) are with index 0-6 (0-11),
but in the set method you check for range 1-7 (1-12).

How is it planed to work? 1-7 or 0-6? I think the question is, do you
use Javascript logic or do you stay close to Pascal/Delphi library?

The set method for ShortTimeFormat is never called. But even if I
change it in WebCore, I cannot set the time format to "HH:mm" (only
hours and minutes with hours 0-23) without getting an error.

Do you plan a FormatDateTime() method that supports all the variables
LongDayNames, LongMonthNames and ShortDayNames ?

Unfortunately I cannot read the regional settings in Javascript, but
the Date object has a method called toLocaleDateString(). But I have
no access to a Date object and/or this method.

What brings me to the idea, that some kind of "inline" statement would
be nice. Then I can write Javascript code directly for such special
cases.

Maybe this is all done in version 1.02. I just want to avoid to
implement my own stuff.

cu Christian
Fri, May 10 2013 4:41 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Christian,

<< How is it planed to work? 1-7 or 0-6? I think the question is, do you use
Javascript logic or do you stay close to Pascal/Delphi library? >>

These numbers are all 1-based, although I can see in the source code that
there's an issue with the assignments/reads, which are using the wrong index
into the array.  They should look like this, instead:

function TFormatSettings.GetShortMonthName(Month: Integer): String;
begin
  CheckMonth(Month);
  Result:=FShortMonthNames[Month-1];
end;

procedure TFormatSettings.SetShortMonthName(Month: Integer; const Value:
String);
begin
  CheckMonth(Month);
  FShortMonthNames[Month-1]:=Value;
end;

function TFormatSettings.GetLongMonthName(Month: Integer): String;
begin
  CheckMonth(Month);
  Result:=FLongMonthNames[Month-1];
end;

procedure TFormatSettings.SetLongMonthName(Month: Integer; const Value:
String);
begin
  CheckMonth(Month);
  FLongMonthNames[Month-1]:=Value;
end;

function TFormatSettings.GetShortDayName(Day: Integer): String;
begin
  CheckDay(Day);
  Result:=FShortDayNames[Day-1];
end;

procedure TFormatSettings.SetShortDayName(Day: Integer; const Value:
String);
begin
  CheckDay(Day);
  FShortDayNames[Day-1]:=Value;
end;

function TFormatSettings.GetLongDayName(Day: Integer): String;
begin
  CheckDay(Day);
  Result:=FLongDayNames[Day-1];
end;

procedure TFormatSettings.SetLongDayName(Day: Integer; const Value: String);
begin
  CheckDay(Day);
  FLongDayNames[Day-1]:=Value;
end;

<< The set method for ShortTimeFormat is never called. But even if I change
it in WebCore, I cannot set the time format to "HH:mm" (only hours and
minutes with hours 0-23) without getting an error. >>

This has been fixed already for 1.02.

<< Do you plan a FormatDateTime() method that supports all the variables
LongDayNames, LongMonthNames and ShortDayNames ? >>

Probably at some point, but not in 1.02, so not soon.

<< Unfortunately I cannot read the regional settings in Javascript, but the
Date object has a method called toLocaleDateString(). But I have no access
to a Date object and/or this method. >>

You're not going to get very consistent results with that method.  The whole
reason for the formatting in EWB is because the locale-specific formatting
in most browsers is not very good.

<< What brings me to the idea, that some kind of "inline" statement would be
nice. Then I can write Javascript code directly for such special cases. >>

Sorry, but this won't be happening (ever).  It's a good way to foul up your
application and not know that you did, and with the compiler not being able
to detect and tell you that you did (think clobbering a global variable or
some other variable declared in EWB).  If you start writing inline JS, you
might as well just write the whole thing in JS.  The whole point of EWB is
to avoid writing JS and avoid these types of issues.

Tim Young
Elevate Software
www.elevatesoft.com
Sun, Aug 11 2013 7:46 AMPermanent Link

Malcolm Taylor

Tim Young [Elevate Software] wrote:

> Christian,
>
> << How is it planed to work? 1-7 or 0-6? I think the question is, do
> you use Javascript logic or do you stay close to Pascal/Delphi
> library? >>
>
> These numbers are all 1-based, although I can see in the source code
> that there's an issue with the assignments/reads, which are using the
> wrong index into the array.  They should look like this, instead:
>
> function TFormatSettings.GetShortMonthName(Month: Integer): String;
> begin
>   CheckMonth(Month);
>   Result:=FShortMonthNames[Month-1];
> end;
>

And after those corrections (using 1.02 b2) I became confused.  
The Help correctly says these arrays are 0-based but I found I had to
pass a 1-based index to get the right values due to the decrement above.
Maybe the Help can be clarified?

Malcolm
Wed, Aug 14 2013 1:37 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Malcolm,

<< And after those corrections (using 1.02 b2) I became confused. The Help
correctly says these arrays are 0-based but I found I had to pass a 1-based
index to get the right values due to the decrement above.  Maybe the Help
can be clarified? >>

I'll make sure that the help reflects the correct terminology (1-based).

Thanks,

Tim Young
Elevate Software
www.elevatesoft.com
Image