Rails' ActiveSupport module extends the builtin ruby Time class with a number of methods.
Notably, there is the to_formatted_s
method, which lets you write Time.now.to_formatted_s(:db)
to get a string in Database format, rather than having to write ugly strftime
format-strings everywhere.
My question is, is there a way to go backwards?
Something like Time.parse_formatted_s(:db)
which would parse a string in Database format, returning a new Time object. This seems like something that rails should be providing, but if it is, I can't find it.
Am I just not able to find it, or do I need to write it myself?
Thanks