RTC 1302 How to know next day ?

RTC 1302 How to know next day , if today is 15/3/2020 . if i add 30 from serial how to program to know

in next 30 day is 14/4/2020

#include <DS1302.h>

// Init the DS1302
DS1302 rtc(2, 3, 4);

// Init a Time-data structure
Time t;

void setup()
{
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);

// Setup Serial connection
Serial.begin(9600);

// The following lines can be commented out to use the values already stored in the DS1302
// rtc.setDOW(MONDAY); // Set Day-of-Week to FRIDAY
// rtc.setTime(15, 1, 0); // Set the time to 12:00:00 (24hr format)
// rtc.setDate(3, 6, 2019); // Set the date to August 6th, 2010
}

void loop()
{
// Get data from the DS1302
t = rtc.getTime();

// Send date over serial connection
Serial.print(“Today is the “);
Serial.print(t.date, DEC);
Serial.print(” Day,”);
Serial.print(rtc.getMonthStr());
Serial.print(" Month,");
Serial.print(t.year, DEC);
Serial.println(" year");

// Send Day-of-Week and time
Serial.print(t.hour, DEC);
Serial.print(" hour,");
Serial.print(t.min, DEC);
Serial.print(" minute,");
Serial.print(t.sec, DEC);
Serial.println(" second");

// Send a divider for readability
Serial.println(" - - - - - - - - - - - - - - - - - - - - -");

// Wait one second before repeating :slight_smile:
delay (1000);
}

You could try something like this:

Time t_tomorrow ; . . . t_tomorrow = rtc.getTime() + (3600UL * 24 ) ; // plus 1 day in seconds . . . Serial.print(t_tomorrow.date, DEC); . . .

etc.

6v6gt: You could try something like this:

Time t_tomorrow ; . . . t_tomorrow = rtc.getTime() + (3600UL * 24 ) ; // plus 1 day in seconds . . . Serial.print(t_tomorrow.date, DEC); . . .

etc.

Error

Error this funtion --> t_tomorrow = rtc.getTime() + (3600UL * 24 ) ; // plus 1 day in seconds

exit status 1 no match for 'operator+' (operand types are 'Time' and 'long unsigned int')

6v6gt: You could try something like this:

Time t_tomorrow ; . . . t_tomorrow = rtc.getTime() + (3600UL * 24 ) ; // plus 1 day in seconds . . . Serial.print(t_tomorrow.date, DEC); . . .

etc.

Is there any other way?

The absolutely easiest way to do calculations like this, is to use epoch time. Let the conversion functions handle year/month/day rollovers. If your RTC library doesn't handle that, ditch it and get a good one, or use the existing one in combination with the Time library.