Skip to content

Commit f5cce45

Browse files
authored
Merge pull request #65 from zencoder/ParseDuration
Expose a useful function
2 parents f9ad615 + 82a5594 commit f5cce45

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

mpd/duration.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (d Duration) MarshalXMLAttr(name xml.Name) (xml.Attr, error) {
3131
}
3232

3333
func (d *Duration) UnmarshalXMLAttr(attr xml.Attr) error {
34-
dur, err := parseDuration(attr.Value)
34+
dur, err := ParseDuration(attr.Value)
3535
if err != nil {
3636
return err
3737
}
@@ -153,7 +153,7 @@ func fmtInt(buf []byte, v uint64) int {
153153
return w
154154
}
155155

156-
func parseDuration(str string) (time.Duration, error) {
156+
func ParseDuration(str string) (time.Duration, error) {
157157
if len(str) < 3 {
158158
return 0, errors.New("At least one number and designator are required")
159159
}

mpd/duration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestParseDuration(t *testing.T) {
3636
"PT1004199059S": (1004199059 * time.Second).Seconds(),
3737
}
3838
for ins, ex := range in {
39-
act, err := parseDuration(ins)
39+
act, err := ParseDuration(ins)
4040
require.NoError(t, err, ins)
4141
require.EqualFloat64(t, ex, act.Seconds(), ins)
4242
}
@@ -54,7 +54,7 @@ func TestParseBadDurations(t *testing.T) {
5454
"-P20H": `Duration cannot be negative`, // Negative duration doesn't make sense
5555
}
5656
for ins, msg := range in {
57-
_, err := parseDuration(ins)
57+
_, err := ParseDuration(ins)
5858
require.EqualError(t, err, msg, fmt.Sprintf("Expected an error for: %s", ins))
5959
}
6060
}

0 commit comments

Comments
 (0)