Methods
Public Instance methods
Overriding case equality method so that it returns true for ActiveSupport::TimeWithZone instances
[ show source ]
# File activesupport/lib/active_support/core_ext/time/calculations.rb, line 30 30: def ===(other) 31: other.is_a?(::Time) 32: end
Return the number of days in the given month. If no year is specified, it will use the current year.
[ show source ]
# File activesupport/lib/active_support/core_ext/time/calculations.rb, line 36 36: def days_in_month(month, year = now.year) 37: return 29 if month == 2 && ::Date.gregorian_leap?(year) 38: COMMON_YEAR_DAYS_IN_MONTH[month] 39: end
Wraps class method time_with_datetime_fallback with utc_or_local set to :local.
[ show source ]
# File activesupport/lib/active_support/core_ext/time/calculations.rb, line 57 57: def local_time(*args) 58: time_with_datetime_fallback(:local, *args) 59: 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
[ show source ]
# File activesupport/lib/active_support/core_ext/time/calculations.rb, line 44 44: def time_with_datetime_fallback(utc_or_local, year, month=1, day=1, hour=0, min=0, sec=0, usec=0) 45: ::Time.send(utc_or_local, year, month, day, hour, min, sec, usec) 46: rescue 47: offset = utc_or_local.to_sym == :local ? ::DateTime.local_offset : 0 48: ::DateTime.civil(year, month, day, hour, min, sec, offset) 49: end
Wraps class method time_with_datetime_fallback with utc_or_local set to :utc.
[ show source ]
# File activesupport/lib/active_support/core_ext/time/calculations.rb, line 52 52: def utc_time(*args) 53: time_with_datetime_fallback(:utc, *args) 54: end