为什么 ColdFusion 的纪元时间是 1899 年 12 月 30 日? [英] why is ColdFusion's Epoch Time Dec 30, 1899?

查看:33
本文介绍了为什么 ColdFusion 的纪元时间是 1899 年 12 月 30 日?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<cfoutput>
    <cfset x = createTimespan(0,0,0,0)>
    <cfset epoch = createDateTime(1899,12,30,0,0,0)>
    <cfset date = epoch + x>
    #date# #dateFormat(date)# #timeFormat(date)#
</cfoutput>

输出:

0 99 年 12 月 30 日上午 12:00

0 30-Dec-99 12:00 AM

1899 年 12 月 30 日有何重要意义?

What's so significant about Dec 30, 1899?

推荐答案

如你所说,可能与COM/OLE自动化日期格式有关;它的第一个版本是在 1995 年用 Microsoft VC++ 编写的(source),这似乎是合理的它利用了 OLE 功能.

As you said, it is probably related to the COM/OLE automation date format; its first version was written in Microsoft VC++ back in 1995 (source), and it's plausible that it exploited OLE features.

反过来,OLE 日期时间类型也受到在 Excel 中使用 VBA 的决定的影响.

The OLE datetime type, in turn, was influenced by the decision of using VBA into Excel.

Excel 必须与 Lotus 123 向后兼容,Lotus 123 将 1900 年视为闰年(但能被 100 整除的年份只有当它们能被 400 整除时才是闰年);虽然它的第 1 天正式为 1900 年 1 月 1 日,但它认为 1900 年 2 月 29 日是现有的一天,因此所有其他天都向前移动"了一天.这意味着,对于自 1900 年 1 月 3 日以来的每一天,实际第 1 天"是 1899 年 12 月 31 日(或者,如果您愿意,第 0 天是 1899 年 12 月 30 日).Excel 人员首先使用了一个小技巧,使他们的函数的行为与 Lotus 123 完全相同.

Excel had to be backwards-compatible with Lotus 123, which considered 1900 as a leap year (but years divisible by 100 are leap years only if they are divisible by 400); while its day 1 was officially 1/1/1900, it considered 29/02/1900 as an existing day, so all the other days were "shifted forward" by one. This meant that, for every day since 1/3/1900, the "actual day 1" was 31/12/1899 (or, if you prefer, day 0 was 30/12/1899). The Excel guys first used a small hack to make their functions behave exactly like Lotus 123 ones.

另一方面,当 VBA 被添加到 Excel 时,负责 VBA 中日期/时间函数的人员决定以某种方式修复整个问题:而不是使用 1/1/1900 作为第 1 天并伪造1900 年 2 月 29 日的存在,他们实际上将时代向后移动了一天:1900 年的前两个月不再与 Lotus 123 兼容,但系统获得了一致性.

On the other hand, when VBA was added to Excel, the people responsible for the date/time functions in VBA decided to fix the whole thing in some way: instead of using 1/1/1900 as day 1 and faking the presence of 29/02/1900, they actually moved the epoch back of one day: the first two months of 1900 weren't compatible anymore with Lotus 123, but the system gained in coherency.

来源:http://www.joelonsoftware.com/items/2006/06/16.html

这篇关于为什么 ColdFusion 的纪元时间是 1899 年 12 月 30 日?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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