From be2a4d84fd9be0de8c2d6db0f1f2b5b8619cc278 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Wed, 14 Mar 2018 11:43:59 +0100 Subject: [PATCH] Create TimeHelper module --- app/helpers/time_helper.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 app/helpers/time_helper.rb diff --git a/app/helpers/time_helper.rb b/app/helpers/time_helper.rb new file mode 100644 index 00000000..ed05ede5 --- /dev/null +++ b/app/helpers/time_helper.rb @@ -0,0 +1,12 @@ +module TimeHelper + + # convert timestamps ('12:34:56.789') to seconds + def time_to_f(timestamp) + unless timestamp.nil? + timestamp = timestamp.split(':') + return timestamp[0].to_i * 60 * 60 + timestamp[1].to_i * 60 + timestamp[2].to_f + end + nil + end + +end