diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2017-01-07 01:12:54 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2017-01-07 01:12:54 -0500 |
commit | 7e138622129c96a634b41f99dc552015cbe4b5a6 (patch) | |
tree | 8975468b8f3a91edb24880150297d52805ec93f8 | |
parent | 90a45f9729f131569889f52cf792007f23df3949 (diff) |
Consistently use Time (rather than Date or DateTime).
-rw-r--r-- | README.org | 6 | ||||
-rw-r--r-- | lib/page.rb | 8 | ||||
-rw-r--r-- | lib/page_local.rb | 6 | ||||
-rw-r--r-- | lib/page_remote.rb | 4 | ||||
-rw-r--r-- | lib/sitegen.rb | 6 | ||||
-rwxr-xr-x | make | 2 |
6 files changed, 16 insertions, 16 deletions
@@ -61,8 +61,8 @@ generator: | html_head_extra | "" | Org-mode | string | | class | "" | no | string (CSS class to apply to ~<body>~) | | tags | "" | LaTeX, kinda[fn:1] | string ("ES HB") or list (["ES", "HB"]) | -| published[fn:2] | most recent git commit for file | no | string (Ruby ~Date.parse()~) or date[fn:3] | -| updated[fn:2] | first git commit for file | no | string (Ruby ~Date.parse()~) or date[fn:3] | +| published[fn:2] | most recent git commit for file | no | string (Ruby ~DateTime::parse()~) or date[fn:3] | +| updated[fn:2] | first git commit for file | no | string (Ruby ~DateTime::parse()~) or date[fn:3] | [fn:1] The ~tags~ attribute is normally a list, but because I don't know how to do a list in Org-mode, I made it take a @@ -76,7 +76,7 @@ with two distinct dates. [fn:3] At various times there have been bugs in the YAML parser library that Pandoc uses, causing it to fail to parse dates, so I just -always put the date in quotes now, and let Ruby ~Date.parse()~ take +always put the date in quotes now, and let Ruby ~DateTime::parse()~ take care of it. * Make targets diff --git a/lib/page.rb b/lib/page.rb index f269b75..130abdf 100644 --- a/lib/page.rb +++ b/lib/page.rb @@ -16,8 +16,8 @@ class Page # # def page_categories => String | Enumerable<String> # - # def page_published => DateTime | nil - # def page_updated => DateTime | nil + # def page_published => Time | nil + # def page_updated => Time | nil # def page_years => Enumerable<Fixnum> def atom_categories # => Enumerable<Category> @@ -31,7 +31,7 @@ class Page @categories end - def atom_published # => DateTime | nil + def atom_published # => Time | nil if @published.nil? unless page_published.nil? @published = page_published @@ -50,7 +50,7 @@ class Page @published end - def atom_updated # => DateTime | nil + def atom_updated # => Time | nil if @updated.nil? unless page_updated.nil? @updated = page_updated diff --git a/lib/page_local.rb b/lib/page_local.rb index ad4e970..7846a3b 100644 --- a/lib/page_local.rb +++ b/lib/page_local.rb @@ -69,13 +69,13 @@ class LocalPage < Page end def _gitdates - @gitdates ||= `git log --format='%cI' -- #{local_infile}`.split("\n").select{|s|!s.empty?}.map{|s|DateTime::iso8601(s)} + @gitdates ||= `git log --format='%cI' -- #{local_infile}`.split("\n").select{|s|!s.empty?}.map{|s|DateTime::iso8601(s).to_time} end def page_published if @_published.nil? raw = _pandoc['published'] - @_published = Datetime::parse(raw) unless raw.nil? + @_published = DateTime::parse(raw).to_time unless raw.nil? end if @_published.nil? @_published = _gitdates.sort.first @@ -86,7 +86,7 @@ class LocalPage < Page def page_updated if @_updated.nil? raw = _pandoc['updated'] - @_updated = DateTime::parse(raw) unless raw.nil? + @_updated = DateTime::parse(raw).to_time unless raw.nil? end if @_updated.nil? @updated = _gitdates.sort.last diff --git a/lib/page_remote.rb b/lib/page_remote.rb index 87f8207..5425944 100644 --- a/lib/page_remote.rb +++ b/lib/page_remote.rb @@ -38,7 +38,7 @@ class RemotePage < Page if str.nil? return nil end - return Date::parse(str) + return DateTime::parse(str).to_time end def page_updated @@ -46,7 +46,7 @@ class RemotePage < Page if str.nil? return nil end - return Date::parse(str) + return DateTime::parse(str).to_time end def page_years diff --git a/lib/sitegen.rb b/lib/sitegen.rb index c687375..c6e89e9 100644 --- a/lib/sitegen.rb +++ b/lib/sitegen.rb @@ -41,13 +41,13 @@ module Sitegen end def self.make(target) - newest = DateTime::new(0) + newest = Time::new(0) (dependencies[target] || []).each do |dep| - ts = dep.make(dep) + ts = make(dep) newest = ts if ts > newest end unless target.is_a?(String) - return DateTime::now + return Time::now end if File::exist?(target) ctime = File::ctime(target) @@ -17,4 +17,4 @@ end Sitegen::want('out/index.atom') # Make! -print Sitegen::make(:all) +Sitegen::make(:all) |