begin process at 2012 02 09 09:46:42
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Date & Heure

 > TRANSFORMER DES MILLISECONDES(INTEGER) EN FORMAT HH:MM:SS:CCC (STRING)

TRANSFORMER DES MILLISECONDES(INTEGER) EN FORMAT HH:MM:SS:CCC (STRING)


 Information sur la source

Note :
3,5 / 10 - par 2 personnes
3,50 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Date & Heure Niveau :Débutant Date de création :05/03/2002 Date de mise à jour :06/03/2002 14:52:20 Vu :5 495

Auteur : fabiin

Ecrire un message privé
Site perso
Commentaire sur cette source (4)
Ajouter un commentaire et/ou une note

 Description

Cette petite fonction permet de transfomer un nombre de millisecondes en un type String format HH:MM:SS:ccc

Vous pouvez facilement la modifier pour un format HH:MM:SS :)

Source

  • function IntToTime(Valeur:integer):string;
  • var
  • TmpVal:real;
  • TmpStr:string;
  • begin
  • TmpVal := Valeur;
  • TmpStr := '';
  • TmpVal := TmpVal / 3600000;
  • TmpStr := inttostr(trunc(TmpVal));
  • TmpVal := (TmpVal-trunc(TmpVal))* 3600000;
  • TmpVal := TmpVal / 60000;
  • TmpStr := TmpStr + ':' + inttostr(trunc(TmpVal));
  • TmpVal := (TmpVal-trunc(TmpVal))*60000;
  • TmpVal := TmpVal / 1000;
  • TmpStr := TmpStr + ':' + inttostr(trunc(TmpVal));
  • TmpVal := (TmpVal-trunc(TmpVal))*1000;
  • TmpVal := TmpVal;
  • TmpStr := TmpStr + ':' + inttostr(trunc(TmpVal));
  • Result := TmpStr;
  • end;
function IntToTime(Valeur:integer):string;
var
TmpVal:real;
TmpStr:string;
begin
TmpVal := Valeur;
TmpStr := '';

TmpVal := TmpVal / 3600000;
TmpStr := inttostr(trunc(TmpVal));

TmpVal := (TmpVal-trunc(TmpVal))* 3600000;
TmpVal := TmpVal / 60000;
TmpStr := TmpStr + ':' + inttostr(trunc(TmpVal));

TmpVal := (TmpVal-trunc(TmpVal))*60000;
TmpVal := TmpVal / 1000;
TmpStr := TmpStr + ':' + inttostr(trunc(TmpVal));

TmpVal := (TmpVal-trunc(TmpVal))*1000;
TmpVal := TmpVal;
TmpStr := TmpStr + ':' + inttostr(trunc(TmpVal));

Result := TmpStr;

end; 

 Conclusion

exemple d'utilisation :
IntToTime(GetTickCount)
vous renvera le temps depuis ke vous avez lancé votre ordinateur :)


 Sources du même auteur

Source avec Zip CAPTUER LE SON SORTANT ET L'ENREGISTRER DANS UN FICHIER WAV
CALCUL D'UNE MOYENNE
CHANGER LA DURÉE D'AFFICHAGE DES BULLES D'AIDES (HINT)
Source avec Zip Source avec une capture ASCII-T : PETIT SOFT D'ASCII ART.
CHANGER CONTRASTE / LUMINOSITÉ (L'ALGORITHME)

 Sources de la même categorie

Source avec Zip Source avec une capture SIMPLE HORLOGE ANALOGIQUE par hamza
Source avec Zip Source avec une capture MÉMO V1.0.0 par Christophe67
Source avec Zip Source avec une capture AGENDA HEBDO par dubois77
Source avec Zip Source avec une capture PAQUES 1.0.0 par Christophe67
Source avec Zip Source avec une capture TIMESERVER V1.0.3 par Christophe67

Commentaires et avis

Commentaire de PhGORMAND le 06/03/2002 16:40:34

Salut.  Que penses tu de ce code ?

Function MilisecondesToTime( M : Integer) : String;
Var
   T  : TDateTime;

Begin
   T:=D /86400000;
   Result := TimeToStr(T);
End;


// Exemple
procedure TForm1.Button1lick(Sender : TObject);
Var
   T : Integer;
begin
   T:=GetTickCount;
   Caption:= MilisecondesToTime(T);
end;

Commentaire de fabiin le 06/03/2002 18:21:25

Wé !!! c cool ton code !!!
Mais comment fait-ton pour avoir les millisecondes ???

Merci @+

Commentaire de PhGORMAND le 07/03/2002 16:47:56

Tu fais comme ça, pour avoir les milisecondes.

Function MilisecondesToTime(D : Integer) : String;
Var
   T : TDateTime;
   F : Double;
Begin
     F := (Frac(D / 1000)) * 1000;
     T := D / 86400000;
     Result := TimeToStr(T) + ':' + IntTostr(Round(F));
End;


Au fait :  http://philippe.gormand.free.fr/

Commentaire de garfieldfr le 22/03/2003 22:57:38

ou comment se compliquer la vie :
Il existe un type TTimeStamp:
TTimeStamp =record
  Time:Integer;
  Date:Integer;
end;

donc le code :
var T:TTimeStamp;
     D:TDateTime;
begin
  T.time := 1254586; //millisecondes
  D:=TimestampToDateTime(T);
  ...et plein d'autre fonction ....
end;

en gros, vous reinventez la roue .... il faut lire la doc !!!!

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 1,778 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales