calendar

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 6 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.

Documentation

Overview

Package calendar is every calendar rule the board, standup and stats share, on years: working days, the week starting Monday, how a --since or a window is read, and the two default-window fallbacks.

Index

Constants

View Source
const FallbackDays = 14

FallbackDays is how far back LastActiveWorkday looks for activity.

Variables

This section is empty.

Functions

func FallbackFrom

func FallbackFrom(now time.Time) time.Time

FallbackFrom is the start of the window LastActiveWorkday looks through.

func LastActiveWorkday

func LastActiveWorkday(now time.Time, w Workdays, activity []time.Time) time.Time

LastActiveWorkday is local midnight of the latest working day before today with activity; with none in the window, LastWorkday, so a first run never reaches back weeks.

func LastWeekStart

func LastWeekStart(now time.Time) time.Time

LastWeekStart is last week's Monday at local midnight.

func LastWorkday

func LastWorkday(now time.Time, w Workdays) time.Time

LastWorkday is local midnight of the working day before today's.

func OffsetDays

func OffsetDays(value string) (int, error)

OffsetDays reads a count of days or weeks (10d, 3w) as days. Both stats --since and stale_after read this one grammar.

func Parse

func Parse(arg string, now time.Time, forms Forms, workdays func() (Workdays, error)) (years.Period, error)

Parse reads arg as the forms allow, at now. Working days are read only when arg names last-workday, so a broken config fails no other run. The error is bare: each command names its flag and its forms.

Types

type Forms

type Forms int

Forms is what a command's --since or window accepts.

const (
	// Instants is an RFC 3339 time or a YYYY-MM-DD date at local midnight.
	Instants Forms = iota
	// Offsets is a count of days or weeks back from now: 10d, 3w.
	Offsets
	// Windows is every years alias (today, last-workday, last-week...), a
	// date, a time or an offset.
	Windows
)

type Workdays

type Workdays [7]bool

Workdays is the working weekdays, indexed by time.Weekday.

func DefaultWorkdays

func DefaultWorkdays() Workdays

DefaultWorkdays is Monday to Friday.

Jump to

Keyboard shortcuts

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