开发者

Which date time object is the smartest that will take leap years etc. into consideration? [closed]

开发者 https://www.devze.com 2023-04-10 07:12 出处:网络
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post.
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 9 years ago.

Improve this question

If I do this:

DateTime now = DateTime.Now;

And then:

DateTime dt = new DateTime(now.Year, now.Month, now.Y开发者_运维百科ear, ..).AddDays(1);

It will take into consideration leap years and anything else that might be an issue with dates :)

I can't recall but I know .net 4 or 3.5 has new date time objects.


To save Jon Skeet from having to advertise his own project:

  • Noda Time

Noda Time is a .NET library designed to simplify the correct handling of dates and times in the .NET environment. It is based on Joda Time, the industry standard date and time handling library for Java


The DateTime.AddYears() method does consider leap years.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号