add FormatDateSpanish

This commit is contained in:
2025-01-28 15:57:29 +01:00
parent 4782a04fa7
commit 5686b58666
4 changed files with 40 additions and 25 deletions
+13
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"log/slog"
"regexp"
"strconv"
"strings"
"time"
"unicode"
@@ -61,3 +62,15 @@ func Slugify(s string) string {
func isMn(r rune) bool {
return unicode.Is(unicode.Mn, r)
}
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)
}