Last active
March 17, 2017 11:22
-
-
Save terrycojones/5bb61e9ff95c7f90156d39389b19c144 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
case $# in | |
1|2) ;; | |
*) echo "Usage: $(basename $0) year1 [year2]" >&2; exit 1;; | |
esac | |
offset=$(($(date "+%Y") - 1950)) | |
case $(basename $0) in | |
convert-calbc) | |
case $# in | |
1) | |
bp=$(echo "$1 1950 +pq" | dc) | |
echo "cal BP = $bp age = $(($bp + $offset))" | |
;; | |
2) | |
bp1=$(echo "$1 1950 +pq" | dc) | |
bp2=$(echo "$2 1950 +pq" | dc) | |
echo cal BP = $bp1-$bp2 age = $(echo "$bp1 $bp2 + 2 / $offset + pq" | dc) | |
;; | |
esac | |
;; | |
convert-calbp) | |
case $# in | |
1) | |
echo "cal BP = $1 age = $(($1 + $offset))" | |
;; | |
2) | |
echo cal BP = $1-$2 age = $(echo "$1 $2 + 2 / $offset + pq" | dc) | |
;; | |
esac | |
;; | |
*) | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment