test/test/region/christian.rb in when_exe-0.3.7 vs test/test/region/christian.rb in when_exe-0.3.8

- old
+ new

@@ -92,45 +92,10 @@ 2400-03-01 2500-03-01 2600-03-01 2700-03-01 2800-03-01), dates.map {|date| (calendar ^ date.to_i).to_s}) assert_equal([1], dates.map {|date| calendar._century_from_jdn(date.to_i) - calendar._century_from_jdn(date.to_i-1)}.uniq) end end - class Swedish < MiniTest::TestCase - def test__swedish_date - - dates = [] - jdns = [] - [2342042, 2346424].each do |base| - (-3..+3).each do |diff| - jdn = base + diff - jdate = When::Julian ^ jdn - s1date = When::Swedish ^ jdn - s2date = When.tm_pos(*(s1date.cal_date + [{:frame=>When::Swedish}])) - dates << s1date.to_s - jdns << [s1date.to_s == s2date.to_s, s1date.to_i == jdn, s2date.to_i == jdn].uniq - end - end - - assert_equal(%w(1700-02-26 1700-02-27 1700-02-28 1700-03-01 1700-03-02 1700-03-03 1700-03-04 - 1712-02-26 1712-02-27 1712-02-28 1712-02-29 1712-02-30 1712-03-01 1712-03-02), dates) - assert_equal([[true]], jdns.uniq) - end - - def test__swedish_easter - - dates = [] - civil = When.Calendar('Civil?old=Swedish&reform_date=1753-03-01') - ((1700..1711).to_a + (1740..1752).to_a+[1802,1805,1818]).each do |year| - dates << When.tm_pos(year, {:frame=>civil}).easter.to_s - end - assert_equal(%w(1700-04-01 1701-04-21 1702-04-06 1703-03-29 1704-04-17 1705-04-02 1706-03-25 - 1707-04-14 1708-04-05 1709-04-18 1710-04-10 1711-03-26 1740-04-06 1741-03-22 - 1742-03-14 1743-04-03 1744-03-18 1745-04-07 1746-03-30 1747-03-22 1748-04-03 - 1749-03-26 1750-03-18 1751-03-31 1752-03-22 1802-04-25 1805-04-21 1818-03-29), dates) - end - end - class Civil < MiniTest::TestCase def test__border frame = When.Calendar('Civil?reform=1752-9-14&border=0-3-25(1753)0-1-1') assert_equal("1641=03-24", (frame ^ When.when?('1642-4-3') ).to_s) assert_equal("1642-03-25", (frame ^ When.when?('1642-4-4') ).to_s) @@ -161,9 +126,25 @@ 1582-09-28) date = When.when?('1582-11-01', :frame=>'Civil?reform=1582-10-15') 25.times do assert_equal(sample.shift, date.to_s) date = date - When::P1D + end + end + + def test_civil_epoch + epoch = 1001 + diff = 1 - epoch + civil = When.Calendar("Civil?origin_of_MSC=#{diff}&old=(Julian?origin_of_MSC=#{diff})") + assert_equal('0582-10-04', (civil ^ When.when?('1582-10-14')).to_s) + assert_equal('0582-10-15', (civil ^ When.when?('1582-10-15')).to_s) + date = When.when?("1000-1-1", :frame=>civil) + assert_equal('1014-01-01', (date & When.Residue('甲午').to('year')).to_s) + assert_equal(%w(1000-01-01 2000-01-01), [date.to_s, (When::Gregorian^date).to_s]) + 399.times do + date += When::P1Y + cal_date = date.cal_date + assert_equal((When::Gregorian^date).cal_date, [cal_date[0]-diff] + cal_date[1..2]) end end def test__reform_year date = When.when?('1752^^Civil?reform=1752-9-14&border=(1000)0-3-25(1753)0-1-1')