44 lines
1.6 KiB
Text
44 lines
1.6 KiB
Text
F biorhythms(birthdate_str, targetdate_str)
|
||
‘
|
||
Print out biorhythm data for targetdate assuming you were
|
||
born on birthdate.
|
||
|
||
birthdate and targetdata are strings in this format:
|
||
|
||
YYYY-MM-DD e.g. 1964-12-26
|
||
’
|
||
|
||
print(‘Born: ’birthdate_str‘ Target: ’targetdate_str)
|
||
|
||
V birthdate = time:strptime(birthdate_str, ‘%Y-%m-%d’)
|
||
V targetdate = time:strptime(targetdate_str, ‘%Y-%m-%d’)
|
||
|
||
V days = (targetdate - birthdate).days()
|
||
|
||
print(‘Day: ’days)
|
||
|
||
V cycle_labels = [‘Physical’, ‘Emotional’, ‘Mental’]
|
||
V cycle_lengths = [23, 28, 33]
|
||
V quadrants = [(‘up and rising’, ‘peak’), (‘up but falling’, ‘transition’), (‘down and falling’, ‘valley’), (‘down but rising’, ‘transition’)]
|
||
|
||
L(i) 3
|
||
V label = cycle_labels[i]
|
||
V length = cycle_lengths[i]
|
||
V position = days % length
|
||
V quadrant = Int(floor((4 * position) / length))
|
||
V percentage = Int(round(100 * sin(2 * math:pi * position / length), 0))
|
||
V transition_date = (targetdate + TimeDelta(days' floor((quadrant + 1) / 4 * length) - position)).strftime(‘%Y-%m-%d’)
|
||
V (trend, next) = quadrants[quadrant]
|
||
|
||
String description
|
||
I percentage > 95
|
||
description = ‘peak’
|
||
E I percentage < -95
|
||
description = ‘valley’
|
||
E I abs(percentage) < 5
|
||
description = ‘critical transition’
|
||
E
|
||
description = percentage‘% (’trend‘, next ’next‘ ’transition_date‘)’
|
||
print(label‘ day ’position‘: ’description)
|
||
|
||
biorhythms(‘2043-03-09’, ‘2072-07-11’)
|