没有时间.NET日期 - 是有一个,或者我不应该需要吗?我不、是有、日期、时间

2023-09-03 05:38:24 作者:在网络上

我正在做一些领域建模和未来的跨其中我的脑海里最好的暴露为一个日期,而不是​​一个DateTime属性,没有时间组件。

I'm doing some domain modelling and coming across a property which to my mind would be best exposed as a Date rather than a DateTime, without a time component.

有一个很好的理由,为什么没有这样类型的框架?它被认为是一个足够好的主意,一个日期类型添加到SQL Server。另外,如果有人知道的一个方便的实施日期类,请让我知道!

Is there a good reason why there is no such type in the Framework? It was deemed a good enough idea to add a Date type to SQL Server. Also, if someone knows of a handy implementation of a Date class, please let me know!

推荐答案

没有,没有一个,是的,应该有。

No, there isn't one, and yes, there should be.

我不相信有一个很好的理由以外的其他的日期和时间API在.NET中是不是在我(非常偏颇)看法很不错。

I don't believe there's a good reason other than that the date and time API in .NET isn't very good in my (very biased) view.

我工作的一个新的API名为野田佳彦时间其中的确实有一个日期,只类( LocalDate ),但它没有准备好生产呢。它可能已经这样做了,你需要的一切,当然,如果它的近的不那么你可以总是要求只是你必须尽早实现的功能,而不是以后...

I'm working on a new API called Noda Time which of course does have a date-only class in (LocalDate) but it's not ready for production yet. It may already do everything you need it to, of course, and if it nearly does then you could always ask for just the features you need to be implemented sooner rather than later...