imap/src/osdep/nt/env_nt.c
/* Write current time
 * Accepts: destination string
 *	    optional format of day-of-week prefix
 *	    format of date and time
 *	    flag whether to append symbolic timezone
 */
Write current time
Accepts: destination string
optional format of day-of-week prefix
format of date and time
flag whether to append symbolic timezone
Write current time Accepts : destination string optional format of day - of - week prefix format of date and time flag whether to append symbolic timezone
static void do_date (char *date,char *prefix,char *fmt,int suffix)
{
  time_t tn = time (0);
  struct tm *t = gmtime (&tn);
  int zone = t->tm_hour * 60 + t->tm_min;
  int julian = t->tm_yday;
  t = localtime (&tn);		
  zone = t->tm_hour * 60 + t->tm_min - zone;
  if (julian = t->tm_yday -julian)
    zone += ((julian < 0) == (abs (julian) == 1)) ? -24*60 : 24*60;
  if (prefix) {			
    sprintf (date,prefix,days[t->tm_wday]);
    date += strlen (date);	
  }
  sprintf (date,fmt,t->tm_mday,months[t->tm_mon],t->tm_year+1900,
	   t->tm_hour,t->tm_min,t->tm_sec,zone/60,abs (zone) % 60);
  if (suffix) {			
    char *tz;
    tzset ();			
    tz = tzname[daylight ? (((struct tm *) t)->tm_isdst > 0) : 0];
    if (tz && tz[0]) {
      char *s;
      for (s = tz; *s; s++) if (*s & 0x80) return;
      sprintf (date + strlen (date)," (%.50s)",tz);
    }
  }
}
static void do_date ( char * date , char * prefix , char * fmt , int suffix ) { time_t tn = time ( 0 ) ; struct tm * t = gmtime ( & tn ) ; int zone = t -> tm_hour * 60 + t -> tm_min ; int julian = t -> tm_yday ; t = localtime ( & tn ) ; zone = t -> tm_hour * 60 + t -> tm_min - zone ; if ( julian = t -> tm_yday - julian ) zone += ( ( julian < 0 ) == ( abs ( julian ) == 1 ) ) ? -24 * 60 : 24 * 60 ; if ( prefix ) { sprintf ( date , prefix , days [ t -> tm_wday ] ) ; date += strlen ( date ) ; } sprintf ( date , fmt , t -> tm_mday , months [ t -> tm_mon ] , t -> tm_year + 1900 , t -> tm_hour , t -> tm_min , t -> tm_sec , zone / 60 , abs ( zone ) % 60 ) ; if ( suffix ) { char * tz ; tzset ( ) ; tz = tzname [ daylight ? ( ( ( struct tm * ) t ) -> tm_isdst > 0 ) : 0 ] ; if ( tz && tz [ 0 ] ) { char * s ; for ( s = tz ; * s ; s ++ ) if ( * s & 0x80 ) return ; sprintf ( date + strlen ( date ) , " " , tz ) ; } } }
Write current time
 Accepts: destination string
          optional format of day-of-week prefix
          format of date and time
          flag whether to append symbolic timezone
Write current time Accepts : destination string optional format of day - of - week prefix format of date and time flag whether to append symbolic timezone
/* get local time now */ /* minus UTC minutes since midnight */ /* julian can be one of:
   *  36x  local time is December 31, UTC is January 1, offset -24 hours
   *    1  local time is 1 day ahead of UTC, offset +24 hours
   *    0  local time is same day as UTC, no offset
   *   -1  local time is 1 day behind UTC, offset -24 hours
   * -36x  local time is January 1, UTC is December 31, offset +24 hours
   */ /* want day of week? */ /* make next sprintf append */ /* output the date */ /* append timezone suffix if desired */ /* get timezone from TZ environment stuff */