Commit Graph
58 Commits
Author SHA1 Message Date
Chris S 069445579c Fix conversion to UTC for DST changes
The RepeatRuleDateTime constructor extracts the date's time zone then
passes it to the parent class DateTime. Because PHP's DateTime has full
support for time zones, it compensates for them when parsing a string.
Normally this isn't a problem, because the opposite occurs when a
DateTime is converted back into a string; the two adjustments cancel
each other.

Davical often converts a time to UTC by negating the time zone offset
and adding it to the underlying DateTime (keeping the time zone intact).
A problem occurs when the result is on the other side of a daylight-
saving-time transition. In that case the adjustments do not cancel and
an incorrect time string is returned.

This bug is tricky because the problem doesn't manifest during the DST
transition iself, but hours earlier or later depending on the original
time zone. For example, 2022-03-12T18:30:00-08:00 (America/Los_Angeles)
is 2022-03-13T02:30:00Z. Since 2022-03-13 is a 23-hour day in the Los
Angeles time zone (the 2AM-3AM hour is skipped) this becomes
2022-03-13T03:30:00-07:00 after adding the negated offset. FloatOrUTC()
would strip the new offset and simply return "20220313T033000".
2024-01-19 19:13:07 +13:00
Andrew Ruthven c3970f3be2 Fix RRULE for BYHOUR, BYMINUTE and BYSECOND
Closes #283.
2023-02-15 07:28:35 +00:00
Andrew Ruthven 8444347b02 We no longer support PHP 5.1, assume that DateTime is available 2023-02-15 07:28:35 +00:00
Andrew Ruthven a323ba8dae Don't change the day of the month to 28, if it is > 28
Gosh. The logic was saying, if the modified date has a day of the
month > 28, change it to 28. Which is rather odd. Don't do that.

This closes #248. It also fixes a bug with FREQ=MONTHLY;BYMONTHDAY=-1
as it turns out.
2022-12-18 13:52:48 +13:00
Andrew Ruthven 6e68c221e9 Add more logging to investigate the 28th problem on issue #248
I reckon this is useful logging to have, keep it around.
2022-12-18 13:52:48 +13:00
Andrew Ruthven 7a8c7b5b25 Convert loop_limit to a config item 2022-12-15 20:50:44 +00:00
Andrew Ruthven d93a5196b8 Increase loop limit for finding next instance for Recurrence Rules.
With complex rules, it make take more than 10 expansions to find the
next valid date. Increase this to 100, it doesn't slow things down too
much.

I've also added some additional error logging if this issue occurs
again.

Closes #268.
2022-12-15 20:50:44 +00:00
Andrew Ruthven 0fdb3ff558 Add more logging to try and find the root cause for issue 268 2022-12-15 20:50:44 +00:00
Andrew Ruthven 3909ec52f1 Convert RRule debugging to use dbg_error_log
This stops the debugging from being sent to stdout, which goes to the client and
mucks up the test results.
2022-12-15 20:50:44 +00:00
Andrew Ruthven 6ad794eae6 freq_name is only used locally
This doesn't need to be an object field.
2022-12-10 14:37:31 +13:00
Andrew Ruthven aab8ddfd30 Ensure that all fields are defined, not added dynamically.
PHP 8.2 deprecates dynmically adding properties. See:
  https://php.watch/versions/8.2/dynamic-properties-deprecated
2022-12-10 14:37:31 +13:00
Andrew Ruthven 8096807c6d Fixes for warnings in PHP 8.1 2022-02-12 23:41:28 +13:00
Piotr Filip 467a6bf890 fix: Rfc5545Duration __toString returns "P" when in_duration==0 2021-09-18 13:48:39 +00:00
Andrew Ruthven 1e5c1fd1f3 Disable the debug mode, leave extra debugging output available 2021-09-18 23:22:57 +12:00
Andrew Ruthven 19e69060b9 Enable more debugging so I can see timezone differences in CI 2021-09-18 22:15:27 +12:00
Andrew Ruthven e4f48ddc1a For RRULE BYMONTHDAY skip expansions where the new day is not the day we expect.
This fixes one of the issues raised in #248.
2021-08-11 22:36:38 +12:00
Andrew Ruthven ccedbd1be9 Include the UID of the card which caused us to hit the RRULE limit
This will helpfully assist tracking down issues with recurrence rules.
2021-02-06 20:19:03 +13:00
Piotr Filip e98bf7b682 fix: events with recurrence rule are sometimes counted one too many times in freebusy 2021-01-25 00:08:13 +13:00
Milan Crha 710bc6cccd Add missing 'break;' into RRule.php 2019-06-19 09:20:56 +00:00
Jamie McClymont b07019ed96 Make calquery expansion aware of the calendar default timezone
This fixes cases where we emit floating times
2019-02-28 16:00:19 +13:00
Florian Schlichting 97a2686459 fix more PHP7+ type hints for PHP5 compatibility (fixes #197) 2019-02-13 08:49:19 +01:00
Andrew Ruthven ebd169e555 Merge branch 'JJJollyjim/davical-freebusy-modified-instances' 2019-01-30 22:19:25 +13:00
Andrew Ruthven 8966a044a2 Merge branch 'JJJollyjim/davical-rrule-expansion-limit' 2019-01-29 23:06:03 +13:00
Jamie McClymont cf2f019419 Increase, and make configurable, the limit for rrule expansion 2019-01-28 04:51:37 +00:00
Jamie McClymont aea6be279b RRule Expansion: Do not emit recurrences for instances with RRULEs
This matches the behaviour of Evolution and Thunderbird
2019-01-28 17:17:28 +13:00
Jamie McClymont ffa06343a3 Fix bugs in expansion of events with overridden instances 2019-01-28 15:29:55 +13:00
Jamie McClymont cf7de16e59 Handle default timezones in getVCalendarRange
Also includes some PHPUnit-based tests for this function!
2019-01-03 17:48:42 +13:00
Jamie McClymont 5fc3875345 Pull the freebusy floating-time handling into a function 2019-01-03 16:04:28 +13:00
Andrew Ruthven 2873c89149 Fix a typo of this.
Closes #145
2018-10-02 19:53:44 +13:00
Andrew Ruthven 22e0e4aa38 Improve parsing of RFC5545 durations
The previous regex failed to parse PT15M which is a valid duration.

This version more correctly implements:
  https://tools.ietf.org/html/rfc5545#section-3.3.6

It isn't totally correct as it incorrectly allows:

  PT10H20S

Which is invalid due to no minutes being present. Oh well.
2017-05-17 11:06:29 +12:00
Florian Schlichting eaef540766 replace RRule with RRule-v2 2016-12-30 08:54:14 +01:00
Andrew McMillan 31400d3d7e Not the whole solution, but this is more correct than the other. 2010-08-30 17:00:26 +12:00
Andrew McMillan 8223e2e9f7 Replace deprecated split() calls. 2010-04-26 19:46:23 +12:00
Andrew McMillan e8b722f9e1 Fix RenderGMT() to render GMT correctly. 2010-04-16 12:45:17 +12:00
Andrew McMillan cb8cd84d81 Comment out debugging messages for peformance. 2009-12-28 00:23:48 +13:00
Andrew McMillan 471d0025f1 Call by reference is naughty, according to the PHP developers :-( 2009-09-10 22:00:43 +12:00
Andrew McMillan 897ac95221 Fix bug in duration handling. Allow wider input possibilities. 2009-06-16 22:44:57 +12:00
Andrew McMillan 1fba1ff769 Add a RenderGMT() method to iCalDate. 2009-03-31 22:18:10 +13:00
Andrew McMillan 28bb70e6fd Fix RRule problem and remove uninitialised variable warnings. 2008-10-27 16:52:33 +13:00
Andrew McMillan 1dae32c106 Correct DAILY with BYDAY rule handling. 2008-10-26 22:16:20 +13:00
Andrew McMillan 40212665ca Make 'WEEKLY' a first-class frequency. 2008-10-25 13:12:10 +13:00
Andrew McMillan f7c7620dea [RRule] Fix bug in GetNext for a daily event with a BYDAY rule. 2008-10-24 18:02:01 +13:00
Andrew McMillan 5c8cfa4031 Rename @package to davical. 2008-09-18 12:03:00 +12:00
Andrew McMillan 7009f8ed81 Remove closing PHP tag. 2008-06-06 20:13:37 +12:00
Andrew McMillan bf996862a8 Correct comments to reflect reality. 2008-01-24 07:49:44 +13:00
Andrew McMillan 9a32c2c806 Fix a bug in addition of durations. 2007-11-24 23:06:36 +13:00
Andrew McMillan 48f43b18b3 Final tweaks to RRule, removing debugging and with tests that are now better. 2007-03-07 22:12:39 +13:00
Andrew McMillan bc15ec03e6 Many fixes to the RRule handling both for correctness and PHP5. 2007-03-07 12:39:38 +13:00
Andrew McMillan 37b754f073 Lots of fixes for PHP5 and correctness. Nearly done... 2007-03-07 09:17:08 +13:00
Andrew McMillan f058968e87 Fix typo which becomes obvious when this is run under PHP5. 2007-03-05 14:39:13 +13:00