[REBOL] Re: Discordian dates?
From: johan:forsberg:6117:student:uu:se at: 25-Jun-2001 17:38
On 25-Jun-01, Chris wrote:
> Johan Forsberg wrote:
>
>> Well, I had been thinking about doing it, bot not gotten around to
>> it. Here's the first version of my %ddate.r. It's almost untested,
>> I just threw a few dates at it and they came out OK. Please don't
>> trust it for anything very important as I may have messed something
>> up :)
>
> Disaster! It doesn't handle St Tib's Day! :))
Whoa... an inexcusable mistake! I sort of thought about it, in handling
the leap years, but then I forgot about it :P
Upon further investigation I'm a little confused about how the original
(?) ddate program works when it comes to St. Tib's Day. Both february 29
and march 1 2000 is St. Tib's day according to it..!? The descriptions
I've seen of the POEE calendar just states that it should be inserted
between day 59 and day 60 of Chaos every fourth year (i.e. same place as
the leap day).
Anyhow, attached is a new version, hacked according to my understanding
of St. Tib's Day... it's not pretty though :)
--
Johan Forsberg
-- Attached file included as plaintext by Listar --
-- File: ddate.r
REBOL [
title: "Discordian dates"
version: 0.0.2
author: "Johan Forsberg"
file: %ddate.r
email: [johan--forsberg--6117--student--uu--se]
date: 25-june-2001
ddate: "Sweetmorn, Confusion 30, Year of Our Lady of Discord 3167"
purpose: {Date Converter from the Gregorian to the Semi-Divinely
Revealed POEE Calendar.}
example: {poee-calendar/make-poee-date-string now}
history: [
0.0.1 [25-jun-2001 "First version" "Johan"]
0.0.2 [25-jun-2001 "Corrected for ST. Tib's Day" "Johan"]
]
]
poee-calendar: context [
seasons: ["Chaos" "Discord" "Confusion" "Bureaucracy" "The Aftermath"]
weekdays: ["Setting Orange" "Sweetmorn" "Boomtime" "Pungenday" "Prickle"]
holidays: [
apostle ["Mungoday" "Mojoday" "Syaday" "Zaraday" "Maladay"]
season ["Chaoflux" "Discoflux" "Confuflux" "Bureflux" "Afflux"]
]
leap-year?: function [year] [] [
return either ((year // 4) = 0) and ((year // 400) = 0) [true] [false]
]
get-day-of-year: function [date /notib] [day] [
gregorian: [
31 (either (not notib) and (leap-year? date/year) [29] [28]) 31 30 31 30
31 31 30 31 30 31
]
day: date/day
for i 1 (date/month - 1) 1 [
day: day + do gregorian/:i
]
return day
]
get-season-and-day: function [date] [day season] [
day: get-day-of-year date
season: 1
ly: leap-year? date/year
while [day > 73] [
day: day - either (season = 1) and ly [
74
] [
73
]
season: season + 1
]
return reduce [
either (season = 1) and (day > 59) [day: day - 1 (day = 59)] [false]
season day
]
]
make-poee-date: function [date] [] [
sd: get-season-and-day date
wd: ((get-day-of-year/notib date) // 5) + 1
return compose [
st-tibs-day (sd/1)
weekday (pick weekdays wd)
season (pick seasons sd/2)
day (sd/3)
year (date/year + 1166)
holiday (
switch/default sd/3 [
5 [pick holidays/apostle sd/2]
50 [pick holidays/season sd/2]
] [none]
)
]
]
make-poee-date-string: function [date] [pd] [
pd: make-poee-date date
return rejoin [
either pd/st-tibs-day [
"St. Tib's Day"
] [
rejoin [pd/weekday ", " pd/season " " pd/day]
]
", Year of Our Lady of Discord " pd/year
either none? pd/holiday [""] [rejoin [" -- " pd/holiday]]
]
]
]