<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Cyril Hrubis <<a href="mailto:chrubis@suse.cz" target="_blank">chrubis@suse.cz</a>> wrote:<br></div></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I would have done this a bit differently, first chek for day, mon, year<br>
then do the calculation as:<br>
<br>
if (set_tm->tm_year != read_tm->tm_year)<br>
return 1;<br>
<br>
if (set_tm->tm_mon != read_tm->tm_mon)<br>
return 1;<br>
<br>
if (set_tm->tm_mday != read_tm->tm_mday)<br>
return 1;<br>
<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">I slightly want to keep rtc_time comparison before converting</div><div class="gmail_default" style="font-size:small">into seconds here, because the time change rarely happens,</div><div class="gmail_default" style="font-size:small">we don't need to use seconds every time.</div><div class="gmail_default" style="font-size:small"><br></div>+ if ((set_tm->tm_sec != read_tm->tm_sec)<br>+ || (set_tm->tm_min != read_tm->tm_min)<br>+ || (set_tm->tm_hour != read_tm->tm_hour)) {<br><div class="gmail_default" style="font-size:small"></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
seconds1 = ....<br>
seconds2 = ....<br>
delta = ...<br>
<br>
if (delta < 0 || delta > 3)<br>
return 1;<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">+ }</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
return 0;<br>
<br>
<br>
I find this a bit clearer to read.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Fair enough!</div></div><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>