Module: ScoutAgent::CoreExtensions::TimeClass

Defined in:
lib/scout_agent/core_extensions.rb

Overview

Class extensions for Time.

Instance Method Summary collapse

Instance Method Details

#from_db_s(str) ⇒ Object

Converts a String (str) in the form "NNNN-NN-NN NN:NN" or "NNNN-NN-NN NN:NN:NN" into a proper Time object.



269
270
271
272
273
# File 'lib/scout_agent/core_extensions.rb', line 269

def from_db_s(str)
  if str and str.to_s =~ /\A\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}(?::\d{2})?\z/
    ::Time.local(*str.to_s.scan(/\d+/))
  end
end