forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PSP Clock Problem

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Twenty 2



Joined: 25 Jul 2005
Posts: 15

PostPosted: Sat Aug 06, 2005 1:26 pm    Post subject: PSP Clock Problem Reply with quote

I cant get this script to put the exact time and date it. The date keeps updating every sec and the times way off.Can anyone help?
Code:
 // Time - Displays the date and time
/*
          This program was created by Josh Valdez using a GNU C libarary
          example.
   
          Editted by Twenty 2 and Yeldarb
*/

#include <pspkernel.h>
#include <pspdebug.h>
#include <stdio.h>
#include <time.h>
 
PSP_MODULE_INFO("Hello World", 0, 1, 1);

#define printf pspDebugScreenPrintf
#define clrscr pspDebugScreenClear
#define SIZE 256
   
/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
        sceKernelExitGame();
        return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
    int cbid;

    cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
    sceKernelRegisterExitCallback(cbid);

    sceKernelSleepThreadCB();

    return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
    int thid = 0;

    thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
    if(thid >= 0) {
            sceKernelStartThread(thid, 0, 0);
    }

    return thid;
}

int main(void) {
    pspDebugScreenInit();
   SetupCallbacks();

   char buffer[SIZE];
   time_t curtime, oldtime;
   struct tm *loctime;
   
    while(1) {
        do {
            /* Get the current time. */
             curtime = time (NULL);
        } while(curtime == oldtime);
       
        oldtime = curtime;

   clrscr();

        /* Convert it to local time representation. */
        loctime = localtime (&curtime);

        /* Print out the date and time in the standard format. */
        printf (asctime (loctime), stdout);

        /* Print it out in a nice format. */
        strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime);
        printf (buffer, stdout);
        strftime (buffer, SIZE, "The time is %I:%M %p.\n", loctime);
        printf (buffer, stdout);
    }
       
    sceKernelSleepThread();
       
    return 0;       
Back to top
View user's profile Send private message
Warren



Joined: 24 Jan 2004
Posts: 173
Location: San Diego, CA

PostPosted: Sun Aug 07, 2005 2:42 am    Post subject: Reply with quote

Dunno, but try using the time functions in psprtc.h. I know they work correctly (I had a nice sample written for it but it got nuked in a SVN snafu)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group