+ case 'T':
+ /* Non-standard: Print a Common Log File timestamp */
+ {
+ /*
+ * Write timestamp into tempbuf.
+ *
+ * Complex because not all OSs have tm_gmtoff or
+ * the %z field in strftime()
+ */
+ time_t now;
+ struct tm *tm_now;
+ struct tm gmt;
+ int days, hrs, mins;
+ time (&now);
+ gmt = *gmtime (&now);
+ tm_now = localtime (&now);
+ days = tm_now->tm_yday - gmt.tm_yday;
+ hrs = ((days < -1 ? 24 : 1 < days ? -24 : days * 24) + tm_now->tm_hour - gmt.tm_hour);
+ mins = hrs * 60 + tm_now->tm_min - gmt.tm_min;
+ strftime (tempbuf, BUFSIZ-6, "%d/%b/%Y:%H:%M:%S ", tm_now);
+ sprintf (tempbuf + strlen(tempbuf), "%+03d%02d", mins / 60, abs(mins) % 60);
+ }
+ oldoutc = outc;
+ outc += strlen(tempbuf);
+ if (outc < BUFSIZ-1)
+ {
+ strcpy(outbuf + oldoutc, tempbuf);
+ }
+ else
+ {
+ outbuf[oldoutc] = '\0';
+ }
+ break;