Skip to content
This repository was archived by the owner on Mar 28, 2024. It is now read-only.

edgelaboratories/calendar

Repository files navigation

calendar

Go Reference GolangCI Lint

Provide basic operations on calendars in Go.

Install

go get -u github.com/edgelaboratories/calendar

Requirements

Test

Run the following:

make test

Check out the Makefile for more information.

Purpose

This project aims at offering a unique, simple and fast module to manage calendars with daily granularity. Dates representation is based on github.com/edgelaboratories/date.

This project doesn't aim at supporting daycount conventions. Have a look at github.com/edgelaboratories/daycount instead.

Usage

package main

import (
    "fmt"
    "github.com/edgelaboratories/calendar"
    "github.com/edgelaboratories/date"
)

func main() {
    c := calendar.New(calendar.BusinessDays)

    fmt.Println(c.Convention()) // output is "BusinessDays"
    
    fmt.Println(c.DaysBetween(
        date.New(2021, time.October, 13), // Wednesday
        date.New(2021, time.October, 15), // Friday
    )) // output is 2

    fmt.Println(c.Add(
        date.New(2021, time.October, 13), // Wednesday
        2,
    ).String()) // output is Friday "2021-10-15"
}

About

Provide basic operations on calendars in Go

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 5