birthday

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2020 License: MIT Imports: 3 Imported by: 0

README

birthday

GoDoc Build Status codecov Release

Parse a birthday to get the age and constellation.

Usage

import "github.com/hyperjiang/birthday"

b, _ := birthday.Parse("2020-01-01")

fmt.Println(b.Age)
fmt.Println(b.Constellation)
fmt.Println(b.GetConstellation("zh")) // print constellation in Chinese
fmt.Println(b.Format("Jan 2nd, 2006"))
fmt.Println(b.String())

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Birthday

type Birthday struct {
	Date          time.Time
	Year          int
	Month         time.Month
	Day           int
	Age           int
	Constellation string
}

Birthday is the birthday detail

func Parse

func Parse(date string) (*Birthday, error)

Parse parse birthday from given string date

func ParseFromTime

func ParseFromTime(t time.Time) *Birthday

ParseFromTime parse birthday from given time

func (Birthday) Format

func (b Birthday) Format(layout string) string

Format returns the birthday in given format

func (Birthday) GetConstellation

func (b Birthday) GetConstellation(lang string) (string, error)

GetConstellation gets constellation in given language

func (Birthday) String added in v1.1.0

func (b Birthday) String() string

String returns normalized date

Jump to

Keyboard shortcuts

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