[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#136876: marked as done (strptime fails if there is a timezone in the format)



Your message dated Tue, 10 Apr 2007 23:04:38 +0200
with message-id <20070410210438.GA28243@.madism.org>
and subject line Bug#136876: strptime fails if there is a timezone in the format
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: libc6
Version: 2.2.5-3
Severity: normal

Hi,

here is a test program:

==================
#include <stdio.h>
#include <time.h>
#define _XOPEN_SOURCE

int main(int argc, char **argv)
{
  struct tm t;
  char *s;
  char converted[200];

  if (argc!=4)
	{
	  fprintf(stderr,"Example: %s 'Tue, 27 Nov 2001 06:58:27' '%%a, %%b %%d %%H:%%M:%%S' '%%Y%%m' -> '200111'\n",argv[0]);
	  return 1;
	}

  memset((void *) &t, '\0', sizeof(struct tm));

  s=strptime(argv[1],argv[2],&t);

  if (s == NULL) {
	fprintf(stderr,"Error: format mismatch\n");
	return 1;
  }

  if (strlen(s)) {
	fprintf(stderr,"Error: unconverted data remains: '%.400s'\n", s);
	return 1;
  }

  if (strftime(converted,200,argv[3],&t)==0)
	{
	  fprintf(stderr,"strftime failed\n");
	  return 1;
	}

  fprintf(stdout,"%s\n",converted);

  return 0;

}
==================

Without the timezone:

$ convert-time 'Fri Mar  1 09:12:46 2002' '%a %b %d %H:%M:%S %Y' '%H:%M:%S %Y'
09:12:46 2002


With the timezone:

$ convert-time 'Fri Mar  1 09:12:46 2002 +0000' '%a %b %d %H:%M:%S %Y %z' '%H:%M:%S %Y'
Error: format mismatch


It works the either way, strftime has it right:

$ convert-time 'Fri Mar  1 09:12:46 2002' '%a %b %d %H:%M:%S %Y' '%H:%M:%S %Y %z'
09:12:46 2002 +0000

It also fails with literal timezones and %Z

I didn't set it as important though it breaks python too which relies on
libc for time functions !

Enjoy
Alain


--- End Message ---
--- Begin Message ---
Version: 2.5

  Works with the current libc from experimental

On Tue, Mar 05, 2002 at 04:16:18AM +0100, Alain Tesio wrote:
> Package: libc6
> Version: 2.2.5-3
> Severity: normal
> 
> Hi,
> 
> here is a test program:
> 
> ==================
> #include <stdio.h>
> #include <time.h>
> #define _XOPEN_SOURCE
> 
> int main(int argc, char **argv)
> {
>   struct tm t;
>   char *s;
>   char converted[200];
> 
>   if (argc!=4)
> 	{
> 	  fprintf(stderr,"Example: %s 'Tue, 27 Nov 2001 06:58:27' '%%a, %%b %%d %%H:%%M:%%S' '%%Y%%m' -> '200111'\n",argv[0]);
> 	  return 1;
> 	}
> 
>   memset((void *) &t, '\0', sizeof(struct tm));
> 
>   s=strptime(argv[1],argv[2],&t);
> 
>   if (s == NULL) {
> 	fprintf(stderr,"Error: format mismatch\n");
> 	return 1;
>   }
> 
>   if (strlen(s)) {
> 	fprintf(stderr,"Error: unconverted data remains: '%.400s'\n", s);
> 	return 1;
>   }
> 
>   if (strftime(converted,200,argv[3],&t)==0)
> 	{
> 	  fprintf(stderr,"strftime failed\n");
> 	  return 1;
> 	}
> 
>   fprintf(stdout,"%s\n",converted);
> 
>   return 0;
> 
> }
> ==================
> 
> Without the timezone:
> 
> $ convert-time 'Fri Mar  1 09:12:46 2002' '%a %b %d %H:%M:%S %Y' '%H:%M:%S %Y'
> 09:12:46 2002
> 
> 
> With the timezone:
> 
> $ convert-time 'Fri Mar  1 09:12:46 2002 +0000' '%a %b %d %H:%M:%S %Y %z' '%H:%M:%S %Y'
> Error: format mismatch
> 
> 
> It works the either way, strftime has it right:
> 
> $ convert-time 'Fri Mar  1 09:12:46 2002' '%a %b %d %H:%M:%S %Y' '%H:%M:%S %Y %z'
> 09:12:46 2002 +0000
> 
> It also fails with literal timezones and %Z
> 
> I didn't set it as important though it breaks python too which relies on
> libc for time functions !
> 
> Enjoy
> Alain
> 
> 

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

--- End Message ---

Reply to: