usr.sbin/setkey/setkey.c
int32_t
gmt2local(time_t t)
{
	int dt, dir;
	struct tm *gmt, *loc;
	struct tm sgmt;

	if (t == 0)
		t = time(NULL);
	gmt = &sgmt;
	*gmt = *gmtime(&t);
	loc = localtime(&t);
	dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
	    (loc->tm_min - gmt->tm_min) * 60;

	/*
	 * If the year or julian day is different, we span 00:00 GMT
	 * and must add or subtract a day. Check the year first to
	 * avoid problems when the julian day wraps.
	 */
	dir = loc->tm_year - gmt->tm_year;
	if (dir == 0)
		dir = loc->tm_yday - gmt->tm_yday;
	dt += dir * 24 * 60 * 60;

	return (dt);
}
/*
 * Returns the difference between gmt and local time in seconds.
 * Use gmtime() and localtime() to keep things simple.
 */
Returns the difference between gmt and local time in seconds.
Use gmtime() and localtime() to keep things simple.
Returns the difference between gmt and local time in seconds . Use gmtime () and localtime () to keep things simple .
int32_t
gmt2local(time_t t)
{
	int dt, dir;
	struct tm *gmt, *loc;
	struct tm sgmt;
	if (t == 0)
		t = time(NULL);
	gmt = &sgmt;
	*gmt = *gmtime(&t);
	loc = localtime(&t);
	dt = (loc->tm_hour - gmt->tm_hour) * 60 * 60 +
	    (loc->tm_min - gmt->tm_min) * 60;
	dir = loc->tm_year - gmt->tm_year;
	if (dir == 0)
		dir = loc->tm_yday - gmt->tm_yday;
	dt += dir * 24 * 60 * 60;
	return (dt);
}
int32_t gmt2local ( time_t t ) { int dt , dir ; struct tm * gmt , * loc ; struct tm sgmt ; if ( t == 0 ) t = time ( NULL ) ; gmt = & sgmt ; * gmt = * gmtime ( & t ) ; loc = localtime ( & t ) ; dt = ( loc -> tm_hour - gmt -> tm_hour ) * 60 * 60 + ( loc -> tm_min - gmt -> tm_min ) * 60 ; dir = loc -> tm_year - gmt -> tm_year ; if ( dir == 0 ) dir = loc -> tm_yday - gmt -> tm_yday ; dt += dir * 24 * 60 * 60 ; return ( dt ) ; }
Returns the difference between gmt and local time in seconds.
Returns the difference between gmt and local time in seconds .
/*
	 * If the year or julian day is different, we span 00:00 GMT
	 * and must add or subtract a day. Check the year first to
	 * avoid problems when the julian day wraps.
	 */