r63949 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63948‎ | r63949 | r63950 >
Date:15:03, 19 March 2010
Author:yaron
Status:deferred
Tags:
Comment:
Added David Raison's code for new 'dayofweekinmonth' unit for #set_recurring_event
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_ParserExtensions.php
@@ -409,6 +409,15 @@
410410 $date_str = "$cur_year-$cur_month-$cur_day $cur_time";
411411 $cur_date = SMWDataValueFactory::newTypeIDValue( '_dat', $date_str );
412412 $cur_date_jd = $cur_date->getValueKey();
 413+ } elseif($unit == 'dayofweekinmonth') {
 414+ // e.g., "3rd Monday of every month"
 415+ $check_month = $cur_date->getMonth();
 416+ $cur_date_jd += 28 * $period;
 417+ $cur_date = SMWDataValueFactory::newTypeIDValue('_dat', $cur_date_jd);
 418+ if ($cur_date->getMonth() != (($check_month + $period) % 12 )){
 419+ $cur_date_jd += 7; // add another week
 420+ $cur_date = SMWDataValueFactory::newTypeIDValue('_dat', $cur_date_jd);
 421+ }
413422 } else { // $unit == 'day' or 'week'
414423 // assume 'day' if it's none of the above
415424 $cur_date_jd += ( $unit === 'week' ) ? 7 * $period : $period;

Status & tagging log