I'm trying to make a calculator that will determine the number of seconds until the start of a specific day.

I am currently able to determine the current day & time, but I'm unsure of how to determine the number of seconds until the start of the future day that I want (let's say Saturday for example).

I'm thinking I could calculate how many days apart from Saturday we are and then convert that into seconds, but the issue is that there might be additional time added on (I want to know the time at midnight, start of day).

Anyone know how this would be possible?

```
#pragma once
#include <string>
#include <ctime>

class DateTime
{
public:
   DateTime();

   DateTime(
      const time_t& specific_datetime);

   const std::string GetWeekDay() const;

   const std::string GetMonth() const;

   int GetDate() const;

   const int GetSecondsUntilNextWeekDay(
      const std::string& day_name) const;

private:

   const int GetWeekDayNumberFromName(
      const std::string& name) const;

   tm m_time;
   const time_t m_datetime;

   DateTime(const DateTime &rhs);
   DateTime &operator=(const DateTime &rhs);
};

```

```
#include "DateTime.h"

DateTime::DateTime() :
   m_datetime(std::time(NULL))
{
   localtime_s(&m_time, &m_datetime);
}

DateTime::DateTime(
   const time_t& specific_datetime) :
   m_datetime(specific_datetime)
{
   localtime_s(&m_time, &m_datetime);
}

const std::string DateTime::GetWeekDay() const
{
   switch (m_time.tm_wday)
   {
   case 0:
      return "Sunday";
   case 1:
      return "Monday";
   case 2:
      return "Tuesday";
   case 3:
      return "Wednesday";
   case 4:
      return "Thursday";
   case 5:
      return "Friday";
   case 6:
      return "Saturday";
   default:
      return "Sunday";
   }
}

const std::string DateTime::GetMonth() const
{
   switch (m_time.tm_mon)
   {
   case 0:
      return "January";
   case 1:
      return "February";
   case 2:
      return "March";
   case 3:
      return "April";
   case 4:
      return "May";
   case 5:
      return "June";
   case 6:
      return "July";
   case 7:
      return "August";
   case 8:
      return "September";
   case 9:
      return "October";
   case 10:
      return "November";
   case 11:
      return "December";
   default:
      return "January";
   }
}

int DateTime::GetDate() const
{
   return m_time.tm_mday;
}

int DateTime::GetYear() const
{
   return 1900 + m_time.tm_year;
}

const int DateTime::GetSecondsUntilNextWeekDay(
   const std::string& day_name) const
{
   // Calculate how many seconds left for today...
   const int todays_hours_left = 23 - m_time.tm_hour;
   const int todays_minutes_left = (todays_hours_left * 60) + (59 - m_time.tm_min);
   const int todays_seconds_left = (todays_minutes_left * 60) + (59 - m_time.tm_sec);
   int overlap_seconds = 0;

   // Calculate how many days until the desired date.
   int current_day_number = m_time.tm_wday;
   const int desired_day_number = GetWeekDayNumberFromName(day_name);

   if (desired_day_number >= 0)
   {
      if (desired_day_number <= current_day_number)
      {
         // Find out how many days left in the week, add them to how many days until the today.
         const int max_day = 6;
         const int days_remaining = max_day - current_day_number;
         overlap_seconds = (days_remaining * 24 * 60 * 60);
         current_day_number = 0;
      }

      const int days_left = desired_day_number - current_day_number;
      const int hours_left = days_left * 24;
      const int minutes_left = hours_left * 60;
      const int seconds_left = (minutes_left * 60) - (86400 - todays_seconds_left) + overlap_seconds;

      return seconds_left;
   }

   return -1;
}

const int DateTime::GetWeekDayNumberFromName(
   const std::string& name) const
{
   if (name == "Sunday")
   {
      return 0;
   }
   else if (name == "Monday")
   {
      return 1;
   }
   else if (name == "Tuesday")
   {
      return 2;
   }
   else if (name == "Wednesday")
   {
      return 3;
   }
   else if (name == "Thursday")
   {
      return 4;
   }
   else if (name == "Friday")
   {
      return 5;
   }
   else if (name == "Saturday")
   {
      return 6;
   }

   return -1;
}

```

```
#include <iostream>

#include "DateTime.h"

int main()
{
   DateTime date_time;

   const int seconds = date_time.GetSecondsUntilNextWeekDay("Monday");
   std::cout << "Seconds Till Date: " << seconds;
}

```

I would expect that if I wanted to know how long until the start of Thursday from the current time (9:00 PM on Wednesday) it would return 3 hours or 10800 seconds (either or work).