jekyll_time_since 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/jekyll_time_since/version.rb +1 -1
- data/lib/jekyll_time_since.rb +43 -41
- metadata +2 -3
- data/spec/status_persistence.txt +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e920db50f451b9b1633ec109d830d658463a77c205e5de7e5c79f46285b8cfe0
|
4
|
+
data.tar.gz: 4fa4443f9d98082b57dd37156d1239885faac75984fc16135c5c2a3d3939a6b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1db563761c609395688ffda42c028495e48f93008d405929183715065938008f5d592ece80140431602650630b139efa15066f72b7c93cb81832b19d6d9c72ed
|
7
|
+
data.tar.gz: e02291e860e2464dd135225a08de0747265cdd5db1a17ee2ce0f033ce43c76d70933d587757475e38049ca5df0f6a0ba8df16a5fc84a5114e5622e9976b5e709
|
data/CHANGELOG.md
CHANGED
data/lib/jekyll_time_since.rb
CHANGED
@@ -12,57 +12,59 @@ end
|
|
12
12
|
#
|
13
13
|
# Just a year can be specified, which implies Jan 1 at midnight.
|
14
14
|
# You can specify a time zone
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
module Jekyll
|
16
|
+
# For more information, see https://ruby-doc.org/stdlib-2.7.2/libdoc/time/rdoc/Time.html
|
17
|
+
module TimeSince
|
18
|
+
@logger = PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
20
|
+
# Filters a string containing a year, date or ISO_8601 datetime.
|
21
|
+
# @return [integer] the number of years since the input.
|
22
|
+
def years_since(string)
|
23
|
+
now = DateTime.now
|
24
|
+
string += '-01-01' unless string.include?('-')
|
25
|
+
date = Time.parse(string)
|
26
|
+
years = now.year - date.year
|
27
|
+
years -= 1 if date.month > now.month || (date.month >= now.month && date.day > now.day)
|
28
|
+
years
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
def months_since(string)
|
32
|
+
string += '-01-01' unless string.include?('-')
|
33
|
+
date1 = Date.parse(string)
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
date2 = Time.new.to_date
|
36
|
+
months = ((date2 - date1).to_f / 365 * 12).round
|
37
|
+
months -= 1 if date2.day > date1.day
|
38
|
+
months
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
def weeks_since(string)
|
42
|
+
result = days_since(string)
|
43
|
+
result.to_i / 7
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
def days_since(string)
|
47
|
+
string += '-01-01' unless string.include?('-')
|
48
|
+
date1 = Date.parse(string)
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
date2 = Time.new.to_date
|
51
|
+
(date2 - date1).to_i
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
def hours_since(string)
|
55
|
+
minutes_since(string) / 60
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
def minutes_since(string)
|
59
|
+
seconds_since(string) / 60
|
60
|
+
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
def seconds_since(string)
|
63
|
+
string += '-01-01' unless string.include?('-')
|
64
|
+
(Time.new - Time.parse(string)).to_i
|
65
|
+
end
|
64
66
|
end
|
65
67
|
end
|
66
68
|
|
67
69
|
PluginMetaLogger.instance.info { "Loaded #{JekyllTimeSinceName::PLUGIN_NAME} v#{JekyllTimeSinceVersion::VERSION} plugin." }
|
68
|
-
Liquid::Template.
|
70
|
+
Liquid::Template.register_filter(Jekyll::TimeSince)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_time_since
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Slinn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -58,7 +58,6 @@ files:
|
|
58
58
|
- lib/jekyll_time_since/version.rb
|
59
59
|
- spec/jekyll_time_since_spec.rb
|
60
60
|
- spec/spec_helper.rb
|
61
|
-
- spec/status_persistence.txt
|
62
61
|
homepage: https://www.mslinn.com/blog/2020/12/30/jekyll-plugin-template-collection.html
|
63
62
|
licenses:
|
64
63
|
- MIT
|
data/spec/status_persistence.txt
DELETED