2020-06-23 15:53:23 +08:00
|
|
|
|
#define __HANDLETIME_C__
|
2020-06-23 15:27:59 +08:00
|
|
|
|
#include "../systeminc/version.h"
|
|
|
|
|
#include "../systeminc/system.h"
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include "../systeminc/handletime.h"
|
|
|
|
|
|
|
|
|
|
//#ifdef _STONDEBUG_
|
2020-06-23 15:53:23 +08:00
|
|
|
|
//(180)企??希??1吋
|
2020-06-23 15:27:59 +08:00
|
|
|
|
//#define LSTIME_SECONDS_PER_DAY 180
|
|
|
|
|
//#else
|
2020-06-23 15:53:23 +08:00
|
|
|
|
//(750X12)企????刨??1吋
|
|
|
|
|
#define LSTIME_SECONDS_PER_DAY 5400 /* LSTIME?吋?????企? */
|
2020-06-23 15:27:59 +08:00
|
|
|
|
//#endif
|
|
|
|
|
/*
|
2020-06-23 15:53:23 +08:00
|
|
|
|
LSTIME_SECONDS_PER_DAY ?阪???????????阪?????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
π LS????吋?????????
|
|
|
|
|
9000 (火?) 2.5 [hour]
|
2020-06-23 15:27:59 +08:00
|
|
|
|
900 0.25[hour] = 15[min]
|
|
|
|
|
90 0.025[hour] = 1.5[min] = 90[sec]
|
|
|
|
|
9 9[sec]
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
#define LSTIME_HOURS_PER_DAY 1024 /* LSTIME?吋???LSTIME???? */
|
|
|
|
|
#define LSTIME_DAYS_PER_YEAR 100 /* LSTIME?夙???LSTIME?吋? */
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ?????????
|
|
|
|
|
LSTIME SaTime;
|
|
|
|
|
long serverTime;
|
|
|
|
|
long FirstTime;
|
2020-06-23 15:53:23 +08:00
|
|
|
|
int SaTimeZoneNo; // ?????┼
|
|
|
|
|
BOOL TimeZonePalChangeFlag; // ??┼??????????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
#if 0
|
|
|
|
|
/*------------------------------------------------------------
|
2020-06-23 15:53:23 +08:00
|
|
|
|
* ??????????????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
* ??
|
|
|
|
|
* ??
|
2020-06-23 15:53:23 +08:00
|
|
|
|
* 刺?π
|
|
|
|
|
* ? TRUE(1)
|
|
|
|
|
* ? FALSE(0)
|
2020-06-23 15:27:59 +08:00
|
|
|
|
------------------------------------------------------------*/
|
|
|
|
|
BOOL setNewTime( void )
|
|
|
|
|
{
|
|
|
|
|
if( gettimeofday( &NowTime, (struct timezone*)NULL) != 0 )
|
|
|
|
|
return FALSE;
|
|
|
|
|
NowTime.tv_sec += DEBUG_ADJUSTTIME;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2020-06-23 15:53:23 +08:00
|
|
|
|
??Ρ????byHiO 1998/12/4 18:37
|
2020-06-23 15:27:59 +08:00
|
|
|
|
*******************************************************************/
|
|
|
|
|
static long era = (long)912766409 + 5400;
|
|
|
|
|
/* SA??????? */
|
2020-06-23 15:53:23 +08:00
|
|
|
|
/* LS?夙?叉?????????π?
|
|
|
|
|
???????可?????????*/
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
|
???????LS?????
|
2020-06-23 15:53:23 +08:00
|
|
|
|
long t : time??
|
|
|
|
|
LSTIME *lstime : LSTIME?﹨▍??????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
*******************************************************************/
|
|
|
|
|
void RealTimeToSATime( LSTIME *lstime )
|
|
|
|
|
{
|
2020-06-23 15:53:23 +08:00
|
|
|
|
long lsseconds; /* LS?夙???企? */
|
|
|
|
|
long lsdays; /* LS?夙???吋? */
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
//cary 坋拻
|
2020-06-23 15:27:59 +08:00
|
|
|
|
lsseconds = (TimeGetTime()-FirstTime)/1000 + serverTime - era;
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
/* ?夙???企??1夙???企??????夙??? */
|
2020-06-23 15:27:59 +08:00
|
|
|
|
lstime->year = (int)( lsseconds/(LSTIME_SECONDS_PER_DAY*LSTIME_DAYS_PER_YEAR) );
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
lsdays = lsseconds/LSTIME_SECONDS_PER_DAY;/* ???夙???吋????? */
|
|
|
|
|
lstime->day = lsdays % LSTIME_DAYS_PER_YEAR;/* 夙????吋?????????吋*/
|
2020-06-23 15:27:59 +08:00
|
|
|
|
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
/*(750*12)企?1吋*/
|
2020-06-23 15:27:59 +08:00
|
|
|
|
lstime->hour = (int)(lsseconds % LSTIME_SECONDS_PER_DAY )
|
2020-06-23 15:53:23 +08:00
|
|
|
|
/* ???????吋???????企????? */
|
2020-06-23 15:27:59 +08:00
|
|
|
|
* LSTIME_HOURS_PER_DAY / LSTIME_SECONDS_PER_DAY;
|
2020-06-23 15:53:23 +08:00
|
|
|
|
/* ?吋????企????????吋????????????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
????????*/
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
|
|
|
|
LS????????????
|
2020-06-23 15:53:23 +08:00
|
|
|
|
LSTIME *lstime : LSTIME?﹨▍??????
|
|
|
|
|
long *t : ????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
*******************************************************************/
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************************************************************
|
2020-06-23 15:53:23 +08:00
|
|
|
|
LS????????希?台?
|
|
|
|
|
??π int : ?0??1??2??3
|
|
|
|
|
LSTIME *lstime : LSTIME?﹨▍??????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
*******************************************************************/
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ??┼????????????? ***********************************/
|
2020-06-23 15:27:59 +08:00
|
|
|
|
void TimeZoneProc( void )
|
|
|
|
|
{
|
|
|
|
|
int timeZoneNo;
|
2020-06-23 15:53:23 +08:00
|
|
|
|
//??????????希?台?
|
2020-06-23 15:27:59 +08:00
|
|
|
|
timeZoneNo = getLSTime ( &SaTime );
|
2020-06-23 15:53:23 +08:00
|
|
|
|
// ??┼?阪????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
if( SaTimeZoneNo != timeZoneNo ){
|
2020-06-23 15:53:23 +08:00
|
|
|
|
SaTimeZoneNo = timeZoneNo; // ??┼?
|
|
|
|
|
// ??┼????????????
|
2020-06-23 15:27:59 +08:00
|
|
|
|
if( TimeZonePalChangeFlag == TRUE ){
|
|
|
|
|
PaletteChange( SaTimeZoneNo, PAL_CHANGE_TIME );// ????????
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|