/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2011 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*
* time conversion support
*/
#include <tm.h>
#include <ctype.h>
#include <namval.h>
#ifndef tzname
# if defined(__DYNAMIC__)
# else
# if !_dat_tzname
# if _dat__tzname
# endif
# endif
# endif
# if _dat_tzname && !defined(tzname)
extern char* tzname[];
# endif
#endif
{
"adjust", TM_ADJUST,
"format", TM_DEFAULT,
"leap", TM_LEAP,
"subsecond", TM_SUBSECOND,
"type", TM_type,
"utc", TM_UTC,
0, 0
};
/*
* 2007-03-19 move tm_info from _tm_info_ to (*_tm_infop_)
* to allow future Tm_info_t growth
* by 2009 _tm_info_ can be static
*/
#if _BLD_ast && defined(__EXPORT__)
#define extern extern __EXPORT__
#endif
#undef extern
#if _tzset_environ
struct tm*
{
struct tm* r;
char* e;
char** v = environ;
if (TZ[0])
{
else
e = environ[0];
}
r = localtime(t);
if (TZ[0])
{
if (environ != v)
environ = v;
else
environ[0] = e;
}
return r;
}
#endif
/*
* return minutes west of GMT for local time clock
*
* isdst will point to non-zero if DST is in effect
* this routine also kicks in the local initialization
*/
static int
{
register int n;
register int m;
int h;
/*
* convert to GMT assuming local time
*/
{
/*
* some systems return 0 for negative time_t
*/
epoch = 0;
}
/*
* tmlocaltime() handles DST and GMT offset
*/
{
if (n > 1)
n = -1;
else if (n < -1)
n = 1;
}
}
/*
* stropt() option handler
*/
static int
tmopt(void* a, const void* p, int n, const char* v)
{
NoP(a);
if (p)
{
case TM_DEFAULT:
tm_info.deformat = (n && (n = strlen(v)) > 0 && (n < 2 || v[n-2] != '%' || v[n-1] != '?')) ? strdup(v) : tm_info.format[TM_DEFAULT];
break;
case TM_type:
break;
default:
if (n)
else
break;
}
return 0;
}
/*
* initialize the local timezone
*/
static void
tmlocal(void)
{
register int n;
register char* s;
register char* e;
int i;
int m;
int isdst;
char* t;
#if _tzset_environ
{
char** v = environ;
if (s = getenv("TZ"))
{
else
e = environ[0];
}
else
{
TZ[0] = 0;
e = 0;
}
#endif
#if _lib_tzset
tzset();
#endif
#if _tzset_environ
if (environ != v)
environ = v;
else if (e)
environ[0] = e;
}
#endif
#if _dat_tzname
#endif
tmlocale();
/*
* tm_info.local
*/
/*
* compute local DST offset by roaming
* through the last 12 months until tzwest() changes
*/
for (i = 0; i < 12; i++)
{
{
if (!isdst)
{
isdst = n;
n = m;
m = isdst;
}
m -= n;
break;
}
}
/*
* now get the time zone names
*/
#if _dat_tzname
if (tzname[0])
{
/*
* POSIX
*/
}
else
#endif
{
/*
* BSD
*/
if (s = strchr(s, ','))
*s++ = 0;
else
s = "";
}
{
/*
* POSIX style but skipped by tmlocaltime()
*/
if (*++s && *++s && *++s)
{
*s++ = 0;
tmgoff(s, &t, 0);
for (s = t; isalpha(*t); t++);
*t = 0;
}
else
s = "";
}
else
{
/*
* tm_data.zone table lookup
*/
t = 0;
{
{
{
if (s < e - 1)
{
*s++ = ' ';
}
}
break;
}
}
{
/*
* not in the table
*/
if (s < e - 1)
{
*s++ = ' ';
}
}
}
/*
* set the options
*/
/*
* the time zone type is probably related to the locale
*/
{
t = 0;
{
{
break;
}
}
}
/*
* tm_info.flags
*/
{
}
{
zp++;
{
break;
}
}
}
/*
* initialize tm data
*/
void
{
{
{
}
}
tmlocal();
if (!zp)
}