Module | ActiveSupport::CoreExtensions::Time::Calculations::ClassMethods |
In: |
vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb
|
Overriding case equality method so that it returns true for ActiveSupport::TimeWithZone instances
# File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 28 28: def ===(other) 29: other.is_a?(::Time) 30: end
Return the number of days in the given month. If no year is specified, it will use the current year.
# File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 34 34: def days_in_month(month, year = now.year) 35: return 29 if month == 2 && ::Date.gregorian_leap?(year) 36: COMMON_YEAR_DAYS_IN_MONTH[month] 37: end
Wraps class method time_with_datetime_fallback with utc_or_local set to :local.
# File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 55 55: def local_time(*args) 56: time_with_datetime_fallback(:local, *args) 57: end
Returns a new Time if requested year can be accommodated by Ruby‘s Time class (i.e., if year is within either 1970..2038 or 1902..2038, depending on system architecture); otherwise returns a DateTime
# File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 42 42: def time_with_datetime_fallback(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0, usec=0) 43: ::Time.send(utc_or_local, year, month, day, hour, min, sec, usec) 44: rescue 45: offset = utc_or_local.to_sym == :local ? ::DateTime.local_offset : 0 46: ::DateTime.civil(year, month, day, hour, min, sec, offset) 47: end
Wraps class method time_with_datetime_fallback with utc_or_local set to :utc.
# File vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb, line 50 50: def utc_time(*args) 51: time_with_datetime_fallback(:utc, *args) 52: end