argus
December 2, 2019, 11:04am
1
i want to convert enclosure duration that i have in length
<enclosure length="70588566" type="audio/mpeg" url="http://traffic.libsyn.com/thewebplatform/TWPP-193.mp3" />
to something like that , duration 48:41
i have duration in params like that :
duration: 70588566
i have tried this but it didn’t work:
{{ $duration := .Params.duration }}
{{ time.ParseDuration $duration }}
ju52
December 2, 2019, 12:52pm
2
argus
December 2, 2019, 2:17pm
3
thanks for your reply, i have looked into that and i can’t find a way to make it work
argus
December 2, 2019, 3:07pm
5
i’ve seen that before posting here, the thing is that i have tried all what i have seen there and nothing seem to make it work , i’m new to Go so yeah!
Enclosure 'length'
is measured in bytes , not time
.
2 Likes
bep
December 3, 2019, 9:30am
7
ParseDuration parses a duration string (e.g. “30s”), which is the opposite of what you want
Try:
{{ 70588566 | time.Duration "ms" }}
Unit is one of nanosecond/ns, microsecond/us/µs, millisecond/ms, second/s, minute/m or hour/h.
@regis Duration and ParseDuration does not come up when searching from them in the docs site … hint …
2 Likes