 |
11.02.2012, 23:55
|
#1
|
|
|
|
Разведчик
|
 Регистрация: 01.10.2009
 Сообщений: 15
 Популярность: 1425
 Сказал(а) спасибо: 127
Поблагодарили 5 раз(а) в 5 сообщениях
|
ТВ 2 раза в день(нашёл кусок кода на C++)
Прошу прощение за опечатку в названии- ТВ 2 раза в неделю))
Уважаемые коллеги))  Вот отрыл на просторах нета,решил поделиться,с просьбой огромной-проверить раблотает или нет,и если да,то мне помочь  :
Сам текст: 
Изменить файл из директории home\gfactiond\gfactiond
 |
Цитата: |
 |
|
|
|
|
|
|
|
#include #include #include #include /*Revision time class start*/ typedef struct structTIMESTRU { int nYear; int nMon; int nDay; int nHour; int nMin; int nSec; } TIMESTRU; typedef TIMESTRU * PTIMESTRU; TIMESTRU GetTime(); TIMESTRU GetOffsetTime(TIMESTRU timestru, int nOffsetSec); TIMESTRU GetTime() { TIMESTRU timestru; time_t time1; struct tm * when; time(&time1); when = localtime(&time1); timestru.nYear = when->tm_year + 1900; timestru.nMon = when->tm_mon + 1; timestru.nDay = when->tm_mday; timestru.nHour = when->tm_hour; timestru.nMin = when->tm_min; timestru.nSec = when->tm_sec; return timestru; } TIMESTRU GetOffsetTime(TIMESTRU timestru, int nOffsetSec) { TIMESTRU timestruAfter; time_t ttime; struct tm when; memset(&when, 0, sizeof(when)); when.tm_year = timestru.nYear - 1900; when.tm_mon = timestru.nMon - 1; when.tm_mday = timestru.nDay; when.tm_hour = timestru.nHour; when.tm_min = timestru.nMin; when.tm_sec = timestru.nSec; ttime = mktime(&when) + nOffsetSec; stime(&ttime); when = *localtime(&ttime); timestruAfter.nYear = when.tm_year + 1900; timestruAfter.nMon = when.tm_mon + 1; timestruAfter.nDay = when.tm_mday; timestruAfter.nHour = when.tm_hour; timestruAfter.nMin = when.tm_min; timestruAfter.nSec = when.tm_sec; return timestruAfter; } /*Revision time class conclusion*/ /*The gain week several start*/ int getWeek(int gyear,int gmonth,int gday) { int day,month,year,i,days=0,s,k; int mont[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; char *week[7]={"0","1","2","3","4","5","6"}; year=gyear; month=gmonth; day=gday; if (year%4==0||year%100==0||year%400==0) mont[2]=29; else mont[2]=28; for (i=0;iThe gain star time several finished*/ int main() { TIMESTRU nowt, tom; struct tm when; time_t now; while(1==1) { sleep(1); time(&now); when = *localtime(&now); printf("%d\n",getWeek(when.tm_year+1900,when.tm_mo n+1,when.tm_m day)); if (getWeek(when.tm_year+1900,when.tm_mon+1,when.tm_m day) == 1) { nowt = GetTime(); tom = GetOffsetTime(nowt,48*60*60); printf("Monday arrived, the time automatic revision is %d %d %d\n",tom.nYear,tom.nMon,tom.nDay); }else{ nowt = GetTime(); printf("Server current date: %d %d %d\n",nowt.nYear,nowt.nMon,nowt.nDay); } } return 0; } |
|
 |
|
 |
|
Если вдруг помог-буду рад
Последний раз редактировалось pauldevil; 12.02.2012 в 00:26.
|
|
|
Ваши права в разделе
|
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения
HTML код Выкл.
|
|
|
Заявление об ответственности / Список мошенников
Часовой пояс GMT +4, время: 09:18.
|
 |