Skip to content

Conversation

@ndossche
Copy link
Member

There are two issues:

  1. The 'e' formatter doesn't output the seconds of the timezone even if it has seconds.
  2. var_dump(), (array) cast, serialization, ... don't include the timezone second offset in the output. This means that, for example, serializing and then unserializing a date object loses the seconds of the timezone. This can be observed by comparing the output of getTimezone() for $dt vs the unserialized object in the provided test.

There are two issues:
1. The 'e' formatter doesn't output the seconds of the timezone even if
   it has seconds.
2. var_dump(), (array) cast, serialization, ... don't include the
   timezone second offset in the output. This means that, for example,
   serializing and then unserializing a date object loses the seconds of
   the timezone. This can be observed by comparing the output of
   getTimezone() for `$dt` vs the unserialized object in the provided test.
Comment on lines +800 to +815
case TIMELIB_ZONETYPE_OFFSET: {
int seconds = offset->offset % 60;
if (seconds == 0) {
length = slprintf(buffer, sizeof(buffer), "%c%02d:%02d",
((offset->offset < 0) ? '-' : '+'),
abs(offset->offset / 3600),
abs((offset->offset % 3600) / 60)
);
} else {
length = slprintf(buffer, sizeof(buffer), "%c%02d:%02d:%02d",
((offset->offset < 0) ? '-' : '+'),
abs(offset->offset / 3600),
abs((offset->offset % 3600) / 60),
abs(seconds)
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these lines mix tabs and spaces

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this was already the case to align the switch case. It's a bit annoying to work with.

@ndossche ndossche marked this pull request as ready for review December 23, 2025 09:59
@ndossche ndossche requested a review from derickr as a code owner December 23, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants