Révision 55670b15
Ajouté par Assos Assos il y a presque 10 ans
drupal7/sites/all/modules/date_ical/date_ical.utils.inc | ||
---|---|---|
42 | 42 |
$start_datetime = date_format($start, DATE_FORMAT_DATETIME); |
43 | 43 |
|
44 | 44 |
if (!empty($rrule_values['UNTIL']['datetime'])) { |
45 |
// TODO: The spec says that UNTIL must be specified in UTC, but I think |
|
46 |
// this may not be followd by all feed creators. It may be a good idea to |
|
47 |
// support optionally assuming the date has the same TZID as DTSTART. |
|
48 |
$end = date_ical_date($rrule_values['UNTIL'], $timezone); |
|
49 |
$end_datetime = date_format($end, DATE_FORMAT_DATETIME); |
|
45 |
// The spec says that UNTIL must be in UTC, but not all feed creators |
|
46 |
// follow that rule. If the user specified that he wanted to overcome this |
|
47 |
// problem, use $timezone for the $final_repeat, and then convert the UNTIL |
|
48 |
// in the unparsed RRULE to UTC. |
|
49 |
if (!empty($source->importer->config['parser']['config']['until_not_utc'])) { |
|
50 |
// Change the parsed UNTIL from UTC to $timezone, so that the |
|
51 |
// date_ical_date() won't convert it. |
|
52 |
$rrule_values['UNTIL']['tz'] = $timezone; |
|
53 |
|
|
54 |
// Convert the unparsed UNTIL to UTC, since the Date code will use it. |
|
55 |
// It may currently have a Z on it, but only because iCalcreator blindly |
|
56 |
// adds one to DATETIME-type UNTILs if it's not there. |
|
57 |
$matches = array(); |
|
58 |
if (preg_match('/^(.*?)UNTIL=([\dT]+)Z?(.*?)$/', $repeat_data['RRULE'], $matches)) { |
|
59 |
// If the UNTIL value doesn't have a "T", it's a DATE, making timezone |
|
60 |
// fixes irrelvant. |
|
61 |
if (strpos($matches[2], 'T') !== FALSE) { |
|
62 |
$until_date = new DateObject($matches[2], $timezone); |
|
63 |
$until_date->setTimezone(new DateTimeZone('UTC')); |
|
64 |
$matches[2] = $until_date->format('Ymd\THis'); |
|
65 |
$repeat_data['RRULE'] = "{$matches[1]}UNTIL={$matches[2]}Z{$matches[3]}"; |
|
66 |
} |
|
67 |
} |
|
68 |
else { |
|
69 |
watchdog('date_ical', 'The RRULE string "%rrule" could not be parsed to fix the UNTIL value. Date repeats may not be calculated correctly.', |
|
70 |
array('%rrule' => $repeat_data['RRULE']), WATCHDOG_WARNING |
|
71 |
); |
|
72 |
} |
|
73 |
} |
|
74 |
$final_repeat = date_ical_date($rrule_values['UNTIL'], $timezone); |
|
75 |
$final_repeat_datetime = date_format($final_repeat, DATE_FORMAT_DATETIME); |
|
50 | 76 |
} |
51 | 77 |
elseif (!empty($rrule_values['COUNT'])) { |
52 |
$end_datetime = NULL;
|
|
78 |
$final_repeat_datetime = NULL;
|
|
53 | 79 |
} |
54 | 80 |
else { |
55 |
// No UNTIL and no COUNT? |
|
81 |
// No UNTIL and no COUNT? This is an illegal RRULE.
|
|
56 | 82 |
return array(); |
57 | 83 |
} |
58 | 84 |
|
... | ... | |
69 | 95 |
$date = date_ical_date($rdate, $timezone); |
70 | 96 |
$additions[] = date_format($date, 'Y-m-d'); |
71 | 97 |
} |
72 |
// TODO: EXRULE. |
|
98 |
|
|
99 |
// TODO: EXRULEs. |
|
73 | 100 |
|
74 | 101 |
$date_repeat_compatible_rrule = "{$repeat_data['RRULE']}\n{$repeat_data['RDATE']}\n{$repeat_data['EXDATE']}"; |
75 |
$calculated_dates = date_repeat_calc($date_repeat_compatible_rrule, $start_datetime, $end_datetime, $exceptions, $timezone, $additions);
|
|
102 |
$calculated_dates = date_repeat_calc($date_repeat_compatible_rrule, $start_datetime, $final_repeat_datetime, $exceptions, $timezone, $additions);
|
|
76 | 103 |
$repeat_dates = array(); |
77 | 104 |
foreach ($calculated_dates as $delta => $date) { |
78 | 105 |
// date_repeat_calc always returns DATE_DATETIME dates, which is |
... | ... | |
114 | 141 |
continue; |
115 | 142 |
} |
116 | 143 |
|
117 |
// These keys never have multiple values.
|
|
144 |
// The following keys never have multiple values.
|
|
118 | 145 |
if (in_array($key, array('UNTIL', 'FREQ', 'INTERVAL', 'COUNT', 'WKST'))) { |
119 | 146 |
if ($key == 'UNTIL') { |
120 | 147 |
// This is a function from the date_api module, not date_ical. |
Formats disponibles : Unified diff
Weekly update of contrib modules