dayofweek

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Day of Week Module

A Golang module that allows you to perform operations on a day of week set, and determine if specific days are set.

See the godoc for more details.

Usage

Instantiation

By using the constructor:

// This is          mon,  tue,   wed,   thu,   fri,  sat,  sun
x := dayofweek.New(true, true, false, false, false, true, true)

x.IsSet(dayofweek.Monday)
true

x.IsThursday()
false

x.IsWeekday(time.Weekday variable)
true

x.OnDate(time.Time variable)
false | true

Using a time.Weekday:

var x dayofweek.Dow
x = x.WeekdayToDow(time.Weekday variable)

Generating it

var x dayofweek.Dow
x |= dayofweek.Monday
x |= dayofweek.Sunday

or
x.AddDay(dayofweek.Thursday)

or
x.AddFriday()
x.RemoveDay(dayofweek.Monday)
x.RemoveSunday()

Testing

The object contains multiple methods for testing if a specific day is set

Comparison

The object can be compared to another object to see if the same days are set.

JSON Marshalling

The object contains Marshall and UnMarshall functions as input / output of a string representation.

Documentation

Overview

Package dayofweek defines a representation of weekdays in a week

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dow

type Dow int
const (
	Monday    Dow = 1 << iota // 1
	Tuesday                   // 2
	Wednesday                 // 4
	Thursday                  // 8
	Friday                    // 16
	Saturday                  // 32
	Sunday                    // 64
)

func New

func New(mon, tue, wed, thu, fri, sat, sun bool) *Dow

Return a new Dow with the given days set.

func (*Dow) AddDay

func (me *Dow) AddDay(p Dow)

Add the given dow day (eg. x.AddDay(dayofweek.Monday) )

func (Dow) AddFriday

func (me Dow) AddFriday()

Add Friday

func (Dow) AddMonday

func (me Dow) AddMonday()

Add Monday

func (Dow) AddSaturday

func (me Dow) AddSaturday()

Add Saturday

func (Dow) AddSunday

func (me Dow) AddSunday()

Add Sunday

func (Dow) AddThursday

func (me Dow) AddThursday()

Add Thursday

func (Dow) AddTuesday

func (me Dow) AddTuesday()

Add Tuesday

func (Dow) AddWednesday

func (me Dow) AddWednesday()

Add Wednesday

func (*Dow) Clear

func (me *Dow) Clear()

Clear out all days (unset)

func (Dow) Equal

func (me Dow) Equal(o Dow) bool

Is the supplied Dow equal to us.

func (Dow) IsFriday

func (me Dow) IsFriday() bool

Is Friday Set

func (Dow) IsMonday

func (me Dow) IsMonday() bool

Is Monday Set

func (Dow) IsSaturday

func (me Dow) IsSaturday() bool

Is Saturday Set

func (Dow) IsSet

func (me Dow) IsSet(p Dow) bool

Is a given day set (Eg. x.IsSet(dayofweek.Wednesday) )

func (Dow) IsSunday

func (me Dow) IsSunday() bool

Is Sunday Set

func (Dow) IsThursday

func (me Dow) IsThursday() bool

Is Thursday Set

func (Dow) IsTuesday

func (me Dow) IsTuesday() bool

Is Tuesday Set

func (Dow) IsWednesday

func (me Dow) IsWednesday() bool

Is Wednesday Set

func (Dow) IsWeekday

func (me Dow) IsWeekday(wd time.Weekday) bool

See if time.Weekday is set

func (Dow) MarshalJSON

func (me Dow) MarshalJSON() ([]byte, error)

Marshal function to dump output as a string eg {"Monday, Tuesday"}

func (Dow) OnDate

func (me Dow) OnDate(t time.Time) bool

Check if time.Time's day is set

func (*Dow) Parse

func (me *Dow) Parse(s string) error

Parse updates your Dow object from a given string such as (Mon, Tuesday, wed) Must be csv. Returns error if unable to parse a value.

func (*Dow) ParseRemove

func (me *Dow) ParseRemove(s string) error

Parse a string of dow, and remove those days.

func (*Dow) RemoveDay

func (me *Dow) RemoveDay(p Dow)

Remove a day from us (eg. dayofweek.Wednesday

func (Dow) RemoveFriday

func (me Dow) RemoveFriday()

Remove Friday

func (Dow) RemoveMonday

func (me Dow) RemoveMonday()

Remove Monday

func (Dow) RemoveSaturday

func (me Dow) RemoveSaturday()

Remove Saturday

func (Dow) RemoveSunday

func (me Dow) RemoveSunday()

Remove Sunday

func (Dow) RemoveThursday

func (me Dow) RemoveThursday()

Remove Thursday

func (Dow) RemoveTuesday

func (me Dow) RemoveTuesday()

Remove Tuesday

func (Dow) RemoveWednesday

func (me Dow) RemoveWednesday()

Remove Wednesday

func (*Dow) Set

func (me *Dow) Set(mon, tue, wed, thu, fri, sat, sun bool)

Set Dow to the given days, mon, tue, wed, thu, fri, sat, sun.

func (Dow) String

func (me Dow) String() string

Pretty Print the day of week (eg. "Monday, Wednesday, Friday")

func (Dow) Today

func (me Dow) Today() bool

Check if today is set.

func (*Dow) UnmarshalJSON

func (me *Dow) UnmarshalJSON(d []byte) error

Unmarshal your JSON input into a Dow object. eg: {"run_on_days": "Mon, Tue, Thursday"}

func (Dow) WeekdayToDow

func (me Dow) WeekdayToDow(wd time.Weekday) Dow

Convert time.Weekday to dayofweek.Dow

Jump to

Keyboard shortcuts

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