I have a problem of finding a future year based upon a fixed past year. I can come to the correct answer if I use an if statement, but I feel this should be accomplished with one formula.
For example, let $$\text{CurrentYear} = 2018,\quad \text{cycleYears} = 3,\quad \text{baseYear} = 2015$$
With these values I can simply say $$\text{(mod(CurrentYear $-$ baseYear), cycleYears) $+$ CurrentYear}$$
and I get the expected answer of $2018$. Now, let $\text{baseYear} = 2014$ and get a value of $2019$, off by one. Simple, factor in the remainder to the above formula.
$$ \text{(mod(CurrentYear $-$ baseYear), cycleYears) $+$ CurrentYear $+$ mod(CurrentYear $-$ baseYear)} $$
Now I get the expected answer of $2020$, and this tweak works for the base year of $2015$ as the modulus is zero.
Now, let $\text{baseYear} = 2016$ and the year with the first formula is 2020 (off by one) and with the second one is 2022 (skipped the current year in favor of the next cycle). The correct answer is 2019.
I can get this to work with an if of some sort, checking the modulus value, but I feel this should work without a logic branch.
Thoughts?
Update/Clarifications
I am trying to compute a series of years based upon an base year and how many years this date cycles.
A real-world example would be election years. For a US President, the baseYear could be any leap year, let's say 1976. We also know that that office is elected every 4 years. So, I could use this formula and find out that the next presidential election is in 2020. Like wise, a US Senator is on a 6 year cycle. Some senators could have a base year of 1974, so their next election would be this year in 2018.
To rephrase the question, you want to find the least $y$ satisfying $y \ge y_0$ and $y \equiv y_{base} \pmod \omega$. Here $y_0$ is the current year, $y_{base}$ is the base year, and $\omega$ is the cycle length.
Unfortunately this is hard to do with a conventional modulo operator and no case splits. The related problem of finding the least $y'$ such that $y' > y_0$ and $y' \equiv y_{base} \pmod \omega$ is solved with $$y' = y_0 + \omega - ((y_0 - y_{base}) \bmod \omega)$$ but if your modulo operator gives $0$ as a result instead of $\omega$ then it's arguable that the simplest expression for $y$ is $$y = \begin{cases}y_0 & \text{when } y_0 \equiv y_{base} \pmod \omega \\ y_0 + \omega - ((y_0 - y_{base}) \bmod \omega) & \text{otherwise} \end{cases}$$
I suppose that if you really want to avoid case splits you have $$y = y_0 + ((\omega - ((y_0 - y_{base}) \bmod \omega)) \bmod \omega)$$