Advertisement
NovaYoshi

date difference finder

Dec 28th, 2011
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.72 KB | None | 0 0
  1. int ReadDate3(char *Peek) {
  2.   if(!strcasecmp(Peek, "now"))
  3.     return time(NULL);
  4.   int Month, Day, Year;
  5.   if(!Peek[0]) return -1;
  6.   Month = strtol(Peek, &Peek, 10);
  7.   if(*Peek=='/') Peek++;
  8.   if(!Peek[0]) return -1;
  9.   Day = strtol(Peek, &Peek, 10);
  10.   if(*Peek=='/') Peek++;
  11.   if(!Peek[0]) return -1;
  12.   Year = strtol(Peek, NULL, 10);
  13.   time_t RawTime;
  14.   struct tm *TimeInfo;
  15.   time( &RawTime );
  16.   TimeInfo = localtime ( &RawTime );
  17.   TimeInfo->tm_year = Year - 1900;
  18.   TimeInfo->tm_mon = Month - 1;
  19.   TimeInfo->tm_mday = Day;
  20.   return mktime(TimeInfo);
  21. }
  22.  
  23. int Days = abs(ReadDate3(word[i])-ReadDate3(word[i+1])) / 86400;
  24. xchat_commandf(ph, "%s %i days (%i weeks and %i days)", ReplyCmd, Days, Days/7, Days%7);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement