aboutsummaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorfenner <fenner>2002-10-23 00:21:35 +0000
committerfenner <fenner>2002-10-23 00:21:35 +0000
commit90ee7f7dc55bca21abc9a0b1662208c2c6c5f8f5 (patch)
treea265b86636449863f13b2a6b87253fa4537dedde /functions
parent5ff10079fa8bb0d516923cb625cdbf826474623d (diff)
downloadphpicalendar-90ee7f7dc55bca21abc9a0b1662208c2c6c5f8f5.tar.gz
phpicalendar-90ee7f7dc55bca21abc9a0b1662208c2c6c5f8f5.tar.bz2
phpicalendar-90ee7f7dc55bca21abc9a0b1662208c2c6c5f8f5.zip
Update UNTIL handling. iCal exports an UNTIL that is sometimes
on the day after the event. My guess is that it stores the UNTIL internally as 23:59:59 on the last day of the event, and timezone conversion sometimes changes this to the next day. Luckily, it's possible to recognize this, because iCal uses an illegal UNTIL format for these anyway -- RFC 2445 says that an UNTIL with a time MUST be in UTC, and these are not. Therefore, if an event has an UNTIL with a time that's not in UTC, and the time is before noon, subtract a day. Events with UNTIL= values that comply to the RFC are not modified by this heuristic.
Diffstat (limited to 'functions')
-rw-r--r--functions/ical_parser.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/functions/ical_parser.php b/functions/ical_parser.php
index 71ecb2f..d385b0e 100644
--- a/functions/ical_parser.php
+++ b/functions/ical_parser.php
@@ -192,13 +192,26 @@ if ($parse_file) {
break;
case 'UNTIL':
$until = ereg_replace('T', '', $val);
- $until = ereg_replace('Z', '', $val);
+ $until = ereg_replace('Z', '', $until);
ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $until, $regs);
$year = $regs[1];
$month = $regs[2];
$day = $regs[3];
$until = mktime(0,0,0,$month,$day,$year);
- $until = strtotime('-1 day', $until);
+ if (ereg('^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})$', $val)) {
+ // RFC 2445 says that if an UNTIL has a date-time value,
+ // it MUST be in UTC (i.e. trailing Z). iCal tends to
+ // put an end date on the next day early in the morning,
+ // not in UTC time, so we try to correct for it.
+ //
+ // Bill's guess: iCal stores the UNTIL internally as
+ // 23:59:59 UTC, then accidentally converts that to local
+ // time when exporting the event. Thus, if the UNTIL time
+ // is before noon, it is a day ahead; if it's after noon
+ // it's the right day.
+ if ($regs[4] < 12)
+ $until = strtotime('-1 day', $until);
+ }
break;
case 'INTERVAL':
$number = $val;

© 2014-2024 Faster IT GmbH | imprint | privacy policy