Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,203 +0,0 @@
|
|||
with Ada.Calendar.Arithmetic;
|
||||
with Ada.Text_IO;
|
||||
with Ada.Integer_Text_IO;
|
||||
with Ada.Strings.Unbounded;
|
||||
with Ada.Strings.Unbounded.Text_IO;
|
||||
with Ada.Command_Line;
|
||||
|
||||
procedure Discordian is
|
||||
use Ada.Calendar;
|
||||
use Ada.Strings.Unbounded;
|
||||
use Ada.Command_Line;
|
||||
package UStr_IO renames Ada.Strings.Unbounded.Text_IO;
|
||||
|
||||
subtype Year_Number is Integer range 3067 .. 3565;
|
||||
type Seasons is (Chaos, Discord, Confusion, Bureaucracy, The_Aftermath);
|
||||
type Days_Of_Week is (Sweetmorn, Boomtime, Pungenday,
|
||||
Prickle_Prickle, Setting_Orange);
|
||||
subtype Day_Number is Integer range 1 .. 73;
|
||||
|
||||
type Discordian_Date is record
|
||||
Year : Year_Number;
|
||||
Season : Seasons;
|
||||
Day : Day_Number;
|
||||
Week_Day : Days_Of_Week;
|
||||
Is_Tibs_Day : Boolean := False;
|
||||
end record;
|
||||
|
||||
function Week_Day_To_Str(Day : Days_Of_Week) return Unbounded_String is
|
||||
s : Unbounded_String;
|
||||
begin
|
||||
case Day is
|
||||
when Sweetmorn => s := To_Unbounded_String("Sweetmorn");
|
||||
when Boomtime => s := To_Unbounded_String("Boomtime");
|
||||
when Pungenday => s := To_Unbounded_String("Pungenday");
|
||||
when Prickle_Prickle => s := To_Unbounded_String("Prickle-Prickle");
|
||||
when Setting_Orange => s := To_Unbounded_String("Setting Orange");
|
||||
end case;
|
||||
return s;
|
||||
end Week_Day_To_Str;
|
||||
|
||||
function Holiday(Season: Seasons) return Unbounded_String is
|
||||
s : Unbounded_String;
|
||||
begin
|
||||
case Season is
|
||||
when Chaos => s := To_Unbounded_String("Chaoflux");
|
||||
when Discord => s := To_Unbounded_String("Discoflux");
|
||||
when Confusion => s := To_Unbounded_String("Confuflux");
|
||||
when Bureaucracy => s := To_Unbounded_String("Bureflux");
|
||||
when The_Aftermath => s := To_Unbounded_String("Afflux");
|
||||
end case;
|
||||
return s;
|
||||
end Holiday;
|
||||
|
||||
function Apostle(Season: Seasons) return Unbounded_String is
|
||||
s : Unbounded_String;
|
||||
begin
|
||||
case Season is
|
||||
when Chaos => s := To_Unbounded_String("Mungday");
|
||||
when Discord => s := To_Unbounded_String("Mojoday");
|
||||
when Confusion => s := To_Unbounded_String("Syaday");
|
||||
when Bureaucracy => s := To_Unbounded_String("Zaraday");
|
||||
when The_Aftermath => s := To_Unbounded_String("Maladay");
|
||||
end case;
|
||||
return s;
|
||||
end Apostle;
|
||||
|
||||
function Season_To_Str(Season: Seasons) return Unbounded_String is
|
||||
s : Unbounded_String;
|
||||
begin
|
||||
case Season is
|
||||
when Chaos => s := To_Unbounded_String("Chaos");
|
||||
when Discord => s := To_Unbounded_String("Discord");
|
||||
when Confusion => s := To_Unbounded_String("Confusion");
|
||||
when Bureaucracy => s := To_Unbounded_String("Bureaucracy");
|
||||
when The_Aftermath => s := To_Unbounded_String("The Aftermath");
|
||||
end case;
|
||||
return s;
|
||||
end Season_To_Str;
|
||||
|
||||
procedure Convert (From : Time; To : out Discordian_Date) is
|
||||
use Ada.Calendar.Arithmetic;
|
||||
First_Day : Time;
|
||||
Number_Days : Day_Count;
|
||||
Leap_Year : boolean;
|
||||
begin
|
||||
First_Day := Time_Of (Year => Year (From), Month => 1, Day => 1);
|
||||
Number_Days := From - First_Day;
|
||||
|
||||
To.Year := Year (Date => From) + 1166;
|
||||
To.Is_Tibs_Day := False;
|
||||
Leap_Year := False;
|
||||
if Year (Date => From) mod 4 = 0 then
|
||||
if Year (Date => From) mod 100 = 0 then
|
||||
if Year (Date => From) mod 400 = 0 then
|
||||
Leap_Year := True;
|
||||
end if;
|
||||
else
|
||||
Leap_Year := True;
|
||||
end if;
|
||||
end if;
|
||||
if Leap_Year then
|
||||
if Number_Days > 59 then
|
||||
Number_Days := Number_Days - 1;
|
||||
elsif Number_Days = 59 then
|
||||
To.Is_Tibs_Day := True;
|
||||
end if;
|
||||
end if;
|
||||
To.Day := Day_Number (Number_Days mod 73 + 1);
|
||||
case Number_Days / 73 is
|
||||
when 0 => To.Season := Chaos;
|
||||
when 1 => To.Season := Discord;
|
||||
when 2 => To.Season := Confusion;
|
||||
when 3 => To.Season := Bureaucracy;
|
||||
when 4 => To.Season := The_Aftermath;
|
||||
when others => raise Constraint_Error;
|
||||
end case;
|
||||
case Number_Days mod 5 is
|
||||
when 0 => To.Week_Day := Sweetmorn;
|
||||
when 1 => To.Week_Day := Boomtime;
|
||||
when 2 => To.Week_Day := Pungenday;
|
||||
when 3 => To.Week_Day := Prickle_Prickle;
|
||||
when 4 => To.Week_Day := Setting_Orange;
|
||||
when others => raise Constraint_Error;
|
||||
end case;
|
||||
end Convert;
|
||||
|
||||
procedure Put (Item : Discordian_Date) is
|
||||
begin
|
||||
if Item.Is_Tibs_Day then
|
||||
Ada.Text_IO.Put ("St. Tib's Day");
|
||||
else
|
||||
UStr_IO.Put (Week_Day_To_Str(Item.Week_Day));
|
||||
Ada.Text_IO.Put (", day" & Integer'Image (Item.Day));
|
||||
Ada.Text_IO.Put (" of ");
|
||||
UStr_IO.Put (Season_To_Str (Item.Season));
|
||||
if Item.Day = 5 then
|
||||
Ada.Text_IO.Put (", ");
|
||||
UStr_IO.Put (Apostle(Item.Season));
|
||||
elsif Item.Day = 50 then
|
||||
Ada.Text_IO.Put (", ");
|
||||
UStr_IO.Put (Holiday(Item.Season));
|
||||
end if;
|
||||
end if;
|
||||
Ada.Text_IO.Put (" in the YOLD" & Integer'Image (Item.Year));
|
||||
Ada.Text_IO.New_Line;
|
||||
end Put;
|
||||
|
||||
Test_Day : Time;
|
||||
Test_DDay : Discordian_Date;
|
||||
Year : Integer;
|
||||
Month : Integer;
|
||||
Day : Integer;
|
||||
YYYYMMDD : Integer;
|
||||
begin
|
||||
|
||||
if Argument_Count = 0 then
|
||||
Test_Day := Clock;
|
||||
Convert (From => Test_Day, To => Test_DDay);
|
||||
Put (Test_DDay);
|
||||
end if;
|
||||
|
||||
for Arg in 1..Argument_Count loop
|
||||
|
||||
if Argument(Arg)'Length < 8 then
|
||||
Ada.Text_IO.Put("ERROR: Invalid Argument : '" & Argument(Arg) & "'");
|
||||
Ada.Text_IO.Put("Input format YYYYMMDD");
|
||||
raise Constraint_Error;
|
||||
end if;
|
||||
|
||||
begin
|
||||
YYYYMMDD := Integer'Value(Argument(Arg));
|
||||
exception
|
||||
when Constraint_Error =>
|
||||
Ada.Text_IO.Put("ERROR: Invalid Argument : '" & Argument(Arg) & "'");
|
||||
raise;
|
||||
end;
|
||||
|
||||
Day := YYYYMMDD mod 100;
|
||||
if Day < Day_Number'First or Day > Day_Number'Last then
|
||||
Ada.Text_IO.Put("ERROR: Invalid Day:" & Integer'Image(Day));
|
||||
raise Constraint_Error;
|
||||
end if;
|
||||
|
||||
Month := ((YYYYMMDD - Day) / 100) mod 100;
|
||||
if Month < Month_Number'First or Month > Month_Number'Last then
|
||||
Ada.Text_IO.Put("ERROR: Invalid Month:" & Integer'Image(Month));
|
||||
raise Constraint_Error;
|
||||
end if;
|
||||
|
||||
Year := ((YYYYMMDD - Day - Month * 100) / 10000);
|
||||
if Year < 1901 or Year > 2399 then
|
||||
Ada.Text_IO.Put("ERROR: Invalid Year:" & Integer'Image(Year));
|
||||
raise Constraint_Error;
|
||||
end if;
|
||||
|
||||
Test_Day := Time_Of (Year => Year, Month => Month, Day => Day);
|
||||
|
||||
Convert (From => Test_Day, To => Test_DDay);
|
||||
Put (Test_DDay);
|
||||
|
||||
end loop;
|
||||
|
||||
end Discordian;
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
function isLeapYear(integer year)
|
||||
return remainder(year,4)=0 and remainder(year,100)!=0 or remainder(year,400)=0
|
||||
end function
|
||||
|
||||
constant YEAR = 1, MONTH = 2, DAY = 3, DAY_OF_YEAR = 8
|
||||
|
||||
constant month_lengths = {31,28,31,30,31,30,31,31,30,31,30,31}
|
||||
function dayOfYear(sequence Date)
|
||||
integer d
|
||||
if length(Date) = DAY_OF_YEAR then
|
||||
d = Date[DAY_OF_YEAR]
|
||||
else
|
||||
d = Date[DAY]
|
||||
for i = Date[MONTH]-1 to 1 by -1 do
|
||||
d += month_lengths[i]
|
||||
if i = 2 and isLeapYear(Date[YEAR]) then
|
||||
d += 1
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
return d
|
||||
end function
|
||||
|
||||
constant seasons = {"Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"}
|
||||
constant weekday = {"Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"}
|
||||
constant apostle = {"Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay"}
|
||||
constant holiday = {"Chaoflux", "Discoflux", "Confuflux", "Bureflux", "Afflux"}
|
||||
|
||||
function discordianDate(sequence Date)
|
||||
sequence dyear, dseas, dwday
|
||||
integer leap, doy, dsday
|
||||
dyear = sprintf("%d",Date[YEAR]+1166)
|
||||
leap = isLeapYear(Date[YEAR])
|
||||
if leap and Date[MONTH] = 2 and Date[DAY] = 29 then
|
||||
return "St. Tib's Day, in the YOLD " & dyear
|
||||
end if
|
||||
|
||||
doy = dayOfYear(Date)
|
||||
if leap and doy >= 60 then
|
||||
doy -= 1
|
||||
end if
|
||||
|
||||
dsday = remainder(doy,73)
|
||||
if dsday = 5 then
|
||||
return apostle[doy/73+1] & ", in the YOLD " & dyear
|
||||
elsif dsday = 50 then
|
||||
return holiday[doy/73+1] & ", in the YOLD " & dyear
|
||||
end if
|
||||
|
||||
dseas = seasons[doy/73+1]
|
||||
dwday = weekday[remainder(doy-1,5)+1]
|
||||
|
||||
return sprintf("%s, day %d of %s in the YOLD %s", {dwday, dsday, dseas, dyear})
|
||||
end function
|
||||
|
||||
sequence today
|
||||
today = date()
|
||||
today[YEAR] += 1900
|
||||
puts(1, discordianDate(today))
|
||||
|
|
@ -1,43 +1,41 @@
|
|||
(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>
|
||||
<span style="color: #000000;">weekday</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"Sweetmorn"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Boomtime"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Pungenday"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Prickle-Prickle"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Setting Orange"</span><span style="color: #0000FF;">},</span>
|
||||
<span style="color: #000000;">apostle</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"Mungday"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Mojoday"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Syaday"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Zaraday"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Maladay"</span><span style="color: #0000FF;">},</span>
|
||||
<span style="color: #000000;">holiday</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"Chaoflux"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Discoflux"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Confuflux"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Bureflux"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Afflux"</span><span style="color: #0000FF;">}</span>
|
||||
with javascript_semantics
|
||||
constant 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"}
|
||||
|
||||
<span style="color: #008080;">function</span> <span style="color: #000000;">discordianDate</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">dt</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #004080;">integer</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">y</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m</span><span style="color: #0000FF;">,</span><span style="color: #000000;">d</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">dt</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #000000;">leap</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">is_leap_year</span><span style="color: #0000FF;">(</span><span style="color: #000000;">y</span><span style="color: #0000FF;">),</span>
|
||||
<span style="color: #000000;">doy</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">day_of_year</span><span style="color: #0000FF;">(</span><span style="color: #000000;">y</span><span style="color: #0000FF;">,</span><span style="color: #000000;">m</span><span style="color: #0000FF;">,</span><span style="color: #000000;">d</span><span style="color: #0000FF;">)-</span><span style="color: #000000;">1</span>
|
||||
<span style="color: #004080;">string</span> <span style="color: #000000;">dyear</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%d"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">y</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1166</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">leap</span> <span style="color: #008080;">and</span> <span style="color: #000000;">m</span><span style="color: #0000FF;">=</span><span style="color: #000000;">2</span> <span style="color: #008080;">and</span> <span style="color: #000000;">d</span><span style="color: #0000FF;">=</span><span style="color: #000000;">29</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #008000;">"St. Tib's Day, in the YOLD "</span> <span style="color: #0000FF;">&</span> <span style="color: #000000;">dyear</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">leap</span> <span style="color: #008080;">and</span> <span style="color: #000000;">doy</span><span style="color: #0000FF;">>=</span><span style="color: #000000;">60</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #000000;">doy</span> <span style="color: #0000FF;">-=</span> <span style="color: #000000;">1</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #004080;">integer</span> <span style="color: #000000;">dsday</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">remainder</span><span style="color: #0000FF;">(</span><span style="color: #000000;">doy</span><span style="color: #0000FF;">,</span><span style="color: #000000;">73</span><span style="color: #0000FF;">)+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #000000;">dseason</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">doy</span><span style="color: #0000FF;">/</span><span style="color: #000000;">73</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">if</span> <span style="color: #000000;">dsday</span><span style="color: #0000FF;">=</span><span style="color: #000000;">5</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #000000;">apostle</span><span style="color: #0000FF;">[</span><span style="color: #000000;">dseason</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">&</span> <span style="color: #008000;">", in the YOLD "</span> <span style="color: #0000FF;">&</span> <span style="color: #000000;">dyear</span>
|
||||
<span style="color: #008080;">elsif</span> <span style="color: #000000;">dsday</span><span style="color: #0000FF;">=</span><span style="color: #000000;">50</span> <span style="color: #008080;">then</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #000000;">holiday</span><span style="color: #0000FF;">[</span><span style="color: #000000;">dseason</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">&</span> <span style="color: #008000;">", in the YOLD "</span> <span style="color: #0000FF;">&</span> <span style="color: #000000;">dyear</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
|
||||
<span style="color: #004080;">string</span> <span style="color: #000000;">dseas</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">seasons</span><span style="color: #0000FF;">[</span><span style="color: #000000;">dseason</span><span style="color: #0000FF;">],</span>
|
||||
<span style="color: #000000;">dwday</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">weekday</span><span style="color: #0000FF;">[</span><span style="color: #7060A8;">remainder</span><span style="color: #0000FF;">(</span><span style="color: #000000;">doy</span><span style="color: #0000FF;">,</span><span style="color: #000000;">5</span><span style="color: #0000FF;">)+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">]</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #7060A8;">sprintf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"%s, day %d of %s in the YOLD %s"</span><span style="color: #0000FF;">,</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">dwday</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">dsday</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">dseas</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">dyear</span><span style="color: #0000FF;">})</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
|
||||
function discordianDate(sequence dt)
|
||||
integer {y,m,d} = dt,
|
||||
leap = is_leap_year(y),
|
||||
doy = day_of_year(y,m,d)-1
|
||||
string dyear = sprintf("%d",y+1166)
|
||||
if leap and m=2 and d=29 then
|
||||
return "St. Tib's Day, in the YOLD " & dyear
|
||||
end if
|
||||
if leap and doy>=60 then
|
||||
doy -= 1
|
||||
end if
|
||||
integer dsday = remainder(doy,73)+1,
|
||||
dseason = floor(doy/73+1)
|
||||
if dsday=5 then
|
||||
return apostle[dseason] & ", in the YOLD " & dyear
|
||||
elsif dsday=50 then
|
||||
return holiday[dseason] & ", in the YOLD " & dyear
|
||||
end if
|
||||
string dseas = seasons[dseason],
|
||||
dwday = weekday[remainder(doy,5)+1]
|
||||
return sprintf("%s, day %d of %s in the YOLD %s", {dwday, dsday, dseas, dyear})
|
||||
end function
|
||||
|
||||
<span style="color: #000080;font-style:italic;">-- test code</span>
|
||||
-- test code
|
||||
|
||||
<span style="color: #004080;">sequence</span> <span style="color: #000000;">dt</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">2015</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">}</span>
|
||||
<span style="color: #008080;">include</span> <span style="color: #004080;">timedate</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
|
||||
<span style="color: #004080;">atom</span> <span style="color: #000000;">oneday</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">timedelta</span><span style="color: #0000FF;">(</span><span style="color: #000000;">days</span><span style="color: #0000FF;">:=</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #7060A8;">set_timedate_formats</span><span style="color: #0000FF;">({</span><span style="color: #008000;">"DD/MM/YYYY"</span><span style="color: #0000FF;">})</span>
|
||||
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">5</span> <span style="color: #008080;">do</span>
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s: %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dt</span><span style="color: #0000FF;">),</span><span style="color: #000000;">discordianDate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dt</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: #000000;">72</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%s: %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dt</span><span style="color: #0000FF;">),</span><span style="color: #000000;">discordianDate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dt</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>
|
||||
<!--
|
||||
sequence dt = {2015,1,1,0,0,0,0,0}
|
||||
include timedate.e
|
||||
atom oneday = timedelta(days:=1)
|
||||
set_timedate_formats({"DD/MM/YYYY"})
|
||||
for i=1 to 5 do
|
||||
printf(1,"%s: %s\n",{format_timedate(dt),discordianDate(dt)})
|
||||
dt = adjust_timedate(dt,oneday*72)
|
||||
printf(1,"%s: %s\n",{format_timedate(dt),discordianDate(dt)})
|
||||
dt = adjust_timedate(dt,oneday)
|
||||
end for
|
||||
|
|
|
|||
|
|
@ -1,22 +0,0 @@
|
|||
function ConvertTo-Discordian ( [datetime]$GregorianDate )
|
||||
{
|
||||
$DayOfYear = $GregorianDate.DayOfYear
|
||||
$Year = $GregorianDate.Year + 1166
|
||||
If ( [datetime]::IsLeapYear( $GregorianDate.Year ) -and $DayOfYear -eq 60 )
|
||||
{ $Day = "St. Tib's Day" }
|
||||
Else
|
||||
{
|
||||
If ( [datetime]::IsLeapYear( $GregorianDate.Year ) -and $DayOfYear -gt 60 )
|
||||
{ $DayOfYear-- }
|
||||
$Weekday = @( 'Sweetmorn', 'Boomtime', 'Pungenday', 'Prickle-Prickle', 'Setting Orange' )[(($DayOfYear - 1 ) % 5 )]
|
||||
$Season = @( 'Chaos', 'Discord', 'Confusion', 'Bureaucracy', 'The Aftermath' )[( [math]::Truncate( ( $DayOfYear - 1 ) / 73 ) )]
|
||||
$DayOfSeason = ( $DayOfYear - 1 ) % 73 + 1
|
||||
$Day = "$Weekday, $Season $DayOfSeason"
|
||||
}
|
||||
$DiscordianDate = "$Day, $Year YOLD"
|
||||
return $DiscordianDate
|
||||
}
|
||||
|
||||
ConvertTo-Discordian ([datetime]'1/5/2016')
|
||||
ConvertTo-Discordian ([datetime]'2/29/2016')
|
||||
ConvertTo-Discordian ([datetime]'12/8/2016')
|
||||
Loading…
Add table
Add a link
Reference in a new issue