Comments (5)
Could you be a bit more specific, provide examples of the string before and after the DB and what error you get from the lib? I'm sorry but I don't understand your bug report at the moment.
from php-rrule.
Of course!
Let's assume I have an Rule String... let's use the one on the documentation:
DTSTART;TZID=America/New_York:19970901T090000 RRULE:FREQ=DAILY;UNTIL=19971224T000000Z;WKST=SU;BYDAY=MO,WE,FR;BYMONTH=1
Which I then proceed to store into my database, through code or even just copy paste, into a Wordpress or ProcessWire field; and why would I do that? Cause I want to store it, of course, they're pretty low weight for their power ;).
Let's also assume that I then try to retrieve it from the database and get [What appears to be] the same string:
$rrule_string = DTSTART;TZID=America/New_York:19970901T090000 RRULE:FREQ=DAILY;UNTIL=19971224T000000Z;WKST=SU;BYDAY=MO,WE,FR;BYMONTH=1
Which I decide to use to instantiate an RRule: new RRule($rrule_string)
.
After following these steps, i'll be greeted with an error saying: 'Failed to parse RFC string, invalid property parameters: "TZID=America/New_York:19970901T090000RRULE..."'
Which surprised me, because it looked like my string was right. But upon closer inspection I could see that it was trying to convert certain lines together, yet I wasn't sure of why
I already dragged this on for too long (sorry) so, after much research I was able to find this line of code on the parseRfcString function: foreach ( explode("\n", $string) as $line ) {
meaning that, even thought I believed my string to be properly formatted, it really wasn't.
The format was expecting new lines instead of spaces. Which may be me having not read enough of either documentation to notice that the proper format required them, but it looked like a space to me.
Anyway, the fix (for me) was really as simple as adding this line of code previous to the for each loop:
if(is_string($config)) { //If the string comes from the db it may have changed the newline to a space $config = str_replace(" ", "\n", $config); }
I'm sorry I wasn't able to properly explain myself before, and I really hope this helps! It's a wonderful library that I really love using, and I specially appreciate your effort in making it :)
from php-rrule.
Ok thanks, this is much more detailed now. It looks to me that the problem comes from the way you store and/or retrieve it. Does Wordpress or Processwire convert \n
to spaces maybe?
I won't change the parser, the RFC states that DTSTART and RRULE must be on 2 different lines. A space is not RFC-compliant.
from php-rrule.
Most CMS' do some weird mumbo jumbo when storing strings, I guess it's just the way that it is.
I won't change the parser, the RFC states that DTSTART and RRULE must be on 2 different lines. A space is not RFC-compliant.
Seems about fair, I know there's an official documentation, but I wouldn't mind adding the specifics of an RFC string, or a link to them in the README.MD
or wherever you feel would be appropriate. Just to help out anybody who runs into the same problem as me.
Other than that tho, thank you for your time and attention in hearing me out man, I guess this issue's closed ;)
from php-rrule.
Done, wiki has been updated.
from php-rrule.
Related Issues (20)
- Humanreadable gets monthly wrong HOT 4
- addExRule not working for me HOT 4
- Drop support for PHP < 7.3 HOT 2
- Daylight Savings Time issue with PHP 8.1 HOT 13
- How to create Rrule for every day from X to Y? HOT 4
- How to use exdate with byhour? HOT 3
- Question: Performance optimization when calculating occurrences using multiple rules HOT 3
- exRule and addRule conflict HOT 3
- More forgiving DTSTART behavior when using only date for UNTIL HOT 2
- Nested exrules HOT 2
- occursAt sometimes failing HOT 2
- Problem with getOccurrencesAfter HOT 9
- Removing all dates that are inside a DatePeriod from Rset HOT 1
- bi-weekly occurance wrong HOT 3
- dtstart vs. Repeat Dates / Current Time Not Considered in Calculation HOT 5
- humanreadable not so much HOT 2
- Looking for a way to add DTEND HOT 1
- Exrul not working
- Add alias methods for better reading of code HOT 1
- Legacy Code - Can I 'require_once' instead of composer ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-rrule.