langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
25
Task/Discordian-date/Perl-6/discordian-date.pl6
Normal file
25
Task/Discordian-date/Perl-6/discordian-date.pl6
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
my @seasons = < Chaos Discord Confusion Bureaucracy >, 'The Aftermath';
|
||||
my @days = < Sweetmorn Boomtime Pungenday Prickle-Prickle >, 'Setting Orange';
|
||||
sub ordinal ( Int $n ) { $n ~ ( $n % 100 == 11|12|13
|
||||
?? 'th' !! < th st nd rd th th th th th th >[$n % 10] ) }
|
||||
|
||||
sub ddate ( Str $ymd ) {
|
||||
my $d = DateTime.new: "{$ymd}T00:00:00Z" or die;
|
||||
|
||||
my $yold = 'in the YOLD ' ~ $d.year + 1166;
|
||||
|
||||
my $day_of_year0 = $d.day-of-year - 1;
|
||||
|
||||
if $d.is-leap-year {
|
||||
return "St. Tib's Day, $yold" if $d.month == 2 and $d.day == 29;
|
||||
$day_of_year0-- if $day_of_year0 >= 60; # Compensate for St. Tib's Day
|
||||
}
|
||||
|
||||
my $weekday = @days[ $day_of_year0 mod 5 ];
|
||||
my $season = @seasons[ $day_of_year0 div 73 ];
|
||||
my $season_day = ordinal( $day_of_year0 mod 73 + 1 );
|
||||
|
||||
return "$weekday, the $season_day day of $season $yold";
|
||||
}
|
||||
|
||||
say "$_ is {.&ddate}" for < 2010-07-22 2012-02-28 2012-02-29 2012-03-01 >;
|
||||
8
Task/Discordian-date/Pike/discordian-date.pike
Normal file
8
Task/Discordian-date/Pike/discordian-date.pike
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
> Calendar.Discordian.now()->format_ext_ymd();
|
||||
Result: "Pungenday, 59 Bureaucracy 3177"
|
||||
> Calendar.Discordian.Day(Calendar.Day(2011,11,11))->format_ext_ymd();
|
||||
Result: "Setting Orange, 23 The Aftermath 3177"
|
||||
> Calendar.Discordian.Day(Calendar.Badi.Day(168,13,9))->format_ext_ymd();
|
||||
Result: "Setting Orange, 23 The Aftermath 3177"
|
||||
> Calendar.Day((Calendar.Discordian.Month()+1)->day(1));
|
||||
Result: Day(Thu 20 Oct 2011)
|
||||
65
Task/Discordian-date/PowerBASIC/discordian-date.powerbasic
Normal file
65
Task/Discordian-date/PowerBASIC/discordian-date.powerbasic
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#COMPILE EXE
|
||||
#DIM ALL
|
||||
|
||||
'change this for systems that use a different character
|
||||
$DATESEP = "-"
|
||||
|
||||
FUNCTION day(date AS STRING) AS LONG
|
||||
'date is same format as date$
|
||||
DIM tmpdash1 AS LONG, tmpdash2 AS LONG
|
||||
tmpdash1 = INSTR(date, $DATESEP)
|
||||
tmpdash2 = INSTR(-1, date, $DATESEP)
|
||||
FUNCTION = VAL(MID$(date, tmpdash1 + 1, tmpdash2 - tmpdash1 - 1))
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION month(date AS STRING) AS LONG
|
||||
'date is same format as date$
|
||||
DIM tmpdash AS LONG
|
||||
tmpdash = INSTR(date, $DATESEP)
|
||||
FUNCTION = VAL(LEFT$(date, tmpdash - 1))
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION year(date AS STRING) AS LONG
|
||||
'date is same format as date$
|
||||
DIM tmpdash AS LONG
|
||||
tmpdash = INSTR(-1, date, $DATESEP)
|
||||
FUNCTION = VAL(MID$(date, tmpdash + 1))
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION julian(date AS STRING) AS LONG
|
||||
'date is same format as date$
|
||||
'doesn't account for leap years (not needed for ddate)
|
||||
'days preceding 1st of month
|
||||
' jan feb mar apr may jun jul aug sep oct nov dec
|
||||
DATA 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
|
||||
FUNCTION = VAL(READ$(month(date))) + day(date)
|
||||
END FUNCTION
|
||||
|
||||
FUNCTION PBMAIN () AS LONG
|
||||
'Season names
|
||||
DATA "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"
|
||||
'Weekdays
|
||||
DATA "Setting Orange", "Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle"
|
||||
|
||||
DIM dyear AS LONG, dseason AS STRING, dday AS LONG, dweekday AS STRING
|
||||
DIM tmpdate AS STRING, jday AS LONG, result AS STRING
|
||||
|
||||
IF LEN(COMMAND$) THEN
|
||||
tmpdate = COMMAND$
|
||||
ELSE
|
||||
tmpdate = DATE$
|
||||
END IF
|
||||
dyear = year(tmpdate) + 1166
|
||||
IF (2 = month(tmpdate)) AND (29 = day(tmpdate)) THEN
|
||||
result = "Saint Tib's Day, " & STR$(dyear) & " YOLD"
|
||||
ELSE
|
||||
jday = julian(tmpdate)
|
||||
dseason = READ$((jday \ 73) + 1)
|
||||
dday = (jday MOD 73)
|
||||
IF 0 = dday THEN dday = 73
|
||||
dweekday = READ$((jday MOD 5) + 6)
|
||||
result = dweekday & ", " & dseason & " " & TRIM$(STR$(dday)) & ", " & TRIM$(STR$(dyear)) & " YOLD"
|
||||
END IF
|
||||
|
||||
? result
|
||||
END FUNCTION
|
||||
14
Task/Discordian-date/PureBasic/discordian-date.purebasic
Normal file
14
Task/Discordian-date/PureBasic/discordian-date.purebasic
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Procedure.s Discordian_Date(Y, M, D)
|
||||
Protected DoY=DayOfYear(Date(Y,M,D,0,0,0)), Yold$=Str(Y+1166)
|
||||
Dim S.s(4)
|
||||
S(0)="Chaos": S(1)="Discord": S(2)="Confusion": S(3)="Bureaucracy"
|
||||
S(4)="The Aftermath"
|
||||
If (Y%4=0 And Y%100) Or Y%400=0
|
||||
If M=2 And D=29
|
||||
ProcedureReturn "St. Tib's Day, YOLD " + Yold$
|
||||
ElseIf DoY>=2*30
|
||||
DoY-1
|
||||
EndIf
|
||||
EndIf
|
||||
ProcedureReturn S(DoY/73)+" "+Str(DoY%73)+", Yold "+Yold$
|
||||
EndProcedure
|
||||
Loading…
Add table
Add a link
Reference in a new issue