Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.1k views
in Technique[技术] by (71.8m points)

why is ColdFusion's Epoch Time Dec 30, 1899?

<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>

output:

0 30-Dec-99 12:00 AM

What's so significant about Dec 30, 1899?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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

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.

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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...