Page 1 of 1

Qn on time() and gmtime()

Posted: Wed Jan 28, 2009 9:18 pm
by Pete
I'll start by saying I'm currently using no$gba 2.6 for my development and debugging so it's easily possible that this is the culprit but wanted to ask if there's might be any other reason why the following snippet of code always returns the same value no matter how long elapses between times it's called?

Code: Select all

int TimeInSeconds(void)
{
	time_t unixTime = time(NULL);
	struct tm* timeStruct = gmtime((const time_t *)&unixTime);
	int seconds = 0;

	seconds += timeStruct->tm_hour * 3600;
	seconds += timeStruct->tm_min * 60;
	seconds += timeStruct->tm_sec;

	return seconds;
}
If it's just gonna be a no$ issue, sorry for the dumb qn :oops:

Re: Qn on time() and gmtime()

Posted: Thu Jan 29, 2009 12:25 pm
by eKid
Test on hardware. :)

I think only the latest no$gba version has time support, but it doesn't seem to be available anymore... :/