Class: DateTimeFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/shellutils/date_time_formatter.rb

Instance Method Summary collapse

Instance Method Details

#format(time = Time.new) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/shellutils/date_time_formatter.rb', line 3

def format time=Time.new
year = format_to_length time.year, 4
month = format_to_length time.month, 2
day = format_to_length time.day, 2
hour = format_to_length time.hour, 2
minute = format_to_length time.min, 2
second = format_to_length time.sec, 2
  "#{year}-#{month}-#{day}_#{hour}-#{minute}-#{second}"
end