AuthorMessage
NeiSep
Ametuar
Posts: 93

Ok i got this weird problem i can't get date to be a vaild date format.
Quote:

procedure TForm1.Timer2Timer(Sender: TObject);
var
e, i : integer;
date1, date2, date3, date4, date5, date6, date7 : string;
date8, date9, date10 : string;
begin
  i := -1;
  while (i < hubs.Count - 1) do
    begin
      i := i + 1;
     date1 := copy(hubs[i],pos('|',hubs[i]),length(hubs[i]));
     date2 := copy(date1,2,length(hubs[i]));
     date3 := copy(date2,pos('|',date2),length(hubs[i]));
     date4 := copy(date3,2,length(date3));
     date5 := copy(date4,pos('|',date4),length(hubs[i]));
     date6 := copy(date5,2,length(date5));
     date7 := copy(date6,pos('|',date6),length(hubs[i]));
     date8 := copy(date7,2,length(date7));
     date9 := copy(date8,pos('|',date8),length(hubs[i]));
     date10 := copy(date9,2,length(hubs[i]));
//     memo2.Lines.Add(date10);
      if (MinutesSinceDate(StrToDateTime(date10)) >= 20) then
        begin
          hubs.Delete(i);
          i := i - 1;
        end;
    end;
end;

i also use function called MinutesSinceDate looks like this:
Quote:

function MinutesSinceDate(aDate : TDateTime) : Integer;
var
  SecDifference : Double;
begin
  SecDifference := Now - aDate;
  SecDifference := SecDifference * 60 * 24;
  Result := Trunc(SecDifference)
end;

Meka][Meka
Unstopable
Posts: 700

need more info, such as what text is in hub vars and such things. a good explanation of what u r trying to accomplish, and what is going wrong.
NeiSep
Ametuar
Posts: 93

o lol yes ofcourse sorry
Well what i trying todo is to delete the old records in a TStringList i think it is.
And the Hubs thing contains this kind of info:
[Asgard]Lappen´s Jämtland|norrland.asgards.org:4111|100Mbit server maxtesting useramaunt|1304|39058628603248|2005-12-04 17:53:08
Mickey
Ametuar
Posts: 115

Quote:
date1, date2, date3, date4, date5, date6, date7 : string;
date8, date9, date10 : string;

Why don't you use an array there? It looks too bad this way.
Array like this:
Quote:
var
 MyDate:  array[1..10] of string;
...
 MyDate[1] := ...;
 MyDate[2] := ...;
...
 MyDate[10] := ...;

NeiSep
Ametuar
Posts: 93

never tought of that but that was not my problem here lol.
Mickey
Ametuar
Posts: 115

Quoted from NeiSep
never tought of that but that was not my problem here lol.

I know but
Quote:
date1, date2, date3, date4, date5, date6, date7 : string;
date8, date9, date10 : string;

is very ugly and don't know how to call.  :?  Never do this way
NeiSep
Ametuar
Posts: 93

hmm still i know that it is ugly you haven't see my rest of the code lol...
Anyway i still got problem to make a difference between 2 dates i just want to calculate how many minutes it has gone since 2005-12-06 16:00 etc
so if someone can help me i would be happy 
Mickey
Ametuar
Posts: 115

Once in past I made a prog to count how many days till I meet a special person. There is the part of the code for counting days beetwen 2 dates:
Code:
...
function TfrmDays.NumToText(N:Integer; T:String):String;
begin
  Result := IntToStr(N) + T;
  if N>1 then
    Result := Result + 's';
end;
procedure TfrmDays.FormCreate(Sender: TObject);
var
  MeetingDay : TDateTime;
  RemainingDays : Integer;
begin
   MeetingDay := StrToDate('2006.05.22.');
   RemainingDays := Trunc(MeetingDay - Date);
   labelToday.Caption := DateToStr(Date);
   labelMeettingDay.Caption := DateToStr(MeetingDay);
   labelRemainedDays.Caption := IntToStr(RemainingDays);
   labelRemainedWeeksDays.Caption := 'So we''ll meet after ' +
     NumToText(RemainingDays div 7,' week') + ' and ' + NumToText(RemainingDays mod 7,' day');
end;
...

It is not counting minutes and seconfds but you can go same way.
NeiSep
Ametuar
Posts: 93

oki going to test it ..