Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the default year of a new instance of the Date class equal -4712?

Tags:

ruby

Running:

require 'date'
y = Date.new
puts "default year is #{y.year}"

Output:

default year is -4712

Is there any particular reason why the year of a Date object defaults to -4712? I thought perhaps there's a technical (or conventional) reason. I have googled this and looked it up on the Ruby documentation (2.2.3) and I can't see an answer as to why.

like image 338
Sagar Pandya Avatar asked Nov 15 '15 08:11

Sagar Pandya


1 Answers

The day of January 1, 4713 BC is the beginning of the Julian day, from Wiki:

The Julian Day Number (JDN) is the integer assigned to a whole solar day in the Julian day count starting from noon Greenwich Mean Time, with Julian day number 0 assigned to the day starting at noon on January 1, 4713 BC, proleptic Julian calendar (November 24, 4714 BC, in the proleptic Gregorian calendar), a date at which three multi-year cycles started and which preceded any historical dates. For example, the Julian day number for the day starting at 12:00 UT on January 1, 2000, was 2,451,545.

The year of this day, is 4713 BC, or technically -4712.

like image 153
Yu Hao Avatar answered Oct 24 '22 11:10

Yu Hao