Subject: PINE doesn't read the timezone info

From: Keith K Chau <[email-masked]>
Date: Sat, 20 Aug 1994 17:06:19 +0000

Hi!

I am running PINE 3.89 under Linux (Slackware distribution)... it seems 
that PINE doesn't even read the timezone info from the system and 
out-going messages always bear "+0000". (as you may probably see now :) 

Any help is appreciated.

Keith

---

From: [email-masked] (Paul Eggert)
Date: Sun, 21 Aug 1994 00:16:54 GMT

> out-going messages always bear "+0000". (as you may probably see now :) 

Most likely your pine wasn't properly configured for Linux, and is
using the wrong definition of rfc822_date.  Try using the following
definition of rfc822_date instead.

It would simplify porting if imap used the following code,
which is more portable (though a tiny bit less efficient)
than the zillions of rfc822_date variants that come with the
imap distribution.

#include <sys/types.h>
#include <time.h>

char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
		  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

char *days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};

#define TM_YEAR_ORIGIN 1900

/* Return difference between a and b, in minutes (ignoring seconds).  */
static time_t difftm(a, b)
	struct tm *a, *b;
{
  int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
  int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
  return
    (
      (
	/* difference in day of year */
	   a->tm_yday - b->tm_yday
	/* + intervening leap days */
	+  ((ay >> 2) - (by >> 2))
	-  (ay/100 - by/100)
	+  ((ay/100 >> 2) - (by/100 >> 2))
	/* + difference in years * 365 */
	+  (time_t)(ay-by) * 365
      )*24 + (a->tm_hour - b->tm_hour)
    )*60 + (a->tm_min - b->tm_min);
}

/* Write current time in RFC 822 format
 * Accepts: destination string
 */

void rfc822_date (date)
	char *date;
{
  time_t time_sec = time (0);
  struct tm gm, *t;
  int zone, signzone, abszone;

  gm = *gmtime (&time_sec);
  t = localtime (&time_sec);
  zone = difftm (t, &gm);
  signzone = zone < 0 ? '-' : '+';
  abszone = abs (zone);
  sprintf (date, "%s, %d %s %d %02d:%02d:%02d %c%02d%02d",
	   days[t->tm_wday], t->tm_mday, months[t->tm_mon],
	   t->tm_year + TM_YEAR_ORIGIN,
	   t->tm_hour, t->tm_min, t->tm_sec,
	   signzone, abszone/60, abszone%60);
}