Sha256: 87701de0b35f3424497ac9579e88770ee1ac220f067c8bdfbf6be046b1b38bb4

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require 'active_support/time_with_zone'
require 'working_hours/module'

module WorkingHours
  module CoreExt
    module DateAndTime

      def +(other)
        if (other.is_a?(WorkingHours::Duration))
          other.since(self)
        else
          super(other)
        end
      end

      def -(other)
        if (other.is_a?(WorkingHours::Duration))
          other.until(self)
        else
          super(other)
        end
      end

      def working_days_until(other)
        WorkingHours.working_days_between(self, other)
      end

      def working_time_until(other)
        WorkingHours.working_time_between(self, other)
      end

      def working_day?
        WorkingHours.working_day?(self)
      end

      def in_working_hours?
        WorkingHours.in_working_hours?(self)
      end
    end
  end
end

class Date
  prepend WorkingHours::CoreExt::DateAndTime
end

class DateTime
  prepend WorkingHours::CoreExt::DateAndTime
end

class Time
  prepend WorkingHours::CoreExt::DateAndTime
end

class ActiveSupport::TimeWithZone
  prepend WorkingHours::CoreExt::DateAndTime
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
working_hours-1.0.1 lib/working_hours/core_ext/date_and_time.rb
working_hours-1.0.0 lib/working_hours/core_ext/date_and_time.rb
working_hours-0.9.0 lib/working_hours/core_ext/date_and_time.rb