:clock1: Date and Time - Golang Formatting Library

Kair

Date and Time - Golang Formatting Library

Mentioned in Awesome Go License: MIT Go Report Card codecov Build Status GitHub GoDoc

Setup

To get Kair

> Go CLI
go get github.com/GuilhermeCaruso/kair
> Go DEP
dep ensure -add github.com/GuilhermeCaruso/kair
> Govendor
govendor fetch github.com/GuilhermeCaruso/kair

Example

package main

import (
	"fmt"

	k "github.com/GuilhermeCaruso/kair"
)

func main() {
	now := k.Now()

    fmt.Printf("Right now is %s \n", now.CustomFormat("dd/MM/YYYY hh:mm:ss"))

	date := k.Date(29, 05, 1980)

	fmt.Printf("The %s was a %s in %s\n",
		date.Format("L"),
		date.CustomFormat("DD"),
        date.CustomFormat("MMMM")) //The 29/05/1980 was a Thursday in May 
}

Formatters

  • Standard
    "LT":   10:20 AM,
    "LTS":  10:20:00 AM,
    "L":    20/05/2018,
    "l":    20/5/2018,
    "LL":   May 20, 2018,
    "ll":   May 20, 2018,
    "LLL":  May 20, 2018 10:20 AM,
    "lll":  May 20, 2018 10:20 AM,
    "LLLL": Sunday, May 20, 2018 10:20 AM,
    "llll": Sun, May 20, 2018 10:20 AM,
    "":     2018-05-20 10:20:00 +0000 UTC,
  • Custom
    "MMMM": Long Month,
    "MMM":  Month,
    "MM":   Zero Number Month,
    "M":    Number Month,
    "YYYY": Long Year,
    "YY":   Year,
    "DD":   Long Day,
    "D":    Day,
    "dd":   Long Number Day,
    "d":    Number Day,
    "hh":   Long Hour,
    "h":    Hour,
    "mm":   Long Minute,
    "m":    Minute,
    "ss":   Long Second,
    "s":    Second

Contributing

Please feel free to make suggestions, create issues, fork the repository and send pull requests!

To do:

  • Implement Standard Format
  • Implement Custom Format
  • Implement Now(), Date() and DateTime() initializers
  • Implement Relative Time (FromNow, StartOf ...)
  • Implement CalendarTime (add, subtract, calendar)

License

MIT License © Guilherme Caruso

Owner
Guilherme Caruso
Software Engineer | Go Evangelist | Beginner Rustacean | INTP-T |
Guilherme Caruso
Similar Resources

timeutil - useful extensions (Timedelta, Strftime, ...) to the golang's time package

timeutil - useful extensions to the golang's time package timeutil provides useful extensions (Timedelta, Strftime, ...) to the golang's time package.

Dec 22, 2022

time format golang

a simple plugin to change date and time format

Sep 29, 2021

Go-timeparser - Flexible Time Parser for Golang

go-timeparser Flexible Time Parser for Golang Installation Download timeparser w

Dec 29, 2022

Copy of stdlib's time.Duration, but ParseDuration accepts other bigger units such as days, weeks, months and years

duration Copy of stdlib's time.Duration, but ParseDuration accepts other units as well: d: days (7 * 24 * time.Hour) w: weeks (7 * Day) mo: months (30

Jun 21, 2022

🌐 A time zone helper

🌐 A time zone helper

🌐 A time zone helper tz helps you schedule things across time zones. It is an interactive TUI program that displays time across a few time zones of y

Dec 29, 2022

Structural time package for jalali calendar

Jalali Structural time package for jalali calendar. This package support parse from string, json and time. Structures There are three data structures

Mar 21, 2022

Timediff is a Go package for printing human readable, relative time differences 🕰️

timediff is a Go package for printing human readable, relative time differences. Output is based on ranges defined in the Day.js JavaScript library, and can be customized if needed.

Dec 25, 2022

Show time by timezone

Show time by timezone

Jan 22, 2022

Go-olson-timezone - A Golang library that tries to figure out your local timezone

go-olson-timezone A Golang library that tries to figure out your local timezone.

Feb 16, 2022
Related tags
fasttime - fast time formatting for go

fasttime - fast time formatting for go

Dec 13, 2022
A natural language date/time parser with pluggable rules

when when is a natural language date/time parser with pluggable rules and merge strategies Examples tonight at 11:10 pm at Friday afternoon the deadli

Dec 26, 2022
Time struct in Go that uses 4 bytes of memory vs the 24 bytes of time.Time

A tiny time object in Go. Tinytime uses 4 bytes of memory vs the 24 bytes of a standard time.Time{}

Oct 3, 2022
GoLang Parse many date strings without knowing format in advance.

Go Date Parser Parse many date strings without knowing format in advance. Uses a scanner to read bytes and use a state machine to find format. Much fa

Dec 31, 2022
A fast ISO8601 date parser for Go

A fast ISO8601 date parser for Go go get github.com/relvacode/iso8601 The built-in RFC3333 time layout in Go is too restrictive to support any ISO860

Jan 7, 2023
Go time library inspired by Moment.js

Goment Current Version: 1.4.0 Changelog Goment is a port of the popular Javascript datetime library Moment.js. It follows the Moment.js API closely, w

Dec 24, 2022
Clock is a small library for mocking time in Go.

clock Clock is a small library for mocking time in Go. It provides an interface around the standard library's time package so that the application can

Dec 30, 2022
Carbon for Golang, an extension for Time

Carbon A simple extension for Time based on PHP's Carbon library. Features: Time is embedded into Carbon (provides access to all of Time's functionali

Dec 20, 2022
Now is a time toolkit for golang

Now Now is a time toolkit for golang Install go get -u github.com/jinzhu/now Usage Calculating time based on current time import "github.com/jinzhu/n

Dec 23, 2022
Golang package to manipulate time intervals.

timespan timespan is a Go library for interacting with intervals of time, defined as a start time and a duration. Documentation API Installation Insta

Sep 26, 2022