コード例 #1
0
ファイル: dng_date_time.cpp プロジェクト: crass/dngconvert
void dng_date_time_info::Decode_ISO_8601 (const char *s)
	{
	
	Clear ();
		
	uint32 len = (uint32) strlen (s);
	
	if (!len)
		{
		return;
		}
		
	unsigned year  = 0;
	unsigned month = 0;
	unsigned day   = 0;
	
	if (sscanf (s,
				"%u-%u-%u",
				&year,
				&month,
				&day) != 3)
		{
		return;
		}
		
	SetDate ((uint32) year,
			 (uint32) month,
			 (uint32) day);
	
	if (fDateTime.NotValid ())
		{
		Clear ();
		return;
		}
		
	for (uint32 j = 0; j < len; j++)
		{
		
		if (s [j] == 'T')
			{
			
			unsigned hour   = 0;
			unsigned minute = 0;
			unsigned second = 0;

			if (sscanf (s + j + 1,
						"%u:%u:%u",
						&hour,
						&minute,
						&second) == 3)
				{
				
				SetTime ((uint32) hour,
						 (uint32) minute,
						 (uint32) second);
				
				if (fDateTime.NotValid ())
					{
					Clear ();
					return;
					}
					
				for (uint32 k = j + 1; k < len; k++)
					{
					
					if (s [k] == '.')
						{
						
						while (++k < len && s [k] >= '0' && s [k] <= '9')
							{
							
							char ss [2];
							
							ss [0] = s [k];
							ss [1] = 0;
							
							fSubseconds.Append (ss);
							
							}
						
						break;
						
						}
					
					}
					
				for (uint32 k = j + 1; k < len; k++)
					{
					
					if (s [k] == 'Z')
						{
						
						fTimeZone.SetOffsetMinutes (0);
						
						break;
						
						}
						
					if (s [k] == '+' || s [k] == '-')
						{
						
						int32 sign = (s [k] == '-' ? -1 : 1);
						
						unsigned tzhour = 0;
						unsigned tzmin  = 0;
						
						if (sscanf (s + k + 1,
									"%u:%u",
									&tzhour,
									&tzmin) > 0)
							{
							
							fTimeZone.SetOffsetMinutes (sign * (tzhour * 60 + tzmin));
															
							}
						
						break;
						
						}
					
					}
				
				}
				
			break;
		
			}
		
		}

	}
コード例 #2
0
//=================================================================== SetDate
BOOL CNSDateEdit::SetDate( CTime &d )
{
    return SetDate( d.GetYear(), d.GetMonth(), d.GetDay() );
}
コード例 #3
0
ファイル: ghp_ScheduleSvr.c プロジェクト: Jongil-Park/Lin_PRJ
int schedule_main(void)
/****************************************************************/
{
	GHP_SCHED_T *pSched;
	SEND_DATA *pData;

	int nClientFd = -1;
	int nClientLength = 0;
	struct sockaddr_in client_addr;	
	signal(SIGPIPE, SIG_IGN);								// Ignore broken_pipe signal.
	
	pSched = new_sched();
	if (pSched == NULL) {
		if ( g_dbgShow ) {
			fprintf( stdout, "Can't create SCHED Memory space.\n" );
			fflush(stdout);
		}
		//exit(1);
		system("killall duksan");
	}

	if ( shced_open(pSched) < 0 ) {
		exit(0);
	}	
		
	while (1) {
		sched_sleep( 0, 500 );
		// ready to accept socket
		nClientFd = accept(pSched->nFd, (struct sockaddr *)&client_addr, &nClientLength); 
		if ( g_dbgShow ) {
			fprintf( stdout, "[SCHED]  Socket Accept OK.\n");
			fflush( stdout );		
		}
		
		// check accept error
		if ( nClientFd == -1 ) {
			if ( g_dbgShow ) {
				fprintf( stdout, "+ [SCHED] Accept Error.\n");
				fflush( stdout );
			}

			// kill application3
			sched_sleep( 3, 0 );
			system("killall duksan");
		}
		

		for (;;) {
			// receive message
			sched_sleep(0, 100);
			pSched->nRecvByte = sched_recv_message(nClientFd, pSched->bRxBuf);

			// parsing message
            if( pSched->nRecvByte == 0 ) { 
				if ( g_dbgShow ) {
					fprintf( stdout, "+ [SCHED] Socket Close.\n");
					fflush( stdout );
				}

				// close socket
                close(nClientFd); 		
				
				// init variable
				memset( pSched->bTxBuf, 0x00, MAX_BUF_LENGTH );
				memset( pSched->bRxBuf, 0x00, MAX_BUF_LENGTH );
				memset( pSched->bPrevBuf, 0x00, MAX_BUF_LENGTH );
				pSched->nRecvByte = 0;
				pSched->nTempWp = 0;
				pSched->nIndexPrev = 0;
				
				// wait delay
				sched_sleep(3, 0);
                break;
            }
			else if ( pSched->nRecvByte > 0 )	{
				if ( g_dbgShow ) {
					fprintf( stdout, "+ [SCHED] Receive Byte %d\n", pSched->nRecvByte);
					fflush( stdout );
				}
				
				if (  pSched->nIndexPrev + pSched->nRecvByte >  MAX_BUF_LENGTH) {
				;
				}
				else {
					// copy message
					memcpy(&pSched->bPrevBuf[pSched->nIndexPrev], pSched->bRxBuf,  pSched->nRecvByte);
					pSched->nIndexPrev = pSched->nIndexPrev + pSched->nRecvByte;

					if ( g_dbgShow ) {
						fprintf( stdout, "+ [SCHED] Copy Byte %d\n", pSched->nIndexPrev);
						fflush( stdout );
					}
					
					// check message length
					pData = (SEND_DATA *)pSched->bPrevBuf;
					if(pSched->nIndexPrev == pData->length && Check_Message(pData)) {
						Parsing_Data(pData);
						SetDate(pData);
					}
				}
			}
		}
		continue;
	}
}
コード例 #4
0
ファイル: ISODates.cpp プロジェクト: PhineasCampbell/phin
// Constructor using the ISO 8601 YYYYMMDD date format
ISODate::ISODate(long Date)
{
	SetDate(Date);
	_dateAdjustment = MF;
	return;
}
コード例 #5
0
// Date constructor
Date::Date(int nMonth, int nDay, int nYear)
{
    SetDate(nMonth, nDay, nYear);
}
コード例 #6
0
void TimeMenu::OnShow(bool popping)
{
	Menu::OnShow(popping);
	SetTime(timeEntry);
	SetDate(dateEntry);
}
コード例 #7
0
ファイル: misc.cpp プロジェクト: koreapyj/openttd-yapp
void InitializeGame(uint size_x, uint size_y, bool reset_date, bool reset_settings)
{
	/* Make sure there isn't any window that can influence anything
	 * related to the new game we're about to start/load. */
	UnInitWindowSystem();

	AllocateMap(size_x, size_y);

	_pause_mode = PM_UNPAUSED;
	_fast_forward = 0;
	_tick_counter = 0;
	_tick_skip_counter = 0;
	_cur_tileloop_tile = 1;
	_thd.redsq = INVALID_TILE;
	if (reset_settings) MakeNewgameSettingsLive();

	if (reset_date) {
		SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1), 0);
		InitializeOldNames();
	}

	PoolBase::Clean(PT_NORMAL);

	ResetPersistentNewGRFData();

	InitializeSound();
	InitializeMusic();

	InitializeVehicles();

	InitNewsItemStructs();
	InitializeLandscape();
	InitializeRailGui();
	InitializeRoadGui();
	InitializeAirportGui();
	InitializeDockGui();
	InitializeGraphPerformance();
	InitializeObjectGui();
	InitializeAIGui();
	InitializeTrees();
	InitializeIndustries();
	InitializeObjects();
	InitializeBuildingCounts();

	InitializeNPF();

	InitializeCompanies();
	AI::Initialize();
	Game::Initialize();
	InitializeCheats();

	InitTextEffects();
#ifdef ENABLE_NETWORK
	NetworkInitChatMessage();
#endif /* ENABLE_NETWORK */
	InitializeAnimatedTiles();

	InitializeEconomy();

	ResetObjectToPlace();
	ClearRailPlacementEndpoints();

	GamelogReset();
	GamelogStartAction(GLAT_START);
	GamelogRevision();
	GamelogMode();
	GamelogGRFAddList(_grfconfig);
	GamelogStopAction();
}
コード例 #8
0
ファイル: classMAnnivDate.cpp プロジェクト: Seldom/miranda-ng
/**
 * name:	MAnnivDate
 * class:	MAnnivDate
 * desc:	constructor, which duplicates an existing anniversary date
 * param:	mda	- anniversary date to copy
 * return:	nothing
 **/
MAnnivDate::MAnnivDate(MAnnivDate &mda)
{
	SetDate(mda);
}