package utils import ( "crypto/hmac" "crypto/sha256" "encoding/hex" "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()) } func HashField(field string, token []byte) string { h := hmac.New(sha256.New, token) h.Write([]byte(field)) return hex.EncodeToString(h.Sum(nil)) }