b4965dce219c8b83a9b82b218c2680cd42457a08
2 # Desc: Prints a list of galactic tick dates
3 # Usage: ./calcGalTick.sh [int start] [int end]
4 # Input: arg1: int start index
6 # Example: ./calcGalTick.sh 0 250
7 # Depends: bc 1.07.1; date (GNU coreutils) 8.32
9 # Ref/Attrib: [1] Galactic Tick Day Calendar. (2021-10-20). https://github.com/GalacticTick/GalacticTick.github.io/blob/master/documents/press-3.pdf
11 # Galactic Tick duration equation (seconds)
12 ## (Earth years per galactic turn) / (100ths of arcseconds per turn) * (solar days in Earth year)
13 sGalTickEq
="(225 * 10^6) / (1296000 * 100) * (365.25) * (24*3600)";
14 #sGalTickEq="(225 * 10^6) / (1296000 * 100) * (365.24217) * (24*3600)";
16 # Galactic tick duration (seconds)
17 sGalTick
="$(echo "$sGalTickEq" | bc -l)"; # 54788453.99999999999996457600
18 #sGalTick="$(printf "%.0f" "$sGalTick")"; # round to int
20 # Unix epoch of first tick (seconds; date Hans Lippershey patented the first telescope)
21 ueFirstTick
="$(date --date="1608-10-02" +%s)";
23 yell
() { echo "$0: $*" >&2; } # print script path and all args to stderr
24 die
() { yell
"$*"; exit 111; } # same as yell() but non-zero exit status
25 must
() { "$@" || die
"cannot $*"; } # runs args as command, reports args if command fails
27 # Usage: printGalTickDate [int]
28 # Input: arg1: nthGalTick int n'th observance since frist Galactic Tick
29 # var: sGalTick: int Galactic tick duration
30 # var: ueFirstTick: int Unix epoch of first tick
31 # Output: str: ISO-8601 date string
32 # Example: printGalTickDate 239
34 # Depends: bc 1.07.1; date (GNU coreutils) 8.32
36 local nthGalTick output
;
38 # Calc Unix epoch of n'th observance since first Galactic Tick
39 ## 0th tick was first tick
41 ueTickEq
="( $ueFirstTick + ( ($nthGalTick - 0) * $sGalTick ) )";
42 ueTick
="$( echo "$ueTickEq" | bc -l )";
45 #output="$(date --date="@$ueTick" +%Y-%m-%dT%H:%M:%S%z)";
46 output
="$(date --date="@
$ueTick" +%Y-%m-%d)";
48 printf "%s\n" "$output";
49 }; # print ISO-8601 calendar date of tick
53 for ((tick
="$start"; tick
<="$end"; tick
++)); do
54 printf "%03d: " "$tick"; # observance number
55 printGalTickDate
"$tick"; # date
61 # Author: Steven Baltakatei Sandoval