From 8a7ecfce36457fef52a792f52b9cad4587e214a1 Mon Sep 17 00:00:00 2001 From: Grzegorz Kaczorek Date: Mon, 24 Sep 2018 18:31:36 +0200 Subject: [PATCH] Document two methods, simplify one of the methods (#7270) Merge pull request 7270 --- lib/jekyll/document.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/document.rb b/lib/jekyll/document.rb index 5179b44d..851e3498 100644 --- a/lib/jekyll/document.rb +++ b/lib/jekyll/document.rb @@ -60,12 +60,19 @@ module Jekyll data end + # Returns the document date. If metadata is not present then calculates it + # based on Jekyll::Site#time or the document file modification time. + # + # Return document date string. def date data["date"] ||= (draft? ? source_file_mtime : site.time) end + # Return document file modification time in the form of a Time object. + # + # Return document file modification Time object. def source_file_mtime - @source_file_mtime ||= File.mtime(path) + File.mtime(path) end # Returns whether the document is a draft. This is only the case if