Parse RRULE to readable text?

时光总嘲笑我的痴心妄想 提交于 2019-12-24 04:20:22

问题


I am looking for a library (php) or some pseudocode to parse Ical RRULEs to readable text(like for example google calendar)

RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=1FR,3FR,5FR

-> Monthly on Friday of weeks 1, 3, 5 of the month

回答1:


I was wondering the same thing and I struggled to find one, but I found one which is still in development, and you can find it here: https://github.com/simshaun/recurr/tree/v0.2-dev

I was able to get it working with this code:

$timezone        = 'America/New_York';
$startDate       = new \DateTime('2013-06-12 20:00:00', new \DateTimeZone($timezone));
$rule            = new \Recurr\Rule('FREQ=MONTHLY;COUNT=5', $startDate, $timezone);
$textTransformer = new  \Recurr\Transformer\TextTransformer();
echo $textTransformer->transform($rule);

I believe it's not perfect yet and I guess it's still changing while in dev, but looks very promising.



来源:https://stackoverflow.com/questions/21646111/parse-rrule-to-readable-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!