Skip to content

Commit 2d629f2

Browse files
Andrea Schiaviniplusjade
authored andcommitted
Using Time.parse to ensure date format is valid
1 parent 02e2f86 commit 2d629f2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ task :post do
4545
abort("rake aborted: '#{CONFIG['posts']}' directory not found.") unless FileTest.directory?(CONFIG['posts'])
4646
title = ENV["title"] || "new-post"
4747
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
48-
date = ENV['date'] || Time.now.strftime('%Y-%m-%d')
48+
date = (Time.parse(ENV['date']) || Time.now).strftime('%Y-%m-%d')
4949
filename = File.join(CONFIG['posts'], "#{date}-#{slug}.#{CONFIG['post_ext']}")
5050
if File.exist?(filename)
5151
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'

0 commit comments

Comments
 (0)