2017-10-03 13 views
1
irb(main):002:0> require 'date' 
=> true 
irb(main):003:0> x = Date.new 
=> #<Date: -4712-01-01 ((0j,0s,0n),+0s,2299161j)> 

ご覧のとおり、年は-4712に設定されています。 どうすれば間違っていますか?私のUbuntuで 年が右に設定されていますレール間違った年-4712

10月4日午前1時39分58秒STD 2017

答えて

1

あなたはofficial documentationで答えを見つけることができます。現在の日付については

# Date.new([year=-4712[, month=1[, mday=1[, start=Date::ITALY]]]]) -> date 
# 
# Creates a date object denoting the given calendar date. 
# 
# In this class, BCE years are counted astronomically. Thus, the 
# year before the year 1 is the year zero, and the year preceding the 
# year zero is the year -1. The month and the day of month should be 
# a negative or a positive number (as a relative month/day from the 
# end of year/month when negative). They should not be zero. 
# 
# The last argument should be a Julian day number which denotes the 
# day of calendar reform. Date::ITALY (2299161=1582-10-15), 
# Date::ENGLAND (2361222=1752-09-14), Date::GREGORIAN (the proleptic 
# Gregorian calendar) and Date::JULIAN (the proleptic Julian 
# calendar) can be specified as a day of calendar reform. 
# 
# Date.new(2001)   #=> #<Date: 2001-01-01 ...> 
# Date.new(2001,2,3)  #=> #<Date: 2001-02-03 ...> 
# Date.new(2001,2,-1)  #=> #<Date: 2001-02-28 ...> 
3

を、 today

2.4.2 :002 > require "date" 
=> true 
2.4.2 :003 > x = Date.today 
=> #<Date: 2017-10-03 ((2458030j,0s,0n),+0s,2299161j)> 
関連する問題