ps2 system time
ps2 system time
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?
			
			
									
									
						Hey.
Here a simple code i wrote some time ago:
Best regards
Polo
			
			
									
									
						Here a simple code i wrote some time ago:
Code: Select all
#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 */
Polo