I’ve been Googling this for a few hours and I’m drawing blanks. I’ve found some solutions posted in other forums, but they seem very costly for what they are.
I’m trying to implement seasonal events in my game. I’m not using server time or anything, so I’m just using System.DateTime.Today to get the current date, which I’m happy with as an approach. The issue I’m having is trying to figure out how to do an if statement to see if it sits between two dates, which feels like it should be easy.
For comparing it to specific dates it’s been suggested that I use System.DateTime.Today.ToString(“MM-dd”) and then use an if statement to see if it equals a date (e.g. “25-12”). This is fine for specific dates, but because it’s made into a string it means I can’t use that approach for ranges.
Problem is I can’t use DateTime.Today as-is because it includes the year, and I only need to check the range against day/month. E.g. Halloween period from say 26th Oct - 1st Nov.
A potential workaround is to split out the month and date and use some nested if statements. E.g. if month = 10 || 11, and then another statement to check if day > 26. But this has its own problems, and feels clunkier than it should be.
Am I missing a really obvious approach? I’ve checked the documentation which says how to retrieve dates but not how to use them. Any guidance online seems to be for checking against one date, or using server times.
Thanks in advance!