// This function returns the number of seconds until midnight in the timezone specified by tz.
// The timezone is specified using an integer in the range [-12, 12].
// If the timezone is invalid, return -1.
int seconds2midnight(int tz) {
// Check the timezone
if (tz < -12 || tz > 12) {
return -1;
}
// Get the current time
auto now = std::chrono::system_clock::now();
// Convert the current time to a number of seconds since the epoch
auto seconds_since_epoch = std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count();
// Calculate the number of seconds since midnight
auto seconds_in_day = seconds_since_epoch % 86400;
// Calculate the number of seconds until midnight
auto seconds2midnight = (86400 - seconds_in_day - tz * 3600) % 86400;
return seconds2midnight;
}
--
FROM 120.244.140.*