Documentation
¶
Index ¶
- Constants
- func ApplyDelta(original time.Time, delta time.Duration) time.Time
- func ComputeDelta(displayedOriginal, displayedNew time.Time) time.Duration
- func ContainsRR(s string) bool
- func ContainsShift(s string) bool
- func FormatGit(t time.Time) string
- func FormatLocal(t time.Time) string
- func ParseLocal(s string) (time.Time, error)
- func ParseShift(expr string) (time.Duration, error)
- func ResolveAll(commits []Commit, now time.Time, splitDates bool) error
- func ResolveRR(timeStr string) (string, error)
- type Commit
Constants ¶
const DisplayLayout = "2006-01-02 15:04:05"
Variables ¶
This section is empty.
Functions ¶
func ApplyDelta ¶
ApplyDelta adds a duration to the original timestamp (preserving its timezone offset) and returns the result.
func ComputeDelta ¶
ComputeDelta returns the duration between the displayed original and the displayed new time. Both must already be in local timezone representation.
func ContainsRR ¶
ContainsRR returns true if the string contains an RR token.
func ContainsShift ¶
ContainsShift returns true if the token looks like a shift expression (starts with + or - followed by a digit).
func FormatGit ¶
FormatGit returns the timestamp in RFC 3339 format suitable for GIT_AUTHOR_DATE / GIT_COMMITTER_DATE environment variables.
func FormatLocal ¶
FormatLocal renders t in the user's local timezone without showing the offset.
func ParseLocal ¶
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 ¶
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 ¶
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.
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.