AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi TimeStampToDateTime - difference Delphi5 - Delphi7

TimeStampToDateTime - difference Delphi5 - Delphi7

Ein Thema von Cadere · begonnen am 10. Dez 2006 · letzter Beitrag vom 10. Dez 2006
Antwort Antwort
Benutzerbild von Cadere
Cadere

Registriert seit: 22. Jun 2004
Ort: Helmond
5 Beiträge
 
Delphi 5 Enterprise
 
#1

TimeStampToDateTime - difference Delphi5 - Delphi7

  Alt 10. Dez 2006, 12:30
Hello,

On my computer I recently installed Delphi 7.
In my latest project I used to use this routine:

// in other routine: Starttime := GetTickCount();
// in other routne: perform action

function CalcTimeNeeded : string;
var Starttime,
delta : Comp;

begin
delta := GetTickCount() - StartTime;
result := FormatDateTime('hh"h":nn"m":ss"s":zzz"ms"',TimeSta mpToDateTime(MSecsToTimeStamp(delta)));
end;

In Delphi5 this works perfect. In Delphi7 I get an exception-error on TimeStampToDateTime.
How can I get this working in Delphi7 (or later???)

Thanks in Advance.
Jan.
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#2

Re: TimeStampToDateTime - difference Delphi5 - Delphi7

  Alt 10. Dez 2006, 12:37
What exception ist thrown?
Markus Kinzler
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#3

Re: TimeStampToDateTime - difference Delphi5 - Delphi7

  Alt 10. Dez 2006, 13:00
Hi Jan,

you should get rid of the global variable StartTime and there is no need to employ the TTimeStamp structure:

Delphi-Quellcode:
function TicksToStr(ticks: Cardinal): String;
begin
  Result := FormatDateTime('hh"h":nn"m":ss"s":zzz"ms"', ticks / MSecsPerDay);
end;
Kind regards
  Mit Zitat antworten Zitat
Benutzerbild von Cadere
Cadere

Registriert seit: 22. Jun 2004
Ort: Helmond
5 Beiträge
 
Delphi 5 Enterprise
 
#4

Re: TimeStampToDateTime - difference Delphi5 - Delphi7

  Alt 10. Dez 2006, 13:07
Hi

The exception raised is:
Project ... raised exception class EConvertError with message "0.8906" is not a valid timestamp".

Nice routine, marabu, with TicksToStr.. I'm going to try it.

Thanks.
Jan.
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#5

Re: TimeStampToDateTime - difference Delphi5 - Delphi7

  Alt 10. Dez 2006, 13:09
Zitat:
The exception raised is:
Project ... raised exception class EConvertError with message "0.8906" is not a valid timestamp".
It seams your system settings aren't appropriate ( decimal separator isn't '.')
Markus Kinzler
  Mit Zitat antworten Zitat
marabu

Registriert seit: 6. Apr 2005
10.109 Beiträge
 
#6

Re: TimeStampToDateTime - difference Delphi5 - Delphi7

  Alt 10. Dez 2006, 13:16
Hi Markus,

there is nothing wrong with that - it is an internal message displayed, after all. MSecsToTimeStamp() is implemented differently under D7 and enforces the rule that the Date part of a TimeStamp must be >= 1. D5 didn't care about this.

Kind Regards
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:49 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz