运行:
require 'date' y = Date.new puts "default year is #{y.year}"
输出:
default year is -4712
Date对象的年份默认为-4712有什么特别的原因吗?我想也许有一个技术(或传统)的原因.我已经搜索了这篇文章并查看了Ruby文档(2.2.3),我无法找到答案.
解决方法
公元前4713年1月1日是维基的
Julian day年的开始:
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.
这一天是公元前4713年,或技术上-4712.