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<>T
|
|||
|
//#define LSTIME_SECONDS_PER_DAY 180
|
|||
|
//#else
|
|||
|
//(750X12)<29><>????<3F>S??1<>T
|
|||
|
#define LSTIME_SECONDS_PER_DAY 5400 /* LSTIME?<3F>T????<3F><>?<3F><>? */
|
|||
|
//#endif
|
|||
|
/*
|
|||
|
LSTIME_SECONDS_PER_DAY ?<EFBFBD><EFBFBD>???????<EFBFBD><EFBFBD>????<EFBFBD><EFBFBD>?????????
|
|||
|
|
|||
|
<EFBFBD>k LS????<EFBFBD>T?????<EFBFBD><EFBFBD>????
|
|||
|
9000 (<EFBFBD><EFBFBD>?) 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>T???LSTIME???? */
|
|||
|
#define LSTIME_DAYS_PER_YEAR 100 /* LSTIME?<3F>g???LSTIME?<3F>T? */
|
|||
|
|
|||
|
|
|||
|
// ?????????
|
|||
|
LSTIME SaTime;
|
|||
|
long serverTime;
|
|||
|
long FirstTime;
|
|||
|
int SaTimeZoneNo; // ?????<3F>q
|
|||
|
BOOL TimeZonePalChangeFlag; // ??<3F>q??????????????
|
|||
|
#if 0
|
|||
|
/*------------------------------------------------------------
|
|||
|
* ???????????????<EFBFBD><EFBFBD>???
|
|||
|
* ??
|
|||
|
* ??
|
|||
|
* <EFBFBD><EFBFBD>?<EFBFBD>k
|
|||
|
* <EFBFBD><EFBFBD>? TRUE(1)
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> FALSE(0)
|
|||
|
------------------------------------------------------------*/
|
|||
|
BOOL setNewTime( void )
|
|||
|
{
|
|||
|
if( gettimeofday( &NowTime, (struct timezone*)NULL) != 0 )
|
|||
|
return FALSE;
|
|||
|
NowTime.tv_sec += DEBUG_ADJUSTTIME;
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
/*******************************************************************
|
|||
|
??<EFBFBD>T????byHiO 1998/12/4 18:37
|
|||
|
*******************************************************************/
|
|||
|
static long era = (long)912766409 + 5400;
|
|||
|
/* SA??????? */
|
|||
|
/* LS?<3F>g?<3F>e?????????<3F>k?
|
|||
|
???????<EFBFBD>i?????????*/
|
|||
|
|
|||
|
/*******************************************************************
|
|||
|
???????LS?????
|
|||
|
long t : time?<EFBFBD><EFBFBD>?
|
|||
|
LSTIME *lstime : LSTIME?<EFBFBD>B<EFBFBD>l??????
|
|||
|
*******************************************************************/
|
|||
|
void RealTimeToSATime( LSTIME *lstime )
|
|||
|
{
|
|||
|
long lsseconds; /* LS?<3F>g???<3F><>? */
|
|||
|
long lsdays; /* LS?<3F>g???<3F>T? */
|
|||
|
|
|||
|
//cary ʮ<><CAAE>
|
|||
|
lsseconds = (TimeGetTime()-FirstTime)/1000 + serverTime - era;
|
|||
|
|
|||
|
/* ?<3F>g???<3F><>??1<>g???<3F><>??????<3F>g??? */
|
|||
|
lstime->year = (int)( lsseconds/(LSTIME_SECONDS_PER_DAY*LSTIME_DAYS_PER_YEAR) );
|
|||
|
|
|||
|
lsdays = lsseconds/LSTIME_SECONDS_PER_DAY;/* ???<3F>g???<3F>T???<3F><>?? */
|
|||
|
lstime->day = lsdays % LSTIME_DAYS_PER_YEAR;/* <20>g????<3F>T?????????<3F>T*/
|
|||
|
|
|||
|
|
|||
|
/*(750*12)<29><>?1<>T*/
|
|||
|
lstime->hour = (int)(lsseconds % LSTIME_SECONDS_PER_DAY )
|
|||
|
/* ???????<3F>T?<3F><>??????<3F><>????? */
|
|||
|
* LSTIME_HOURS_PER_DAY / LSTIME_SECONDS_PER_DAY;
|
|||
|
/* ?<3F>T????<3F><>????????<3F>T????????????????
|
|||
|
????????*/
|
|||
|
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
/*******************************************************************
|
|||
|
LS????????????
|
|||
|
LSTIME *lstime : LSTIME?<EFBFBD>B<EFBFBD>l??????
|
|||
|
long *t : <EFBFBD><EFBFBD>????????
|
|||
|
*******************************************************************/
|
|||
|
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????????<EFBFBD><EFBFBD>?<EFBFBD>x?
|
|||
|
??<EFBFBD>k int : ?0?<EFBFBD><EFBFBD>1??2??3
|
|||
|
LSTIME *lstime : LSTIME?<EFBFBD>B<EFBFBD>l??????
|
|||
|
*******************************************************************/
|
|||
|
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>q????????????? ***********************************/
|
|||
|
void TimeZoneProc( void )
|
|||
|
{
|
|||
|
int timeZoneNo;
|
|||
|
//??????????<3F><>?<3F>x?
|
|||
|
timeZoneNo = getLSTime ( &SaTime );
|
|||
|
// ??<3F>q?<3F><>????
|
|||
|
if( SaTimeZoneNo != timeZoneNo ){
|
|||
|
SaTimeZoneNo = timeZoneNo; // ??<3F>q?<3F><>
|
|||
|
// ??<3F>q????????????
|
|||
|
if( TimeZonePalChangeFlag == TRUE ){
|
|||
|
PaletteChange( SaTimeZoneNo, PAL_CHANGE_TIME );// ????????
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|