Birthday: Merge macOS with BSD

This commit is contained in:
Dylan Araps 2016-12-16 12:07:01 +11:00
parent 708beb1716
commit 14610a992c
1 changed files with 26 additions and 21 deletions

View File

@ -1736,20 +1736,26 @@ get_birthday() {
birthday="$(ls -lUT /var/log/install.log | awk '{printf $6 " " $7 " " $9 " " $8}')" birthday="$(ls -lUT /var/log/install.log | awk '{printf $6 " " $7 " " $9 " " $8}')"
;; ;;
"BSD") "BSD" | "Mac OS X")
case "$kernel_name" in case "$kernel_name" in
"Darwin")
birthday_file="/var/log/install.log"
;;
"OpenBSD"* | "Bitrig"*) "OpenBSD"* | "Bitrig"*)
birthday="$(ls -alctT / | awk '/lost\+found/ {printf $6 " " $7 " " $9 " " $8}')" birthday_file="/"
;; ;;
"FreeBSD"*) "FreeBSD"*)
birthday="$(ls -alctT /etc/hostid | awk '{printf $6 " " $7 " " $9 " " $8}')" birthday_file="/etc/hostid"
;; ;;
"NetBSD"* | "DragonFly"*) "NetBSD"* | "DragonFly"*)
birthday="$(ls -alctT /etc/defaults/rc.conf | awk '{printf $6 " " $7 " " $9 " " $8}')" birthday_file="/etc/defaults/rc.conf"
;; ;;
esac esac
birthday="$(ls -alctT "$birthday_file" | awk '{printf $6 " " $7 " " $9 " " $8}')"
;; ;;
"Windows") "Windows")
@ -1765,8 +1771,8 @@ get_birthday() {
;; ;;
esac esac
birthday="${birthday%\.*}"
birthday="${birthday//-/ }" birthday="${birthday//-/ }"
birthday="${birthday%:*}"
birthday=($birthday) birthday=($birthday)
birthday="$(convert_time "${birthday[@]}")" birthday="$(convert_time "${birthday[@]}")"
} }
@ -2919,25 +2925,24 @@ convert_time() {
year="$1" year="$1"
day="$3" day="$3"
# Split time into hours/minutesr # Split time into hours/minutes
time="${4%\:*}" hour="${4/:*}"
hour="${time/:*}" min="${4/${hour}}"
min="${time/${hour}}"
# Get month. (Month code is used for day of week) # Get month. (Month code is used for day of week)
case "$2" in case "$2" in
1) month="Jan"; month_code="0" ;; 1 | "Jan") month="Jan"; month_code="0" ;;
2) month="Feb"; month_code="3" ;; 2 | "Feb") month="Feb"; month_code="3" ;;
3) month="Mar"; month_code="3" ;; 3 | "Mar") month="Mar"; month_code="3" ;;
4) month="Apr"; month_code="6" ;; 4 | "Apr") month="Apr"; month_code="6" ;;
5) month="May"; month_code="1" ;; 5 | "May") month="May"; month_code="1" ;;
6) month="Jun"; month_code="4" ;; 6 | "Jun") month="Jun"; month_code="4" ;;
7) month="Jul"; month_code="6" ;; 7 | "Jul") month="Jul"; month_code="6" ;;
8) month="Aug"; month_code="2" ;; 8 | "Aug") month="Aug"; month_code="2" ;;
9) month="Sep"; month_code="5" ;; 9 | "Sep") month="Sep"; month_code="5" ;;
10) month="Oct"; month_code="0" ;; 10 | "Oct") month="Oct"; month_code="0" ;;
11) month="Nov"; month_code="3" ;; 11 | "Nov") month="Nov"; month_code="3" ;;
12) month="Dec"; month_code="5" ;; 12 | "Dec") month="Dec"; month_code="5" ;;
esac esac
# Get leap year. # Get leap year.