Method: Rsmart::ETL.parse_datetime

Defined in:
lib/rsmart_toolbox/etl.rb

.parse_datetime(str, opt = { valid_values: /^$|(\d{4}\-\d{2}\-\d{2}){1}\s(\d{2}:\d{2}:\d{2})?/ }) ⇒ String

Parse a SQL datetime from a String.

Parameters:

  • str (String)

    the String to be parsed.

  • opt (Hash) (defaults to: { valid_values: /^$|(\d{4}\-\d{2}\-\d{2}){1}\s(\d{2}:\d{2}:\d{2})?/ })

    options Hash will be passed through to #parse_string.

Returns:

  • (String)

    the parsed datetime. nil or empty inputs will return ” by default.

See Also:



296
297
298
299
# File 'lib/rsmart_toolbox/etl.rb', line 296

def self.parse_datetime(str, opt={ valid_values: /^$|(\d{4}\-\d{2}\-\d{2}){1}\s(\d{2}:\d{2}:\d{2})?/ })
  opt[:valid_values] = /^$|(\d{4}\-\d{2}\-\d{2}){1}\s(\d{2}:\d{2}:\d{2})?/ if opt[:valid_values].nil?
  return parse_string str, opt
end