Discordian date: Difference between revisions

Content added Content deleted
(Add MAD)
m (→‎{{header|AppleScript}}: Tidied opening block comment.)
Line 699: Line 699:


<lang applescript>on gregorianToDiscordian(inputDate) -- Input: AppleScript date object.
<lang applescript>on gregorianToDiscordian(inputDate) -- Input: AppleScript date object.
(* Rules:
(*
Discordian weeks have five days each and always start at the beginning of the year. There are seventy-three in a year. (73 * 5 = 365.)
Discordian years are aligned with, and the same length as, Gregorian years.
Discordian seasons have seventy-three days each. There are five of them in a year.
Each has 73 5-day weeks and 5 73-day seasons. (73 * 5 = 365.)
The first day of a Discordian year is also that of its first week and first season.
In leap years, an extra day called "St. Tib's Day" is inserted between days 59 and 60, the same slot as the Gregorian 29th February. It's considered to be outside the Discordian week and season, so the day after it is Setting Orange, Chaos 60, not Sweetmorn, Chaos 61. Discordian dates always correspond to particular Gregorian dates.
In leap years, an extra day called "St. Tib's Day", is inserted between days 59 and 60.
Year 1 YOLD is 1166 BC.
It's considered to be outside the calendar, so the day after it is Setting Orange, Chaos 60,
This handler is only guaranteed for AD Gregorian dates and it's the calling process's responsibility to convert any user text input from the user's format to an AS date object.
Since the Discordian calendar is an American invention, this handler's output is in the US style: "Weekday, Season day, year".
not Sweetmorn, Chaos 61. Year 1 YOLD is 1166 BC, but this handler takes an AS date object
as its input and is only good for AD Gregorian dates. Since the Discordian calendar's an
American invention, the output here's in the US style: "Weekday, Season day, year".
*)
*)
-- Calculate the input date's day-of-year number.
-- Calculate the input date's day-of-year number.
copy inputDate to startOfYear
copy inputDate to startOfYear
Line 741: Line 742:
end gregorianToDiscordian
end gregorianToDiscordian


set gregorianDate to (current date)'s date string
set ASDate to (current date)
set ASDate to date gregorianDate
set gregorianDate to ASDate's date string
set discordianDate to gregorianToDiscordian(ASDate)
set discordianDate to gregorianToDiscordian(ASDate)
return {Gregorian:gregorianDate, Discordian:discordianDate}</lang>
return {Gregorian:gregorianDate, Discordian:discordianDate}</lang>


{{output}}
{{output}}
<pre>{Gregorian:"Tuesday 25 February 2020", Discordian:"Sweetmorn, Chaos 56, 3186"}</pre>
<lang applescript>{Gregorian:"Saturday 5 December 2020", Discordian:"Prickle-Prickle, The Aftermath 47, 3186"}</lang>


=={{header|AWK}}==
=={{header|AWK}}==