42 lines
1.8 KiB
Text
42 lines
1.8 KiB
Text
with javascript_semantics
|
|
include timedate.e
|
|
|
|
constant cycles = {"Physical day ", "Emotional day", "Mental day "},
|
|
lengths = {23, 28, 33},
|
|
quadrants = {{"up and rising", "peak"},
|
|
{"up but falling", "transition"},
|
|
{"down and falling", "valley"},
|
|
{"down but rising", "transition"}}
|
|
|
|
procedure biorhythms(string birthDate, targetDate)
|
|
timedate bd = parse_date_string(birthDate,{"YYYY-MM-DD"}),
|
|
td = parse_date_string(targetDate,{"YYYY-MM-DD"})
|
|
integer days = floor(timedate_diff(bd, td, DT_DAY)/(60*60*24))
|
|
printf(1,"Born %s, Target %s\n",{birthDate,targetDate})
|
|
printf(1,"Day %d\n",days)
|
|
for i=1 to 3 do
|
|
integer len = lengths[i],
|
|
posn = remainder(days,len),
|
|
quadrant = floor(posn/len*4)+1
|
|
atom percent = floor(sin(2*PI*posn/len)*1000)/10
|
|
string cycle = cycles[i],
|
|
desc = iff(percent>95 ? " peak" :
|
|
iff(percent<-95 ? " valley" :
|
|
iff(abs(percent)<5 ? " critical transition" : "other")))
|
|
if desc == "other" then
|
|
timedate t = adjust_timedate(td,timedelta(days:=floor(quadrant/4*len)-posn))
|
|
string transition = format_timedate(t,"YYYY-MM-DD"),
|
|
{trend,next} = quadrants[quadrant]
|
|
desc = sprintf("%5.1f%% (%s, next %s %s)", {percent, trend, next, transition})
|
|
end if
|
|
printf(1,"%s %2d : %s\n", {cycle, posn, desc})
|
|
end for
|
|
printf(1,"\n")
|
|
end procedure
|
|
|
|
constant datePairs = {
|
|
{"1943-03-09", "1972-07-11"},
|
|
{"1809-01-12", "1863-11-19"},
|
|
{"1809-02-12", "1863-11-19"} // correct DOB for Abraham Lincoln
|
|
}
|
|
for i=1 to length(datePairs) do biorhythms(datePairs[i][1], datePairs[i][2]) end for
|