Days between dates.
Just an experiment to determine the amount of days between two dates. In this case it is the days left in the current presidency.
[code]
#!/bin/bash
D=`date +%Y-%m-%d`
D1=`date +%s -d "$D"`
D2=`date +%s -d "2017-01-20"`
((diff_sec=D2-D1))
echo - | awk -v SECS=$diff_sec '{printf "Number of days : %d",SECS/(60*60*24)}'
echo " till Obama leaves office."
[/code]
Result:
$ ./datediff.sh
Number of days : 656 days till Obama leaves office.
$
Or for semi-gui, you could use a launcher to start the program and then not need the command line.
[code] #!/bin/bash D=`date +%Y-%m-%d` D1=`date +%s -d "$D"` D2=`date +%s -d "2017-01-20"` ((diff_sec=D2-D1)) a=`echo - | awk -v SECS=$diff_sec '{printf "Number of days : %d",SECS/(60*60*24)}'` a=$a" till Obama leaves office." zenity --info --text="$a" [/code]
Comments
Post a Comment