begin process at 2010 02 10 08:32:14
  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 :4 379

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 DECOMPTEUR AVEC ENREGISTREMENT DES OPTIONS par michaelminelli1
Source avec Zip Source avec une capture MODIFIER LES DATES DE CRÉATION, DE MODIFICATION ET DE DERNIE... par ni69
Source avec Zip Source avec une capture UN CHRONOS SIMPLE AVEC UN COMPOSENT LABEL ANIMÉ par jackalunion
DATE EN ARABE par AITFRAH1
Source avec Zip LE PROGRAMMATEUR par HAFTARIFOUAD

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...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
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 : 0,608 sec (4)

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