Discordian date: Difference between revisions

m
syntax highlighting fixup automation
m (→‎{{header|C sharp}}: Regularize header markup to recommended on category page)
m (syntax highlighting fixup automation)
Line 10:
This program is written to run under CP/M, and it takes a Gregorian date as an argument on the command line, in <code>DDMMYYYY</code> format.
 
<langsyntaxhighlight lang="8080asm"> ;; On the 44th day of Discord in the YOLD 3186, ddate
;; has finally come to CP/M.
bdos: equ 5 ; CP/M syscalls
Line 233:
tibsday: db 'Saint Tib',39,'s Day$'
yold: db ' in the YOLD $'
</syntaxhighlight>
</lang>
 
{{out}}
Line 260:
This code is written to compile to a <code>.COM</code> file using <code>nasm</code>.
 
<langsyntaxhighlight lang="asm"> ;; DDATE for MS-DOS (assembles using nasm)
bits 16
cpu 8086
Line 462:
xflux: db 'flux!$'
tibsday: db "Saint Tib's Day$"
yold: db ' in the YOLD $'</langsyntaxhighlight>
 
{{out}}
Line 481:
 
discordian.adb:
<langsyntaxhighlight Adalang="ada">with Ada.Calendar.Arithmetic;
with Ada.Text_IO;
with Ada.Integer_Text_IO;
Line 684:
 
end Discordian;
</syntaxhighlight>
</lang>
 
{{Out}}
Line 699:
{{Trans|ALGOL W}} which was itself, {{Trans|MAD}}
Algol 68 has variable length strings which simplifies this a lot relative to the Algol W version.
<langsyntaxhighlight lang="algol68">BEGIN # DISCORDIAN DATE CALCULATION - TRANSLATION OF MAD VIA ALGOL W #
INT greg, gmonth, gday, gyear;
[]STRING holys = []STRING( "MUNG", "MOJO", "SYA", "ZARA", "MALA" )[ AT 0 ];
Line 727:
FI
FI
END</langsyntaxhighlight>
{{out}}
<pre>
Line 757:
Algol W doesn't have the array initialisation equivalent of MAD's VECTOR VALUES and also does not allow implicit declarations.
Algol W does not have I/O formsts or variable length strings in output, which makes this version somewhat longer.
<langsyntaxhighlight lang="algolw">BEGIN % DISCORDIAN DATE CALCULATION - TRANSLATION OF MAD %
INTEGER GREG, GMONTH, GDAY, GYEAR;
STRING(16) ARRAY HOLY5 ( 0 :: 4 );
Line 812:
END IF_FAY_EQ_5__DAY_EQ_50
END
END.</langsyntaxhighlight>
{{out}}
<pre>
Line 836:
=={{header|AppleScript}}==
 
<langsyntaxhighlight lang="applescript">on gregorianToDiscordian(inputDate) -- Input: AppleScript date object.
(*
Discordian years are aligned with, and the same length as, Gregorian years.
Line 883:
set gregorianDate to ASDate's date string
set discordianDate to gregorianToDiscordian(ASDate)
return {Gregorian:gregorianDate, Discordian:discordianDate}</langsyntaxhighlight>
 
{{output}}
<langsyntaxhighlight lang="applescript">{Gregorian:"Saturday 5 December 2020", Discordian:"Prickle-Prickle, The Aftermath 47, 3186"}</langsyntaxhighlight>
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# DDATE.AWK - Gregorian to Discordian date contributed by Dan Nielsen
# syntax: GAWK -f DDATE.AWK [YYYYMMDD | YYYY-MM-DD | MM-DD-YYYY | DDMMMYYYY | YYYY] ...
Line 988:
errors++
}
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 1,003:
{{trans|PowerBASIC}}
 
<langsyntaxhighlight lang="qbasic">#INCLUDE "datetime.bi"
 
DECLARE FUNCTION julian(AS DOUBLE) AS INTEGER
Line 1,053:
NEXT
FUNCTION = tmp + DAY(d)
END FUNCTION</langsyntaxhighlight>
{{out}}
<pre>"Discordian date.exe" 19-10-2015
Line 1,060:
=={{header|Batch File}}==
{{works with|Windows XP Service Pack 3}}
<langsyntaxhighlight lang="dos">@echo off
goto Parse
 
Line 1,237:
 
:End
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,276:
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<langsyntaxhighlight lang="bbcbasic"> INSTALL @lib$+"DATELIB"
PRINT "01/01/2011 -> " FNdiscordian("01/01/2011")
Line 1,313:
ENDIF
= Weekday$(day% MOD 5) + ", " + STR$(day% MOD 73 + 1) + " " + \
\ Season$(day% DIV 73) + ", YOLD " + STR$(year% + 1166)</langsyntaxhighlight>
{{Out}}
<pre>
Line 1,334:
Reads the date to convert from stdin as three separate numeric inputs (year, month, and day).
 
<langsyntaxhighlight lang="befunge">0" :raeY">:#,_&>\" :htnoM">:#,_&>04p" :yaD">:#,_$&>55+,1-:47*v
v"f I".+1%,,,,"Day I":$_:#<0#!4#:p#-4#1g4-#0+#<<_v#!*!-2g40!-<
>"o",,,/:5+*66++:4>g#<:#44#:9#+*#1-#,_$$0 v_v#!< >$ 0 "yaD " v
@,+55.+*+92"j"$_,#!>#:<", in the YOLD"*84 <.>,:^ :"St. Tib's"<
$# #"#"##"#"Chaos$Discord$Confusion$Bureaucracy$The Aftermath$</langsyntaxhighlight>
 
{{out}} (multiple runs)
Line 1,363:
For the source code of <code>ddate</code> in util-linux package, see [[http://jubal.westnet.com/hyperdiscordia/ddate.html]].
 
<langsyntaxhighlight Clang="c">#include <stdlib.h>
#include <stdio.h>
#include <time.h>
Line 1,434:
return 0;
}</langsyntaxhighlight>
 
Demonstration:
Line 1,456:
 
=={{header|C sharp|C#}}==
<langsyntaxhighlight lang="csharp">using System;
 
public static class DiscordianDate
Line 1,510:
}
 
}</langsyntaxhighlight>
{{out}}
<pre>
Line 1,532:
 
=={{header|C++}}==
<langsyntaxhighlight lang="cpp">
#include <iostream>
#include <algorithm>
Line 1,619:
return 0;
}
</syntaxhighlight>
</lang>
{{out}}<pre>
Enter a date (dd mm yyyy) or 0 to quit: 19 10 2015
Line 1,641:
 
=={{header|Clojure}}==
<langsyntaxhighlight lang="clojure">(require '[clj-time.core :as tc])
 
(def seasons ["Chaos" "Discord" "Confusion" "Bureaucracy" "The Aftermath"])
Line 1,663:
(let [day-of-year (dec (.getDayOfYear (tc/date-time year month day)))
dday (discordian-day day-of-year (leap-year? year))]
(format "%s, YOLD %s" dday (+ year year-offset))))</langsyntaxhighlight>
 
{{out}}
Line 1,680:
 
=={{header|CLU}}==
<langsyntaxhighlight lang="clu">% This program needs to be merged with PCLU's "useful.lib",
% so it can use get_argv to read the command line.
%
Line 1,879:
stream$putl(po, eris_date$from_date(d).format)
end
end start_up</langsyntaxhighlight>
{{out}}
<pre>$ ./ddate
Line 1,893:
=={{header|D}}==
 
<langsyntaxhighlight lang="d">import std.stdio, std.datetime, std.conv, std.string;
immutable seasons = ["Chaos", "Discord", "Confusion",
Line 1,972:
}
}
}</langsyntaxhighlight>
{{out}}
<pre>$ ./ddate 20100722 20120228 20120229 20120301 20100105 20110503 20151019 00000101 -11660101
Line 1,989:
{{libheader| System.DateUtils}}
{{Trans|D}} Partial translation of D.
<syntaxhighlight lang="delphi">
<lang Delphi>
program Discordian_date;
 
Line 2,084:
 
readln;
end.</langsyntaxhighlight>
 
=={{header|Euphoria}}==
{{trans|D}}
<langsyntaxhighlight lang="euphoria">function isLeapYear(integer year)
return remainder(year,4)=0 and remainder(year,100)!=0 or remainder(year,400)=0
end function
Line 2,146:
today = date()
today[YEAR] += 1900
puts(1, discordianDate(today))</langsyntaxhighlight>
 
=={{header|F Sharp|F#}}==
 
<langsyntaxhighlight lang="fsharp">open System
 
let seasons = [| "Chaos"; "Discord"; "Confusion"; "Bureaucracy"; "The Aftermath" |]
Line 2,175:
|> Seq.iter(fun (s,d) -> printfn "%s is %s" s (ddate d))
0
</syntaxhighlight>
</lang>
{{out}}
<pre>2012-02-28 is Chaos 59, 3178 YOLD
Line 2,185:
 
=={{header|Fortran}}==
<syntaxhighlight lang="fortran">
<lang FORTRAN>
program discordianDate
implicit none
Line 2,384:
end if
end function Pleapyear
</syntaxhighlight>
</lang>
<pre>
compiled as ddate.
Line 2,400:
=={{header|FreeBASIC}}==
{{trans|BASIC}}
<langsyntaxhighlight lang="freebasic">#Include "datetime.bi"
 
meses:
Line 2,456:
cDiscordiano("15/07/2019")
cDiscordiano("19/03/2025")
Sleep</langsyntaxhighlight>
{{out}}
<pre>
Line 2,475:
=={{header|Go}}==
A package modeled after the time package in the Go standard library
<langsyntaxhighlight lang="go">package ddate
 
import (
Line 2,607:
}
return
} </langsyntaxhighlight>
Example program using above package
<langsyntaxhighlight lang="go">package main
 
import (
Line 2,651:
fmt.Fprintf(os.Stderr, "usage: %s [+format] [day month year]\n", os.Args[0])
os.Exit(1)
}</langsyntaxhighlight>
{{Out}}
<pre>
Line 2,662:
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import Data.Time (isLeapYear)
import Data.Time.Calendar.MonthDay (monthAndDayToDayOfYear)
import Text.Printf (printf)
Line 2,705:
weekday = toEnum $ dayOfYear `mod` 5
season = toEnum $ dayOfYear `div` 73
dayOfSeason = 1 + dayOfYear `mod` 73</langsyntaxhighlight>
 
Examples:
 
<langsyntaxhighlight lang="haskell">test = mapM_ display dates
where
display d = putStr (show d ++ " -> ") >> print (fromYMD d)
Line 2,719:
,(2010,9,2)
,(2010,12,31)
,(2011,1,1)]</langsyntaxhighlight>
 
<pre>λ> test
Line 2,744:
=={{header|Icon}} and {{header|Unicon}}==
This version is loosely based on a modified translation of the original ddate.c and like the original the leap year functionality is Julian not Gregorian.
<langsyntaxhighlight Iconlang="icon">link printf
 
procedure main()
Line 2,798:
ddate.sday || " of " || seasons[ddate.season])) ||
" in the YOLD " || ddate.year
end</langsyntaxhighlight>
 
{{Out}}
Line 2,815:
 
=={{header|J}}==
<langsyntaxhighlight lang="j">require'dates'
leap=: _1j1 * 0 -/@:= 4 100 400 |/ {.@]
bs=: ((#:{.) + 0 j. *@[ * {:@]) +.
disc=: ((1+0 73 bs[ +^:(58<]) -/@todayno@(,: 1 1,~{.)@]) ,~1166+{.@])~ leap</langsyntaxhighlight>
 
Example use:
 
<syntaxhighlight lang="text"> disc 2012 2 28
3178 1 59
disc 2012 2 29
Line 2,837:
3181 4 73
disc 2000 3 13
3166 1 72j1</langsyntaxhighlight>
 
see [[Talk:Discordian_date|talk page]]. But, in essence, this version uses season ordinals with a single imaginary day after the 59th of the first season, on leap years. This is implemented so that that imaginary day has been passed for all remaining days of a leap year.
Line 2,843:
=={{header|Java}}==
 
<langsyntaxhighlight lang="java">import java.util.Calendar;
import java.util.GregorianCalendar;
 
Line 2,902:
assert (discordianDate(new GregorianCalendar(y, m, d)).equals(result));
}
}</langsyntaxhighlight>
 
{{Out}}
Line 2,909:
=={{header|JavaScript}}==
 
<langsyntaxhighlight lang="javascript">
/**
* All Hail Discordia! - this script prints Discordian date using system date.
Line 3,028:
 
module.exports = discordianDate;
</syntaxhighlight>
</lang>
 
Example use:
 
<langsyntaxhighlight lang="javascript">
console.log(discordianDate(new Date(Date.now())));
"Boomtime, the 2nd day of Chaos in the YOLD 3183"
</syntaxhighlight>
</lang>
 
look at [http://www.cs.cmu.edu/~tilt/principia/body.html#applecorps calendar];
Line 3,041:
 
=={{header|JotaCode}}==
<langsyntaxhighlight lang="jotacode">@print(
"Today is ",
@let(1,@add(@switch(@time("mon"),
Line 3,075:
", YOLD ",
@add(@time("year"),3066))
)),".")</langsyntaxhighlight>
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">using Dates
 
function discordiandate(year::Integer, month::Integer, day::Integer)
Line 3,113:
@show discordiandate(2017, 08, 15)
@show discordiandate(1996, 02, 29)
@show discordiandate(1996, 02, 19)</langsyntaxhighlight>
 
{{out}}
Line 3,122:
=={{header|Kotlin}}==
{{trans|Java}}
<langsyntaxhighlight lang="scala">import java.util.Calendar
import java.util.GregorianCalendar
 
Line 3,176:
test(2011, 4, 3, "Discoflux, in the YOLD 3177")
test(2015, 9, 19, "Boomtime, day 73 of Bureaucracy in the YOLD 3181")
}</langsyntaxhighlight>
 
=={{header|MAD}}==
 
<langsyntaxhighlight MADlang="mad"> R DISCORDIAN DATE CALCULATION
R
R PUNCH CARD SHOULD CONTAIN -
Line 3,223:
END OF CONDITIONAL
END OF CONDITIONAL
END OF PROGRAM</langsyntaxhighlight>
 
{{out}}
Line 3,243:
 
=={{header|Maple}}==
<langsyntaxhighlight lang="maple">convertDiscordian := proc(year, month, day)
local days31, days30, daysThisYear, i, dYear, dMonth, dDay, seasons, week, dayOfWeek;
days31 := [1, 3, 5, 7, 8, 10, 12];
Line 3,279:
convertDiscordian (2016, 1, 1);
convertDiscordian (2016, 2, 29);
convertDiscordian (2016, 12, 31);</langsyntaxhighlight>
{{out}}
<pre>
Line 3,288:
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">DiscordianDate[y_, m_, d_] := Module[{year = ToString[y + 1166], month = m, day = d},
 
DMONTHS = {"Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"};
Line 3,302:
Print["Today is ", DDAYS[[Mod[dday,4] + 1]],", ",DMONTHS[[season+1]]," ",dday,", YOLD ",year]
];
]</langsyntaxhighlight>
{{Out}}
<pre>DiscordianDate[2012,2,28]
Line 3,315:
=={{header|Nim}}==
We use a DateTime object as intermediate representation.
<langsyntaxhighlight Nimlang="nim">import times, strformat
 
const
Line 3,397:
showDiscordianDate(2010, 07, 22)
showDiscordianDate(2012, 09, 02)
showDiscordianDate(2012, 12, 31)</langsyntaxhighlight>
 
{{out}}
Line 3,409:
 
=={{header|Pascal}}==
<syntaxhighlight lang="pascal">
<lang Pascal>
program ddate;
{
Line 3,569:
WriteLn(Eris);
end.
</syntaxhighlight>
</lang>
{{Out}}
<pre>
Line 3,585:
=={{header|Perl}}==
{{trans|Raku}}
<langsyntaxhighlight lang="perl">use 5.010;
use strict;
use warnings;
Line 3,618:
say "$_ is " . ddate($_) for qw< 2010-07-22 2012-02-28 2012-02-29 2012-03-01 >;
</syntaxhighlight>
</lang>
{{out}}
<pre>2010-07-22 is Pungenday, the 57th day of Confusion in the YOLD 3176
Line 3,627:
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">seasons</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"Chaos"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Discord"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Confusion"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Bureaucracy"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"The Aftermath"</span><span style="color: #0000FF;">},</span>
Line 3,669:
<span style="color: #000000;">dt</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">adjust_timedate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dt</span><span style="color: #0000FF;">,</span><span style="color: #000000;">oneday</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 3,687:
 
 
<syntaxhighlight lang="php">
<lang PHP>
<?php
$Anerisia = array(31,28,31,30,31,30,31,31,30,31,30,31);
Line 3,770:
 
?>
</syntaxhighlight>
</lang>
 
{{Out}}
Line 3,788:
=={{header|PicoLisp}}==
{{trans|Python}}
<langsyntaxhighlight PicoLisplang="picolisp">(de disdate (Year Month Day)
(let? Date (date Year Month Day)
(let (Leap (date Year 2 29) D (- Date (date Year 1 1)))
Line 3,801:
(inc (% D 73))
", YOLD "
(+ Year 1166) ) ) ) ) )</langsyntaxhighlight>
 
=={{header|Pike}}==
Pike includes a Discordian calendar.
dates can be converted from any calendar to any other.
<langsyntaxhighlight Pikelang="pike">> Calendar.Discordian.now()->format_ext_ymd();
Result: "Pungenday, 59 Bureaucracy 3177"
> Calendar.Discordian.Day(Calendar.Day(2011,11,11))->format_ext_ymd();
Line 3,813:
Result: "Setting Orange, 23 The Aftermath 3177"
> Calendar.Day((Calendar.Discordian.Month()+1)->day(1));
Result: Day(Thu 20 Oct 2011)</langsyntaxhighlight>
 
=={{header|PowerBASIC}}==
<langsyntaxhighlight lang="powerbasic">#COMPILE EXE
#DIM ALL
 
Line 3,880:
 
? result
END FUNCTION</langsyntaxhighlight>
 
=={{header|PowerShell}}==
{{works with|powershell|2}}
<langsyntaxhighlight lang="powershell">
function ConvertTo-Discordian ( [datetime]$GregorianDate )
{
Line 3,907:
ConvertTo-Discordian ([datetime]'2/29/2016')
ConvertTo-Discordian ([datetime]'12/8/2016')
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 3,917:
=={{header|Prolog}}==
{{works with|SWI Prolog}}
<langsyntaxhighlight lang="prolog">% See https://en.wikipedia.org/wiki/Discordian_calendar
 
main:-
Line 3,996:
holy_day(3, 50, 'Bureflux').
holy_day(4, 5, 'Maladay').
holy_day(4, 50, 'Afflux').</langsyntaxhighlight>
 
{{out}}
Line 4,009:
 
=={{header|PureBasic}}==
<langsyntaxhighlight PureBasiclang="purebasic">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)
Line 4,022:
EndIf
ProcedureReturn S(DoY/73)+" "+Str(DoY%73)+", Yold "+Yold$
EndProcedure</langsyntaxhighlight>
 
=={{header|Python}}==
<langsyntaxhighlight lang="python">import datetime, calendar
 
DISCORDIAN_SEASONS = ["Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"]
Line 4,042:
season, dday = divmod(day_of_year, 73)
return "%s %d, YOLD %d" % (DISCORDIAN_SEASONS[season], dday + 1, year + 1166)
</syntaxhighlight>
</lang>
 
=={{header|Racket}}==
{{trans|D}}
 
<langsyntaxhighlight lang="racket">#lang racket/base
;;;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;;;; Derived from 'D' Implementation
Line 4,097:
(check-equal? (discordian/ymd 2010 1 5) "Mungday, in the YOLD 3176")
(check-equal? (discordian/ymd 2011 5 3) "Discoflux, in the YOLD 3177"))
;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~FIN</langsyntaxhighlight>
 
{{Out}}
Line 4,106:
{{Works with|rakudo|2015-11-04}}
<!-- Hi ‎Grondilu! Keep up the good work! -->
<syntaxhighlight lang="raku" perl6line>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
Line 4,131:
 
say "$_ is {.&ddate}" for < 2010-07-22 2012-02-28 2012-02-29 2012-03-01 >;
</syntaxhighlight>
</lang>
 
{{out}}
Line 4,146:
 
If the Gregorian date is omitted or specified as an asterisk &nbsp; ('''*'''), &nbsp; the current date is used.
<langsyntaxhighlight lang="rexx">/*REXX program converts a mm/dd/yyyy Gregorian date ───► a Discordian date. */
@day.1= 'Sweetness' /*define the 1st day─of─Discordian─week*/
@day.2= 'Boomtime' /* " " 2nd " " " " */
Line 4,179:
leapyear: procedure; parse arg y /*obtain a four─digit Gregorian year. */
if y//4 \== 0 then return 0 /*Not ÷ by 4? Then not a leapyear. */
return y//100 \== 0 | y//400 == 0 /*apply the 100 and 400 year rules.*/</langsyntaxhighlight>
{{out|input|text=&nbsp; when using the (various) following inputs of:}}
<pre>
Line 4,204:
 
=={{header|Ruby}}==
<langsyntaxhighlight lang="ruby">require 'date'
 
class DiscordianDate
Line 4,248:
%Q{#{@st_tibs ? "St. Tib's Day" : "%s, %s %d" % [weekday, season, day]}, #{year} YOLD}
end
end</langsyntaxhighlight>
 
Testing:
<langsyntaxhighlight lang="ruby">[[2012, 2, 28], [2012, 2, 29], [2012, 3, 1], [2011, 10, 5], [2015, 10, 19]].each do |date|
dd = DiscordianDate.new(*date)
puts "#{"%4d-%02d-%02d" % date} => #{dd}"
end</langsyntaxhighlight>
{{Out}}
<pre>2012-02-28 => Prickle-Prickle, Chaos 59, 3178 YOLD
Line 4,272:
permission of the author.
 
<langsyntaxhighlight lang="rust">extern crate chrono;
 
use chrono::NaiveDate;
Line 4,343:
format!("{}{}", s, suffix)
}
</syntaxhighlight>
</lang>
 
{{Out}}<pre>$ ./ddate -1166-1-1
Line 4,367:
 
{{trans|Python}}
<langsyntaxhighlight lang="scala">package rosetta
 
import java.util.GregorianCalendar
Line 4,400:
} else
println("usage: DDate [day month year]")
}</langsyntaxhighlight>
Test:
<langsyntaxhighlight lang="scala">scala rosetta.DDate 2010 7 22
Confusion 57, 3176 YOLD
scala rosetta.DDate 28 2 2012
Line 4,412:
scala rosetta.DDate 19 10 2015
Bureaucracy 73, 3181 YOLD
</syntaxhighlight>
</lang>
 
=={{header|Seed7}}==
<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "time.s7i";
Line 4,467:
writeln("Discordian date computation works.");
end if;
end func;</langsyntaxhighlight>
 
{{out}}
Line 4,477:
=={{header|Sidef}}==
{{trans|Perl}}
<langsyntaxhighlight lang="ruby">require('Time::Piece');
 
var seasons = %w(Chaos Discord Confusion Bureaucracy The\ Aftermath);
Line 4,507:
%w(2010-07-22 2012-02-28 2012-02-29 2012-03-01).each { |ymd|
say "#{ymd} is #{ddate(ymd)}"
}</langsyntaxhighlight>
{{out}}
<pre>
Line 4,517:
 
=={{header|Swift}}==
<langsyntaxhighlight lang="swift">import Foundation
 
let monthDays = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]
Line 4,563:
showDiscordianDate(year: 2019, month: 7, day: 15)
showDiscordianDate(year: 2025, month: 3, day: 19)
showDiscordianDate(year: 2017, month: 12, day: 8)</langsyntaxhighlight>
 
{{out}}
Line 4,576:
 
=={{header|Tcl}}==
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
proc disdate {year month day} {
# Get the day of the year
Line 4,598:
incr year 1166
return "$season $dos, $year YOLD"
}</langsyntaxhighlight>
Demonstrating:
<langsyntaxhighlight lang="tcl">puts [disdate 2010 7 22]; # Today
puts [disdate 2012 2 28]
puts [disdate 2012 2 29]
puts [disdate 2012 3 1]</langsyntaxhighlight>
{{Out}}
<pre>
Line 4,616:
{{libheader|Wren-date}}
{{libheader|Wren-fmt}}
<langsyntaxhighlight lang="ecmascript">import "/date" for Date
import "/fmt" for Fmt
 
Line 4,667:
var dt = Date.parse(date)
System.print("%(date) = %(discordian.call(dt))")
}</langsyntaxhighlight>
 
{{out}}
Line 4,692:
=={{header|zkl}}==
{{trans|D}}
<langsyntaxhighlight lang="zkl">fcn discordianDate(y,m,d){
var [const]
seasons=T("Chaos","Discord","Confusion","Bureaucracy","The Aftermath"),
Line 4,712:
dWday:=weekday[(doy - 1)%5];
"%s, day %s of %s in the YOLD %s".fmt(dWday,dsDay,dSeas,dYear);
}</langsyntaxhighlight>
<langsyntaxhighlight lang="zkl">foreach y,m,d in (T(T(2010,7,22), T(2012,2,28), T(2012,2,29), T(2012,3,1),
T(2010,1, 5), T(2011,5, 3))){
"%d-%02d-%02d is -->%s".fmt(y,m,d,discordianDate(y,m,d)).println();
}</langsyntaxhighlight>
{{out}}
<pre>
10,327

edits