Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Time String to Time
Thu, Jan 26 2017 10:51 PMPermanent Link

KimHJ

Comca Systems, Inc

On the EWB I have a TButtonComboBox with different times. In the String List I entered times like this 8:00 AM, 9:00 AM, etc..
I'm using the EDB and the DataColumn is set to Time.

I can select any AM time and 12:00 PM any other time gives me "Invalid Time" error.

I tried to change the time to 24 hour, but then I get error on all.
1:00 PM or 01:00 PM or 13:00 any time after 12:00 PM gives a "Invalid Time" error.

1:00:00 PM will be accepted but saves as 01:00 (1:00 AM).

If I use EDB Manager and type 1:00 PM into the field it change it right away to 13:00

Thanks.
Mon, Jan 30 2017 9:39 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Kim,

<< On the EWB I have a TButtonComboBox with different times. In the String List I entered times like this 8:00 AM, 9:00 AM, etc..
I'm using the EDB and the DataColumn is set to Time.

I can select any AM time and 12:00 PM any other time gives me "Invalid Time" error.

I tried to change the time to 24 hour, but then I get error on all.
1:00 PM or 01:00 PM or 13:00 any time after 12:00 PM gives a "Invalid Time" error.

1:00:00 PM will be accepted but saves as 01:00 (1:00 AM). >>

This is a bug and will be fixed in 2.06.  The hot fix is as follows:

In the WebCore unit, change (replace( the line noted below:

function StrToTime(const Value: String; UTC: Boolean=False): DateTime;
var
  I: Integer;
  TempComps: TStringsArray;
  TempHour: Integer;
  TempMinute: Integer;
  TempSecond: Integer;
  TempMessage: String;
begin
  Result:=DateTime(0);
  TempMessage:=Translate('ERR_DATETIME_INVALID',[Translate('ERR_DATETIME_TIME'),Value]);
  try
     TempHour:=0;
     TempMinute:=0;
     TempSecond:=0;
     with FormatSettings do
        begin
        TempComps:=ParseShortTime(Value);
        for I:=0 to 3 do
           begin
           if (ShortTimeFormatComp[I]=FULL_HOUR24_FORMAT) or
              (ShortTimeFormatComp[I]=PART_HOUR24_FORMAT) then
              TempHour:=StrToInt(TempComps[I])
           else if (ShortTimeFormatComp[I]=FULL_HOUR12_FORMAT) or
                   (ShortTimeFormatComp[I]=PART_HOUR12_FORMAT) then
              TempHour:=StrToInt(TempComps[I])
           else if (ShortTimeFormatComp[I]=FULL_MIN_FORMAT) or
                   (ShortTimeFormatComp[I]=PART_MIN_FORMAT) then
              TempMinute:=StrToInt(TempComps[I])
           else if (ShortTimeFormatComp[I]=FULL_SEC_FORMAT) or
                   (ShortTimeFormatComp[I]=PART_SEC_FORMAT) then
              TempSecond:=StrToInt(TempComps[I])
           else if (ShortTimeFormatComp[I]=FULL_AMPM_FORMAT) then
              begin
              if SameText(TempComps[I],TimePMString) and (TempHour < AMPM_HOURS) then
                 Inc(TempHour,AMPM_HOURS);
              end;
           end;
        end;
     if (not (IsHour(TempHour) and IsMinute(TempMinute) and IsSecond(TempSecond))) then   <<<<< Here !!!!!
        raise Exception.Create(TempMessage)
     else
        Result:=EncodeTime(TempHour,TempMinute,TempSecond,0,UTC);
  except
     raise Exception.Create(TempMessage);
  end;
end;

The TempAMPM variable as removed, as it isn't necessary.  The IsHour function call should be as shown above.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Jan 31 2017 4:58 PMPermanent Link

KimHJ

Comca Systems, Inc

Tim Young [Elevate Software] wrote:

>This is a bug and will be fixed in 2.06.  

Thanks,
Kim
Image