在VB.net中计算朱利安日! [英] Julian day calculation in VB.net!

查看:74
本文介绍了在VB.net中计算朱利安日!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个计算朱利安日的功能:

I have this function that calculates Julian day:

'The date is June 11 2015
        Dim y As Integer = Now.Year
        Dim m As Integer = Now.Month
        Dim d As Integer = Now.Day

        If m <= 2 Then
            y -= 1
            m += 12
        End If
        Dim A As Double = CDbl(Math.Floor(y / 100.0))
        Dim B As Double = 2 - A + Math.Floor(A / 4)

        Dim JD As Double = Math.Floor(365.25 * (y + 4716)) + Math.Floor(30.6001 * (m + 1)) + d + B - 1524.5



此函数的输出为2457184.5。

我有这个等式h还计算朱利安日:


The output of this function is "2457184.5".
And I have this equation which also calculates Julian day:

Dim JD As Double = ((367 * y) - (CInt((7 / 4) * (y + Int((m + 9) / 12)))) + CInt(275 * (m / 9)) + d - 730531.5)



但这个等式的输出是 5639.5

我的问题是哪一个是对的,哪一个是错的,为什么?

提前谢谢。


But the output of this equation is "5639.5"
My question is which one is right and which one is wrong and why?
Thanks in advance.

推荐答案

请参阅Wes Aday的评论。



首先,你可以使用这个类: https://msdn.microsoft.com/en-us/library/system.globalization.juliancalendar%28v=vs.110%29.aspx [ ^ ]。



您可以在这里找到合适的食谱:http://en.wikipedia.org/wiki/Julian_day [ ^ ]。



我认为遵循它应该是微不足道的。您可以查看结果,例如: http://www.nr.com/julian.html [ ^ ]。



-SA
Please see the comment by Wes Aday.

First of all, you can use this class: https://msdn.microsoft.com/en-us/library/system.globalization.juliancalendar%28v=vs.110%29.aspx[^].

Here is where you can find right recipe: http://en.wikipedia.org/wiki/Julian_day[^].

I think following it should be trivial. You can check up your results, for example, here: http://www.nr.com/julian.html[^].

—SA


之间总是存在混淆朱利安日 [ ^ ]
引用:

自朱利安时期开始以来的连续天数

the continuous count of days since the beginning of the Julian Period

朱利安日历 [ ^ ]这是基本上是一个民事日历,表示日期为年,月,日。对于后一个目的,您可以使用System.Globalization.JulianCalendar类,但不能使用前者。 Brittanica对朱利安时期进行了简洁的解释[ ^ ]



解决方案1中给出并在上面重复的维基百科链接给出了朱利安日的正确计算方法。此上显示了该计算的C#表示。发布 [ ^ ],但是你的第一个方法看起来相当准确。



测试我更喜欢美国海军天文台< a href =http://aa.usno.navy.mil/data/docs/JulianDate.php>网站 [ ^ ]因为它适合从中午开始的朱利安日(即根据时间正确显示小数部分)<某个方法是根据2000年1月1日以来的天数计算准朱利安日(注意小写),这在某些方面很常用应用领域,例如可变大小的限制。这不适合用于(例如)天文学或金融服务(尤其是养老金)。我最后一次使用这种方法是在80年代早期的CP / M上的乳品管理系统中(除了有限的记忆),我们的约束是世界上最古老的已知奶牛的诞生年!

and the Julian Calendar[^] which is essentially a civil calendar which represents dates as year, month, day. For the latter purpose you can use the System.Globalization.JulianCalendar class but not the former. Brittanica gives a nice terse explanation of Julian Period[^]

The Wikipedia link given in Solution 1 and repeated above gives the correct calculation method for a Julian Day. There is a C# representation of that calculation presented on this post[^], however the first of your methods appears to be reasonably accurate.

For testing I prefer the US Naval Observatory website[^] as it caters for a Julian Day beginning at mid-day (i.e. correctly displays the decimal part based on time of day)

Your second method is calculating a quasi-julian day (note the lower case) based on number of days since 01-Jan-2000, which is common enough use in some application areas, for example where there are constraints on variable size. It would not be an appropriate method to use for (for example) Astronomy or Financial services (especially Pensions). The last time I used that approach was on a Dairy Management system on CP/M back in the early 80's where (apart from limited memory) our constraint was the birth year of the oldest known dairy cow in the world!


这篇关于在VB.net中计算朱利安日!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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