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