Index: trunk/extensions/SemanticMediaWiki/includes/parserhooks/SMW_SetRecurringEvent.php |
— | — | @@ -61,6 +61,22 @@ |
62 | 62 | $timeValue->setDataItem( $timeDataItem ); |
63 | 63 | return $timeValue; |
64 | 64 | } |
| 65 | + |
| 66 | + /** |
| 67 | + * Returns the "Julian day" value from an object of type |
| 68 | + * SMWTimeValue. |
| 69 | + */ |
| 70 | + static public function getJD( $dateDataValue ) { |
| 71 | + if ( is_null( $dateDataValue ) ) { |
| 72 | + return null; |
| 73 | + } |
| 74 | + $dateDataItem = $dateDataValue->getDataItem(); |
| 75 | + // This might have returned an 'SMWDIError' object. |
| 76 | + if ( $dateDataItem instanceof SMWDITime ) { |
| 77 | + return $dateDataItem->getJD(); |
| 78 | + } |
| 79 | + return null; |
| 80 | + } |
65 | 81 | |
66 | 82 | /** |
67 | 83 | * Helper function used in this class, as well as by the |
— | — | @@ -115,7 +131,7 @@ |
116 | 132 | |
117 | 133 | foreach ( $excluded_dates as $date_str ) { |
118 | 134 | $date = SMWDataValueFactory::newTypeIDValue( '_dat', $date_str ); |
119 | | - $excluded_dates_jd[] = $date->getDataItem()->getJD(); |
| 135 | + $excluded_dates_jd[] = self::getJD( $date ); |
120 | 136 | } |
121 | 137 | break; |
122 | 138 | default: |
— | — | @@ -147,12 +163,10 @@ |
148 | 164 | } |
149 | 165 | |
150 | 166 | // Get the Julian day value for both the start and end date. |
151 | | - if ( !is_null( $end_date ) ) { |
152 | | - $end_date_jd = $end_date->getDataItem()->getJD(); |
153 | | - } |
| 167 | + $end_date_jd = self::getJD( $end_date ); |
154 | 168 | |
155 | 169 | $cur_date = $start_date; |
156 | | - $cur_date_jd = $start_date->getDataItem()->getJD(); |
| 170 | + $cur_date_jd = self::getJD( $cur_date ); |
157 | 171 | $i = 0; |
158 | 172 | $reached_end_date = false; |
159 | 173 | |