Convert long int seconds to double precision floating-point value

497 Views Asked by At

I have a long int variable wich containes seconds since Jan. 1, 1970 in this format:

long int seconds = 1231241242144214;

i need to convert this seconds to double precision floating-point value. The integer part of the value is the number of days since midnight, 30 December 1899. The fractional part of the value represents time. .5 is equal to 12:00 PM.

how can i convert?

1

There are 1 best solutions below

1
On BEST ANSWER

There are 86400 seconds in a day, and 25569 days between these epochs. So the answer is:

double DelphiDateTime = (UnixTime / 86400.0) + 25569;

You really do need to store the Unix time in an integer variable though.