I'm not quite sure how to describe the problem programmatically but I have a server and I don't want to run a separate thread/loop to check for a new day but essentially any time a user connects to the server it runs a check to see if it's a new day meaning past 11:59pm on local time. And if so, the server should perform a single operation but only that one time until a new day starts again. And I'm not sure how to go about doing this. My first issue would be how would I check if it's past 11:59 on any given day. And my second question is how do I make sure whatever operation I'm performing is only performed once until the next day?
I thought about just keeping a variable look bool and operating on that
pseudo
if(time>11:59){
if(!newday){
//do single operation
newday = true;
}
}
But this won't work simply because every minute past 11:59 will be greater than and newday will never be reset back to false..
I don't know if I'm overthinking a very simple concept or I just don't understand what I'm doing. Should I not use a specific time to check whether a new day has begun? Should I run on a 24 hour basis rather than 12?