| View previous topic :: View next topic |
| Author |
Message |
JorDy
Joined: 11 Dec 2005 Posts: 121
|
Posted: Sun May 06, 2007 9:00 am Post subject: 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? |
|
| Back to top |
|
 |
Polo35
Joined: 09 Apr 2006 Posts: 25
|
Posted: Sun May 06, 2007 4:54 pm Post subject: |
|
|
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 |
|
 |
JorDy
Joined: 11 Dec 2005 Posts: 121
|
Posted: Sun May 06, 2007 8:30 pm Post subject: |
|
|
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 |
|
 |
Polo35
Joined: 09 Apr 2006 Posts: 25
|
Posted: Wed May 09, 2007 3:31 am Post subject: |
|
|
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 |
|
 |
JorDy
Joined: 11 Dec 2005 Posts: 121
|
Posted: Wed May 09, 2007 4:32 am Post subject: |
|
|
| absolutely perfect!! thank you so much |
|
| Back to top |
|
 |
|