Functions for working with the idealized calendar of Planet Xhilr
Revisión | 3bed05a2926702ed4083fa3ce559718977ca2159 (tree) |
---|---|
Tiempo | 2017-06-13 16:58:46 |
Autor | Joel Matthew Rees <joel.rees@gmai...> |
Commiter | Joel Matthew Rees |
sans leap year check, year / 12
@@ -0,0 +1,40 @@ | ||
1 | +# bc script for calculating idealized lengths of months | |
2 | +# relative to skip years | |
3 | +# for the world of Bobbie, Karel, Dan, and Kristie, | |
4 | +# | |
5 | +# by Joel Matthew Rees, winter/spring 2017. | |
6 | +# Copyright 2017, Joel Matthew Rees | |
7 | +# | |
8 | +# Permission granted to use for personal entertainment only. | |
9 | +# (If you need it for other purposes, rewriting it yourself is not that hard, | |
10 | +# and the result will satisfy your needs much more effectively.) | |
11 | +# | |
12 | +# http://joel-rees-economics.blogspot.com/2017/03/soc500-03-08-calendar-math.html | |
13 | +# http://joel-rees-economics.blogspot.com/2017/03/soc500-03-09-calculating-skip-years.html | |
14 | +# | |
15 | +# Novel here: | |
16 | +# http://joel-rees-economics.blogspot.com/2017/01/soc500-00-00-toc.html | |
17 | +# | |
18 | +# | |
19 | +# Save as "econcalcmonth.bc" | |
20 | +# invoke as "bc -l econcalcmonth.bc | |
21 | +# | |
22 | +# In the running bc session, run it with | |
23 | +# showmonths(7) for seven years, etc. | |
24 | + | |
25 | +define showmonths( years ) { | |
26 | + sum = 0; | |
27 | + for ( year = 0; year < years; ++year ) { | |
28 | + for ( month = 1; month <= 12; ++month ) { | |
29 | + days = 29; | |
30 | + sum += days; | |
31 | + product = year * ( 241957 / 686 ) + month * ( 241957 / 686 ) / 12; | |
32 | + if ( ( product - sum ) >= 0 ) { | |
33 | + days += 1; sum += 1; | |
34 | + } | |
35 | + print year, " ", month, ": ", days, " (", sum , ", ", product, ")\n"; | |
36 | + } | |
37 | + } | |
38 | +} | |
39 | + | |
40 | + |