作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将我的 Julian 日期数字转换为普通日期,即 JavaScript 中的 UTC 日期格式.例如,我有儒略数“57115”。我想转换为 2015 年 4 月 10 日之类的格式。
最佳答案
试试下面的代码
var X = parseFloat(57115)+0.5;
var Z = Math.floor(X); //Get day without time
var F = X - Z; //Get time
var Y = Math.floor((Z-1867216.25)/36524.25);
var A = Z+1+Y-Math.floor(Y/4);
var B = A+1524;
var C = Math.floor((B-122.1)/365.25);
var D = Math.floor(365.25*C);
var G = Math.floor((B-D)/30.6001);
//must get number less than or equal to 12)
var month = (G<13.5) ? (G-1) : (G-13);
//if Month is January or February, or the rest of year
var year = (month<2.5) ? (C-4715) : (C-4716);
month -= 1; //Handle JavaScript month format
var UT = B-D-Math.floor(30.6001*G)+F;
var day = Math.floor(UT);
//Determine time
UT -= Math.floor(UT);
UT *= 24;
var hour = Math.floor(UT);
UT -= Math.floor(UT);
UT *= 60;
var minute = Math.floor(UT);
UT -= Math.floor(UT);
UT *= 60;
var second = Math.round(UT);
alert(new Date(Date.UTC(year, month, day, hour, minute, second)));
关于javascript - 在javascript中将朱利安日期数字转换为正常日期(utc),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29627533/
我一直在尝试了解 Julialang 的类型系统但是一些设计方面仍然让我感到困惑。我希望有人能澄清一下。 所以这里的问题是关于抽象类型及其具体实现。从我understand Julia抽象类型不会对其
相同的代码 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:
我是一名优秀的程序员,十分优秀!