From: Larry on
Hi,

is there any way to convert this to gmtime_s??

// getDateTime (Fri, 10 Oct 2008 14:41:59 GMT)
string getDateTime(void)
{
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = gmtime(&rawtime);
char buffer[30];
strftime(buffer,30,"%a, %d %b %Y %X GMT",timeinfo);
return static_cast<string>(buffer);
}

I cannot work out why VC++ is throwing so many warnings about that!

thanks
From: Preben Friis on
"Larry" <dontmewithme(a)got.it> wrote in message
news:4b5db35b$0$1120$4fafbaef(a)reader3.news.tin.it...

> is there any way to convert this to gmtime_s??

string getDateTime(void)
{
time_t rawtime;
struct tm timeinfo;
time(&rawtime);
gmtime_s(&timeinfo, &rawtime);
char buffer[30];
strftime(buffer, 30, "%a, %d %b %Y %X GMT", &timeinfo);
return static_cast<string>(buffer);
}

From: David Given on
On 25/01/10 15:41, Preben Friis wrote:
[...]
> return static_cast<string>(buffer);

I don't know what C++ library you're using, so I don't know whether
string is an object or not, but just to be on the safe side I should
point out that if it's typedef'd to a char* you will end up with a world
of fail here.

--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────

│ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ }
│ --- Conway's Game Of Life, in one line of APL
From: Preben Friis on
"David Given" <dg(a)cowlark.com> wrote in message
news:hjl3dm$qq$2(a)news.eternal-september.org...
> On 25/01/10 15:41, Preben Friis wrote:
> [...]
>> return static_cast<string>(buffer);
>
> I don't know what C++ library you're using, so I don't know whether
> string is an object or not, but just to be on the safe side I should
> point out that if it's typedef'd to a char* you will end up with a world
> of fail here.

I just left that part from the original snippet, since the question was
regarding gmtime_s ....

From: David Given on
On 25/01/10 23:19, Preben Friis wrote:
[...]
> I just left that part from the original snippet, since the question was
> regarding gmtime_s ....

Sorry, missnip on my part --- wasn't meaning to lecture you.

--
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────

│ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ }
│ --- Conway's Game Of Life, in one line of APL