-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use system time for holidays #36628
Comments
Thanks a ton, I somehow missed this part of the language standard the last time I was looking for a solution. |
References Ideally we'd have a json calendar of future holidays we update yearly or something, though there's no real reason it can't be updated for the next decade or so. |
For holidays like Easter and Thanksgiving? Yeah, that'd probably be handy. I trust that my code for Thanksgiving will work (found out that Thanksgiving is always on either the 25th or 26th), but not really my Easter code. Tried doing the math, and I just assumed it isn't mathematically possible for Easter to occur on anything past April 7th. |
So what exactly is stopping us from adding this? |
Someone doing it. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. Please do not 'bump' or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered. |
It seriously can't be that hard to implement, right? Would the code I gave not work? |
The code you gave would not work, but could be very easily turned into actual C++ instead of psuedocode and work (though there are some things that are wrong there regardless of pseudocode/actual C++. |
e.g. holiday get_holiday_from_time()
{
std::tm local_time;
std::time_t current_time = std::time( nullptr );
local_time = std::localtime( ¤tTime );
int month = local_time.tm_mon;
int day = local_time.tm_mday;
int wday = local_time.tm_wday;
if( month == 0 && day == 1 ) {
return holiday::new_year;
} else if( ( month == 2 && day >= 21 ) ||
( month == 3 && day <= 7 ) && wday == 0 ) {
return holiday::easter;
} else if( month == 6 && day == 4 ) {
return holiday::independence_day;
} else if( month == 9 ) {
return holiday::halloween;
} else if( month == 10 && ( day == 25 || day == 26 ) && wday == 4 ) {
return holiday::thanksgiving;
} else if( month == 11 && day <= 25 ) {
return holiday::christmas;
} else {
return holiday::none;
}
} This probably works, no guarantees. |
I've noticed that we've been manually changing the title screens for the holiday variants. I don't think it's really necessary to make an entirely new patch update just for a small Easter egg. I have a better solution: system time. The game will pull from the system's internal clock, and will display whatever title screen based on that. I did a bit of digging to see if C++ supports pulling from system time, and, with my very little knowledge on programming code from scratch, here's what I got.
The text was updated successfully, but these errors were encountered: