Bug 154804 - strptime '%z' format doesn't work.
strptime '%z' format doesn't work.
Product: Fedora
Classification: Fedora
Component: glibc (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2005-04-14 06:53 EDT by David Woodhouse
Modified: 2007-11-30 17:11 EST (History)
2 users (show)

See Also:
Fixed In Version: 2.3.5-3
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-04-28 08:34:56 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description David Woodhouse 2005-04-14 06:53:48 EDT
The '%z' format character isn't functional. Try the following:

#define _BSD_SOURCE
#include <time.h>
#include <stdio.h>

int main(void)
	struct tm tm;

	strptime("1113472456 +1000", "%s %z", &tm);

	if (tm.tm_gmtoff == 36000) {
		return 0;
	} else {
		printf("Error: tm_gmtoff is %ld\n", tm.tm_gmtoff);
		return 1;

The man page states that "In most cases the corresponding fields are parsed, but
no field in tm is changed.". I assume that in the case of at least %F and %z,
the field in tm _should_ be changed.
Comment 1 Jakub Jelinek 2005-04-15 14:52:11 EDT
%z has never been implemented, so I'd say this is mainly a documentation
bug that documents a GNU extension that never existed.
You can see that strptime returns NULL, i.e. an error.
Unlike %z, %Z does not cause a failure, but is simply ignored.
%z perhaps could be implemented, but %Z would be much harder.
Comment 2 Ulrich Drepper 2005-04-27 00:33:01 EDT
I fixed this in upstream glibc.
Comment 3 Jakub Jelinek 2005-04-28 08:34:56 EDT
%z has been implemented in CVS glibc, should appear in glibc-2.3.5-3 and above.

Note You need to log in before you can comment on or make changes to this bug.