Module: EasyFormat::DateTime

Defined in:
lib/easy_format/date_time.rb

Class Method Summary collapse

Class Method Details

.hhmmss(time = Time.now) ⇒ Object



15
16
17
18
19
# File 'lib/easy_format/date_time.rb', line 15

def hhmmss(time = Time.now)
  log_deprecation('EasyFormat::DateTime', __method__)
  time = ::Time.parse(time) unless time.is_a?(Time)
  time.strftime('%H%M%S')
end

.log_deprecation(namespace, method_name) ⇒ Object



5
6
7
# File 'lib/easy_format/date_time.rb', line 5

def log_deprecation(namespace, method_name)
  EasyIO.logger.warn "#{namespace}.#{method_name} is deprecated! Use EasyTime.#{method_name} instead (require 'easy_time')!"
end

.yyyymmdd(date = Time.now) ⇒ Object



9
10
11
12
13
# File 'lib/easy_format/date_time.rb', line 9

def yyyymmdd(date = Time.now)
  log_deprecation('EasyFormat::DateTime', __method__)
  date = ::Time.parse(date) unless date.is_a?(Time)
  date.strftime('%Y%m%d')
end

.yyyymmdd_hhmmss(date_and_time = Time.now) ⇒ Object



21
22
23
24
25
# File 'lib/easy_format/date_time.rb', line 21

def yyyymmdd_hhmmss(date_and_time = Time.now)
  log_deprecation('EasyFormat::DateTime', __method__)
  date_and_time = ::Time.parse(date_and_time) unless date_and_time.is_a?(Time)
  date_and_time.strftime('%Y%m%d_%H%M%S')
end