diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index c56ec42e..6dc88f14 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -64,15 +64,14 @@ Given /^I have the following (draft|post)s?(?: (.*) "(.*)")?:$/ do |status, dire if "draft" == status path = File.join(before || '.', '_drafts', after || '.', "#{title}.#{ext}") else - date = if post['date'].split.size > 1 - parsed_date = DateTime.strptime(post['date'], '%Y-%m-%d %H:%M %z') - post['date'] = parsed_date.to_s - parsed_date.strftime('%Y-%m-%d') + format = if has_time_component?(post['date']) + '%Y-%m-%d %H:%M %z' else - parsed_date = Date.strptime(post['date'], '%m/%d/%Y') # WHY WOULD YOU EVER DO THIS - post['date'] = parsed_date.to_s - parsed_date.strftime('%Y-%m-%d') + '%m/%d/%Y' # why even end + parsed_date = DateTime.strptime(post['date'], format) + post['date'] = parsed_date.to_s + date = parsed_date.strftime('%Y-%m-%d') path = File.join(before || '.', '_posts', after || '.', "#{date}-#{title}.#{ext}") end diff --git a/features/support/env.rb b/features/support/env.rb index 8522fa7d..38bab950 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -17,5 +17,9 @@ def run_jekyll(opts = {}) system command end +def has_time_component?(date_string) + date_string.split(" ").size > 1 +end + # work around "invalid option: --format" cucumber bug (see #296) Test::Unit.run = true if RUBY_VERSION < '1.9'