vytah•

doing a var dump changes the outcome

Wat.

I can't even.

I've lost my ability to can.

36
myaut•

doing a var dump changes the outcome

It's like Schrodinger cat - measurement is changing the outcome.

13
shitbangsOP•

I was thinking of the double slit experiment, but r/php seems to disagree

lol

7
cybercobra•

Have you tried odd?

2
andyana•

I spent five hours fucking around with dateinterval on Friday. I eventually gave up, and this explains it.

11
OneWingedShark•

Yeah, PHP sucks at date/time problems; yes, I know it has the "awesome" try-to-read-any-formatting... but that's a whole can of worms in itself.

In Ada, time can be pretty easy to handle:

Use all type Ada.Calendar.Time; -- Makes operators visible.

Function Is_In( Query, Start, Stop : Ada.Calendar.Time ) return Boolean is
  ( Start <= Query and Query <= Stop  );

Function  Is_In( Query, Start : Ada.Calendar.Time; Stop : Duration ) return Boolean is
  ( Is_In( Query => Query, Start => Start, Stop  => Start+Stop)  );
2
merreborn•

What the fuck.

...However, using > to compare two objects in a language without operator overloading seems like a bad idea.

At first I thought maybe the object was implicitly being cast to a string, and the strings compared, but trying to cast a dateinterval to a string results in Object of class DateInterval could not be converted to string. So it's not string comparison. What exactly happens when you use an inequality comparison operator on two objects in PHP?

This is interesting: http://3v4l.org/jLSDU

  1. HHVM doesn't replicate this bug
  2. In all cases, the objects start out equal
  3. In non-HHVM PHP, after the read-with-side-effects, the objects become inequal

Hm. I guess the object returned by createFromDateString is lazily evaluated in some way?

7
h3st•

Even if the object is lazy, you have to force it before you can compare it. Otherwise you're just comparing thunks, and that doesn't make any sense.

3
[deleted]•

to compare two objects in a language without operator overloading

PHP does have operator overloading for internal classes (i.e. those written in C). It's just not exposed to userland.

3