Mi piacerebbe avere un po 'di tempo, diciamo 6:45, e aggiungere un numero di ore, diciamo 1,45 ore, per portare a un'altra volta. Quindi vorrei aggiungere 1,45 ore alle 6:45 per avere un'altra volta.
C'è una riga di comando utile per questo? Ho fatto un po 'di Google, ho letto la pagina man datee non ho trovato nulla del genere. wcalcnon sembra gestire i calcoli del tempo.
EDIT: 6 marzo 2015. Questo è lo script con cui ho finito per usare le ore decimali. Potrebbe essere utile un controllo degli errori per assicurarsi che HH: MM usi 2 cifre per le ore.
#!/bin/bash
# Mar 6, 2015
# Add decimal hours to given time.
# Syntax: timeadd HH:MM HOURS
# There MUST be 2 digits for the hours in HH:MM.
# Times must be in military time.
# Ex: timeadd 05:51 4.51
# Ex: timeadd 14:12 2.05
echo " "
# If we have less than 2 parameters, show instructions and exit.
if [ $# -lt 2 ]
then
echo "Usage: timeadd HH:MM DECHOURS"
exit 1
fi
intime=$1
inhours=$2
# Below is arithmetic expansion $(())
# The bc calculator is standard on Ubuntu.
# Below rounds to the minute.
inminutes=$(echo "scale=0; ((($inhours * 60)*10)+5)/10" | bc)
echo "inminutes=$inminutes"
now=$(date -d "$intime today + $inminutes minutes" +'%H:%M')
echo "New time is $now"