Module: TimeReceive::ClassMethods
- Included in:
- TimeReceive
- Defined in:
- lib/time_receive.rb
Instance Method Summary collapse
Instance Method Details
#now(format_string = nil) ⇒ Object
19 20 21 22 |
# File 'lib/time_receive.rb', line 19 def now(format_string = nil) formatter = format_string ? TimeFormatter.new(format_string) : TimeFormatter.new("%Y-%m-%d %H:%M:%S") formatter.format(Time.now) end |
#parse_time(time_string, format_string) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/time_receive.rb', line 24 def parse_time(time_string, format_string) begin Time.strptime(time_string, format_string) rescue ArgumentError raise TimeReceiveError, "Invalid time string: #{time_string}" end end |