lib/drexed/datetime.rb in drexed-datetime-0.0.6 vs lib/drexed/datetime.rb in drexed-datetime-0.0.7

- old
+ new

@@ -1,29 +1,31 @@ require "drexed/datetime/version" module Drexed module Datetime - ## Time.datetime_to("yyyy-mm-dd") => "2012-03-04" - def datetime_to(tach) - delineators = tach.scan /\W+/ - formatters = tach.scan /[a-z]+/i - units = { "yy" => "y", - "yyyy" => "Y", - "m" => "-m", - "mm" => "m", - "M" => "b", - "MM" => "B", - "d" => "-d", - "dd" => "d", - "D" => "a", - "DD" => "A", - "h" => "-I", - "hh" => "I", - "H" => "-H", - "HH" => "H", - "mi" => "M", - "p" => "P", - "P" => "p" } - strftime(formatters.map{ |f| "%#{units[f]}#{delineators.shift || ""}" }.join) + class Engine < ::Rails::Engine + ## Time.datetime_to("yyyy-mm-dd") => "2012-03-04" + def datetime_to(tach) + delineators = tach.scan /\W+/ + formatters = tach.scan /[a-z]+/i + units = { "yy" => "y", + "yyyy" => "Y", + "m" => "-m", + "mm" => "m", + "M" => "b", + "MM" => "B", + "d" => "-d", + "dd" => "d", + "D" => "a", + "DD" => "A", + "h" => "-I", + "hh" => "I", + "H" => "-H", + "HH" => "H", + "mi" => "M", + "p" => "P", + "P" => "p" } + strftime(formatters.map{ |f| "%#{units[f]}#{delineators.shift || ""}" }.join) + end end end end