problem changing time at specific date

Hello,

2 litle problems and don’t know how to resolve them (or what the problem is…)

1st problem:
I want to change the hour at specific time and date

EX: when it’s 11,6,2019 02h 00m 00s

time should change to 03h

CODE (whole code in attachement)

if(t.hour == 2 && t.min == 00 && t.sec == 00 && t.date == 11,6,2019 ){

rtc.setTime( 3, 0, 0 );

but he sets time every cycle to 3.0.0 … not only if the “if” value is true…
(it works when I remove the part of the date in the ‘IF’ part…
but i need it to be on a specific day…

2nd problem:

I’dd like to do the same thing but 2h has to become 1h… (on another day)

problem: within an hour it’ll be 2 again, and I just want the clock to turn back one time!

who can help me?
code in attachment : problem in lines ( 138 - 154) i think

THX!

problem_code.ino (7.79 KB)

Please add your code between code tags next time >


I would suggest watching these:

-I see a lot of empty else statements. You should remove them if you aren't doing anything with them.
-Press Control + T to auto format your code (if you are using the Arduino IDE).
-I think it would be better to store your hours, minutes, seconds and dates in an Array.
-I am not a genius but aren't you using the wrong variable type for this? An integer is to store your dates, I think.

Hello,

I'm rather new to coding so =I take existing codes and adapt them by trying to use logics, so I don't get all of what you say...

ok for the empty 'else', i'l remove them completely.

I'll use the ctrl T to auto format, but don't know how to tackle the 2 other things...

I was hoping it was just an error in one of these lines :slight_smile:

so, no quick fix?

t.date == 11,6,2019

I'm not familiar with how t.date is stored but if it works without t.date included then I would suspect that finding out how t.date works would give you your answer. Maybe you have to check day of month, month and year separately instead of all at the same time.