Sha256: b8fe4d40b96e7d9e760ac21bc12d10b55ba442d24df407f83ef1c6cfd305f330
Contents?: true
Size: 990 Bytes
Versions: 9
Compression:
Stored size: 990 Bytes
Contents
# frozen_string_literal: true module Timely module Date def at_time(hour = nil, minute = nil, second = nil) if hour.is_a?(::Time) time = hour hour = time.hour minute = time.min second = time.sec end ::Time.local(year, month, day, hour, minute, second) end alias at at_time # returns true if date between from and to # however if from and/or to are nil, it ignores that query # e.g. date.between?(from, nil) is "date > from", # date.between?(from, nil) is "date < to" # date.between?(nil, nil) is true def between?(from, to) from = from.to_date if from && !from.is_a?(Date) to = to.to_date if to && !to.is_a?(Date) if from && to self >= from && self <= to elsif from self >= from elsif to self <= to else true # i.e. no restrictive range return true end end end end class Date include Timely::Date end
Version data entries
9 entries across 9 versions & 1 rubygems