将unix时间戳转换为julian [英] Convert unix timestamp to julian

查看:202
本文介绍了将unix时间戳转换为julian的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将unix时间戳(1232559922)转换为小数日期(2454853.03150)。

How can I convert from a unix timestamp (say 1232559922) to a fractional julian date (2454853.03150).

我发现一个网站( http://aa.usno.navy.mil/data/docs/JulianDate.php )执行类似的计算,但我需要编程。

I found a website ( http://aa.usno.navy.mil/data/docs/JulianDate.php ) that performs a similar calculation but I need to do it programatically.

解决方案可以是C / C ++,python,perl,bash等...

Solutions can be in C/C++, python, perl, bash, etc...

推荐答案

Unix纪元(零点)是1970年1月1日GMT。这对应于愚人节2440587.5

The Unix epoch (zero-point) is January 1, 1970 GMT. That corresponds to the Julian day of 2440587.5

所以,在伪代码中:

function float getJulianFromUnix( int unixSecs )
{
   return ( unixSecs / 86400.0 ) + 2440587.5;
}

这篇关于将unix时间戳转换为julian的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆