Sha256: e559e4895345ab4fe9f6eaa44d6a9a5ef63c150531c92aa4e63c3b4291208cf2

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require_relative '../test_helper'

class TimeCalculationsTest < Minitest::Test
  context "beginning_of_hour" do
    Time.zone = 'Pacific Time (US & Canada)'
    [
      Time.now,
      Time.zone.now,
      Time.local(2009),
      Time.local(2009,3,4,5),
      Time.local(2001,12,31,23,59),
      Time.local(1970,1,1)
    ].each_with_index do |time, index|
      should "give back a time with no minutes, seconds, or msec: #{time} (#{index})" do
        t = time.beginning_of_hour
        assert_equal t.year,  time.year
        assert_equal t.month, time.month
        assert_equal t.day,   time.day
        assert_equal t.hour,  time.hour
        assert_equal 0, t.min
        assert_equal 0, t.sec
        assert_equal 0, t.usec
      end
    end
  end

  context "end_of_day_whole_sec" do
    should "return the end of day with whole_sec" do
      t = Time.now
      end_of_day = t.end_of_day
      end_whole_sec = t.end_of_day_whole_sec
      assert_equal 0.0, end_whole_sec.usec
      assert_equal end_of_day.to_i, end_whole_sec.to_i
      assert_equal end_of_day.sec, end_whole_sec.sec
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
invoca-utils-0.4.1 test/unit/time_calculations_test.rb
invoca-utils-0.4.0 test/unit/time_calculations_test.rb
invoca-utils-0.3.0 test/unit/time_calculations_test.rb
invoca-utils-0.2.0 test/unit/time_calculations_test.rb
invoca-utils-0.2.0.pre.1 test/unit/time_calculations_test.rb
invoca-utils-0.1.1 test/unit/time_calculations_test.rb
invoca-utils-0.1.0 test/unit/time_calculations_test.rb