14887Schin /***********************************************************************
24887Schin * *
34887Schin * This software is part of the ast package *
4*12068SRoger.Faulkner@Oracle.COM * Copyright (c) 1985-2010 AT&T Intellectual Property *
54887Schin * and is licensed under the *
64887Schin * Common Public License, Version 1.0 *
78462SApril.Chin@Sun.COM * by AT&T Intellectual Property *
84887Schin * *
94887Schin * A copy of the License is available at *
104887Schin * http://www.opensource.org/licenses/cpl1.0.txt *
114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
124887Schin * *
134887Schin * Information and Software Systems Research *
144887Schin * AT&T Research *
154887Schin * Florham Park NJ *
164887Schin * *
174887Schin * Glenn Fowler <gsf@research.att.com> *
184887Schin * David Korn <dgk@research.att.com> *
194887Schin * Phong Vo <kpv@research.att.com> *
204887Schin * *
214887Schin ***********************************************************************/
224887Schin #pragma prototyped
234887Schin /*
244887Schin * Glenn Fowler
254887Schin * AT&T Bell Laboratories
264887Schin *
274887Schin * time conversion support
284887Schin */
294887Schin
304887Schin #include <ast.h>
314887Schin #include <tm.h>
324887Schin
334887Schin /*
344887Schin * n is minutes west of UTC
354887Schin *
364887Schin * append p and SHHMM part of n to s
374887Schin * where S is + or -
384887Schin *
394887Schin * n ignored if n==d
404887Schin * end of s is returned
414887Schin */
424887Schin
434887Schin char*
tmpoff(register char * s,size_t z,register const char * p,register int n,int d)444887Schin tmpoff(register char* s, size_t z, register const char* p, register int n, int d)
454887Schin {
464887Schin register char* e = s + z;
474887Schin
484887Schin while (s < e && (*s = *p++))
494887Schin s++;
504887Schin if (n != d && s < e)
514887Schin {
524887Schin if (n < 0)
534887Schin {
544887Schin n = -n;
554887Schin *s++ = '+';
564887Schin }
574887Schin else
584887Schin *s++ = '-';
594887Schin s += sfsprintf(s, e - s, "%02d%02d", n / 60, n % 60);
604887Schin }
614887Schin return s;
624887Schin }
63