"Bertram" <> writes:
> I try format date with compiler Mingw con function strftime.
> time_t t;
> char buffer[100];
>
> The option tha I use is:
> strftime(buffer,sizeof(buffer),DayDate="%d.%B.%Y.% A Time%H:%M:%S
> WeekYear=%U %W" ,(localtime ((time (&t), &t))));
>
> printf ("BUFFER=%s\n", buffer);
>
> But the option: %U or %W don't work!
How exactly does it not work? What output did you expect, and what
output did you actually get?
It works for me with MinGW under Cygwin, and should work with
any conforming C compiler. Here's the test program I used; I've
modified it from your code so it's a bit less convoluted (e.g.,
no assignments or comma operators in parameter expressions):
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
time_t time_now = time(NULL);
struct tm *tm_now = localtime(&time_now);
char buffer[100];
size_t result = strftime(buffer,
sizeof buffer,
"%d.%B.%Y.%A Time%H:%M:%S WeekYear=%U %W",
tm_now);
if (result == 0) {
fprintf(stderr, "strftime() failed\n");
exit(EXIT_FAILURE);
}
printf ("BUFFER=\"%s\"\n", buffer);
return 0;
}
And here's the output:
BUFFER="02.January.2013.Wednesday Time09:12:29 WeekYear=00 00"
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"