ytodo/humanTimeOutput.rb

30 lines
653 B
Ruby
Raw Permalink Normal View History

2009-06-08 14:56:37 +00:00
#!/usr/bin/env ruby
require 'time'
module HumanTimeOutput
def self.included(base)
base.class_eval do
alias_method :original_to_s, :to_s unless method_defined?(:original_to_s)
# alias_method :to_s, :to_s_humanized
end
end
2009-06-08 14:56:37 +00:00
def is_today?
selfTab=self.to_a
nowTab=Time.now.to_a
return selfTab[4] == nowTab[4] &&
selfTab[5] == nowTab[5] &&
selfTab[6] == nowTab[6]
2009-06-08 14:56:37 +00:00
end
def to_s_humanized
if self.is_today?
return "today"
else
self.original_to_s
end
2009-06-08 14:56:37 +00:00
end
end
Time.send :include, HumanTimeOutput
2009-06-08 14:56:37 +00:00