53 lines
1.5 KiB
Plaintext
53 lines
1.5 KiB
Plaintext
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
#===============================================================================
|
||
|
|
# Flight details starting 2017-12-24
|
||
|
|
# Edinburgh (EDI) to Doha (DOH)
|
||
|
|
# Doha (DOH) to Auckland (AKL)
|
||
|
|
#
|
||
|
|
# Departure EDI: 14:55 (+0000)
|
||
|
|
# Arrival DOH: 12:55 (+0300)
|
||
|
|
# Flight time: 6hr 55min
|
||
|
|
#
|
||
|
|
# Connection: 1hr 40min
|
||
|
|
#
|
||
|
|
# Departure DOH: 02:25 (+0300)
|
||
|
|
# Arrival AKL: 05:00 (+1300)
|
||
|
|
# Flight time: 16hr 10min
|
||
|
|
#===============================================================================
|
||
|
|
|
||
|
|
minutes () {
|
||
|
|
local hhmm="${1:?Usage: minutes time variable}"
|
||
|
|
local -n ref="${2:?Usage: minutes time variable}"
|
||
|
|
local hh mm
|
||
|
|
|
||
|
|
hh=${hhmm%%:*}
|
||
|
|
mm=${hhmm##*:}
|
||
|
|
|
||
|
|
ref=$((hh * 60 + mm))
|
||
|
|
}
|
||
|
|
|
||
|
|
echo "Outward flights:"
|
||
|
|
|
||
|
|
dep_edi="$(date -Iminutes -d "2017-12-24 14:55")"
|
||
|
|
minutes '6:55' flight1
|
||
|
|
arr_doh=$(date -Iminutes -d "$dep_edi + $flight1 minutes")
|
||
|
|
|
||
|
|
printf "%-20s %s\n" "Leave Edinburgh at" "$(date -d "$dep_edi" '+%F %R %z')"
|
||
|
|
printf "%-20s %s\n\n" "Arrive Doha at" "$(date -d "$arr_doh" '+%F %R %z')"
|
||
|
|
|
||
|
|
minutes '1:40' doha # connection
|
||
|
|
|
||
|
|
dep_doh=$(date -Iminutes -d "$arr_doh + $doha minutes")
|
||
|
|
minutes '16:10' flight2
|
||
|
|
arr_akl=$(date -Iminutes -d "$dep_doh + $flight2 minutes")
|
||
|
|
|
||
|
|
printf "%-20s %s\n" "Leave Doha at" "$(date -d "$dep_doh" '+%F %R %z')"
|
||
|
|
printf "%-20s %s\n\n" "Arrive Auckland at" "$(date -d "$arr_akl" '+%F %R %z')"
|
||
|
|
|
||
|
|
printf "%-20s %s\n" "New Zealand time" \
|
||
|
|
"$(TZ="Pacific/Auckland" date -d "$(date -Iminutes -d "$arr_akl")" '+%F %R %z')"
|
||
|
|
|
||
|
|
dur=$((flight1 + doha + flight2))
|
||
|
|
printf "%-20s %s\n" "Duration" "$((dur/60))hr $((dur%60))min"
|