Sha256: 357c4a5fa1288d85786ad71a0229096dbc08b8db0f3341bcadd25341f1ba536a

Contents?: true

Size: 1.55 KB

Versions: 28

Compression:

Stored size: 1.55 KB

Contents

require 'test_helper'

# This tests our Ourtime class
class OurtimeTest < Minitest::Test
  def test_initialize_with_local_format_string_gmt
    # Creating an Ourtime from a local-format String (with seconds)
    ot = Ourtime.new('01.02.1993 04:05:06')
    assert_equal '1993-02-01 04:05:06', ot.thetime.strftime('%Y-%m-%d %H:%M:%S')
    assert_kind_of Time, ot.thetime
    assert_equal 0.hours, ot.thetime.gmt_offset
  end

  def test_initialize_with_local_format_string_bst
    # Creating an Ourtime from a local-format String (with seconds)
    ot = Ourtime.new('01.08.1993 04:05:06')
    assert_equal '1993-08-01 04:05:06', ot.thetime.strftime('%Y-%m-%d %H:%M:%S')
    assert_kind_of Time, ot.thetime
    assert_equal 1.hours, ot.thetime.gmt_offset
  end

  def test_initialize_with_time
    # Creating an Ourtime from a Time
    ot = Ourtime.new(Time.mktime(1993, 2, 1, 4, 5))
    assert_equal '01.02.1993 04:05', ot.to_s
    assert_equal 0.hours, ot.thetime.gmt_offset
  end

  def test_initialize_with_no_parameters
    assert Ourtime.new.blank?  # delegates to empty?
  end

  def test_initialize_with_iso_string_bst
    # Parsing an ISO datetime
    ot = Ourtime.new('1993-05-05 06:07:08')
    assert_equal '1993-05-05 06:07:08', ot.thetime.strftime('%Y-%m-%d %H:%M:%S')
    assert_equal 1.hours, ot.thetime.gmt_offset
  end

  def test_initialize_with_iso_string_gmt
    # Parsing an ISO datetime
    ot = Ourtime.new('1993-01-05 06:07:08')
    assert_equal '1993-01-05 06:07:08', ot.thetime.strftime('%Y-%m-%d %H:%M:%S')
    assert_equal 0.hours, ot.thetime.gmt_offset
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
ndr_support-5.10.4 test/ourtime_test.rb
ndr_support-5.10.3 test/ourtime_test.rb
ndr_support-5.10.2 test/ourtime_test.rb
ndr_support-5.10.1 test/ourtime_test.rb
ndr_support-5.10.0 test/ourtime_test.rb
ndr_support-5.9.7 test/ourtime_test.rb
ndr_support-5.9.6 test/ourtime_test.rb
ndr_support-5.9.5 test/ourtime_test.rb
ndr_support-5.9.4 test/ourtime_test.rb
ndr_support-5.9.3 test/ourtime_test.rb
ndr_support-5.9.2 test/ourtime_test.rb
ndr_support-5.9.1 test/ourtime_test.rb
ndr_support-5.9.0 test/ourtime_test.rb
ndr_support-5.8.4 test/ourtime_test.rb
ndr_support-5.8.3 test/ourtime_test.rb
ndr_support-5.8.2 test/ourtime_test.rb
ndr_support-5.8.1 test/ourtime_test.rb
ndr_support-5.8.0 test/ourtime_test.rb
ndr_support-5.7.1 test/ourtime_test.rb
ndr_support-5.7.0 test/ourtime_test.rb