Anope IRC Services

Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: module request: calculate time ago of registered/seen nick/chan  (Read 3353 times)

0 Members and 1 Guest are viewing this topic.

demon

  • Anope User
  • Offline Offline
  • Posts: 59

I haven't seen a module adding in nickserv and chanserv abilities like:

Registered : May 06 14:19:06 2008 (6 weeks, 3 days, 19:14:21 ago)

Last seen  : Dec 19 21:34:28 2007 (26 weeks, 2 days, 12:01:01 ago)

I know its not that important cause you can make these calculations alone.. but many times its easy to see that this chan is registered for 2 years.. and don't have to see the registration time and do the calculation..

its just needs a function to do these calculations.. i paste it below.. it just needs someone to add it in a module cause i dont know how to make modules and i dont have time unfortunately to read about.

char *time_ago(time_t event)
{
   static char ret[128];
   int years, weeks, days, hours, minutes, seconds;

   event = CURRTIME - event;
   years = weeks = days = hours = minutes = seconds = 0;

   while (event >= 60 * 60 * 24 * 365)
   {
      event -= 60 * 60 * 24 * 365;
      years++;
   }
   while (event >= 60 * 60 * 24 * 7)
   {
      event -= 60 * 60 * 24 * 7;
      weeks++;
   }
   while (event >= 60 * 60 * 24)
   {
      event -= 60 * 60 * 24;
      days++;
   }
   while (event >= 60 * 60)
   {
      event -= 60 * 60;
      hours++;
   }
   while (event >= 60)
   {
      event -= 60;
      minutes++;
   }

   seconds = event;

   if (years)
      snprintf(ret, sizeof(ret),
          "%d year%s, %d week%s, %d day%s, %02d:%02d:%02d", years, years == 1 ? "" : "s", weeks, weeks == 1 ? "" : "s", days, days == 1 ? "" : "s", hours, minutes, seconds);
   else if (weeks)
      snprintf(ret, sizeof(ret), "%d week%s, %d day%s, %02d:%02d:%02d", weeks, weeks == 1 ? "" : "s", days, days == 1 ? "" : "s", hours, minutes, seconds);
   else if (days)
      snprintf(ret, sizeof(ret), "%d day%s, %02d:%02d:%02d", days, days == 1 ? "" : "s", hours, minutes, seconds);
   else if (hours)
      snprintf(ret, sizeof(ret), "%d hour%s, %d minute%s, %d second%s", hours, hours == 1 ? "" : "s", minutes, minutes == 1 ? "" : "s", seconds, seconds == 1 ? "" : "s");
   else if (minutes)
      snprintf(ret, sizeof(ret), "%d minute%s, %d second%s", minutes, minutes == 1 ? "" : "s", seconds, seconds == 1 ? "" : "s");
   else
      snprintf(ret, sizeof(ret), "%d second%s", seconds, seconds == 1 ? "" : "s");

   return ret;
}

(code is not mine.. i got it from atheme services)
Logged

katsklaw

  • Guest
(No subject)
« Reply #1 on: June 21, 2008, 11:00:20 AM »

This topic was discussed a long time ago and we come to the conclusion that Anope users are smart enough to do basic all by themselves and don't need such data "dummied up", Perhaps other services package users are as privileged.

Since you lack the time, then perhaps you can understand why there is a good chance that the 3 active module coders may not do this module either. Who knows though, perhaps today is your lucky day.

[Edited on 21-6-2008 by katsklaw]
Logged

demon

  • Anope User
  • Offline Offline
  • Posts: 59
(No subject)
« Reply #2 on: June 22, 2008, 07:57:25 PM »

I dont think it has anything to do with how smart or stupid is someone.. It has more to do with the easyness of finding out how many years a nick is register for, how many days before the nick was seen online and also in how many days the nick will expire for example.. We know it will expire in 21 days, but why not knowing exactly the date/time that will happen?

Its your choice to not make something like that.. and i totally understand it.. i just made a suggestion..
Logged
Pages: [1]   Go Up