Documentation
¶
Index ¶
- Constants
- func ArrayDiffInt(array1 []int, arrayOthers ...[]int) []int
- func ArrayUnshift(s []string, elements ...string) []string
- func CustomRelTime(a, b time.Time, albl, blbl string, magnitudes []RelTimeMagnitude) string
- func Implode(glue string, values []string) string
- func InsertNth(s string, n int, insert rune) string
- func InsertTagsIgnoringNewLines(oldMessage string, newMessage string, tags []formatter.TagPos) string
- func IsStringSliceEqual(a, b []string) bool
- func Map(strings []string, function func(string) string) []string
- func MaxInt(list []int) int
- func RangeInt(start int, end int) []int
- func RelTime(a, b time.Time, albl, blbl string) string
- func RemoveDecoration(outputFormatter formatter.OutputFormatterInterface, message string) string
- func StrSplit(data string, length int) []string
- func Strlen(s string) int
- func StrlenWithoutDecoration(outputFormatter formatter.OutputFormatterInterface, message string) int
- func Syscall(val any) int
- func Time(then time.Time) string
- func Wordwrap(message string, width int, breaker rune) string
- type RelTimeMagnitude
Constants ¶
const ( Day = 24 * time.Hour Week = 7 * Day Month = 30 * Day Year = 12 * Month LongTime = 37 * Year )
Seconds-based time units
Variables ¶
This section is empty.
Functions ¶
func ArrayDiffInt ¶
func ArrayUnshift ¶
unshift a string from array
func CustomRelTime ¶ added in v1.4.3
func CustomRelTime(a, b time.Time, albl, blbl string, magnitudes []RelTimeMagnitude) string
CustomRelTime formats a time into a relative string.
It takes two times two labels and a table of relative time formats. In addition to the generic time delta string (e.g. 5 minutes), the labels are used applied so that the label corresponding to the smaller time is applied.
func IsStringSliceEqual ¶
compare byte by byte a string to another
func RelTime ¶ added in v1.4.3
RelTime formats a time into a relative string.
It takes two times and two labels. In addition to the generic time delta string (e.g. 5 minutes), the labels are used applied so that the label corresponding to the smaller time is applied.
RelTime(timeInPast, timeInFuture, "earlier", "later") -> "3 weeks earlier"
func RemoveDecoration ¶
func RemoveDecoration(outputFormatter formatter.OutputFormatterInterface, message string) string
remove all string decoration (tags)
func StrlenWithoutDecoration ¶
func StrlenWithoutDecoration(outputFormatter formatter.OutputFormatterInterface, message string) int
length of an undecorated string
Types ¶
type RelTimeMagnitude ¶ added in v1.4.3
A RelTimeMagnitude struct contains a relative time point at which the relative format of time will switch to a new format string. A slice of these in ascending order by their "D" field is passed to CustomRelTime to format durations.
The Format field is a string that may contain a "%s" which will be replaced with the appropriate signed label (e.g. "ago" or "from now") and a "%d" that will be replaced by the quantity.
The DivBy field is the amount of time the time difference must be divided by in order to display correctly.
e.g. if D is 2*time.Minute and you want to display "%d minutes %s" DivBy should be time.Minute so whatever the duration is will be expressed in minutes.