ruby - string in ddmmyyyy format to to date -
i have folder contains bunch of folders naming convention of mmddyyyy
(for example 04102013
, 04092013
, etc.). have text file contains these paths , have programed in ruby array strips out path left date (however believe stored sting).
what need take dates in array , add amount of days them. amount of days static , same value needs applied across board in array. on 8th line getting invalid date (argumenterror
). end result needs array +7 days every item in array. right can't values date format.
require 'date' myarray = io.readlines "/path/to/myfile.txt" myarray.each |s| s.gsub!('/path/to/my/dated/folders/', '') end print myarray myarray.map! {date.strptime("%m%d%y")} # myarray.map! {+(7)} print myarray
try:
myarray.map!{|s| date.strptime(s, '%m%d%y') + 7}
Comments
Post a Comment