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 

ps2 system time

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



Joined: 11 Dec 2005
Posts: 121

PostPosted: Sun May 06, 2007 9:00 am    Post subject: ps2 system time Reply with quote

There seems to be an error with the Hours returned from cdReadClock, my ps2 system clock was around 23:37 when i ran this but cdReadClock returned that my hours was 08 yet everything else was correct. I also got a friend to run this and his time was 18:?? and his returned 20:?? can someone tell me what the problem is?
Back to top
View user's profile Send private message
Polo35



Joined: 09 Apr 2006
Posts: 25

PostPosted: Sun May 06, 2007 4:54 pm    Post subject: Reply with quote

Time return by cdreadclock is time in Japan GTM+9.

Take a look in myps2 1.2 source code, there is a libps2time which deal with ps2 clock.

Best regards

Polo
Back to top
View user's profile Send private message
JorDy



Joined: 11 Dec 2005
Posts: 121

PostPosted: Sun May 06, 2007 8:30 pm    Post subject: Reply with quote

thanks a lot! i thought there was something strange with the time difference!

*edit* im now getting a funny date, its the 6th of may and its telling me its the 29th
Back to top
View user's profile Send private message
Polo35



Joined: 09 Apr 2006
Posts: 25

PostPosted: Wed May 09, 2007 3:31 am    Post subject: Reply with quote

Hey.

Here a simple code i wrote some time ago:

Code:
#define BCD2DEC(bcd)      (((((bcd)>>4) & 0x0F) * 10) + ((bcd) & 0x0F))
#define IS_LEAP_YEAR(Y)  ( ((Y)>0) && !((Y)%4) && ( ((Y)%100) || !((Y)%400) ) )

static char CurClock[ 256 ];

void GetClock ( void ) {

   CdvdClock_t clock;
   int            nMinute;
   int            nHour;
   int            nDay;
   int            nMonth;
   int            nYear;
   s32            nGMTOffset;

   int            nMonthsDays[] =
          {   31, 28, 31,   30,   31,   30,   31,   31,   30,   31,   30,   31   };

   cdReadClock( &clock );
   s32 TimeZone = configGetTimezone();
   int DayLightSaving = configIsDaylightSavingEnabled();


   nGMTOffset = TimeZone / 60;
   nMinute       = BCD2DEC(clock.minute);
   nHour         = BCD2DEC(clock.hour);      // Hour in Japan (GMT + 9)
   nDay         = BCD2DEC(clock.day);
   nMonth      = BCD2DEC(clock.month);
   nYear         = BCD2DEC(clock.year);
   nYear         = nYear + 2000;
   nMonth       = nMonth;
   nDay         = nDay;
   nHour         = nHour - 9 + nGMTOffset + DayLightSaving;

   if( nHour < 0 ) {
      nHour += 24;
      if( --nDay == 0 ) {
         if( --nMonth == 0 ) {
            nMonth = 11;
            nYear--;
         } /* end if */
         nDay = nMonthsDays[nMonth];
         if( nMonth == 2 && IS_LEAP_YEAR(nYear) )
            nDay++;
      } /* end if */
   } /* end if */

   snprintf( CurClock, sizeof( CurClock ), "%02i/%02i/%i  %02i:%02i", nDay, nMonth, nYear, nHour, nMinute );

} /* end GetClock */


Best regards

Polo
Back to top
View user's profile Send private message
JorDy



Joined: 11 Dec 2005
Posts: 121

PostPosted: Wed May 09, 2007 4:32 am    Post subject: Reply with quote

absolutely perfect!! thank you so much
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 -> PS2 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