00_common.sh 954 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. is_not_holidays() {
  3. if [ -z "$1" ]; then
  4. echo "0"
  5. return
  6. fi
  7. path=$(dirname $0)
  8. if grep -w "$1" "${path}/holidays.txt" > /dev/null; then
  9. echo "0"
  10. else
  11. echo "1"
  12. fi
  13. }
  14. get_day_of_week() {
  15. local format="${1:-chinese}"
  16. case "$format" in
  17. "full") # 完整星期名称(Monday, Tuesday, etc.)
  18. date +%A
  19. ;;
  20. "short") # 缩写星期名称(Mon, Tue, etc.)
  21. date +%a
  22. ;;
  23. "num1") # 数字表示(1-7,周一到周日)
  24. date +%u
  25. ;;
  26. "num0") # 数字表示(0-6,周日到周六)
  27. date +%w
  28. ;;
  29. "chinese") # 中文星期(星期一,星期二,等等)
  30. LC_ALL=zh_CN.UTF-8 date +%A
  31. ;;
  32. *)
  33. echo "Invalid format. Use 'full', 'short', 'num1', 'num0', or 'chinese'."
  34. ;;
  35. esac
  36. }