Code Monkey home page Code Monkey logo

Comments (5)

rlanvin avatar rlanvin commented on August 28, 2024

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.

orlando-paredes-hamsho avatar orlando-paredes-hamsho commented on August 28, 2024

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.

rlanvin avatar rlanvin commented on August 28, 2024

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.

orlando-paredes-hamsho avatar orlando-paredes-hamsho commented on August 28, 2024

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.

rlanvin avatar rlanvin commented on August 28, 2024

Done, wiki has been updated.

from php-rrule.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.