#!/usr/bin/ruby #TODO: convert this to a date mixin #TODO: Rewrite this as native ruby #Specify the location of your date command. Should only be necessary on Windows. DATE="d:/cygwin/bin/date" if (DATE == nil) DATE=`which date` end def easy_date_time(line,sepa = ',') array = line.split(sepa, 4) array[0]=replace_easy_date(array[0]) array[1]=replace_easy_time(array[1]) array[2]=replace_easy_time(array[2]) array.join(',') end def replace_easy_date(easy) date_format(easy,"F") end def replace_easy_time(easy) date_format(easy,"R") end def date_format(easy,format) formatted = '' if (easy != '') cmd = "#{DATE} -d'" + easy + "' +%" + format formatted = `#{cmd}`.chop end return formatted end