safai 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/safai.rb +1 -0
- data/lib/safai/date.rb +27 -0
- metadata +2 -1
data/lib/safai.rb
CHANGED
data/lib/safai/date.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
class Safai::Date
|
2
|
+
|
3
|
+
def self.smart_due_date(i)
|
4
|
+
if i == nil
|
5
|
+
return ""
|
6
|
+
elsif i.class.to_s == "Time" or i.class.to_s == "ActiveSupport::TimeWithZone"
|
7
|
+
i = i.to_date
|
8
|
+
i_display = i.year == Time.now.year ? i.strftime("%d-%b") : i.strftime("%d-%b-%Y")
|
9
|
+
end
|
10
|
+
if Date.today == i
|
11
|
+
return "<span style=\"background-color:#F7FAB9;padding:0px 2px 0px 2px;\">Today</span>"
|
12
|
+
elsif i - Date.today == 1
|
13
|
+
return "<span style=\"background-color:#F7FAB9;padding:0px 2px 0px 2px;\">Tomorrow</span>"
|
14
|
+
elsif Date.today - i > 0.9
|
15
|
+
return "<span style=\"background-color:#FFC7C7;padding:0px 2px 0px 2px;\">" + i_display + "</span>"
|
16
|
+
elsif Date.today - i < 1
|
17
|
+
return "<span style=\"background-color:#D2FFCC;padding:0px 2px 0px 2px;\">" + i_display + "</span>"
|
18
|
+
end
|
19
|
+
return i_display
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.smart_date(i)
|
23
|
+
return "" if i.blank?
|
24
|
+
i.year == Time.now.year ? i.strftime("%d-%b") : i.strftime("%d-%b-%Y")
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- lib/safai/clean.rb
|
57
57
|
- lib/safai/gravatar.rb
|
58
58
|
- lib/safai/money.rb
|
59
|
+
- lib/safai/date.rb
|
59
60
|
homepage: http://rubygems.org/gems/safai
|
60
61
|
licenses: []
|
61
62
|
post_install_message:
|