I have this method in Rails and it works in the transmission parameter date_string, nil. In particular, when it GetFileInfo -dreturns nil.
What is the way Rails-y handle this?
def calling_method
...
m = MyModel.create(creation_date: cdate_for(path))
...
end
def cdate_for(path)
local_datetime_for(`GetFileInfo -d "#{path}"`.chomp!)
end
def local_datetime_for(date_string)
t = Time.strptime(date_string, '%m/%d/%Y %H:%M:%S')
DateTime.parse(t.to_s)
end
OK to return zero from this, assuming it Model.create(creation_date: return_value_here)can handle nil values.
Edit: Added some other methods to illustrate the call chain.
source
share