Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

coldfusion

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

like image 846
Henry Avatar asked Jan 30 '26 04:01

Henry


1 Answers

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

like image 108
Matteo Italia Avatar answered Feb 02 '26 08:02

Matteo Italia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!