ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/misc.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/misc.c (file contents):
Revision 6422 by michael, Wed Aug 26 18:12:52 2015 UTC vs.
Revision 6513 by michael, Sun Sep 6 18:32:38 2015 UTC

# Line 30 | Line 30
30   #include "ircd.h"
31  
32  
33 static const char *const months[] =
34 {
35  "January",   "February", "March",   "April",
36  "May",       "June",     "July",    "August",
37  "September", "October",  "November","December"
38 };
39
40 static const char *const weekdays[] =
41 {
42  "Sunday",   "Monday", "Tuesday", "Wednesday",
43  "Thursday", "Friday", "Saturday"
44 };
45
33   const char *
34   date(time_t lclock)
35   {
36 <  static char buf[80], plus;
50 <  struct tm *lt, *gm;
51 <  struct tm gmbuf;
52 <  int minswest;
36 >  static char buf[80];
37    static time_t lclock_last;
38  
39    if (!lclock)
40      lclock = CurrentTime;
41  
42 <  if (lclock_last == lclock)
59 <    return buf;
60 <
61 <  lclock_last = lclock;
62 <  gm = gmtime(&lclock);
63 <  memcpy(&gmbuf, gm, sizeof(gmbuf));
64 <  gm = &gmbuf;
65 <  lt = localtime(&lclock);
66 <
67 <  /*
68 <   * There is unfortunately no clean portable way to extract time zone
69 <   * offset information, so do ugly things.
70 <   */
71 <  minswest = (gm->tm_hour - lt->tm_hour) * 60 + (gm->tm_min - lt->tm_min);
72 <
73 <  if (lt->tm_yday != gm->tm_yday)
42 >  if (lclock_last != lclock)
43    {
44 <    if ((lt->tm_yday > gm->tm_yday && lt->tm_year == gm->tm_year) ||
45 <        (lt->tm_yday < gm->tm_yday && lt->tm_year != gm->tm_year))
77 <      minswest -= 24 * 60;
78 <    else
79 <      minswest += 24 * 60;
44 >    lclock_last = lclock;
45 >    strftime(buf, sizeof(buf), "%A %B %-e %Y -- %T %z", localtime(&lclock));
46    }
47  
82  plus = (minswest > 0) ? '-' : '+';
83  if (minswest < 0)
84    minswest = -minswest;
85
86  snprintf(buf, sizeof(buf), "%s %s %d %d -- %02u:%02u:%02u %c%02u:%02u",
87           weekdays[lt->tm_wday], months[lt->tm_mon],lt->tm_mday,
88           lt->tm_year + 1900, lt->tm_hour, lt->tm_min, lt->tm_sec,
89           plus, minswest/60, minswest%60);
48    return buf;
49   }
50  
# Line 102 | Line 60 | date_iso8601(time_t lclock)
60    if (lclock_last != lclock)
61    {
62      lclock_last = lclock;
63 <    strftime(buf, sizeof(buf), "%FT%H:%M:%S%z", localtime(&lclock));
63 >    strftime(buf, sizeof(buf), "%FT%T%z", localtime(&lclock));
64    }
65  
66    return buf;
# Line 121 | Line 79 | date_iso8601(time_t lclock)
79   * Thu Nov 24 18:22:48 1986
80   */
81   const char *
82 < myctime(time_t lclock)
82 > date_ctime(time_t lclock)
83   {
84 <  static char buf[32];
127 <  char *p;
84 >  static char buf[MAX_DATE_STRING];
85    static time_t lclock_last;
86  
87    if (!lclock)
88      lclock = CurrentTime;
89  
90 <  if (lclock_last == lclock)
91 <    return buf;
92 <
93 <  lclock_last = lclock;
94 <  strlcpy(buf, ctime(&lclock), sizeof(buf));
90 >  if (lclock_last != lclock)
91 >  {
92 >    lclock_last = lclock;
93 >    strftime(buf, sizeof(buf), "%a %b %-e %T %Y", localtime(&lclock));
94 >  }
95  
139  if ((p = strchr(buf, '\n')))
140    *p = '\0';
96    return buf;
97   }
98  

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)