Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
pooza committed May 11, 2024
1 parent 02279ed commit f352eab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ginseng/refines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ def self.key_flatten(prefix, node)
end
end

class ::Time
def today?
return strftime('%Y/%m/%d') == Date.today.strftime('%Y/%m/%d')
end
end

class ::NilClass
def empty?
return true
Expand Down
9 changes: 9 additions & 0 deletions test/time_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Ginseng
class TimeTest < TestCase
def test_today?
assert_false(Time.parse('2000/01/01 00:00').today?)
assert_false(Time.parse('1970/01/01 00:00').today?)
assert_predicate(Time.now, :today?)
end
end
end

0 comments on commit f352eab

Please sign in to comment.