VB.NET中需要的DateTime数据类型的变体 [英] A variant of the DateTime data type needed in VB.NET

查看:133
本文介绍了VB.NET中需要的DateTime数据类型的变体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要指定一种新的数据类型,几乎完全是

现有DateTime类型的克隆,具有以下特定差异,并且所有

由此产生的性质和方法的差异,这个变化意味着这一点。


1752年9月14日星期四之前的那一天应该是

报告为1752年9月2日星期三,依此类推,所有早期的

日期。请注意,此更改不仅会中断一天一天的稳定序列,而且还会破坏日期的映射到

DayoftheWeek日期和日期到DayoftheMonth和

DayoftheYear在1752年的早期日期。


这是英国历史上实际发生的事情(我相信,

在北美)当格里高利历最终在这里采用时。


我注意到,因为DateTime是一个值类型而不是一个参考

类型,我既不能继承它,也不能基于它构建一个类。所以它似乎是一个结构必须要走的路。
。但是我不是在

所有确定构建它的详细步骤,并让它工作

根据需要。


如果此结构包含一个或多个(隐藏的)DateTime元素,那么

是否便于使用和调整基础数据类型的现有属性和方法?


我的结构能够在构建后使用现有的DateTime格式

选项吗?

-

Alan M Dunsmuir

解决方案

Alan,


日期时间实际上是一个包含刻度线的值从某个开始日期开始

(当它来自服务器或内部时,它与实例不同)。


您使用方法来显示和操纵。


其中一个是


DateTime.AddDays(-x),你可能最适合在一个

例程。


Cor


< blockquote>在消息< um ************* @ TK2MSFTNGP15.phx.gbl> ;, Cor Ligthert

< no ********* ***@planet.nl>写道

日期时间实际上是一个值,它包含来自特定开始日期的刻度(当它来自服务器或内部是
时,它的实例不同)。



这不能解决1752年9月14日之前的一天正确确定当天的问题。也不会。

正确计算两个提供日期之间的天数。

-

Alan M Dunsmuir


Alan,


您可以尝试自己构建完整的新日期时间结构。 (

日期时间是不可继承的。)


或者您也可以看看是否可以这样做。
http:// msdn .microsoft.com / library / de ... endartopic.asp

我希望这会有所帮助


Cor

I need to specify a new data type, almost entirely a ''clone'' of the
existing DateTime type, with the following specific difference, and all
the consequent differences in properties and methods which this one
change implies.

The day immediately before Thursday September 14, 1752 should be
reported as Wednesday September 2, 1752, and so on, for all earlier
dates. Note that this change not only disrupts the steady sequence of
''one day at a time'', but also breaks the mapping of Date on to
DayoftheWeek for all earlier dates, and Date on to DayoftheMonth and
DayoftheYear for earlier dates in 1752.

This is what actually occurred historically in the UK (and, I believe,
in North America) when the Gregorian calendar was finally adopted here.

I note that, since DateTime is a Value Type rather than a Reference
Type, I can neither inherit from it nor build a Class based on it. So it
would seem that a Structure has got to be the way to go. But I am not at
all sure of the detailed steps in building this, and getting it to work
as required.

Should this structure contain one or more (hidden) DateTime elements, to
facilitate use and adaptation of the existing properties and methods of
the underlying data type?

Would my structure be able to use the existing DateTime formatting
options once it has been built?
--
Alan M Dunsmuir

解决方案

Alan,

A datetime is actual a value that contains ticks from a certain start date
(which differs by instance when it is from a server or is internally).

You use methods to show that and to manipulate.

One of them is

DateTime.AddDays(-x), what is maybe the most properiate for you to use in a
routine.

Cor


In message <um*************@TK2MSFTNGP15.phx.gbl>, Cor Ligthert
<no************@planet.nl> writes

A datetime is actual a value that contains ticks from a certain start
date (which differs by instance when it is from a server or is
internally).



This would not solve the problem of the correct determination of the day
of the week, for dates prior to September 14, 1752. Nor would it
calculate correctly the number of days between two supplied dates.
--
Alan M Dunsmuir


Alan,

You can try to build your complete new datetime structure yourself. (The
datetime is not inheritable).

Or you can as well look if you can do it with this.
http://msdn.microsoft.com/library/de...endartopic.asp

I hope this helps

Cor


这篇关于VB.NET中需要的DateTime数据类型的变体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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