class RuboCop::Cop::Style::DateTime

something.to_time
# good
something.to_datetime
# good
@example AllowCoercion: true
something.to_time
# good - coerces to ‘Time`
something.to_datetime
# bad - coerces to `DateTime`
@example AllowCoercion: false (default)
DateTime.iso8601(’1751-04-23’, Date::ENGLAND)
# good - uses ‘DateTime` with start argument for historical date
Time.iso8601(’2016-06-29’)
# good - uses ‘Time` for modern date
DateTime.iso8601(’2016-06-29’)
# bad - uses ‘DateTime` for modern date
Time.now
# good - uses `Time` for current time
DateTime.now
# bad - uses `DateTime` for current time
@example
and/or DST.
replaceable in certain situations when dealing with multiple timezones
although highly overlapping, have particularities that make them not
`Time` class. This cop is disabled by default since these classes,
This cop checks for consistent usage of the `DateTime` class over the

def disallow_coercion?

def disallow_coercion?
  !cop_config['AllowCoercion']
end

def on_send(node)

def on_send(node)
  return unless date_time?(node) ||
                (to_datetime?(node) && disallow_coercion?)
  return if historic_date?(node)
  message = to_datetime?(node) ? COERCION_MSG : CLASS_MSG
  add_offense(node, message: message)
end