holiday_colombia

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 2 Imported by: 0

README

��# holiday_colombia

Build Status Go Report Card GoDoc License

holiday_colombia It is a library to manage holidays in Colombia. Provides functions to check if a day is a holiday, get the next business day from a given date, and count the number of business days between two dates.

Facility

go get -u github.com/Anderson-losada-expe/holiday_colombia 

Use

  • Here's a quick example of how to use the library:
package main

import (
	"fmt"
	"time"

	"github.com/Anderson-losada-expe/holiday_colombia"
)

func main() {
	// Crear una instancia de HolidayUtil para el a�o actual
	hu := holiday_colombia.NewHolidayUtil(time.Now().Year())

	// Verificar si una fecha espec�fica es festiva
	isHoliday := hu.IsHoliday(1, 1) // A�o Nuevo
	fmt.Printf("�El 1 de enero es festivo? %v\n", isHoliday)

	// Obtener el pr�ximo d�a h�bil desde una fecha dada
	startDate := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
	nextBusinessDay := hu.GetNextBusinessDay(startDate, 1)
	fmt.Printf("Pr�ximo d�a h�bil despu�s de %v: %v\n", startDate, nextBusinessDay)

	// Contar la cantidad de d�as h�biles entre dos fechas
	dateInit := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
	dateEnd := time.Date(2022, time.January, 10, 0, 0, 0, 0, time.UTC)
	businessDays := hu.CountBusinessDays(dateInit, dateEnd)
	fmt.Printf("D�as h�biles entre %v y %v: %d\n", dateInit, dateEnd, businessDays)

	// Calcular el n�mero de d�as laborables en un mes con d�as de fin de semana espec�ficos
	month := time.April
	weekendDays := []time.Weekday{time.Saturday, time.Sunday}
	workdays := hu.CalculateWorkDay(month, weekendDays)
	fmt.Printf("D�as laborables en %s: %d\n", month, workdays)

	// Obtener la lista de d�as laborables en un mes con d�as de fin de semana espec�ficos
	workdaysList := hu.GetWorkDaysList(month, weekendDays)
	fmt.Printf("Lista de d�as laborables en %s: %v\n", month, workdaysList)
}

Functions

NewHolidayUtil(year int) *holiday_colombia.HolidayUtil
  • Creates a new HolidayUtil instance for the given year.
IsHoliday(month, day int) bool
  • Indicates if a day is a holiday.
GetNextBusinessDay(date time.Time, days int) time.Time
  • Returns the next business day from a given date and number of days.
CountBusinessDays(dateInit, dateEnd time.Time) int
  • Counts the number of business days between two dates.
CountBusinessDays(dateInit, dateEnd time.Time) int
  • Counts the number of business days between two dates.
CalculateWorkDay(month time.Month, weekendDays []time.Weekday) int
  • Calculates the number of workdays in a month with specified weekend days.
GetWorkDaysList(month time.Month, weekendDays []time.Weekday) []time.Time
  • Returns the list of workdays in a month with specified weekend days.

License

This project is under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HolidayUtil

type HolidayUtil struct {
	// contains filtered or unexported fields
}

HolidayUtil representa la utilidad para gestionar días festivos.

func NewHolidayUtil

func NewHolidayUtil(year int) *HolidayUtil

NewHolidayUtil crea una nueva instancia de HolidayUtil para el año dado.

func (*HolidayUtil) CalculateWorkDay

func (hu *HolidayUtil) CalculateWorkDay(month time.Month, weekendDays []time.Weekday) int

func (*HolidayUtil) CountBusinessDays

func (hu *HolidayUtil) CountBusinessDays(dateInit, dateEnd time.Time) int

CountBusinessDays cuenta la cantidad de días hábiles entre dos fechas.

func (*HolidayUtil) GetNextBusinessDay

func (hu *HolidayUtil) GetNextBusinessDay(date time.Time, days int) time.Time

GetNextBusinessDay devuelve el próximo día hábil desde una fecha dada y una cantidad de días.

func (*HolidayUtil) GetWorkDaysList

func (hu *HolidayUtil) GetWorkDaysList(month time.Month, weekendDays []time.Weekday) []time.Time

GetWorkDaysList returns a list of workdays in a month, considering holidays and custom weekend days.

func (*HolidayUtil) GetYear

func (hu *HolidayUtil) GetYear() int

GetYear devuelve el año.

func (*HolidayUtil) IsHoliday

func (hu *HolidayUtil) IsHoliday(month, day int) bool

IsHoliday indica si un día es festivo.

Jump to

Keyboard shortcuts

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