Guest User

Untitled

a guest
May 26th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. if [ "`date '+%Y-%m-%d' -d $d 2>/dev/null`" == "$d" ]
  2. then
  3. echo "1"
  4. elif [ "`date '+%d-%m-%Y' -d $d 2>/dev/null`" == "$d" ]
  5. then
  6. echo "2"
  7. elif [ "`date '+%Y/%m/%d' -d $d 2>/dev/null`" == "$d" ]
  8. then
  9. echo "3"
  10. elif [ "`date '+%d/%m/%Y' -d $d 2>/dev/null`" == "$d" ]
  11. then
  12. echo "4"
  13. else
  14. echo `date '+%d-%m-%Y' -d $d`
  15. echo "other"
  16. fi
  17.  
  18. date: invalid date `01-01-2018'
  19.  
  20. other
  21.  
  22. case $d in
  23. [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9])
  24. # assume yyyy-mm-dd
  25. ;;
  26. [0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9])
  27. # in the civilized world, assume dd/mm/yyyy
  28. # in the US, assume mm/dd/yyyy
  29. # in the general case, assume nothing; give up
  30. ;;
  31. ... etc ...
  32. esac
Add Comment
Please, Sign In to add comment