timestamp

package
v0.0.0-...-742fb98 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DisplayLayout = "2006-01-02 15:04:05"

Variables

This section is empty.

Functions

func ApplyDelta

func ApplyDelta(original time.Time, delta time.Duration) time.Time

ApplyDelta adds a duration to the original timestamp (preserving its timezone offset) and returns the result.

func ComputeDelta

func ComputeDelta(displayedOriginal, displayedNew time.Time) time.Duration

ComputeDelta returns the duration between the displayed original and the displayed new time. Both must already be in local timezone representation.

func ContainsRR

func ContainsRR(s string) bool

ContainsRR returns true if the string contains an RR token.

func ContainsShift

func ContainsShift(s string) bool

ContainsShift returns true if the token looks like a shift expression (starts with + or - followed by a digit).

func FormatGit

func FormatGit(t time.Time) string

FormatGit returns the timestamp in RFC 3339 format suitable for GIT_AUTHOR_DATE / GIT_COMMITTER_DATE environment variables.

func FormatLocal

func FormatLocal(t time.Time) string

FormatLocal renders t in the user's local timezone without showing the offset.

func ParseLocal

func ParseLocal(s string) (time.Time, error)

ParseLocal parses a timestamp string in DisplayLayout and interprets it in the user's local timezone. This is used when reading the todo file.

func ParseShift

func ParseShift(expr string) (time.Duration, error)

ParseShift parses a compound shift expression like "+1d2h30m" or "-45s" into a time.Duration. Supported units: w (weeks), d (days), h (hours), m (minutes), s (seconds).

func ResolveAll

func ResolveAll(commits []Commit, now time.Time, splitDates bool) error

ResolveAll resolves the EditedRaw fields of each commit into final timestamps. The commits slice must be in oldest-first order.

The now parameter is captured once and used for all NOW references. Bare shift expressions (e.g. "+1h30m") resolve relative to the previous commit's already-resolved author date, so they chain naturally.

func ResolveRR

func ResolveRR(timeStr string) (string, error)

ResolveRR replaces all RR(...) and bare RR tokens in a time-of-day string (HH:MM:SS). The input must be exactly the time portion; the date portion must be handled separately.

Examples:

"RR:RR:00"          -> "14:37:00"
"RR(08,17):RR:00"   -> "12:45:00"

Types

type Commit

type Commit struct {
	Hash           string
	OrigAuthorDate time.Time
	OrigCommitDate time.Time
	Subject        string
	Body           string

	// EditedRaw is the raw string from the timestamp column after editing.
	EditedRaw string
	// EditedRaw2 is the second timestamp column (--split-dates mode only).
	EditedRaw2 string

	ResolvedAuthorDate time.Time
	ResolvedCommitDate time.Time

	// NewSubject is the commit subject after editing (may be unchanged).
	NewSubject string
}

Commit holds the original and resolved timestamps for one commit.

Jump to

Keyboard shortcuts

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