lib/jekyll/post.rb in jekyll-2.2.0 vs lib/jekyll/post.rb in jekyll-2.3.0
- old
+ new
@@ -58,20 +58,20 @@
data.default_proc = proc do |hash, key|
site.frontmatter_defaults.find(File.join(dir, name), type, key)
end
- if data.has_key?('date')
- self.date = Time.parse(data["date"].to_s)
+ if data.key?('date')
+ self.date = Utils.parse_date(data["date"].to_s, "Post '#{relative_path}' does not have a valid date in the YAML front matter.")
end
populate_categories
populate_tags
end
def published?
- if data.has_key?('published') && data['published'] == false
+ if data.key?('published') && data['published'] == false
false
else
true
end
end
@@ -157,20 +157,13 @@
# name - The String filename of the post file.
#
# Returns nothing.
def process(name)
m, cats, date, slug, ext = *name.match(MATCHER)
- self.categories ||= []
- self.categories += (cats || '').downcase.split('/')
- self.date = Time.parse(date)
+ self.date = Utils.parse_date(date, "Post '#{relative_path}' does not have a valid date in the filename.")
self.slug = slug
self.ext = ext
- rescue ArgumentError
- path = File.join(@dir || "", name)
- msg = "Post '#{path}' does not have a valid date.\n"
- msg << "Fix the date, or exclude the file or directory from being processed"
- raise Errors::FatalException.new(msg)
end
# The generated directory into which the post will be placed
# upon generation. This is derived from the permalink or, if
# permalink is absent, set to the default date
@@ -221,11 +214,11 @@
{
:year => date.strftime("%Y"),
:month => date.strftime("%m"),
:day => date.strftime("%d"),
:title => slug,
- :i_day => date.strftime("%d").to_i.to_s,
- :i_month => date.strftime("%m").to_i.to_s,
+ :i_day => date.strftime("%-d"),
+ :i_month => date.strftime("%-m"),
:categories => (categories || []).map { |c| c.to_s }.join('/'),
:short_month => date.strftime("%b"),
:short_year => date.strftime("%y"),
:y_day => date.strftime("%j"),
:output_ext => output_ext