Skip to content

Commit

Permalink
Using Time.parse to ensure date format is valid
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Schiavini authored and plusjade committed Mar 1, 2012
1 parent 02e2f86 commit 2d629f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -45,7 +45,7 @@ task :post do
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts'])
title = ENV["title"] || "new-post"
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
date = ENV['date'] || Time.now.strftime('%Y-%m-%d')
date = (Time.parse(ENV['date']) || Time.now).strftime('%Y-%m-%d')
filename = File.join(CONFIG['posts'], "#{date}-#{slug}.#{CONFIG['post_ext']}")
if File.exist?(filename)
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
Expand Down

0 comments on commit 2d629f2

Please sign in to comment.