<div dir="ltr">Hi Daniel,<br><br>We compare the code from /src/lib/srutils/tmrec with the code from /src/modules/cplc.<br><br>The algorithm used to calculate the time is the same.<br><br>The main difference between them is that module /src/modules/cplc defines a variable *tmrec_p pointing to the same struct used by tmrec_t and, the functions use tmrec_p instead of tmrec_t*.<br><br>Code from tmrec.h:<br>typedef struct _tmrec<br>{<br>...<br> tr_byxxx_t *byday;<br> tr_byxxx_t *bymday;<br> tr_byxxx_t *byyday;<br> tr_byxxx_t *bymonth;<br> tr_byxxx_t *byweekno;<br> int wkst;<br>} tmrec_t;<br><br>Code from cpl_time.h:<br>typedef struct _tmrec<br>{<br>...<br> tr_byxxx_p byday;<br> tr_byxxx_p bymday;<br> tr_byxxx_p byyday;<br> tr_byxxx_p bymonth;<br> tr_byxxx_p byweekno;<br> int wkst;<br>} tmrec_t, *tmrec_p;<br><br><br>We don't think this could causes the issue verified, but we decided to test it out.<br>We change the /src/lib/srutils/tmrec to use tmrec_p pointers, test with the code compiled, but the behavior is the same.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 2, 2020 at 4:56 PM Daniel-Constantin Mierla <<a href="mailto:miconda@gmail.com">miconda@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Thanks for troubleshooting further and reporting back. I actually
looked a bit to the code and indeed the months seems to be 0-11.</p>
<p>Can you check if the code matches with the one in cpl-c module.
The tmrec library I wrote long time ago was embedded in cplc back
in the days of 2003-2005, inside the file
src/modules/cplc/cpl_time.c.</p>
<p>Later when other modules were added needing time recurrence
matching, another clone of tmrec library was made internal lib for
kamailio (in master now is src/core/utils/tmrec.c, older stable
should be src/lib/srutils/tmrec.c), but maybe some bugs were fixed
in cpl-c module, as it was quite used in the past, and not
propagated to the stand alone lib.</p>
<p>Cheers,<br>
Daniel<br>
</p>
<div>On 02.03.20 17:48, David Gonçalves
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">During our tests with yearly scenarios, we think we
found two unexpected behaviors.<br>
<br>
First, on the documentation, it is indicated that months can
have a value between 1-12. However, we think that acceptable
values can be between 0-11.<br>
<br>
Second, we tested a yearly recurrence on the last day of the
month (e.g., 31 of December, 30 of November). With a valid
timestamp, we always obtain not match on tmrec.<br>
We tested the penultimate day of the month (e.g., 30 of
December, 29 of November) and, both days work with a valid
timestamp.<br>
<br>
With these scenarios, it seems that the monthly and yearly
problems always occur with the last occurrence of an event.<br>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Tue, Feb 25, 2020 at 11:56
AM David Gonçalves <<a href="mailto:david.goncalves@itcenter.com.pt" target="_blank">david.goncalves@itcenter.com.pt</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">Hi,<br>
<br>
During some tests with the module tmrec, we stumble upon an
unexpected behavior of the monthly recurrence with days of
the week.<br>
The last week does not match our expected date.<br>
For example, the last Monday of March 2020 is day 30
(fifth Monday of the month) however, neither the 5MO or -1MO
configuration on the bday parameter match with a timestamp
configured to day 30. The same situation is verified on
months with only 4 weeks.<br>
<br>
To easily explain the behavior we create this configuration:
<div><br>
<div>$var(ts)="1584355625"; # Monday, March 16, 2020
10:47:05<br>
if(tmrec_match("20200101T090000|PT8H|monthly||1|3MO||||","$(var(ts){<a href="http://s.int" target="_blank">s.int</a>})")) {<br>
xlog("L_INFO","Epoch $var(ts) matches with 3MO\n");<br>
}else{<br>
xlog("L_INFO","Epoch $var(ts) doesn't match with
3MO\n");<br>
}<br>
<br>
$var(ts)="1584960425"; # Monday, March 23, 2020
10:47:05<br>
if(tmrec_match("20200101T090000|PT8H|monthly||1|4MO||||","$(var(ts){<a href="http://s.int" target="_blank">s.int</a>})")) {<br>
xlog("L_INFO","Epoch $var(ts) matches with 4MO\n");<br>
}else{<br>
xlog("L_INFO","Epoch $var(ts) doesn't match with
4MO\n");<br>
}<br>
<br>
$var(ts)="1585565225"; # Monday, March 30, 2020
10:47:05<br>
if(tmrec_match("20200101T090000|PT8H|monthly||1|5MO||||","$(var(ts){<a href="http://s.int" target="_blank">s.int</a>})")){<br>
xlog("L_INFO","Epoch $var(ts) matches with 5MO\n");<br>
}else{<br>
xlog("L_INFO","Epoch $var(ts) doesn't match with
5MO\n");<br>
}<br>
<br>
$var(ts)="1584960425"; # Monday, March 23, 2020
10:47:05<br>
if(tmrec_match("20200101T090000|PT8H|monthly||1|-1MO||||","$(var(ts){<a href="http://s.int" target="_blank">s.int</a>})")){<br>
xlog("L_INFO","Epoch $var(ts) matches with -1MO\n");<br>
}else{<br>
xlog("L_INFO","Epoch $var(ts) doesn't match with
-1MO\n");<br>
}<br>
<br>
The results were:<br>
Epoch 1584355625 matches with 3MO<br>
Epoch 1584960425 matches with 4MO<br>
Epoch 1585565225 doesn't match with 5MO<br>
Epoch 1584960425 matches with -1MO<br>
<br>
Are we configuring the tmrec_match wrongly?<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div style="font-size:12.8px"><br>
<table style="color:rgb(80,0,80);font-size:12.8px;font-family:Arial,Helvetica,sans-serif;width:600px;border-collapse:collapse">
<tbody>
</tbody>
</table>
</div>
</div>
<div dir="ltr"><span style="font-family:verdana,sans-serif;font-size:12.8px"><br>
</span></div>
<div dir="ltr"><font color="#000000"><span style="font-family:verdana,sans-serif;font-size:12.8px">Cumprimentos
/ Best regards,</span></font></div>
<div dir="ltr"><font color="#000000"><font face="verdana, sans-serif"><br>
</font></font>
<div><span style="font-family:verdana,sans-serif;font-size:12.8px"><font color="#000000"><b>David Gonçalves</b></font></span></div>
<div><font color="#000000"><span style="font-family:verdana,sans-serif;font-size:12.8px">Research </span><span style="font-family:verdana,sans-serif;font-size:12.8px">and</span><span style="font-family:verdana,sans-serif;font-size:12.8px"> </span><span style="font-family:verdana,sans-serif;font-size:12.8px">Development</span><span style="font-family:verdana,sans-serif;font-size:12.8px"> </span><span style="font-family:verdana,sans-serif;font-size:12.8px">Technician</span><br>
</font></div>
<div><font color="#000000"><span style="font-family:verdana,sans-serif;font-size:12.8px"><br>
</span></font></div>
<div><span style="font-family:verdana,sans-serif;font-size:12.8px"><font color="#000000">Phone: +351 256 370
980</font></span></div>
<div><font face="verdana, sans-serif" color="#000000">Email:</font><font face="verdana, sans-serif" color="#444444"> <a href="mailto:david.goncalves@itcenter.com.pt" target="_blank">david.goncalves@itcenter.com.pt</a></font></div>
<div><font face="verdana, sans-serif" color="#444444"><br>
</font></div>
<div><font face="verdana, sans-serif" color="#444444"><img src="http://www.itcenter.com.pt/app/themes/itcenter/assets/images/logo-itcenter.png?v=1"><br>
</font></div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr">
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div style="font-size:12.8px"><br>
<table style="color:rgb(80,0,80);font-size:12.8px;font-family:Arial,Helvetica,sans-serif;width:600px;border-collapse:collapse">
<tbody>
</tbody>
</table>
</div>
</div>
<div dir="ltr"><span style="font-family:verdana,sans-serif;font-size:12.8px"><br>
</span></div>
<div dir="ltr"><font color="#000000"><span style="font-family:verdana,sans-serif;font-size:12.8px">Cumprimentos
/ Best regards,</span></font></div>
<div dir="ltr"><font color="#000000"><font face="verdana, sans-serif"><br>
</font></font>
<div><span style="font-family:verdana,sans-serif;font-size:12.8px"><font color="#000000"><b>David Gonçalves</b></font></span></div>
<div><font color="#000000"><span style="font-family:verdana,sans-serif;font-size:12.8px">Research </span><span style="font-family:verdana,sans-serif;font-size:12.8px">and</span><span style="font-family:verdana,sans-serif;font-size:12.8px"> </span><span style="font-family:verdana,sans-serif;font-size:12.8px">Development</span><span style="font-family:verdana,sans-serif;font-size:12.8px"> </span><span style="font-family:verdana,sans-serif;font-size:12.8px">Technician</span><br>
</font></div>
<div><font color="#000000"><span style="font-family:verdana,sans-serif;font-size:12.8px"><br>
</span></font></div>
<div><span style="font-family:verdana,sans-serif;font-size:12.8px"><font color="#000000">Phone: +351 256 370 980</font></span></div>
<div><font face="verdana, sans-serif" color="#000000">Email:</font><font face="verdana, sans-serif" color="#444444"> <a href="mailto:david.goncalves@itcenter.com.pt" target="_blank">david.goncalves@itcenter.com.pt</a></font></div>
<div><font face="verdana, sans-serif" color="#444444"><br>
</font></div>
<div><font face="verdana, sans-serif" color="#444444"><img src="http://www.itcenter.com.pt/app/themes/itcenter/assets/images/logo-itcenter.png?v=1"><br>
</font></div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
Kamailio (SER) - Users Mailing List
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<pre cols="72">--
Daniel-Constantin Mierla -- <a href="http://www.asipto.com" target="_blank">www.asipto.com</a>
<a href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - March 9-11, 2020, Berlin - <a href="http://www.asipto.com" target="_blank">www.asipto.com</a>
Kamailio World Conference - April 27-29, 2020, in Berlin -- <a href="http://www.kamailioworld.com" target="_blank">www.kamailioworld.com</a></pre>
</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div style="font-size:12.8px"><br><table style="color:rgb(80,0,80);font-size:12.8px;font-family:Arial,Helvetica,sans-serif;width:600px;border-collapse:collapse"><tbody></tbody></table></div><div style="font-size:12.8px"></div></div><div dir="ltr"><span style="font-family:verdana,sans-serif;font-size:12.8px"><br></span></div><div dir="ltr"><font color="#000000"><span style="font-family:verdana,sans-serif;font-size:12.8px">Cumprimentos / Best regards,</span></font></div><div dir="ltr"><font color="#000000"><font face="verdana, sans-serif"><br></font></font><div><span style="font-family:verdana,sans-serif;font-size:12.8px"><font color="#000000"><b>David Gonçalves</b></font></span></div><div><font color="#000000"><span style="font-family:verdana,sans-serif;font-size:12.8px">Research </span><span style="font-family:verdana,sans-serif;font-size:12.8px">and</span><span style="font-family:verdana,sans-serif;font-size:12.8px"> </span><span style="font-family:verdana,sans-serif;font-size:12.8px">Development</span><span style="font-family:verdana,sans-serif;font-size:12.8px"> </span><span style="font-family:verdana,sans-serif;font-size:12.8px">Technician</span><br></font></div><div><font color="#000000"><span style="font-family:verdana,sans-serif;font-size:12.8px"><br></span></font></div><div><span style="font-family:verdana,sans-serif;font-size:12.8px"><font color="#000000">Phone: +351 256 370 980</font></span></div><div><font face="verdana, sans-serif" color="#000000">Email:</font><font color="#444444" face="verdana, sans-serif"> <a href="mailto:david.goncalves@itcenter.com.pt" target="_blank">david.goncalves@itcenter.com.pt</a></font></div><div><font color="#444444" face="verdana, sans-serif"><br></font></div><div><font color="#444444" face="verdana, sans-serif"><img src="http://www.itcenter.com.pt/app/themes/itcenter/assets/images/logo-itcenter.png?v=1"><br></font></div><div><br></div><div><br></div></div></div></div></div></div></div>