An open API service indexing awesome lists of open source software.

https://github.com/ppalone/duration-parser


https://github.com/ppalone/duration-parser

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# Duration Parser

A small golang library to parse YouTube video duration format (eg `DD:HH:MM:SS`)

## How to get?

```
go get github.com/ppalone/duration-parser
```

## Format

YouTube video duration format is `DD:HH:MM:SS` (For example `01:10:45:01`)

```
DD: Days
HH: Hours (must be less than or equal to 23)
MM: Minutes (must be less than or equal to 59)
SS: Seconds (must be less than or equal to 59)
```

## Usage

```go
package main

import (
"fmt"

parser "github.com/ppalone/duration-parser"
)

func main() {
s := "01:30"
d, _ := parser.Parse(s)
fmt.Println("Duration in seconds:", d.Seconds())
}
```