Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
33
Task/Discordian-date/Phix/discordian-date-1.phix
Normal file
33
Task/Discordian-date/Phix/discordian-date-1.phix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
constant seasons = {"Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"}
|
||||
constant weekday = {"Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"}
|
||||
constant apostle = {"Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay"}
|
||||
constant holiday = {"Chaoflux", "Discoflux", "Confuflux", "Bureflux", "Afflux"}
|
||||
|
||||
function discordianDate(sequence dt)
|
||||
string dyear, dseas, dwday
|
||||
integer leap, doy, dsday,dseason
|
||||
integer {y,m,d} = dt
|
||||
dyear = sprintf("%d",y+1166)
|
||||
leap = isleapyear(y)
|
||||
if leap and m=2 and d=29 then
|
||||
return "St. Tib's Day, in the YOLD " & dyear
|
||||
end if
|
||||
|
||||
doy = day_of_year(y,m,d)-1
|
||||
if leap and doy>=60 then
|
||||
doy -= 1
|
||||
end if
|
||||
|
||||
dsday = remainder(doy,73)+1
|
||||
dseason = floor(doy/73+1)
|
||||
if dsday=5 then
|
||||
return apostle[dseason] & ", in the YOLD " & dyear
|
||||
elsif dsday=50 then
|
||||
return holiday[dseason] & ", in the YOLD " & dyear
|
||||
end if
|
||||
|
||||
dseas = seasons[dseason]
|
||||
dwday = weekday[remainder(doy,5)+1]
|
||||
|
||||
return sprintf("%s, day %d of %s in the YOLD %s", {dwday, dsday, dseas, dyear})
|
||||
end function
|
||||
10
Task/Discordian-date/Phix/discordian-date-2.phix
Normal file
10
Task/Discordian-date/Phix/discordian-date-2.phix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
sequence dt = {2015,1,1,0,0,0,0,0}
|
||||
include timedate.e
|
||||
atom oneday = timedelta(days:=1)
|
||||
set_timedate_formats({"DD/MM/YYYY: "})
|
||||
for i=1 to 5 do
|
||||
?format_timedate(dt)&discordianDate(dt)
|
||||
dt = adjust_timedate(dt,oneday*72)
|
||||
?format_timedate(dt)&discordianDate(dt)
|
||||
dt = adjust_timedate(dt,oneday)
|
||||
end for
|
||||
31
Task/Discordian-date/Sidef/discordian-date.sidef
Normal file
31
Task/Discordian-date/Sidef/discordian-date.sidef
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
require('Time::Piece');
|
||||
|
||||
var seasons = %w(Chaos Discord Confusion Bureaucracy The\ Aftermath);
|
||||
var week_days = %w(Sweetmorn Boomtime Pungenday Prickle-Prickle Setting\ Orange);
|
||||
|
||||
func ordinal (n) {
|
||||
"#{n}" + (n % 100 ~~ [11,12,13] ? 'th'
|
||||
: <th st nd rd th th th th th th>[n % 10])
|
||||
}
|
||||
|
||||
func ddate(ymd) {
|
||||
var d = %s'Time::Piece'.strptime(ymd, '%Y-%m-%d');
|
||||
var yold = "in the YOLD #{d.year + 1166}";
|
||||
|
||||
var day_of_year0 = d.day_of_year;
|
||||
|
||||
if (d.is_leap_year) {
|
||||
return "St. Tib's Day, #{yold}" if ([d.mon, d.mday] == [2, 29]);
|
||||
day_of_year0-- if (day_of_year0 >= 60); # Compensate for St. Tib's Day
|
||||
}
|
||||
|
||||
var weekday = week_days[day_of_year0 % week_days.len];
|
||||
var season = seasons[day_of_year0 / 73];
|
||||
var season_day = ordinal(day_of_year0 % 73 + 1);
|
||||
|
||||
return "#{weekday}, the #{season_day} day of #{season} #{yold}";
|
||||
}
|
||||
|
||||
%w(2010-07-22 2012-02-28 2012-02-29 2012-03-01).each { |ymd|
|
||||
say "#{ymd} is #{ddate(ymd)}"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue