Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Strftime Mingw don't work

Reply
Thread Tools

Re: Strftime Mingw don't work

 
 
Keith Thompson
Guest
Posts: n/a
 
      01-02-2013
"Bertram" <(E-Mail Removed)> 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) http://www.velocityreviews.com/forums/(E-Mail Removed) <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"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Strftime Mingw don't work Lew Pitcher C Programming 7 01-05-2013 06:01 PM
Windows GCC Support (Mingw & Mingw-w64) xeno fears Python 1 10-04-2009 06:40 PM
[g++ mingw eclipse] How do I setup Eclipse to use MinGw's g++ compiler? Sam Smith C++ 0 10-18-2004 11:36 AM
strftime not working as expected Bryan O'Malley C++ 8 02-17-2004 08:34 AM
gcc 3.3, solaris 8, compile error - 'strftime', 'localtime', etc. "not declared" Bimal C Programming 1 08-20-2003 12:33 PM



Advertisments