summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
authorAndrea Schiavini <andrea.schiavini@gmail.com>2012-02-13 12:46:46 +0100
committerJade Dominguez <plusjade@gmail.com>2012-03-01 03:38:08 -0800
commit2d629f296120ffd42c3ed5f4a1b94fff15b3204d (patch)
tree1d0abd5b9f5f9d3ea2e2bfb86fad91f3a9227170 /Rakefile
parent02e2f861e799310994e5dfd42df479a443d9e963 (diff)
Using Time.parse to ensure date format is valid
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile2
1 files changed, 1 insertions, 1 deletions
diff --git a/Rakefile b/Rakefile
index 7829d7c..65c2249 100644
--- a/Rakefile
+++ b/Rakefile
@@ -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'