Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
date_ical
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
drupal.org
date_ical
Commits
60c78022
Commit
60c78022
authored
Apr 23, 2014
by
Robert Rollins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Final fix for the non-UTC UNTIL feature (I hope).
parent
17349daa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
8 deletions
+77
-8
date_ical.utils.inc
date_ical.utils.inc
+12
-8
tests/until_tests.ics
tests/until_tests.ics
+65
-0
No files found.
date_ical.utils.inc
View file @
60c78022
...
...
@@ -52,17 +52,21 @@ function _date_ical_get_repeat_dates($field_name, $repeat_data, $item, $source)
$rrule_values
[
'UNTIL'
][
'tz'
]
=
$timezone
;
// Convert the unparsed UNTIL to UTC, since the Date code will use it.
// It
's currently got
a Z on it, but only because iCalcreator blindly
// add
ed it. Since the user set "until_not_utc", we know it's not UTC
.
// It
may currently have
a Z on it, but only because iCalcreator blindly
// add
s one to DATETIME-type UNTILs if it's not there
.
$matches
=
array
();
if
(
preg_match
(
'/^(.*?)UNTIL=(.*?)Z(.*?)$/'
,
$repeat_data
[
'RRULE'
],
$matches
))
{
$until_date
=
new
DateObject
(
$matches
[
2
],
$timezone
);
$until_date
->
setTimezone
(
new
DateTimeZone
(
'UTC'
));
$matches
[
2
]
=
$until_date
->
format
(
'Ymd\THis'
);
$repeat_data
[
'RRULE'
]
=
"
{
$matches
[
1
]
}
UNTIL=
{
$matches
[
2
]
}
Z
{
$matches
[
3
]
}
"
;
if
(
preg_match
(
'/^(.*?)UNTIL=(.*?)Z?(.*?)$/'
,
$repeat_data
[
'RRULE'
],
$matches
))
{
// If the UNTIL value doesn't have a "T", it's a DATE, making timezone
// fixes irrelvant.
if
(
strpos
(
$matches
[
2
],
'T'
)
!==
FALSE
)
{
$until_date
=
new
DateObject
(
$matches
[
2
],
$timezone
);
$until_date
->
setTimezone
(
new
DateTimeZone
(
'UTC'
));
$matches
[
2
]
=
$until_date
->
format
(
'Ymd\THis'
);
$repeat_data
[
'RRULE'
]
=
"
{
$matches
[
1
]
}
UNTIL=
{
$matches
[
2
]
}
Z
{
$matches
[
3
]
}
"
;
}
}
else
{
watchdog
(
'date_ical'
,
'The RRULE string
%rrule
could not be parsed to fix the UNTIL value. Date repeats may not be calculated correctly.'
,
watchdog
(
'date_ical'
,
'The RRULE string
"%rrule"
could not be parsed to fix the UNTIL value. Date repeats may not be calculated correctly.'
,
array
(
'%rrule'
=>
$repeat_data
[
'RRULE'
]),
WATCHDOG_WARNING
);
}
...
...
tests/until_tests.ics
0 → 100644
View file @
60c78022
BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Events Feed
X-WR-TIMEZONE:America/New_York
X-WR-CALDESC:A calendar for the events feed
BEGIN:VTIMEZONE
TZID:America/New_York
X-LIC-LOCATION:America/New_York
BEGIN:DAYLIGHT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
TZNAME:EDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
TZNAME:EST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
SUMMARY:Event w/ Bad UNTIL
UID:12345acbdef1
DTSTART;TZID=America/Los_Angeles:20140323T190000
DTEND;TZID=America/Los_Angeles:20140323T210000
RRULE:FREQ=DAILY;UNTIL=20140328T190000;WKST=SU
DESCRIPTION:description
END:VEVENT
BEGIN:VEVENT
SUMMARY:Event w/ UTC UNTIL
UID:12345acbdef2
DTSTART;TZID=America/Los_Angeles:20140323T190000
DTEND;TZID=America/Los_Angeles:20140323T210000
RRULE:FREQ=DAILY;UNTIL=20140328T230000Z;WKST=SU
DESCRIPTION:description
END:VEVENT
BEGIN:VEVENT
SUMMARY:Event w/ COUNT
UID:12345acbdef3
DTSTART;TZID=America/Los_Angeles:20140323T190000
DTEND;TZID=America/Los_Angeles:20140323T210000
RRULE:FREQ=DAILY;COUNT=6;WKST=SU
DESCRIPTION:description
END:VEVENT
BEGIN:VEVENT
SUMMARY:Event w/ DATE-type UNTIL
UID:12345acbdef4
DTSTART;VALUE=DATE:20140323
DTEND;VALUE=DATE:20140323
RRULE:FREQ=DAILY;UNTIL=20140328;WKST=SU
DESCRIPTION:description
END:VEVENT
END:VALENDAR
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment