开发者

Recurring Calendar Events that don't expire

I'm looking for a library in PHP (or better yet in ruby) to handle an events calendar. I've looked a dozens of them and every one breaks down when it comes to recurring events. Many require and end date and most crea开发者_C百科te every recurring event as a entry in a database or something.

Every suggestion I get is to use the Google calendar which does do exactly what I want but I'm sure they won't let me build a service on top of there service.


Sounds like you may not want to roll your own, but what about just setting up a cron job to check every x minutes if there are any events that have to be sent out?


Haven't used Runt myself, but it looks like it might do what you want.

According to their homepage:

Runt is an implementation of select temporal patterns by Martin Fowler in the super-fantastic Ruby language. Runt provides:

  • ability to define recurring events using simple, set-like expressions
  • an interfaced-based API for creating schedules for arbitrary events/objects
  • precisioned date types using Time Points
  • date Ranges
  • everlasting peace and/or eternal life


RiCal's recurrence rules would work for this. They do the math, the implementation would be up to you.

require 'rubygems'
require 'ri_cal'
rule = RiCal::PropertyValue::RecurrenceRule::RecurringMonthDay.new(15)
p rule.include?(Date.new(2025, 7, 15)) # true


One good thing to know about recurring events is that our calendar cycles every 28 years. i.e. today is thursday 3 december 2010, so I know that in excaclty 28 years(10226 days) we will be thursday 3 december 2038. With this knowledge you can build an occurencies table on a limited period of time and just "move" it to your targeted time range...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜