现在查找N天的日期 [英] Find the date in N days by now
本文介绍了现在查找N天的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在寻找一种算法来找了一天,在未来,这是N天,从今天的日期。
I'm looking for an algorithm to find the date of a day in the future, which is in N days from today.
我的主要问题是如何处理闰年在中间。
My main problem is how to deal with leap years in the middle.
推荐答案
如果我没有拿你的问题,你最好的选择是做到以下几点:
If I take your question correctly, your best option is to do the following:
- 转换的日期成数字,其中的数表示的天数,因为在特定日期
- 添加N至该号码
- 将结果反馈转换为一个日期
您可以使用儒略日数约会做到这一点。
You can do this using the julian day number for a date.
请参见朱利安天数(JDN)了解更多信息,维基百科的文章。
See the Wikipedia article on Julian Day Number (JDN) for more information.
说了这么多,如果你实际上使用的是现代的编程语言,最有设施,以处理日期已,如Java,C#/。NET,巨蟒等。
Having said that, if you're actually using a modern programming language, most have facilities to deal with dates already, such as Java, C#/.NET, Python, etc.
这篇关于现在查找N天的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文