Merge pull request #581 from konimex/install_date

Install Date: Rewrite function
This commit is contained in:
Herdiansyah 2017-01-02 11:28:43 +07:00 committed by GitHub
commit d855121612
2 changed files with 17 additions and 32 deletions

View file

@ -92,6 +92,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques
- Removed all `date` usage from `get_install_date()`. - Removed all `date` usage from `get_install_date()`.
- Added a new function called `convert_time()` which takes the time stamped `ls` output and converts it to a pretty format. The function only uses bash so its much faster than calling `date`. This makes things simple and keeps the output consistent across all Operating Systems. Example: `2016-12-06 16:58:58.000000000` --> `Tue 06 Dec 2016 4:58 PM` - Added a new function called `convert_time()` which takes the time stamped `ls` output and converts it to a pretty format. The function only uses bash so its much faster than calling `date`. This makes things simple and keeps the output consistent across all Operating Systems. Example: `2016-12-06 16:58:58.000000000` --> `Tue 06 Dec 2016 4:58 PM`
- Added an option so users can choose between using 24-hour and 12-hour time format - Added an option so users can choose between using 24-hour and 12-hour time format
- `get_install_date()` will detect which `ls` program is being used instead of hardcoding them per OS.
**Disk**<br \> **Disk**<br \>

View file

@ -1762,43 +1762,27 @@ get_users() {
get_install_date() { get_install_date() {
case "$os" in case "$os" in
"Linux" | "iPhone OS") "Linux" | "iPhone OS") install_file="/lost+found" ;;
install_date="$(ls -alct --full-time / | awk '/lost\+found|private/ {printf $6 " " $7}')" "Mac OS X") install_file="/var/log/install.log" ;;
;; "Solaris") install_file="/var/sadm/system/logs/install_log" ;;
"Windows") install_file="/cygdrive/c/Windows/explorer.exe" ;;
"Mac OS X") "Haiku") install_file="/boot" ;;
install_date="$(ls -lUT /var/log/install.log | awk '{printf $9 " " $6 " " $7 " " $8}')"
;;
"BSD" | "MINIX") "BSD" | "MINIX")
case "$kernel_name" in case "$kernel_name" in
"OpenBSD"* | "Bitrig"* | "MINIX") "FreeBSD") install_file="/etc/hostid" ;;
install_file="/" "NetBSD" | "DragonFly"*) install_file="/etc/defaults/rc.conf" ;;
;; *) install_file="/" ;;
esac
"FreeBSD"*)
install_file="/etc/hostid"
;;
"NetBSD"* | "DragonFly"*)
install_file="/etc/defaults/rc.conf"
;; ;;
esac esac
install_date="$(ls -alctT "$install_file" | awk '{printf $9 " " $6 " " $7 " " $8 " "}')" ls_prog="$(ls --version 2>&1)"
;; case "$ls_prog" in
*"BusyBox"*) install_date="$(ls -tdce "$install_file" | awk '{printf $10 " " $7 " " $8 " " $9}')" ;;
"Windows") *"crtime"*) install_date="$(ls -tdcE "$install_file" | awk '{printf $6 " " $7}')" ;; # xpg4 (Solaris)
install_date="$(ls -alct --full-time /cygdrive/c/Windows/explorer.exe | awk '{printf $8 " " $9}')" *"ACFHLRSZ"*) install_date="$(ls -dl "$install_file" | awk '{printf $6 " " $7}')" ;; # Toybox
;; *"GNU coreutils"*) install_date="$(ls -tcd --full-time "$install_file" | awk '{printf $6 " " $7}')" ;;
*) install_date="$(ls -dlctT "$install_file" | awk '{printf $9 " " $6 " "$7 " " $8}')" ;;
"Solaris")
install_date="$(ls -alct --full-time /var/sadm/system/logs/install_log | awk '{printf $6 " " $7}')"
;;
"Haiku")
install_date="$(ls -alctd --full-time /boot | awk '{printf $6 " " $7}')"
;;
esac esac
install_date="${install_date//-/ }" install_date="${install_date//-/ }"