From 48880c01e480888db6b67b822c496b8ed6b9339e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Nieto?= <xiam@menteslibres.org>
Date: Sun, 16 Sep 2012 07:49:34 -0500
Subject: [PATCH] Time and date duration.

---
 db.go | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/db.go b/db.go
index 886408e2..6ad6a8ab 100644
--- a/db.go
+++ b/db.go
@@ -26,8 +26,8 @@ package db
 import (
 	"fmt"
 	"github.com/gosexy/sugar"
-	"strconv"
 	"regexp"
+	"strconv"
 	"strings"
 	"time"
 )
@@ -239,22 +239,22 @@ func (item Item) GetDuration(name string) time.Duration {
 	duration, _ := time.ParseDuration("0h0m0s")
 
 	switch item[name].(type) {
-		case time.Duration:
-			duration = item[name].(time.Duration)
-		case string:
-			var matched bool
-			var re *regexp.Regexp
-			value := item[name].(string)
-
-			matched, _ = regexp.MatchString(`^\d{2}:\d{2}:\d{2}$`, value)
-
-			if matched {
-				re, _ = regexp.Compile(`^(\d{2}):(\d{2}):(\d{2})$`)
-				all := re.FindAllStringSubmatch(value, -1)
-
-				formatted := fmt.Sprintf("%sh%sm%ss", all[0][1], all[0][2], all[0][3])
-				duration, _ = time.ParseDuration(formatted)
-			}
+	case time.Duration:
+		duration = item[name].(time.Duration)
+	case string:
+		var matched bool
+		var re *regexp.Regexp
+		value := item[name].(string)
+
+		matched, _ = regexp.MatchString(`^\d{2}:\d{2}:\d{2}$`, value)
+
+		if matched {
+			re, _ = regexp.Compile(`^(\d{2}):(\d{2}):(\d{2})$`)
+			all := re.FindAllStringSubmatch(value, -1)
+
+			formatted := fmt.Sprintf("%sh%sm%ss", all[0][1], all[0][2], all[0][3])
+			duration, _ = time.ParseDuration(formatted)
+		}
 	}
 	return duration
 }
-- 
GitLab