Sha256: 2033f923705e311e1779242c55b14710fbd2f916be6addc87080b494ef9cc9cc

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

describe "Parsi::Date.jd" do
  it "constructs a date form given Chronological Julian day number" do
    Parsi::Date.jd(2456228).should == Parsi::Date.civil(1391, 8, 6)
    Parsi::Date.jd(2456229).should == Parsi::Date.civil(1391, 8, 7)
  end

  it "returns a Date object representing Julian day 0 if no arguments passed"do
    Parsi::Date.jd.should == Parsi::Date.civil(-5334, 9, 1)
  end

  it "constructs a Date object if passed a negative number" do
    Parsi::Date.jd(-1).should == Parsi::Date.civil(-5334, 8, 30)
  end
end

describe "Parsi::Date#jd" do
  it "determines the Julian day for a Date object" do
    Parsi::Date.civil(1391, 8, 7).jd.should == 2456229
  end
end

describe "Parsi::Date#to_gregorian" do
  it "converts date to Gregorian date" do
    date = Parsi::Date.civil(1391, 8, 7).to_gregorian
    date.should be_a(Date)
    date.should == Date.civil(2012, 10, 28)
  end
end

describe "Date#to_parsi" do
  it "converts date to Parsi date" do
    date = Date.civil(2012, 10, 28).to_parsi
    date.should be_a(Parsi::Date)
    date.should == Parsi::Date.civil(1391, 8, 7)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parsi-date-0.3.1 spec/parsi-date/conversion_spec.rb
parsi-date-0.3.0 spec/parsi-date/conversion_spec.rb