lib/makit/humanize.rb in makit-0.0.21 vs lib/makit/humanize.rb in makit-0.0.22
- old
+ new
@@ -12,10 +12,15 @@
size = bytes.to_f / (1024 ** exp)
format("%.#{precision}f %s", size, units[exp])
end
+ def self.get_humanized_timestamp(timestamp)
+ return timestamp.strftime("%Y-%m-%d %I:%M:%S %p") if timestamp.respond_to?(:strftime)
+ timestamp.strftime("%Y-%m-%d %H:%M:%S")
+ end
+
def self.get_make_result_summary(make_result)
summary = "Make Result\n"
summary += " Repository: #{make_result.repository}\n"
summary += " Commit: #{make_result.commit}\n"
summary += " Branch: #{make_result.branch}\n"
@@ -86,21 +91,21 @@
"#{hours}h #{minutes}m #{seconds}s"
end
def self.get_humanized_duration(seconds)
minutes = (seconds / 60).to_i
- seconds = (seconds % 60).to_i
- hours = (minutes / 60).to_i
- minutes = minutes % 60
- days = (hours / 24).to_i
- hours = hours % 24
+ seconds = (seconds % 60).to_i
+ hours = (minutes / 60).to_i
+ minutes = minutes % 60
+ days = (hours / 24).to_i
+ hours = hours % 24
- parts = []
- parts << "#{days} days" if days > 0
- parts << "#{hours} hours" if hours > 0
- parts << "#{minutes} minutes" if minutes > 0
- parts << "#{seconds} seconds" if seconds > 0
+ parts = []
+ parts << "#{days} days" if days > 0
+ parts << "#{hours} hours" if hours > 0
+ parts << "#{minutes} minutes" if minutes > 0
+ parts << "#{seconds} seconds" if seconds > 0
- parts.join(", ")
+ parts.join(", ")
end
end
end