加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 23:07:13 所属栏目:百科 来源:网络整理
导读:运行: require 'date'y = Date.newputs "default year is #{y.year}" 输出: default year is -4712 Date对象的年份默认为-4712有什么特别的原因吗?我想也许有一个技术(或传统)的原因.我已经搜索了这篇文章并查看了Ruby文档(2.2.3),我无法找到答案. 解决方
运行:
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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读