Hi,

No, this one's an actual problem. :) The 'xofmonth' concept sounds interesting (though there might be a nicer name than that) - but what would a call to #set_recurring_event look like, using 'xofmonth'?

-Yaron

On Wed, Mar 3, 2010 at 9:51 PM, David Raison <david@hackerspace.lu> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi again,

I hope this is not going to turn out to be another Pebkac for me ;)

Have you foreseen the possibility of tweaking the recurring events parser to not parse monthly
recurring events by date (i.e. each 6th of a month) but by days of the week (i.e. every first
Saturday of a month)?

Actually, there are two possibilities to do this (or let's rather say, two that I thought of, not
being familiar with the SMWDataValueFactory). The first and, IMHO simplest, being:

Index: SMW_ParserExtensions.php
===================================================================
- --- SMW_ParserExtensions.php (revision 63234)
+++ SMW_ParserExtensions.php (working copy)
@@ -416,6 +416,14 @@
$date_str = "$cur_year-$cur_month-$cur_day $cur_time";
$cur_date = SMWDataValueFactory::newTypeIDValue('_dat', $date_str);
$cur_date_jd = $cur_date->getNumericValue();
+ } elseif($unit == 'xofmonth') {
+ $check_month = $cur_date->getMonth();
+ $cur_date_jd += 28 * $period;
+ $cur_date = SMWDataValueFactory::newTypeIDValue('_dat', $cur_date_jd);
+ if ($cur_date->getMonth() != (($check_month + $period) % 12 )){
+ $cur_date_jd += 7; // add another week
+ $cur_date = SMWDataValueFactory::newTypeIDValue('_dat', $cur_date_jd);
+ }
} else { // $unit == 'day' or 'week'
// assume 'day' if it's none of the above
$cur_date_jd += ($unit === 'week') ? 7 * $period : $period;


Either there is no way to not have to calculate $cur_date twice, or I'm just too tired to find it.
Here's the actual data: Setting [0] and Browsing [1]

The other possibility would be to look up what day of the week [date(N)] and in what quarter of the
month the $cur_day is [$cur_day ceil($cur_day / 7)] is and then ask php for every "xth $dayOfWeek"
in the subsequent "$cur_month += $period".

But that seems more complicated than method one.

cheers,
D.

[0] https://www.hackerspace.lu/w/index.php?title=Sandbox&action=edit&section=1
[1] https://www.hackerspace.lu/wiki/Special:Browse?title=Special%3ABrowse&article=Sandbox

- --
HaxoGreen 2010 - the Hackers' Summercamp in Luxembourg
July 22nd till July 25th 2010, in Dudelange, Luxembourg
Register Now: http://events.hackerspace.lu/camp/2010/
- ----
mailto:david@hackerspace.lu
xmpp:kwisatz@jabber.hackerspaces.org
mobile: +43 650 73 63 834 | +352 691 44 23 24
++++++++++++++++++++++++++++++++++++++++++++
Wear your geek: http://syn2cat.spreadshirt.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkuPIEMACgkQYTtdUdP5zDeBEwCgtwu69suVdVTqtsS4AqtNhiTZ
c/oAn1ZSNypHIHZVJh9xk2hETiL6SOHE
=/C/s
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel



--
WikiWorks MediaWiki Consulting http://wikiworks.com