Documentation ¶
Index ¶
- func DurationTilNext(start time.Time, now time.Time, between time.Duration) time.Duration
- func FormatDuration(duration time.Duration) string
- func GetUniqueShortNames(nameSet map[string]bool, fromRight bool, minChars int) map[string]string
- func GetUniqueShortNamesFromEdges(nameSet map[string]bool, minCharsEachSide int) map[string]string
- func JoinWithEqualSpacing(width int, items ...string) string
- func StyleStyledString(s string, st lipgloss.Style) string
- func TimeSince(t time.Time) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DurationTilNext ¶
DurationTilNext calculates the duration until the between occurrence of a periodic event.
Parameters: - start: A start time for the periodic event - now: The current time - between: The duration between occurrences of the event
Returns: The duration until the between occurrence of the event
Examples:
For a minutely event: start = 2023-01-01 00:00:00 now = 2023-01-01 00:01:30 between = 1 minute Result: 30 seconds (until 2023-01-01 00:02:00)
For an hourly event: start = 2023-01-01 00:00:00 now = 2023-01-01 02:45:00 between = 1 hour Result: 15 minutes (until 2023-01-01 03:00:00)
For a custom duration event (every 45 minutes): start = 2023-01-01 00:00:00 now = 2023-01-01 01:20:00 between = 45 minutes Result: 25 minutes (until 2023-01-01 01:45:00)
func FormatDuration ¶ added in v0.2.0
func GetUniqueShortNames ¶
GetUniqueShortNames takes in the set of names and tries to create a unique set of substrings of them, starting at minChars length and increasing if necessary. If fromRight is true, it starts from the end of each name. Returns a mapping of name -> short name with the names in nameSet as keys.
func GetUniqueShortNamesFromEdges ¶
GetUniqueShortNamesFromEdges does the same thing as GetUniqueShortNames, but removes chars in the middle of the name instead of the beginning or end. if e.g. apple would return app..ple, just return apple
func JoinWithEqualSpacing ¶
func StyleStyledString ¶ added in v0.4.0
StyleStyledString is for styling a string that contains ANSI escape codes.
Types ¶
This section is empty.