Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matriphe/bedinde
Go package that provide basic formatting and function.
https://github.com/matriphe/bedinde
hacktoberfest
Last synced: about 2 months ago
JSON representation
Go package that provide basic formatting and function.
- Host: GitHub
- URL: https://github.com/matriphe/bedinde
- Owner: matriphe
- License: mit
- Created: 2018-05-13T10:34:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-22T16:09:15.000Z (over 6 years ago)
- Last Synced: 2024-10-12T11:44:53.691Z (3 months ago)
- Topics: hacktoberfest
- Language: Go
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bedinde
[![Build Status](https://travis-ci.org/matriphe/bedinde.svg?branch=master)](https://travis-ci.org/matriphe/bedinde)
**Bedinde** is Go package that provide basic formatting and function.
[The word *bedinde* in Indonesian means *helper*](https://kbbi.kemdikbud.go.id/entri/bedinde), so basically this is a helpers package.
## Installation
```shell
go get -u github.com/matriphe/bedinde
```## Function Lists
### InArray
Check if value is in array.
```go
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.
```go
r := bedinde.FormatNumber(12345, "id") // return "12.345"
r := bedinde.FormatNumber(12345, "en") // return "12,345"
```### FormatPhone
Format phone number to E164 standard.
```go
r := bedinde.FormatPhone("081823456789", "id") // return "+6281823456789"
r := bedinde.FormatPhone("081823456789", "sg") // return "+65081823456789"
```### FormatTimeDiff
Format time difference to its components.
```go
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`.
```go
r := bedinde.DateStringToTime("2018-05-22", "Asia/Jakarta") // return 2018-05-22 00:00:00 +0700 WIB
```### DatetimeStringToTime
Convert datetime string to `time.Time`.
```go
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](LICENSE) for more information.