/[svn]/ircd-hybrid/branches/8.2.x/src/misc.c
ViewVC logotype

Diff of /ircd-hybrid/branches/8.2.x/src/misc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6497 by michael, Wed Aug 26 18:56:18 2015 UTC revision 6498 by michael, Sat Sep 5 17:47:34 2015 UTC
# Line 30  Line 30 
30  #include "ircd.h"  #include "ircd.h"
31    
32    
 static const char *const months[] =  
 {  
   "January",   "February", "March",    "April",  
   "May",       "June",     "July",     "August",  
   "September", "October",  "November", "December"  
 };  
   
 static const char *const weekdays[] =  
 {  
   "Sunday",   "Monday", "Tuesday", "Wednesday",  
   "Thursday", "Friday", "Saturday"  
 };  
   
33  const char *  const char *
34  date(time_t lclock)  date(time_t lclock)
35  {  {
36    static char buf[80], plus;    static char buf[80];
37    static time_t lclock_last;    static time_t lclock_last;
   struct tm *lt, *gm;  
   struct tm gmbuf;  
   int minswest;  
38    
39    if (!lclock)    if (!lclock)
40      lclock = CurrentTime;      lclock = CurrentTime;
41    
42    if (lclock_last == lclock)    if (lclock_last != lclock)
     return buf;  
   
   lclock_last = lclock;  
   gm = gmtime(&lclock);  
   memcpy(&gmbuf, gm, sizeof(gmbuf));  
   gm = &gmbuf;  
   lt = localtime(&lclock);  
   
   /*  
    * There is unfortunately no clean portable way to extract time zone  
    * offset information, so do ugly things.  
    */  
   minswest = (gm->tm_hour - lt->tm_hour) * 60 + (gm->tm_min - lt->tm_min);  
   
   if (lt->tm_yday != gm->tm_yday)  
43    {    {
44      if ((lt->tm_yday > gm->tm_yday && lt->tm_year == gm->tm_year) ||      lclock_last = lclock;
45          (lt->tm_yday < gm->tm_yday && lt->tm_year != gm->tm_year))      strftime(buf, sizeof(buf), "%A %B %-e %Y -- %T %z", localtime(&lclock));
       minswest -= 24 * 60;  
     else  
       minswest += 24 * 60;  
46    }    }
47    
   plus = (minswest > 0) ? '-' : '+';  
   if (minswest < 0)  
     minswest = -minswest;  
   
   snprintf(buf, sizeof(buf), "%s %s %d %d -- %02u:%02u:%02u %c%02u:%02u",  
            weekdays[lt->tm_wday], months[lt->tm_mon], lt->tm_mday,  
            lt->tm_year + 1900, lt->tm_hour, lt->tm_min, lt->tm_sec,  
            plus, minswest/60, minswest%60);  
48    return buf;    return buf;
49  }  }
50    

Legend:
Removed from v.6497  
changed lines
  Added in v.6498

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28