*** log.c.orig	Thu May 18 13:50:18 2000
--- log.c	Thu May 18 15:30:57 2000
***************
*** 95,100 ****
--- 95,102 ----
      /* If not NULL, the list of login names given for the -w option,
         which only prints revisions checked in by given users.  */
      List *authorlist;
+     /* 1 means output times in localtime, 0 means UTC */
+     int use_localtime;
  };
  
  /* This structure is used to pass information through walklist.  */
***************
*** 203,209 ****
      memset (&log_data, 0, sizeof log_data);
  
      optind = 0;
!     while ((c = getopt (argc, argv, "+bd:hlNRr::s:tw::")) != -1)
      {
  	switch (c)
  	{
--- 205,211 ----
      memset (&log_data, 0, sizeof log_data);
  
      optind = 0;
!     while ((c = getopt (argc, argv, "+bd:hlLNRr::s:tw::")) != -1)
      {
  	switch (c)
  	{
***************
*** 219,224 ****
--- 221,229 ----
  	    case 'l':
  		local = 1;
  		break;
+ 	    case 'L':
+ 		log_data.use_localtime = 1;
+ 		break;
  	    case 'N':
  		log_data.notags = 1;
  		break;
***************
*** 296,301 ****
--- 301,308 ----
  	    send_arg ("-h");
  	if (local)
  	    send_arg("-l");
+ 	if (log_data.use_localtime)
+ 	    send_arg("-L");
  	if (log_data.notags)
  	    send_arg("-N");
  	if (log_data.nameonly)
***************
*** 1264,1269 ****
--- 1271,1337 ----
      log_version (log_data, revlist, rcs, vnode, 0);
  }
  
+ static void
+ log_format_localtime(
+ 	char *buf,
+ 	int year,
+ 	int mon, 
+ 	int mday, 
+ 	int hour, 
+ 	int min, 
+ 	int sec)
+ {
+ 
+ 	struct tm rcstm, utctm, loctm, *tmptr;
+ 	time_t nowutc, nowloc, rcstime;
+ 	struct timeval nowtv;
+ 	int add1900 = 0;
+ 
+ 	/* convert the input time, which is in UTC via mktime
+            to a time_t (seconds since long ago, however mktime
+ 	   assumes its input is in localtime which it is nol.t */
+ 
+ 	rcstm.tm_sec = sec;
+ 	rcstm.tm_min = min;
+ 	rcstm.tm_hour = hour;
+ 	rcstm.tm_mday = mday;
+ 	rcstm.tm_mon = mon;
+ 	rcstm.tm_year = year - 1900;
+ 	rcstm.tm_isdst = -1;  /* assume times are already adjusted for DST */ 
+ 			     /* this is because it's really a UTC, */
+ 			     /* and not affected  by Daylight Savings Time */
+ 
+ 	rcstime = mktime(&rcstm); /* UTC converted as if it were localtime */
+ 			          /* yielding a wrong time */
+ 
+ 	/* find the diff between local time and UTC,
+            then apply this difference to the UTC time 
+ 	   in the log entry */
+ 
+ 	gettimeofday(&nowtv, NULL) ; /* time now, in secs since long ago */
+ 
+ 	tmptr = gmtime_r(&nowtv.tv_sec, &utctm);
+ 	tmptr = localtime_r(&nowtv.tv_sec, &loctm);
+ 
+ 	nowutc = mktime(&utctm); /*   utc converted as if it were localtime */
+ 	nowloc = mktime(&loctm); /* local converted as if it were localtime */
+ 
+ 	rcstime += (nowloc - nowutc); /* subtract the wrongness */
+ 
+ 	/* take the time_t and make it a struct tm */	
+ 	bcopy(localtime(&rcstime), &rcstm, sizeof(rcstm));
+ 
+ 	/* format the converted time to a string */
+ 
+         sprintf (buf, "%04d/%02d/%02d %02d:%02d:%02d", 
+ 		rcstm.tm_year+1900, 
+ 		rcstm.tm_mon, 
+ 		rcstm.tm_mday,
+ 		rcstm.tm_hour, 
+ 		rcstm.tm_min, 
+ 		rcstm.tm_sec);
+ }
+ 
  /*
   * Print the log output for a single version.
   */
***************
*** 1299,1306 ****
  		   &sec);
      if (year < 1900)
  	year += 1900;
!     sprintf (buf, "%04d/%02d/%02d %02d:%02d:%02d", year, mon, mday,
! 	     hour, min, sec);
      cvs_output (buf, 0);
  
      cvs_output (";  author: ", 0);
--- 1367,1378 ----
  		   &sec);
      if (year < 1900)
  	year += 1900;
! 
!     if (log_data->use_localtime) 
!        log_format_localtime(buf, year, mon, mday, hour, min, sec);
!     else
!        sprintf (buf, "%04d/%02d/%02d %02d:%02d:%02d", year, mon, mday,
! 	        hour, min, sec);
      cvs_output (buf, 0);
  
      cvs_output (";  author: ", 0);
