MCPcopy Create free account
hub / github.com/Facets-cloud/flow / formatDueDateInfo

Function formatDueDateInfo

internal/app/show.go:684–706  ·  view source on GitHub ↗

formatDueDateInfo returns a parenthetical like "(in 3 days)", "(today)", or "(overdue by 2 days)" for display next to the date.

(dateStr string, now time.Time)

Source from the content-addressed store, hash-verified

682// formatDueDateInfo returns a parenthetical like "(in 3 days)",
683// "(today)", or "(overdue by 2 days)" for display next to the date.
684func formatDueDateInfo(dateStr string, now time.Time) string {
685 due, err := time.ParseInLocation("2006-01-02", dateStr, now.Location())
686 if err != nil {
687 return ""
688 }
689 y, m, d := now.Date()
690 today := time.Date(y, m, d, 0, 0, 0, 0, now.Location())
691 diff := int(due.Sub(today) / (24 * time.Hour))
692 switch {
693 case diff < 0:
694 abs := -diff
695 if abs == 1 {
696 return "(overdue by 1 day)"
697 }
698 return fmt.Sprintf("(overdue by %d days)", abs)
699 case diff == 0:
700 return "(today)"
701 case diff == 1:
702 return "(tomorrow)"
703 default:
704 return fmt.Sprintf("(in %d days)", diff)
705 }
706}
707
708// temporalSummary builds the "in-progress for 5 days, due in 2 days"
709// line for `flow show task`.

Callers 1

printTaskMetadataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected