lib/timespan/printer.rb in timespan-0.5.1 vs lib/timespan/printer.rb in timespan-0.5.2
- old
+ new
@@ -14,17 +14,21 @@
# %~s, %~m, %~h, %~d and %~w
#
# %td => total days
# %th => total hours
# %tm => total minutes
- # %ts => total seconds
+ # %ts => total seconds
def to_s mode = :full
meth = "print_#{mode}"
raise ArgumentError, "Print mode not supported, was: #{mode}" unless respond_to?(meth)
send(meth)
end
+ def to_str
+ to_s
+ end
+
def print_dates
"#{i18n_t 'from'} #{print :start_time} #{i18n_t 'to'} #{print :end_time}"
end
def print_duration
@@ -42,9 +46,12 @@
end
def print type
return duration.format(duration_format) if type == :duration
raise ArgumentError, "Not a valid print type, was: #{type}" unless valid_print_type? type
+
+ return "ASAP" if type == :start_time && asap?
+
send(type).strftime(time_format)
end
def valid_print_type? type
%w{start_time end_time}.include? type.to_s
\ No newline at end of file