bedinde

package module
v0.0.0-...-8061b6b Latest Latest
Warning

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

Go to latest
Published: May 22, 2018 License: MIT Imports: 7 Imported by: 0

README

Bedinde

Build Status

Bedinde is Go package that provide basic formatting and function.

The word bedinde in Indonesian means helper, so basically this is a helpers package.

Installation

go get -u github.com/matriphe/bedinde

Function Lists

InArray

Check if value is in array.

a := []string{"a", "b", "c", "d"}

exists, index := bedinde.InArray("c", a) // return true, 2
exists, index := bedinde.InArray("e", a) // return false, -1
FormatNumber

Format number using separator.

r := bedinde.FormatNumber(12345, "id") // return "12.345"
r := bedinde.FormatNumber(12345, "en") // return "12,345"
FormatPhone

Format phone number to E164 standard.

r := bedinde.FormatPhone("081823456789", "id") // return "+6281823456789"
r := bedinde.FormatPhone("081823456789", "sg") // return "+65081823456789"
FormatTimeDiff

Format time difference to its components.

d, _ := time.ParseDuration("2h3m4s")
r := bedinde.FormatTimeDiff(d) // return TimeDiff{Day: 0, Hour: 2, Minute: 3, Second: 4}
DateStringToTime

Convert date string to time.Time.

r := bedinde.DateStringToTime("2018-05-22", "Asia/Jakarta") // return 2018-05-22 00:00:00 +0700 WIB
DatetimeStringToTime

Convert datetime string to time.Time.

r := bedinde.DatetimeStringToTime("2018-05-22 22:40:26", "Asia/Jakarta") // return 2018-05-22 22:40:26 +0700 WIB

License

The MIT License (MIT). Please see License File for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateStringToTime

func DateStringToTime(s string, tz string) (time.Time, error)

func DatetimeStringToTime

func DatetimeStringToTime(s string, tz string) (time.Time, error)

func FormatNumber

func FormatNumber(number uint64, lang string) string

func FormatPhone

func FormatPhone(phone string, lang string) string

func InArray

func InArray(needle interface{}, haystack interface{}) (exists bool, index int)

Types

type TimeDiff

type TimeDiff struct {
	Day    uint64
	Hour   uint64
	Minute uint64
	Second uint64
}

func FormatTimeDiff

func FormatTimeDiff(diff time.Duration) TimeDiff

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL