Autor Beitrag
boro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 25.10.06 09:28 
Wie kann man die Zeit im C format time_t (das heist Longint oder Integer) auf Typ TDateTime konvertieren ?

Boro
JDKDelphi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 115
Erhaltene Danke: 22

WIN2000, XP, WIN 7 , UNIX, LINUX
Assembler für (Z8x, 68xxx,R6000,Intel), DELPHI 6 Enterprise, MAGIC eDeveloper V9+V10, C++, C#,VB, .NET, zertifizierter iBOLT-Programmierer
BeitragVerfasst: Mi 25.10.06 11:00 
Titel: t_time(C) nach TDatetime
Hallo,

Tdatetime ist ein Extended bzw Double wert, der im Nachkommaanteil die zeit seit 0.00Uhr
speichert. 12.00Zhr mittags ist also 0.5
Der Vorkommaanteil ist das Datum seit 31.12.1899 oder so.

Vielleicht hilft Dir das

Gruss
espen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 90
Erhaltene Danke: 1


D6 Prof./D7 Prof. MSSQL, MySQL
BeitragVerfasst: Mi 25.10.06 11:49 
Hallo,

beim googeln gefunden:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
Tapani Leppänen <leppanen_tap...@pine.sahako.fi> wrote: 
>Hi, 
>Is there an easy ( or any ) way to convert C-type time_t to 
>Delphi-type TDateTime and vice versa ??? 
>TIA, 
>Tapsa 
>-- 
>Tapani Leppanen                    leppanen_tap...@pine.sahako.fi 
>Heinola Sawmill Machinery Inc.     Automation 


I'll take a wild shot at it: 

time_t is an unsigned long representing seconds elapsed since 1970. 


TDateTime is a decimal representation of time, with the value to the 
left of the decimal being a count of days elapsed since who knows 
when, and the value to the right of the decimal being a fraction of a 
day. 


First, we'll need a reference: create a TDateTime variable for 
0:00:00, 1970, using, I believe, StrToDate, and call that variable, 
say, dt1970. 


To convert from a TDateTime variable to time_t, subtract dt1970 from 
your TDateTime variable, multiply by 24*60*60 (the number of seconds 
in a day), and cast to an unsigned long (i.e.,  a time_t). 


To convert from a time_t variable to a TDateTime, cast your time_t 
variable to a TDateTime, divide by 24*60*60, and add dt1970. 


That ought to do the trick. 


P.S. ( If you're attempting to do conversions for dates prior to 1970, 
you may need to consider a more advanced algorithm).
boro Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Mi 25.10.06 14:37 
Ja, das ist es. Danke vielmals.
Koentest du noch dazu sagen wie man dazu noch local time und Sommer/Winter Zeit einbaut ?
Noch mals vielen Dank.

Boro