Module: kamailio
Branch: master
Commit: 2081b3aac394223b68b849fbac2a9e5ac4392334
URL: 
https://github.com/kamailio/kamailio/commit/2081b3aac394223b68b849fbac2a9e5ac4392334

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-04-29T11:49:04+02:00

core: utils/tmrec - reworked bymonth matching for negative indexes

- GH #4214

---

Modified: src/core/utils/tmrec.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/2081b3aac394223b68b849fbac2a9e5ac4392334.diff
Patch: 
https://github.com/kamailio/kamailio/commit/2081b3aac394223b68b849fbac2a9e5ac4392334.patch

---

diff --git a/src/core/utils/tmrec.c b/src/core/utils/tmrec.c
index d609e136310..eec02d22431 100644
--- a/src/core/utils/tmrec.c
+++ b/src/core/utils/tmrec.c
@@ -1104,6 +1104,7 @@ int check_min_unit(tmrec_t *_trp, ac_tm_t *_atp, tr_res_t 
*_tsw)
 int check_byxxx(tmrec_t *_trp, ac_tm_t *_atp)
 {
        int i;
+       int v;
        ac_maxval_t *_amp = NULL;
        if(!_trp || !_atp)
                return REC_ERR;
@@ -1117,10 +1118,12 @@ int check_byxxx(tmrec_t *_trp, ac_tm_t *_atp)
 
        if(_trp->bymonth) {
                for(i = 0; i < _trp->bymonth->nr; i++) {
-                       if(_atp->t.tm_mon
-                                       == ((_trp->bymonth->xxx[i] - 1) * 
_trp->bymonth->req[i]
-                                                          + 12)
-                                                          % 12)
+                       if(_trp->bymonth->req[i] < 0) {
+                               v = 12 - _trp->bymonth->xxx[i];
+                       } else {
+                               v = _trp->bymonth->xxx[i] - 1;
+                       }
+                       if(_atp->t.tm_mon == v)
                                break;
                }
                if(i >= _trp->bymonth->nr)

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to