Documentation ¶
Index ¶
- Constants
- Variables
- func CheckBeginEnd(begin, end time.Time, pastAlways bool, future time.Duration) error
- func GetInterval(repo Repository, pad *Pad, from, to time.Time, location *time.Location) ([]Event, []Shift, error)
- func GetSystemLocation() *time.Location
- func Intersect(as, bs []string) []string
- func Locations(loc string) []string
- type Auth
- func (auth Auth) Active() bool
- func (auth Auth) CanEdit(shiftname string) bool
- func (auth Auth) CanEditShift(shift Shift) bool
- func (auth Auth) CanEditSomeShift() bool
- func (auth Auth) CanTake(shiftname string) bool
- func (auth Auth) CanTakeShift(shift Shift) bool
- func (auth Auth) CanTakerName(shift Shift, name string) bool
- func (auth Auth) Encode() ([]byte, error)
- func (ref Auth) Restrict(input Auth) Auth
- func (auth Auth) TakerString(shift Shift) string
- type AuthPad
- type Day
- type Event
- type Group
- type Pad
- type Repository
- type Shift
- type Week
Constants ¶
const MaxFuture = 180 * 24 * time.Hour
MaxFuture specifies how far in the future shifts can be created and edited, and the expiry time of pads.
Variables ¶
var SystemLocation *time.Location = GetSystemLocation()
Functions ¶
func CheckBeginEnd ¶
CheckBeginEnd checks that begin or end are non-zero, that end is after begin (or end is zero), and that begin and end are not too far in the past and future.
func GetInterval ¶
func GetInterval(repo Repository, pad *Pad, from, to time.Time, location *time.Location) ([]Event, []Shift, error)
weeks can't be split into days because shifts and events may be contained in multiple days then, but we want them just once in a week (or any other interval)
func GetSystemLocation ¶
GetSystemLocation returns the location linked by /etc/localtime if it is a canonical location, or "Etc/GMT" else.
Types ¶
type Auth ¶
type Auth struct { Admin bool Edit []string EditAll bool EditRetroAlways bool Expires string // yyyy-mm-dd Note string Take []string TakeAll bool TakeDeadline string // cronexpr TakerName []string TakerNameAll bool ViewTakerContact bool ViewTakerName bool // also visible if contained in Auth.TakerName }
func DecodeAuth ¶
func (Auth) CanEditShift ¶
When editing a shift, CanEditShift must be called on the original and on the modified shift.
func (Auth) CanEditSomeShift ¶
func (Auth) CanTakeShift ¶
func (Auth) Encode ¶
Encode copies the contents of auth into url.Values and encodes them. Note that url.Values are designed for url queries, not url path elements. The only difference is the representation of the space character.
func (Auth) Restrict ¶
Restricts returns a copy of input which is restricted to a reference Auth. Note that this function is not symmetric and thus not an intersection.
func (Auth) TakerString ¶
TakerString returns a string containing the taker name and taker contact of the given shift, or "taken" if auth.ViewTakerContact and auth.ViewTakerName are false. If the shift is not taken, an empty string is returned.
type AuthPad ¶
An AuthPad is a pad with verified authentication.
func Verify ¶
Verify verifies the given base64-encoded signature of the given auth string, decodes the auth string and checks auth.Active().
func (AuthPad) EditShiftNames ¶
EditShiftNames returns the shift names that auth can edit. You must check len(Pad.ShiftNames) > 0 separately.
type Day ¶
type Day struct { Begin time.Time // inclusive End time.Time // exclusive Events []Event // both with and without shifts Shifts []Shift // without an event }
func (Day) FmtShiftTime ¶
type Group ¶
Group is used for displaying. It can represent an event or a bunch of independent shifts.
type Pad ¶
type Repository ¶
type Shift ¶
type Shift struct { ID int Modified time.Time // used in ical export Name string // matched against Pad.ShiftNames Note string // free text, not matched EventUID string Begin time.Time // Begin.IsZero() means undefined End time.Time // End.IsZero() means undefined TakerName string TakerContact string }