Module: TimeCore

Included in:
ActiveSupport::TimeWithZone, Date, DateTime, Time
Defined in:
lib/coconut/time_core.rb

Instance Method Summary collapse

Instance Method Details

#to_full(is_text = false, need_year = true) ⇒ Object



15
16
17
18
19
# File 'lib/coconut/time_core.rb', line 15

def to_full(is_text = false, need_year = true)
  arr = ["%Y年", "%m月%d日 %T"]
  arr.delete_at(0) unless need_year
  is_text ? self.strftime(arr.join) : need_year ? self.strftime("%F %T") :self.strftime("%m-%d %T")
end

#to_long(is_text = false, need_year = true) ⇒ Object



9
10
11
12
13
# File 'lib/coconut/time_core.rb', line 9

def to_long(is_text = false, need_year = true)
  arr = ["%Y年", "%m月%d日 %R"]
  arr.delete_at(0) unless need_year
  is_text ? self.strftime(arr.join) : need_year ? self.strftime("%F %R") : self.strftime("%m-%d %R")
end

#to_short(is_text = false, need_year = true) ⇒ Object



3
4
5
6
7
# File 'lib/coconut/time_core.rb', line 3

def to_short(is_text = false, need_year = true)
  arr = ["%Y年", "%m月%d日"]
  arr.delete_at(0) unless need_year
  is_text ? self.strftime(arr.join) : need_year ? self.strftime("%F") : self.strftime("%m-%d") 
end