Files
memberDB/utils/utils.go
2025-11-20 10:40:56 +01:00

37 lines
778 B
Go

package utils
import (
"fmt"
"net/mail"
"time"
)
func IsValidEmail(email string) bool {
_, err := mail.ParseAddress(email)
return err == nil
}
// Try multiple accepted date formats
var birthdayFormats = []string{
"2006-01-02", // ISO: 1999-12-12
"02.01.2006", // D.M.Y: 12.12.1999
"2.1.2006", // D.M.Y without leading zeros: 1.2.1999
}
func IsValidBirthday(birthday string) bool {
for _, layout := range birthdayFormats {
if _, err := time.Parse(layout, birthday); err == nil {
return true
}
}
return false
}
func GetCurrentTime(loc *time.Location) string {
return time.Now().In(loc).Format("2006-01-02 15:04:05")
}
func GetCurrentDay(loc *time.Location) string {
return fmt.Sprint(time.Now().In(loc).Weekday())
}