简体   繁体   English

将long int秒转换为双精度浮点值

[英]Convert long int seconds to double precision floating-point value

I have a long int variable wich containes seconds since Jan. 1, 1970 in this format: 自1970年1月1日以来,我有一个很长的int变量,其中包含秒,其格式为:

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. 该值的整数部分是自1899年12月30日午夜以来的天数。该值的小数部分代表时间。 .5 is equal to 12:00 PM. .5等于12:00 PM。

how can i convert? 我该如何转换?

There are 86400 seconds in a day, and 25569 days between these epochs. 一天中有86400秒,这些时期之间有25569天。 So the answer is: 所以答案是:

double DelphiDateTime = (UnixTime / 86400.0) + 25569;

You really do need to store the Unix time in an integer variable though. 您确实确实需要将Unix时间存储在一个整数变量中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM