Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Day is the equivalent of 24 hours Day = time.Duration(24) * time.Hour )
var (
// Default is the default standard calendar
Default = "default"
)
Functions ¶
func SetDefaultCalendar ¶
SetDefaultCalendar replace the current default calendar by another existing calendar
func UpdateCalendar ¶
UpdateCalendar replace the current default calendar by another existing calendar
Types ¶
type Calendar ¶
type Calendar interface { GetName() string Add(time.Time, time.Duration) time.Time Sub(time.Time, time.Time) time.Duration }
Calendar is an interface for every implementation of calendars It must allow : * Add a duration (which can be negative) to a time.Time (taking working days into account) * Calculate the duration between two time.Time (taking working days into account)
func GetCalendar ¶
GetCalendar returns a calendar by it's name
func GetDefaultCalendar ¶
func GetDefaultCalendar() Calendar
GetDefaultCalendar returns the set default calendar
type CountryCode ¶
type CountryCode int
CountryCode is a standard country code (for supported calendar)
const (
FR CountryCode = iota + 1
)
List of supported country codes
type CustomCalendar ¶
type CustomCalendar struct {
// contains filtered or unexported fields
}
CustomCalendar is a standard calendar containing date entries with specific behavior
func NewCustomCalendar ¶
func NewCustomCalendar(name string) *CustomCalendar
NewCustomCalendar returns a new calendar instance
func (*CustomCalendar) AddEntries ¶
func (calendar *CustomCalendar) AddEntries(entries ...Entry)
AddEntries add a new entry in the calendar
func (*CustomCalendar) GetName ¶
func (calendar *CustomCalendar) GetName() string
GetName returns the calendar name
type Entry ¶
type Entry struct { ID time.Time `json:"id"` WorkingDay bool `json:"workingDay"` // Jour ouvrable WorkedDay bool `json:"workedDay"` // Jour ouvré }
Entry is a single day entry in a calendar
type StandardCalendar ¶
type StandardCalendar struct {
// contains filtered or unexported fields
}
StandardCalendar is a wrapper for a standard calendar implementation (with pre-configured holidays) It only support calendar for France (FR) but can easily implements some more country code
func NewStandardCalendar ¶
func NewStandardCalendar(name string, country CountryCode) *StandardCalendar
NewStandardCalendar returns a new instance of a standard calendar
func (*StandardCalendar) GetName ¶
func (calendar *StandardCalendar) GetName() string
GetName returns calendar name