safai 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/safai.rb +1 -0
  2. data/lib/safai/date.rb +27 -0
  3. metadata +2 -1
data/lib/safai.rb CHANGED
@@ -122,5 +122,6 @@ require 'safai/regex'
122
122
  require 'safai/clean'
123
123
  require 'safai/gravatar'
124
124
  require 'safai/money'
125
+ require 'safai/date'
125
126
  ActionView::Base.send :include, Safai::Helpers
126
127
  ActionView::Base.send :include, Safai::DeviseHelpers
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.10
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: