functions.go 600 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package eliza
  2. import (
  3. "fmt"
  4. "hash/fnv"
  5. "time"
  6. )
  7. func year() string {
  8. year, _, _ := time.Now().Date()
  9. return fmt.Sprintf("%d", year)
  10. }
  11. func date() string {
  12. dw := time.Now().Weekday()
  13. mon := time.Now().Month()
  14. dom := time.Now().Day()
  15. s := "th"
  16. if dom == 1 || dom == 21 || dom == 31 {
  17. s = "st"
  18. }
  19. if dom == 2 || dom == 22 {
  20. s = "nd"
  21. }
  22. if dom == 3 {
  23. s = "rd"
  24. }
  25. return fmt.Sprintf("%s %d%s %s", dw, dom, s, mon)
  26. }
  27. func dayOfWeek() string {
  28. dt := time.Now().Weekday()
  29. return dt.String()
  30. }
  31. func hash(s string) uint32 {
  32. h := fnv.New32a()
  33. h.Write([]byte(s))
  34. return h.Sum32()
  35. }