-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Howdy,
I'm trying to find a good way to implement this, it's a new system so any suggestion considered. I think this is a fairly common problem that I've never really come across a good solution to (except crontab?)? Hopefully some of the smarts around here can point me in the right direction. The system contains events, which will have a start date (eg. 2009-01-01) and an interval (eg. every 7 days). There are 2 issues I'm trying solve. 1. How would I persist this information? The start date is easy, it's just a date. The interval I'm not sure about. A number of seconds (or days if it's only accurate to date) could work for basic things like every week. But what about irregular things like every month, or even more complex values eg. "The first Sunday of the month"? 2. How do I find the "next" date after "today"? At the moment, I have limited the interval to be a number of days (very restrictive - see above), and this works: public function getNextDate(Zend_Date $today = null) { if (null === $today) { $today = Zend_Date::now(); } $next = clone $this->_inaugralDate; while ($next->isEarlier($today)) { $next->add($this->_interval, Zend_Date::DAY); } return $next; } But is there a "better" way, especially taking into account "complex" intervals? - -- Brenton Alker PHP Developer - Brisbane, Australia http://blog.tekerson.com/ http://twitter.com/tekerson -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkrfE80ACgkQ7bkAtAithuuzVQCg1asu82x3iSaqY+RJoUolTVh+ llIAoJQmcCpYAKx435Zy06ZO3rwwYleV =nCvW -----END PGP SIGNATURE-----