146 lines
4.0 KiB
C++
146 lines
4.0 KiB
C++
#define __HANDLETIME_C__
|
||
#include "../systeminc/version.h"
|
||
#include "../systeminc/system.h"
|
||
#include <time.h>
|
||
#include "../systeminc/handletime.h"
|
||
|
||
//#ifdef _STONDEBUG_
|
||
//(180)<29>??<3F>??1<>
|
||
//#define LSTIME_SECONDS_PER_DAY 180
|
||
//#else
|
||
//(750X12)<29>????<3F>??1<>
|
||
#define LSTIME_SECONDS_PER_DAY 5400 /* LSTIME?<3F>????<3F>?<3F>? */
|
||
//#endif
|
||
/*
|
||
LSTIME_SECONDS_PER_DAY ?<3F>???????<3F>????<3F>?????????
|
||
|
||
<20> LS????<3F>?????<3F>????
|
||
9000 (<28>?) 2.5 [hour]
|
||
900 0.25[hour] = 15[min]
|
||
90 0.025[hour] = 1.5[min] = 90[sec]
|
||
9 9[sec]
|
||
|
||
*/
|
||
|
||
#define LSTIME_HOURS_PER_DAY 1024 /* LSTIME?<3F>???LSTIME???? */
|
||
#define LSTIME_DAYS_PER_YEAR 100 /* LSTIME?<3F>???LSTIME?<3F>? */
|
||
|
||
|
||
// ?????????
|
||
LSTIME SaTime;
|
||
long serverTime;
|
||
long FirstTime;
|
||
int SaTimeZoneNo; // ?????<3F>
|
||
BOOL TimeZonePalChangeFlag; // ??<3F>??????????????
|
||
#if 0
|
||
/*------------------------------------------------------------
|
||
* ???????????????<3F>???
|
||
* ??
|
||
* ??
|
||
* <20>?<3F>
|
||
* <20>? TRUE(1)
|
||
* <20><> FALSE(0)
|
||
------------------------------------------------------------*/
|
||
BOOL setNewTime( void )
|
||
{
|
||
if( gettimeofday( &NowTime, (struct timezone*)NULL) != 0 )
|
||
return FALSE;
|
||
NowTime.tv_sec += DEBUG_ADJUSTTIME;
|
||
return TRUE;
|
||
}
|
||
#endif
|
||
|
||
/*******************************************************************
|
||
??<3F>????byHiO 1998/12/4 18:37
|
||
*******************************************************************/
|
||
static long era = (long)912766409 + 5400;
|
||
/* SA??????? */
|
||
/* LS?<3F>?<3F>?????????<3F>?
|
||
???????<3F>?????????*/
|
||
|
||
/*******************************************************************
|
||
???????LS?????
|
||
long t : time?<3F>?
|
||
LSTIME *lstime : LSTIME?<3F><>??????
|
||
*******************************************************************/
|
||
void RealTimeToSATime( LSTIME *lstime )
|
||
{
|
||
long lsseconds; /* LS?<3F>???<3F>? */
|
||
long lsdays; /* LS?<3F>???<3F>? */
|
||
|
||
//cary 十五
|
||
lsseconds = (TimeGetTime()-FirstTime)/1000 + serverTime - era;
|
||
|
||
/* ?<3F>???<3F>??1<>???<3F>??????<3F>??? */
|
||
lstime->year = (int)( lsseconds/(LSTIME_SECONDS_PER_DAY*LSTIME_DAYS_PER_YEAR) );
|
||
|
||
lsdays = lsseconds/LSTIME_SECONDS_PER_DAY;/* ???<3F>???<3F>???<3F>?? */
|
||
lstime->day = lsdays % LSTIME_DAYS_PER_YEAR;/* <20>????<3F>?????????<3F>*/
|
||
|
||
|
||
/*(750*12)<29>?1<>*/
|
||
lstime->hour = (int)(lsseconds % LSTIME_SECONDS_PER_DAY )
|
||
/* ???????<3F>?<3F>??????<3F>????? */
|
||
* LSTIME_HOURS_PER_DAY / LSTIME_SECONDS_PER_DAY;
|
||
/* ?<3F>????<3F>????????<3F>????????????????
|
||
????????*/
|
||
|
||
return;
|
||
}
|
||
|
||
/*******************************************************************
|
||
LS????????????
|
||
LSTIME *lstime : LSTIME?<3F><>??????
|
||
long *t : <20>????????
|
||
*******************************************************************/
|
||
void LSTimeToRealTime( LSTIME *lstime, long *t)
|
||
{
|
||
*t=(long)(
|
||
( lstime->hour*LSTIME_DAYS_PER_YEAR+lstime->day) /* ?? */
|
||
*LSTIME_HOURS_PER_DAY
|
||
|
||
+ lstime->year)
|
||
/*??????????????????nakamura */
|
||
|
||
|
||
*450;
|
||
return;
|
||
}
|
||
|
||
/*******************************************************************
|
||
LS????????<3F>?<3F>?
|
||
??<3F> int : ?0?<3F>1??2??3
|
||
LSTIME *lstime : LSTIME?<3F><>??????
|
||
*******************************************************************/
|
||
LSTIME_SECTION getLSTime (LSTIME *lstime)
|
||
{
|
||
if (NIGHT_TO_MORNING < lstime->hour
|
||
&& lstime->hour <= MORNING_TO_NOON)
|
||
return LS_MORNING;
|
||
else if(NOON_TO_EVENING < lstime->hour
|
||
&& lstime->hour <= EVENING_TO_NIGHT)
|
||
return LS_EVENING;
|
||
else if(EVENING_TO_NIGHT < lstime->hour
|
||
&& lstime->hour <= NIGHT_TO_MORNING)
|
||
return LS_NIGHT;
|
||
else
|
||
return LS_NOON;
|
||
}
|
||
|
||
// ??<3F>????????????? ***********************************/
|
||
void TimeZoneProc( void )
|
||
{
|
||
int timeZoneNo;
|
||
//??????????<3F>?<3F>?
|
||
timeZoneNo = getLSTime ( &SaTime );
|
||
// ??<3F>?<3F>????
|
||
if( SaTimeZoneNo != timeZoneNo ){
|
||
SaTimeZoneNo = timeZoneNo; // ??<3F>?<3F>
|
||
// ??<3F>????????????
|
||
if( TimeZonePalChangeFlag == TRUE ){
|
||
PaletteChange( SaTimeZoneNo, PAL_CHANGE_TIME );// ????????
|
||
}
|
||
}
|
||
}
|
||
|