与日期和时间相关的类并不支持我需要的所有功能. [英] Date and time related classes do not support all features I need.

查看:54
本文介绍了与日期和时间相关的类并不支持我需要的所有功能.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全是鹿,

我在使用DateTime结构时遇到问题.也就是说,它不支持10000年及以后的年份(否则我错了,在这种情况下,我希望您能进行更正),并且我无法找到检查特定DateTime值是否有效的方法.此外,GregorianCalendar仅识别当前时代.
还有更多我需要且无法获得的功能,但我想您明白了.

是否还有其他一些类和/或结构表示相同的事物(日期,时间,时区等),但是实现了更多功能,或者我需要自己实现它们?

在此先感谢.

Deer all,

I''m having problem with DateTime structure. Namely, it does not support year 10000 and later (or I''m wrong in which case I would appreciate correction) and I can''t find method which checks whether particular DateTime value is valid or not. Furthermore, GregorianCalendar recognizes current era only.
There are more features that I need and can not get, but I think you get the point.

Is there some other classes and/or structures which represent the same thing (dates, time, time zones, and so on) but implement more features, or I need to implement them myself?

Thanks in advance.

推荐答案

10000年?这是个玩笑啊啊...

可以,DateTime结构不能给出不可能的日期.由于无法实例化无效的DateTime对象,因此无法检查它们.

但是对于其他几点,您可能需要自己完成或在网上搜索...

如果您想处理遥远的未来或过去,则可能不需要使用DateTime结构.
Year 10000?? Is it a joke ah ah...

OK seriously, DateTime structure can''t give impossible dates. There is no method to check them because you can''t instanciate invalid DateTime objects.

But for the other points, you will probably need to do them by yourself or search the web...

If you want to deal with far future or past, you probably don''t need to use DateTime structure.


有效吗?如果尝试将DateTime设置为无效日期,它将引发异常.如果需要添加功能,则可以使用扩展方法.但是,您什么都不做,将无法指定一个超过最大可能DateTime的日期. CP上有许多有关扩展方法的文章和技巧.
Valid? If you try to set a DateTime to an invalid date, it will throw an exception. If you need to add functionality, you can use extension methods. Nothing you do, though, will allow you to specify a date that exceeds the max possible DateTime. There are a number of articles and tips here on CP about extension methods.


人类没有设计这种日历的经验".在1万年中,我们目前的时间测量方法可能已过时.
http://en.wikipedia.org/wiki/Earth''s_rotation [公历的好奇历史 [日历的历史记录 [ 2月30日 [
The human race doesn''t have the "experience" to design such a calendar. In 10 000 years our current way of measuring time is probably outdated.
http://en.wikipedia.org/wiki/Earth''s_rotation[^].

I''d use a decimal or a double if I wanted to deal with anything on that scale.

You may find this entertaining:
The Curious History of the Gregorian Calendar[^]

Here is some more: History of the Calendar[^]

Have fun :)

Anyway - dates are obviously problematic, ever heard of the 30th of February[^]? I don''t think you''ll come across that one in any of the widely used libraries dealing with dates :)

Regards
Espen Harlinn


这篇关于与日期和时间相关的类并不支持我需要的所有功能.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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