timeperiod

package module
Version: v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2020 License: MIT Imports: 2 Imported by: 0

README

timeperiod

A GO (https://golang.org) package

Convert strings like "3m", "2w" and "5d" to seconds, milli-, micro- or nanoseconds

It returns an int value

Invalid strings will return 0 (zero)

If no unit is given it will assume that the value is in seconds

Units

ns // nanoseconds
us or µs // microseconds
ms // milliseconds
s // seconds
m // minutes
h // hours
d // days
w // weeks

Examples

timeperiod.Seconds("26w") // 15724800
timeperiod.Seconds("2d") // 172800
timeperiod.Seconds("5m") // 300
timeperiod.Milliseconds("5m") // 300000
timeperiod.Microconds("1h") // 3600000000
timeperiod.Nanoseconds("1us") // 1000

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Microseconds

func Microseconds(period string) int

func Milliseconds

func Milliseconds(period string) int

func Nanoseconds

func Nanoseconds(period string) int

func Seconds

func Seconds(period string) int

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL