Skip to content

fernandoporazzi/parse-ms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parse-ms

Parse milliseconds into a struct

Install

$ go get -u github.com/fernandoporazzi/parse-ms

API

type ParsedMilliseconds

type ParsedMilliseconds struct {
	Days         int `json:"days"`
	Hours        int `json:"hours"`
	Minutes      int `json:"minutes"`
	Seconds      int `json:"seconds"`
	Milliseconds int `json:"milliseconds"`
	Microseconds int `json:"microseconds"`
	Nanoseconds  int `json:"nanoseconds"`
}

func Parse

func Parse(m float64) ParsedMilliseconds

Parse returns a struct of type ParsedMilliseconds based on the given float64 input.

Usage

package main

import (
	"encoding/json"
	"fmt"

	parsems "github.com/fernandoporazzi/parse-ms"
)

func main() {
	// struct output
	fmt.Println(parsems.Parse(60500.345678))

	// json output
	js, _ := json.Marshal(parsems.Parse(60500.345678))
	fmt.Println(string(js))
}

Related

  • pretty-milliseconds - Convert milliseconds to a human readable string: 1337000000 → 15d 11h 23m 20s

License

MIT License

About

Parse milliseconds into a detailed struct

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages