Sha256: 891635ce7032c32a31343c64676e2c96f2851710adc0d37571188c3620d38571

Contents?: true

Size: 836 Bytes

Versions: 1

Compression:

Stored size: 836 Bytes

Contents

module TimeExtTool

  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

  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

  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
end

class Date
  include TimeExtTool
end

class DateTime
  include TimeExtTool
end

class Time
  include TimeExtTool
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
time_ext_tool-0.1.1 lib/time_ext_tool/time_core.rb