Skip to content

Bug 54567 DateTimeZone serialize/unserialize - #208

Closed
lonnylot wants to merge 4 commits into
php:PHP-5.4from
lonnylot:issue-54567
Closed

lonnylot wants to merge 4 commits into
php:PHP-5.4from
lonnylot:issue-54567

Conversation

@lonnylot

Copy link
Copy Markdown

Make DateTimeZone serializable and implement __set_state

@smalyshev

Copy link
Copy Markdown
Contributor

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.

@lonnylot

Copy link
Copy Markdown
Author

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.

@lstrojny

lstrojny commented Nov 4, 2012

Copy link
Copy Markdown
Contributor

Will this work with microseconds?
Example

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

@lstrojny

lstrojny commented Nov 4, 2012

Copy link
Copy Markdown
Contributor

Ping @derickr

@lonnylot

lonnylot commented Nov 4, 2012

Copy link
Copy Markdown
Author

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

@derickr

derickr commented Nov 4, 2012

Copy link
Copy Markdown
Member

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

@lstrojny

lstrojny commented Nov 4, 2012

Copy link
Copy Markdown
Contributor

@lonnylot my bad :)

@lstrojny

lstrojny commented Jan 6, 2013

Copy link
Copy Markdown
Contributor

@lonnylot could you please rebase?

@lstrojny

Copy link
Copy Markdown
Contributor

@lonnylot ping

Lonny Kapelushnik added 4 commits January 14, 2013 21:26
Make DateTimeZone serializable and implement __set_state
Fixed handling of unserializing types 1 and 3
Implemented Dmitrys change from df97c3a
Moved the timelib_parse_tz_cor function to ext/date/lib/timelib.c
@lonnylot

Copy link
Copy Markdown
Author

@lstrojny Been a tad busy :)

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

@lonnylot

Copy link
Copy Markdown
Author

Any chance of this making it into 5.5?

@derickr

derickr commented Mar 30, 2013

Copy link
Copy Markdown
Member

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

@derickr

derickr commented Mar 31, 2013

Copy link
Copy Markdown
Member

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
@lonnylot

Copy link
Copy Markdown
Author

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

@nikic

nikic commented Apr 26, 2013

Copy link
Copy Markdown
Member

@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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants