Discordian date: Difference between revisions

add Refal
m (→‎{{header|Wren}}: Minor tidy)
(add Refal)
 
(2 intermediate revisions by one other user not shown)
Line 2,170:
readln;
end.</syntaxhighlight>
 
=={{header|EasyLang}}==
<syntaxhighlight>
seasons$[] = [ "Chaos" "Discord" "Confusion" "Bureaucracy" "The Aftermath" ]
weekday$[] = [ "Sweetmorn" "Boomtime" "Pungenday" "Prickle-Prickle" "Setting Orange" ]
apostle$[] = [ "Mungday" "Mojoday" "Syaday" "Zaraday" "Maladay" ]
holiday$[] = [ "Chaoflux" "Discoflux" "Confuflux" "Bureflux" "Afflux" ]
#
func leap x .
return if x mod 400 = 0 or x mod 4 = 0 and x mod 100 <> 0
.
func day_of_year y m d .
days[] = [ 31 28 31 30 31 30 31 31 30 31 30 31 ]
repeat
m -= 1
until m = 0
d += days[m]
if m = 2 and leap y = 1
d += 1
.
.
return d
.
func$ ddate y m d .
doy = day_of_year y m d
dyear = y + 1166
if leap y = 1 and m = 2 and d = 29
return "St. Tib's Day, in the YOLD " & dyear
.
if leap y = 1 and doy >= 60
doy -= 1
.
dsday = doy mod1 73
dseason = doy div1 73
r$ = weekday$[doy mod1 5] & ", day " & dsday & " of " & seasons$[dseason]
r$ &= " in the YOLD " & dyear & "."
if dsday = 5
r$ &= " Celebrate " & apostle$[dseason] & "!"
elif dsday = 50
r$ &= " Celebrate " & holiday$[dseason] & "!"
.
return r$
.
proc show d$ . .
a[] = number strsplit d$ "-"
write d$ & " --> "
print ddate a[1] a[2] a[3]
.
show "2016-01-05"
show "2016-02-28"
show "2016-02-29"
show "2016-03-01"
show "2016-12-31"
show "2025-03-19"
show substr timestr systime 1 10
</syntaxhighlight>
 
=={{header|Euphoria}}==
Line 4,416 ⟶ 4,472:
2012-03-01 is Setting Orange, the 60th day of Chaos in the YOLD 3178
</pre>
 
=={{header|Refal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
, <Numb <Arg 1>>: s.GY
, <Numb <Arg 2>>: s.GM
, <Numb <Arg 3>>: s.GD
, <DisDate s.GY s.GM s.GD>: {
True e.Desc = <Prout e.Desc>;
False = <Prout 'Invalid input'>;
};
};
 
DisDate {
s.GY 2 29, <IsLeapYear s.GY>: True =
True 'St. Tib\'s day in the YOLD ' <Symb <+ 1166 s.GY>>;
 
s.GY s.GM s.GD, <Compare s.GM 1>: '-' = False;
s.GY s.GM s.GD, <Compare s.GM 12>: '+' = False;
s.GY s.GM s.GD, <Compare s.GD 1>: '-' = False;
s.GY s.GM s.GD, <Compare s.GD <Item s.GM <MonthLength>>>: '+' = False;
 
s.GY s.GM s.GD,
<+ <Item s.GM <MonthOffset>> s.GD>: s.DOY,
<Divmod <- s.DOY 1> 73>: (s.DS1) s.DD1,
<+ s.DS1 1>: s.DS,
<+ s.DD1 1>: s.DD,
<+ <Mod <- s.DOY 1> 5> 1>: s.DWD,
 
<Item s.DWD <Weekday>>: (e.Weekday),
<Item s.DS <Seasons>>: (e.Season),
 
e.Weekday ', day ' <Symb s.DD> ' of '
e.Season ' in the YOLD ' <Symb <+ 1166 s.GY>>: e.Desc,
s.DD: {
5, <Item s.DS <Holy5>>: (e.H) = True e.Desc ': celebrate ' e.H;
50, <Item s.DS <Holy50>>: (e.H) = True e.Desc ': celebrate ' e.H;
s.X = True e.Desc;
};
};
 
Item {
1 t.I e.X = t.I;
s.N t.I e.X = <Item <- s.N 1> e.X>;
};
 
IsLeapYear {
s.GY, <Mod s.GY 4>: 0 = True;
s.GY, <Mod s.GY 100>: 0 = False;
s.GY, <Mod s.GY 400>: 0 = True;
s.GY = False;
};
 
MonthOffset { = 0 31 59 90 120 151 181 212 243 273 304 334; };
MonthLength { = 31 28 31 30 31 30 31 31 30 31 30 31; };
 
Weekday { = ('Sweetmorn') ('Boomtime') ('Pungenday')
('Prickle-Prickle') ('Setting Orange'); };
 
Seasons { = ('Chaos') ('Discord') ('Confusion') ('Bureaucracy')
('The Aftermath'); };
 
Holy5 { = ('Mungday') ('Mojoday') ('Syaday') ('Zaraday') ('Maladay'); };
Holy50 { = ('Chaoflux') ('Discoflux') ('Confuflux')
('Bureflux') ('Afflux'); };</syntaxhighlight>
{{out}}
<pre>$ refgo ddate 2010 7 22
Pungenday, day 57 of Confusion in the YOLD 3176
$ refgo ddate 2012 2 28
Prickle-Prickle, day 59 of Chaos in the YOLD 3178
$ refgo ddate 2012 2 29
St. Tib's day in the YOLD 3178
$ refgo ddate 2012 3 1
Setting Orange, day 60 of Chaos in the YOLD 3178
$ refgo ddate 2010 1 5
Setting Orange, day 5 of Chaos in the YOLD 3176: celebrate Mungday
$ refgo ddate 2011 5 3
Pungenday, day 50 of Discord in the YOLD 3177: celebrate Discoflux</pre>
 
=={{header|REXX}}==
2,115

edits