Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Bug 54567 DateTimeZone serialize/unserialize #208

Closed
wants to merge 4 commits into
from

Conversation

Projects
None yet
6 participants
Contributor

lonnylot commented Sep 28, 2012

Make DateTimeZone serializable and implement __set_state

Contributor

smalyshev commented Oct 1, 2012

This code crashes for me:
php -r 'echo serialize(date_create("2012-10-21 12:30:00 PST")->getTimezone());'

The problem seems to be in this one:

case TIMELIB_ZONETYPE_ABBR:
            ZVAL_STRING(zv, tzobj->tzi.tz->timezone_abbr, 1);

tzobj->tzi.tz doesn't see to have anything useful here.
Please fix and add tests for different zone types, not only one.

Contributor

lonnylot commented Oct 25, 2012

So you're absolutely right on that. Thank you for catching my mistake. Over the past month I've gotten the ABBR timezone to work correctly.

I am still working on the OFFSET timezone. Currently we do not have a way to instantiate a DateTimeZone using an offset. I am playing around with creating a way to do this. If that doesn't turn out to be reasonable I think we'll have to do it w/o implementing the OFFSET timezone.

Contributor

lstrojny commented Nov 4, 2012

Will this work with microseconds?
Example

<?php
$date = DateTime::createFromFormat('U.u', microtime(true));
var_dump(unserialize(serialize($date))->format('U.u'));
Contributor

lstrojny commented Nov 4, 2012

Ping @derickr

Contributor

lonnylot commented Nov 4, 2012

@lstrojny I am not sure, but this pull request has to do specifically w/ DateTimeZone objects, not DateTime objects.

Contributor

derickr commented Nov 4, 2012

Looks good, but misses tests for type 1 and 2 timezone types.

Contributor

lstrojny commented Nov 4, 2012

@lonnylot my bad :)

Contributor

lstrojny commented Jan 6, 2013

@lonnylot could you please rebase?

Contributor

lstrojny commented Jan 14, 2013

@lonnylot ping

Lonny Kapelushnik added some commits Sep 28, 2012

Bug 54567 DateTimeZone serialize/unserialize
Make DateTimeZone serializable and implement __set_state
Made separate tests for each TZ type
Fixed handling of unserializing types 1 and 3
Rebased to PHP-5.4
Implemented Dmitrys change from df97c3a
Moved the timelib_parse_tz_cor function to ext/date/lib/timelib.c
Contributor

lonnylot commented Jan 14, 2013

@lstrojny Been a tad busy :)

I rebased and made a few other changes (all mentioned in the commit message). All tests passed.

Contributor

lonnylot commented Mar 30, 2013

Any chance of this making it into 5.5?

Contributor

derickr commented Mar 30, 2013

Good for reminding me, I'll merge this bug fix after the
DateTimeImmutable fix that I've been working on.

Contributor

derickr commented Mar 31, 2013

I've merged it after adding the .c parser files too, but for some odd reason I can't close this PR.

@dsp dsp closed this Mar 31, 2013

Contributor

lonnylot commented Apr 26, 2013

Can someone close the related bug: https://bugs.php.net/bug.php?id=54567

Owner

nikic commented Apr 26, 2013

@lonnylot Done (and for the other PR as well) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment