• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Functions for working with the idealized calendar of Planet Xhilr


コミットメタ情報

リビジョンc15ac07f1ef24eb22dd62c0b10206b8d9a5df1d9 (tree)
日時2017-06-13 16:37:12
作者Joel Matthew Rees <joel.rees@gmai...>
コミッターJoel Matthew Rees

ログメッセージ

pastebin changes

変更サマリ

差分

--- a/econmonths.bc
+++ b/econmonths.bc
@@ -1,20 +1,43 @@
1-
1+# bc script for showing the lengths of the months relative to skip years
2+# for the world of Bobbie, Karel, Dan, and Kristie,
3+#
4+# by Joel Matthew Rees, winter/spring 2017.
5+# Copyright 2017, Joel Matthew Rees
6+#
7+# Permission granted to use for personal entertainment only.
8+# (If you need it for other purposes, rewriting it yourself is not that hard,
9+# and the result will satisfy your needs much more effectively.)
10+#
11+# http://joel-rees-economics.blogspot.com/2017/03/soc500-03-08-calendar-math.html
12+# http://joel-rees-economics.blogspot.com/2017/03/soc500-03-09-computer-calendar.html
13+#
14+# Novel here:
15+# http://joel-rees-economics.blogspot.com/2017/01/soc500-00-00-toc.html
16+#
17+# Pastebin: https://osdn.net/users/reiisi/pastebin/4955
18+#
19+# Save as "econmonth.bc"
20+# invoke as "bc -l econmonth.bc
21+#
22+# In the running bc session, run it with
23+# showmonths(7) for seven years, etc.
24+
225
326 scale = 10;
427
528
6-months[ 1 ] = 30;
7-months[ 2 ] = 29;
8-months[ 3 ] = 30;
29+months[ 0 ] = 30;
30+months[ 1 ] = 29;
31+months[ 2 ] = 30;
32+months[ 3 ] = 29;
933 months[ 4 ] = 29;
10-months[ 5 ] = 29;
11-months[ 6 ] = 30;
12-months[ 7 ] = 29;
13-months[ 8 ] = 30;
34+months[ 5 ] = 30;
35+months[ 6 ] = 29;
36+months[ 7 ] = 30;
37+months[ 8 ] = 29;
1438 months[ 9 ] = 29;
15-months[ 10 ] = 29;
16-months[ 11 ] = 30;
17-months[ 12 ] = 29;
39+months[ 10 ] = 30;
40+months[ 11 ] = 29;
1841
1942 define abs( n ) {
2043 if ( n >= 0 ) {
@@ -24,8 +47,15 @@ define abs( n ) {
2447 }
2548
2649
50+# If you want to do something similar,
51+# for looking at how leap years in your world
52+# match the actual orbits and revolutions
53+# of your world and its moon,
54+# replace isskip() with an appropriate isleap().
55+# Left as an exercise for the reader.
56+
2757 define isskip( y, m ) {
28- if ( m != 1 ) {
58+ if ( m != 0 ) {
2959 return 0;
3060 }
3161 mem = scale;
@@ -41,28 +71,31 @@ define isskip( y, m ) {
4171 return 0;
4272 }
4373 if ( diff343 == 186 ) {
44-# if ( ( diff343 == 53 ) || ( diff343 == 246 ) ) {
4574 return 0;
4675 }
4776 return 1;
4877 }
4978
5079
80+# Note that we are treating the first year as year 0,
81+# and the first month as month 0.
82+# For your earth, you will need to adjust the year and month input and output.
83+
84+
5185 define showmonths( years ) {
5286 sum = 0;
5387 for ( year = 0; year < years; ++year ) {
54- for ( month = 1; month <= 12; ++month ) {
88+ for ( month = 0; month <= 11; ++month ) {
5589 days = months[ month ];
5690 if ( isskip( year, month ) ) {
5791 days -= 1;
5892 }
5993 sum += days;
60-# product = year * ( 241959 / 686 ) + month * ( 241957 / 686 ) / 12;
61- product = year * ( 241957 / 686 ) + month * ( 241957 / 686 ) / 12;
94+ product = year * ( 241957 / 686 ) + ( month + 1 ) * ( 241957 / 686 ) / 12;
6295 diff = product - sum;
6396 print year, " ", month, ": ", days, " (", sum , ", ", product, ": ", diff, ")";
6497 if ( abs( diff ) >= 1 ) {
65- print "*** ";
98+ print "*** > 1 day! ";
6699 }
67100 print "\n";
68101 }