Method: Lotus::Utils::Kernel.DateTime
- Defined in:
- lib/lotus/utils/kernel.rb
.DateTime(arg) ⇒ DateTime
Coerces the argument to be a DateTime.
794 795 796 797 798 799 800 801 802 803 |
# File 'lib/lotus/utils/kernel.rb', line 794 def self.DateTime(arg) case arg when ->(a) { a.respond_to?(:to_datetime) } then arg.to_datetime when Numeric then DateTime(Time.at(arg)) else DateTime.parse(arg.to_s) end rescue ArgumentError, NoMethodError raise TypeError.new "can't convert #{inspect_type_error(arg)}into DateTime" end |