bool TimeManager::IsDiffDay00(time_t uPrevANSITime, time_t uNextANSITime) { tm kPrevTime; _localtime(uPrevANSITime, kPrevTime); tm kNextTime; _localtime(uNextANSITime, kNextTime); return kPrevTime.tm_year != kNextTime.tm_year || kPrevTime.tm_mday != kNextTime.tm_mday; }
int qse_localtime (const qse_ntime_t* nt, qse_btime_t* bt) { struct tm* tm; time_t t = nt->sec; /* TODO: remove dependency on localtime/localtime_r */ #if defined(_WIN32) tm = localtime (&t); #elif defined(__OS2__) # if defined(__WATCOMC__) struct tm btm; tm = _localtime (&t, &btm); # else # error Please support other compilers # endif #elif defined(__DOS__) # if defined(__WATCOMC__) struct tm btm; tm = _localtime (&t, &btm); # else # error Please support other compilers # endif #elif defined(HAVE_LOCALTIME_R) struct tm btm; tm = localtime_r (&t, &btm); #else /* thread unsafe */ tm = localtime (&t); #endif if (tm == QSE_NULL) return -1; QSE_MEMSET (bt, 0, QSE_SIZEOF(*bt)); bt->sec = tm->tm_sec; bt->min = tm->tm_min; bt->hour = tm->tm_hour; bt->mday = tm->tm_mday; bt->mon = tm->tm_mon; bt->year = tm->tm_year; bt->wday = tm->tm_wday; bt->yday = tm->tm_yday; bt->isdst = tm->tm_isdst; /*bt->offset = tm->tm_offset;*/ return 0; }
void *localtime(const unsigned long *_tod) { #if !CAM_DRYOS return _localtime(_tod); #else // for DRYOS cameras do something with this! - sizeof(x[]) must be >= sizeof(struct tm) : 'static int x[9];' static int x[9]; return _LocalTime(_tod, &x); #endif }
void main() { struct tm time_of_day; time_t ltime; time( <ime ); _localtime( <ime, &time_of_day ); printf( "Date and time is: %s\n", jasctime( &time_of_day ) ); }
void TimeManager::SetTime() { time_t tempAnsiTime = _ansitime(); tm tempLocalTime; _localtime(tempAnsiTime, tempLocalTime); m_SetTime = tempAnsiTime; memcpy(&m_TM, &tempLocalTime, sizeof(tm)); }
void main() { struct tm time_of_day; time_t ltime; auto char buf[26]; time( <ime ); _localtime( <ime, &time_of_day ); tprintf( 12, 1, "Date and time is: %s\n", _asctime( &time_of_day, buf ) ); }
int main() { time_t t1, t2; struct tm tm1, tm2; time( &t1 ); tm1 = *localtime(&t1); t1 = mktime(&tm1); tm1 = *gmtime(&t1); _time( &t2 ); tm2 = *_localtime(&t2); t2 = _mktime(&tm2); tm2 = *_gmtime(&t2); // time, mktime if( t1==t2 ) OutputDebugString( "ok\n" ); else { static char buf[128]; wsprintf( buf, "ng : %d, %d\n", t1, t2 ); OutputDebugString( buf ); } // localtime, gmtime if( 0==memcmp( &tm1, &tm2, sizeof(struct tm) ) ) OutputDebugString( "ok\n" ); else OutputDebugString( "ng\n" ); // ctime OutputDebugString( ctime(&t1) ); OutputDebugString( _ctime(&t2) ); // asctime OutputDebugString( asctime(&tm1) ); OutputDebugString( _asctime(&tm2) ); return 0; }
_WCRTLINK struct tm *localtime( const time_t *timer ) { _INITTHETIME; return _localtime( timer, &_THE_TIME ); }
int PatchZed(char * szDestDir) { struct tm tmbuf; time_t time_of_day; CHAR szZED[CCHMAXPATH]; CHAR szDDIR[CCHMAXPATH]; CHAR szDate[10]; CHAR szTSNT[10]; FILE * infile; int iRes; long lPos; //Change status SetStatus(ID_PATCHINGZED); strcpy(szDDIR, szDestDir); //Get time time_of_day=time(NULL); _localtime(&time_of_day, &tmbuf); //Get file name sprintf(szZED, "%s\\ZED.EXE", szDDIR); //Format the date sprintf(szDate,"%d/%d/%d", tmbuf.tm_mon+1, tmbuf.tm_mday, tmbuf.tm_year); //Open ZED.EXE infile=fopen(szZED, "r+b"); if (infile==NULL) return -1; //Find 'TSNT' //WinMessageBox(HWND_DESKTOP, hwndClient, "Getting ready to search.","",0,NULL); lPos=0x15000; while (strncmp(szTSNT, "TSNT",4)!=0) { iRes=fseek(infile, lPos, SEEK_SET); if (iRes!=0) goto ERROR; iRes=fread(szTSNT, 1, 4, infile); if (iRes!=4) goto ERROR; lPos++; } //Flush the read iRes=fflush(infile); //if (iRes!=0) goto ERROR; //Write date stamp to file. //WinMessageBox(HWND_DESKTOP, hwndClient, "Getting ready to write.","",0,NULL); iRes=fwrite(szDate, 1, strlen(szDate), infile); if (iRes!=strlen(szDate)) goto ERROR; //Close file fclose(infile); return 0; ERROR: fclose(infile); return -1; }
tint32 TimeManager::GetHour(time_t uANSITime) { tm kTm; _localtime(uANSITime, kTm); return kTm.tm_hour; }
_WCRTLINK CHAR_TYPE *__F_NAME( _ctime, __wctime ) ( const time_t *timer, CHAR_TYPE *buf ) { struct tm tm; return( __F_NAME( _asctime, __wasctime ) ( _localtime( timer, &tm ), buf ) ); }