Skip to content

Instantly share code, notes, and snippets.

@neocsr
Created January 17, 2011 04:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neocsr/782490 to your computer and use it in GitHub Desktop.
Save neocsr/782490 to your computer and use it in GitHub Desktop.
Reading a file line by line and parsing each line.
require "date"
new_dates = File.open("new_dates.txt","w")
File.open("old_dates.txt","r") do |f|
while line = f.gets
newdate = DateTime.parse(line)
new_dates << newdate.strftime("%Y-%m-%d %H:%M:%S") << "\n"
end
end
new_dates.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment