module CalendarHelper def planet_for_day(weekday) { "Sunday" => "Sun", "Monday" => "Moon", "Tuesday" => "Mars", "Wednesday" => "Mercury", "Thursday" => "Jupiter", "Friday" => "Venus", "Saturday" => "Saturn" }[weekday] end def moon_phase_matches?(date) # Implement your moon phase calculation logic here # Return true if the current moon phase matches the required phase for spirits # You might want to use a gem like ruby-moon for accurate calculations true # Placeholder return value end def celestial_emoji(planet) { "Sun" => "☉", "Moon" => "☽", "Mars" => "♂", "Mercury" => "☿", "Jupiter" => "♃", "Venus" => "♀", "Saturn" => "♄" }[planet] end def current_time_valid?(date) rank = Rank.find_by(planet: planet_for_day(date.strftime("%A"))) return false unless rank case rank.time.downcase when "anytime" true when "dawn to sunrise" current_hour = Time.now.hour (4..6).include?(current_hour) when "sunrise to noon" current_hour = Time.now.hour (6..12).include?(current_hour) when "3pm to sunrise" current_hour = Time.now.hour (15..23).include?(current_hour) || (0..6).include?(current_hour) when "anytime excluding twilight" current_hour = Time.now.hour !(4..6).include?(current_hour) && !(17..19).include?(current_hour) when "anytime in a desolate place" true # This would need additional context to determine when "on great occasions" # You might want to add logic here to determine what constitutes a "great occasion" true else true # Default to allowing if we don't recognize the time restriction end end end