version-installed-when 1015 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env bash
  2. __rvm_version_installed_when()
  3. {
  4. \typeset installed_at years months days hours minutes seconds part
  5. installed_at="$(\command \cat ${rvm_path}/installed.at)"
  6. if
  7. [[ -n "${installed_at:-}" ]] && (( installed_at ))
  8. then
  9. seconds="$(( $(__rvm_date +%s) - installed_at ))"
  10. if
  11. (( seconds ))
  12. then
  13. minutes="$(( seconds / 60 % 60 ))"
  14. hours="$(( seconds / 3600 % 24 ))"
  15. days="$(( seconds / 86400 % 31 ))"
  16. months="$(( seconds / 2678400 % 12 ))"
  17. years="$(( seconds / 31536000 ))"
  18. seconds="$(( seconds % 60 ))"
  19. installed_at=""
  20. for part in year month day hour minute second
  21. do
  22. partvar="${part}s"
  23. (( ${!partvar} )) || continue
  24. installed_at="${installed_at}${!partvar} ${part}$( (( ${!partvar} == 1 )) || echo "s") "
  25. done
  26. installed_at="${installed_at}ago"
  27. else
  28. installed_at="just now"
  29. fi
  30. else
  31. installed_at="can not read installation time"
  32. fi
  33. echo ${installed_at}
  34. }