functions.go 499 B

123456789101112131415161718192021222324252627282930313233
  1. package eliza
  2. import (
  3. "fmt"
  4. "time"
  5. )
  6. func year() string {
  7. year, _, _ := time.Now().Date()
  8. return fmt.Sprintf("%d", year)
  9. }
  10. func date() string {
  11. dw := time.Now().Weekday()
  12. mon := time.Now().Month()
  13. dom := time.Now().Day()
  14. s := "th"
  15. if dom == 1 || dom == 21 || dom == 31 {
  16. s = "st"
  17. }
  18. if dom == 2 || dom == 22 {
  19. s = "nd"
  20. }
  21. if dom == 3 {
  22. s = "rd"
  23. }
  24. return fmt.Sprintf("%s %d%s %s", dw, dom, s, mon)
  25. }
  26. func dayOfWeek() string {
  27. dt := time.Now().Weekday()
  28. return dt.String()
  29. }