1289177Speter/* $NetBSD: tm2time.c,v 1.2 2017/01/28 21:31:50 christos Exp $ */ 2289177Speter 3289177Speter/* 4289177Speter * Copyright (c) 1995, 1996, 1997, 2004 Kungliga Tekniska H��gskolan 5289177Speter * (Royal Institute of Technology, Stockholm, Sweden). 6289177Speter * All rights reserved. 7289177Speter * 8289177Speter * Redistribution and use in source and binary forms, with or without 9289177Speter * modification, are permitted provided that the following conditions 10289177Speter * are met: 11289177Speter * 12289177Speter * 1. Redistributions of source code must retain the above copyright 13289177Speter * notice, this list of conditions and the following disclaimer. 14289177Speter * 15289177Speter * 2. Redistributions in binary form must reproduce the above copyright 16289177Speter * notice, this list of conditions and the following disclaimer in the 17289177Speter * documentation and/or other materials provided with the distribution. 18289177Speter * 19289177Speter * 3. Neither the name of the Institute nor the names of its contributors 20289177Speter * may be used to endorse or promote products derived from this software 21289177Speter * without specific prior written permission. 22289177Speter * 23289177Speter * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 24289177Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25289177Speter * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26289177Speter * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 27289177Speter * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28289177Speter * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29289177Speter * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30289177Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31289177Speter * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32289177Speter * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33289177Speter * SUCH DAMAGE. 34289177Speter */ 35289177Speter 36289177Speter#include <config.h> 37289177Speter 38289177Speter#ifdef TIME_WITH_SYS_TIME 39289177Speter#include <sys/time.h> 40289177Speter#include <time.h> 41289177Speter#elif defined(HAVE_SYS_TIME_H) 42289177Speter#include <sys/time.h> 43289177Speter#else 44289177Speter#include <time.h> 45289177Speter#endif 46289177Speter#include <krb5/roken.h> 47289177Speter 48289177SpeterROKEN_LIB_FUNCTION time_t ROKEN_LIB_CALL 49289177Spetertm2time (struct tm tm, int local) 50289177Speter{ 51289177Speter time_t t; 52289177Speter 53289177Speter tm.tm_isdst = local ? -1 : 0; 54289177Speter 55289177Speter t = mktime (&tm); 56289177Speter 57289177Speter if (!local) 58289177Speter t += t - mktime (gmtime (&t)); 59289177Speter return t; 60289177Speter} 61289177Speter