Sha256: eca004cd4bdec624fb4ff0690cdcaaec5688feafc82e9fad4bb50b19a3461e40

Contents?: true

Size: 1.43 KB

Versions: 22

Compression:

Stored size: 1.43 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe "fos_dates" do

  it "Time and DateTime have instance methods included from TimeFunctions" do
    Time.new.should respond_to(:as_minutes)
    DateTime.new.should respond_to(:as_minutes)
  end

  it "Date class to_fos_days converts date to days since epoch" do
    Date.new(1900,1,10).to_fos_days.should == 10
  end

  it "Time class to_fos_days converts time to to days since epoch" do
    DateTime.new(1900,1,10,0,0,0).to_time.to_fos_days.should == 10
  end

  it "converts fos date number to a Ruby Date" do
    Date.from_fos_days(10).should == Date.new(1900,1,10)
  end

  it "converts fos time number of 0 to a DateTime of (1902,1,1)" do
    Time.from_fos_time(0).should == DateTime.new(2000,1,1,0,0,0).to_time
  end

  it "converts fos time number to a Ruby DateTime" do
    Time.from_fos_time(100).should == DateTime.new(2000,1,1,1,40,0).to_time
  end

  it "converts a Ruby Time to hundredths" do
    Time.from_fos_time(100).in_hundredths.should ==  "1.66"
  end

  it "Date view defaults to y-m-d" do
    Date.parse('Sept 9, 2009').to_s.should == "2009-09-09"
  end

  it "Time view defaults to M:H" do
    Time.parse('Sept 9, 2009 07:10').to_s.should == "07:10"
  end

  it "DateTime has long_view method that makes long formatted string" do
    tl = TripLeg.new(:dept_date_gmt=>40209, :etd_gmt=>100)
    tl.planned_departure_date_time_gmt__long_view.should == "February 01, 2010 01:40"
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
fossil-0.4.26 spec/sequel/fos_dates_spec.rb
fossil-0.4.25 spec/sequel/fos_dates_spec.rb
fossil-0.4.24 spec/sequel/fos_dates_spec.rb
fossil-0.4.23 spec/sequel/fos_dates_spec.rb
fossil-0.4.22 spec/sequel/fos_dates_spec.rb
fossil-0.4.20 spec/sequel/fos_dates_spec.rb
fossil-0.4.19 spec/sequel/fos_dates_spec.rb
fossil-0.4.18 spec/sequel/fos_dates_spec.rb
fossil-0.4.17 spec/sequel/fos_dates_spec.rb
fossil-0.4.16 spec/sequel/fos_dates_spec.rb
fossil-0.4.15 spec/sequel/fos_dates_spec.rb
fossil-0.4.14 spec/sequel/fos_dates_spec.rb
fossil-0.4.13 spec/sequel/fos_dates_spec.rb
fossil-0.4.12 spec/sequel/fos_dates_spec.rb
fossil-0.4.10 spec/sequel/fos_dates_spec.rb
fossil-0.4.9 spec/sequel/fos_dates_spec.rb
fossil-0.4.8 spec/sequel/fos_dates_spec.rb
fossil-0.4.7 spec/sequel/fos_dates_spec.rb
fossil-0.4.6 spec/sequel/fos_dates_spec.rb
fossil-0.4.5 spec/sequel/fos_dates_spec.rb