summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--time/time.go2
-rw-r--r--time/time_test.go12
2 files changed, 7 insertions, 7 deletions
diff --git a/time/time.go b/time/time.go
index 97bd3d5..a7821d9 100644
--- a/time/time.go
+++ b/time/time.go
@@ -18,7 +18,7 @@ var durationRegex = regexp.MustCompile(`PT(([0-9]{0,2})?H)?(([0-9]{0,2})?M)?(([0
// Recognizes durations in this format: PT3H4M60S
//
// [1]: https://en.wikipedia.org/wiki/ISO_8601#Durations
-func durationToSeconds(duration string) (int, error) {
+func Duration(duration string) (int, error) {
m := durationRegex.FindStringSubmatch(duration)
if m == nil || len(m) == 0 {
return 0, fmt.Errorf("duration invalid: %v", duration)
diff --git a/time/time_test.go b/time/time_test.go
index d55783e..48ef75e 100644
--- a/time/time_test.go
+++ b/time/time_test.go
@@ -6,7 +6,7 @@ package time
import "testing"
func TestDurationToSeconds(t *testing.T) {
- secs, err := durationToSeconds("PT3H4M60S")
+ secs, err := Duration("PT3H4M60S")
if err != nil {
t.Errorf("failed: %v", err)
return
@@ -16,7 +16,7 @@ func TestDurationToSeconds(t *testing.T) {
return
}
- secs, err = durationToSeconds("PT4M60S")
+ secs, err = Duration("PT4M60S")
if err != nil {
t.Errorf("failed: %v", err)
return
@@ -26,7 +26,7 @@ func TestDurationToSeconds(t *testing.T) {
return
}
- secs, err = durationToSeconds("PT12H")
+ secs, err = Duration("PT12H")
if err != nil {
t.Errorf("failed: %v", err)
return
@@ -36,7 +36,7 @@ func TestDurationToSeconds(t *testing.T) {
return
}
- secs, err = durationToSeconds("PT1H")
+ secs, err = Duration("PT1H")
if err != nil {
t.Errorf("failed: %v", err)
return
@@ -46,7 +46,7 @@ func TestDurationToSeconds(t *testing.T) {
return
}
- secs, err = durationToSeconds("PT2H")
+ secs, err = Duration("PT2H")
if err != nil {
t.Errorf("failed: %v", err)
return
@@ -56,7 +56,7 @@ func TestDurationToSeconds(t *testing.T) {
return
}
- secs, err = durationToSeconds("PT45M")
+ secs, err = Duration("PT45M")
if err != nil {
t.Errorf("failed: %v", err)
return