Opened 11 years ago

Closed 11 years ago

#2907 closed bug (invalid)

strftime() doesn't support F conversion specifier

Reported by: scottmc Owned by: axeld
Priority: normal Milestone: R1
Component: - General Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

Not sure if there are other missing options, but I kow at least %F isn't working as expected in Haiku See: http://linux.die.net/man/3/strftime

Change History (7)

comment:1 by scottmc, 11 years ago

Summary: strftime() doesn't support %F conversion specifierstrftime() doesn't support E, F, O and + conversion specifiers

I added a strftime for every one of the modifiers listed in that link above:

416			strftime(p, 100, "%a", tim);
			
418			strftime(p, 100, "%A", tim);
419			strftime(p, 100, "%b", tim);
420			strftime(p, 100, "%B", tim);
421			strftime(p, 100, "%c", tim);
422			strftime(p, 100, "%C", tim);
423			strftime(p, 100, "%d", tim);
424			strftime(p, 100, "%D", tim);
425			strftime(p, 100, "%e", tim);
426			strftime(p, 100, "%E", tim);
427			strftime(p, 100, "%F", tim);
428			strftime(p, 100, "%G", tim);
429			strftime(p, 100, "%g", tim);
430			strftime(p, 100, "%h", tim);
431			strftime(p, 100, "%H", tim);
432			strftime(p, 100, "%I", tim);
433			strftime(p, 100, "%j", tim);
434			strftime(p, 100, "%k", tim);
435			strftime(p, 100, "%l", tim);
436			strftime(p, 100, "%m", tim);
437			strftime(p, 100, "%M", tim);
438			strftime(p, 100, "%n", tim);
439			strftime(p, 100, "%O", tim);
440			strftime(p, 100, "%p", tim);
441			strftime(p, 100, "%P", tim);
442			strftime(p, 100, "%r", tim);
443			strftime(p, 100, "%R", tim);
444			strftime(p, 100, "%s", tim);
445			strftime(p, 100, "%S", tim);
446			strftime(p, 100, "%t", tim);
447			strftime(p, 100, "%T", tim);
448			strftime(p, 100, "%u", tim);
449			strftime(p, 100, "%U", tim);
450			strftime(p, 100, "%V", tim);
451			strftime(p, 100, "%w", tim);
452			strftime(p, 100, "%W", tim);
453			strftime(p, 100, "%x", tim);
454			strftime(p, 100, "%X", tim);
455			strftime(p, 100, "%y", tim);
456			strftime(p, 100, "%Y", tim);
457			strftime(p, 100, "%z", tim);
458			strftime(p, 100, "%Z", tim);
459			strftime(p, 100, "%+", tim);
460			strftime(p, 100, "%%", tim);

Build Results:

/boot/home/develop/pe/Extensions/HeaderHeader.cpp:421: warning: `%c' yields only last 2 digits of year in some locales
/boot/home/develop/pe/Extensions/HeaderHeader.cpp:424: warning: `%D' yields only last 2 digits of year
/boot/home/develop/pe/Extensions/HeaderHeader.cpp:426: warning: conversion lacks type at end of format
/boot/home/develop/pe/Extensions/HeaderHeader.cpp:427: warning: unknown conversion type character `F' in format
/boot/home/develop/pe/Extensions/HeaderHeader.cpp:429: warning: `%g' yields only last 2 digits of year
/boot/home/develop/pe/Extensions/HeaderHeader.cpp:439: warning: conversion lacks type at end of format
/boot/home/develop/pe/Extensions/HeaderHeader.cpp:453: warning: `%x' yields only last 2 digits of year in some locales
/boot/home/develop/pe/Extensions/HeaderHeader.cpp:455: warning: `%y' yields only last 2 digits of year
/boot/home/develop/pe/Extensions/HeaderHeader.cpp:459: warning: unknown conversion type character `+' in format

comment:2 by axeld, 11 years ago

Linux man pages are not a good source for these things, as they often have POSIX incompatible features that we might not always copy.

http://www.opengroup.org/onlinepubs/009695399/functions/strftime.html is a better source of information, but it mentions %F as well :-)

The build warnings are probably due to our old GCC version. '%+' doesn't seem to be in the standard, and you also seem to have used '%O' and '%E' incorrectly, as they are just modifiers and need another specifier.

comment:3 by scottmc, 11 years ago

Summary: strftime() doesn't support E, F, O and + conversion specifiersstrftime() doesn't support F conversion specifier

Thanks for the link. I bought a used POSIX book c1991: http://www.amazon.com/POSIX-Programmers-Guide-Donald-Lewine/dp/0937175730/ref=sr_1_9?ie=UTF8&s=books&qid=1224749293&sr=8-9 Handy to have in paper form, but doesn't include newer things. It is interesting to note that %F was added to POSIX later on. Changing summary backto just F.

comment:4 by bonefish, 11 years ago

%F works fine for me:

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

int
main()
{
	char buffer[256];
	time_t t = time(NULL);
	strftime(buffer, sizeof(buffer), "date is: %F", localtime(&t));
	puts(buffer);
	return 0;
}

Output:

date is: 2008-10-23

Please provide a test case that doesn't work.

comment:5 by scottmc, 11 years ago

svn checkout svn://svn.berlios.de/pe-editor/trunk jam You'll get a warning in HeaderHeader.cpp, but it still builds, if you try to use HeaderHeader in the resulting pe it will crash.

in reply to:  5 comment:6 by scottmc, 11 years ago

> svn checkout svn://svn.berlios.de/pe-editor/trunk pe
> jam

You'll get a warning in HeaderHeader.cpp, but it still builds, if you try to use HeaderHeader in the resulting pe it will crash.

If you need pcre, there is a prebuilt image on haikuports, unzip it to /boot and it will be good to go.

comment:7 by bonefish, 11 years ago

Resolution: invalid
Status: newclosed

At least here Pe doesn't crash when invoked from inside the root directory (i.e. ./generated/distro/pe). It does, however, crash when invoked from another directory (e.g. cd generated/distro; ./pe). The crash happens in strrchr(), which has been passed a NULL pointer by PScriptCmd::Do(). Apparently it failed to get the path.

At any rate this has nothing to do with strftime().

Note: See TracTickets for help on using tickets.