Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Division by zero in ArrayTransformer #152

Open
kachar opened this issue Nov 9, 2018 · 0 comments
Open

Division by zero in ArrayTransformer #152

kachar opened this issue Nov 9, 2018 · 0 comments

Comments

@kachar
Copy link

kachar commented Nov 9, 2018

Parsing and transformig the rule FREQ=HOURLY;BYSETPOS=-1;BYHOUR=12 leads to warning because of division by zero.

Warning:  Division by zero in ../vendor/simshaun/recurr/src/Recurr/Transformer/ArrayTransformer.php on line 466

Seems this case is specific for HOURLY in combination with BYHOUR and BYSETPOS, it works fine for DAILY.

Var $timeSet seems to be empty array because of the condition at line 230.

if ($setPos < 0) {
    $dayPos  = floor($setPos / count($timeSet));
    $timePos = DateUtil::pymod($setPos, count($timeSet));
} else {
    $dayPos  = floor(($setPos - 1) / count($timeSet));
    $timePos = DateUtil::pymod(($setPos - 1), count($timeSet));
}

I admit there's not much sense in rrule defined like that, but exception might be more appropriate, than a warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant