ruby – 为什么Date类的新实例的默认年份等于-4712?

运行:
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.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...