This commit is contained in:
Ingy döt Net 2013-04-10 21:29:02 -07:00
parent 764da6cbbb
commit db842d013d
19005 changed files with 197040 additions and 7 deletions

View file

@ -0,0 +1,55 @@
link printf
procedure main()
Demo(2010,1,1)
Demo(2010,7,22)
Demo(2012,2,28)
Demo(2012,2,29)
Demo(2012,3,1)
Demo(2010,1,5)
Demo(2011,5,3)
Demo(2012,2,28)
Demo(2012,2,29)
Demo(2012,3,1)
Demo(2010,7,22)
Demo(2012,12,22)
end
procedure Demo(y,m,d) #: demo display
printf("%i-%i-%i = %s\n",y,m,d,DiscordianDateString(DiscordianDate(y,m,d)))
end
record DiscordianDateRecord(year,yday,season,sday,holiday)
procedure DiscordianDate(year,month,day) #: Convert normal date to Discordian
static cal
initial cal := [31,28,31,30,31,30,31,31,30,31,30,31]
ddate := DiscordianDateRecord(year+1166)
every (ddate.yday := day - 1) +:= cal[1 to month-1] # zero origin
ddate.sday := ddate.yday
if ddate.year % 4 = 2 & month = 2 & day = 29 then
ddate.holiday := 1 # Note: st tibs is outside of weekdays
else {
ddate.season := (ddate.yday / 73) + 1
ddate.sday := (ddate.yday % 73) + 1
ddate.holiday := 1 + ddate.season * case ddate.sday of { 5 : 1; 50 : 2}
}
return ddate
end
procedure DiscordianDateString(ddate) #: format a Discordian Date String
static days,seasons,holidays
initial {
days := ["Sweetmorn","Boomtime","Pungenday","Prickle-Prickle","Setting Orange"]
seasons := ["Chaos","Discord","Confusion","Bureaucracy","The Aftermath"]
holidays := ["St. Tib's Day","Mungday","Chaoflux","Mojoday","Discoflux",
"Syaday","Confuflux","Zaraday","Bureflux","Maladay","Afflux"]
}
return (( holidays[\ddate.holiday] || "," ) |
( days[1+ddate.yday%5] || ", day " ||
ddate.sday || " of " || seasons[ddate.season])) ||
" in the YOLD " || ddate.year
end

View file

@ -0,0 +1,4 @@
require'dates'
leap=: _1j1 * 0 -/@:= 4 100 400 |/ {.@]
bs=: ((#:{.) + 0 j. *@[ * {:@]) +.
disc=: ((1+0 73 bs[ +^:(58<]) -/@todayno@(,: 1 1,~{.)@]) ,~1166+{.@])~ leap

View file

@ -0,0 +1,10 @@
disc 2012 2 28
3178 1 59
disc 2012 2 29
3178 1 59j1
disc 2012 3 1
3178 1 60j1
disc 2012 12 31
3178 5 73j1
disc 2013 1 1
3179 1 1

View file

@ -0,0 +1,15 @@
DiscordianDate[y_, m_, d_] := Module[{year = ToString[y + 1166], month = m, day = d},
DMONTHS = {"Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"};
DDAYS = {"Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"};
DayOfYear = DateDifference[{y} ,{y, m, d}] + 1;
LeapYearQ = (Mod[#, 4]== 0 && (Mod[#, 100] != 0 || Mod[#, 400] == 0))&@ y;
If [ LeapYearQ && month == 2 && day == 29,
Print["Today is St. Tib's Day, YOLD ", ]
,
If [ LeapYearQ && DayOfYear >= 60, DayOfYear -= 1 ];
{season, dday} = {Quotient[DayOfYear, 73], Mod[DayOfYear, 73]};
Print["Today is ", DDAYS[[Mod[dday,4] + 1]],", ",DMONTHS[[season+1]]," ",dday,", YOLD ",year]
];
]