update library

This commit is contained in:
2025-05-15 14:33:40 +02:00
parent 2aa592252c
commit 155e7a4116
13 changed files with 218 additions and 260 deletions
+28
View File
@@ -11,6 +11,7 @@ import (
"reflect"
"strconv"
"strings"
"time"
)
type (
@@ -329,3 +330,30 @@ func (p Pages) PageRange(maxPagesToShow int) []Page {
return pages
}
func Dict(values ...any) (map[string]any, error) {
if len(values)%2 != 0 {
return nil, errors.New("invalid dict call")
}
dict := make(map[string]any, len(values)/2)
for i := 0; i < len(values); i += 2 {
key, ok := values[i].(string)
if !ok {
return nil, errors.New("dict keys must be strings")
}
dict[key] = values[i+1]
}
return dict, nil
}
func FormatDateSpanish(date time.Time) string {
months := []string{"enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"}
days := []string{"domingo", "lunes", "martes", "miércoles", "jueves", "viernes", "sábado"}
dayName := days[date.Weekday()]
day := date.Day()
month := months[date.Month()-1]
year := date.Year()
return dayName + ", " + strconv.Itoa(day) + " de " + month + " de " + strconv.Itoa(year)
}