/* 
 * $Copyright:	$
 * Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
 * Sequent Computer Systems, Inc.   All rights reserved.
 *  
 * This software is furnished under a license and may be used
 * only in accordance with the terms of that license and with the
 * inclusion of the above copyright notice.   This software may not
 * be provided or otherwise made available to, or used by, any
 * other person.  No title to or ownership of the software is
 * hereby transferred.
 */


/*	Copyright (c) 1987 AT&T	*/
/*	  All Rights Reserved  	*/

/*	THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T	*/
/*	The copyright notice above does not evidence any   	*/
/*	actual or intended publication of such source code.	*/

#ident "$Header: nl_ctime.c 1.1 90/01/09 $@(#)nl_ctime.c	1.3 89/12/01"

/*LINTLIBRARY*/
/*
 * nl_ctime.c
 *
 *	X/OPEN  functions for time
 */

#include <time.h>
#include <locale.h>
#include <stdio.h>
#include <langinfo.h>

/*
 * declaration of externals
 */
char *asctime();
char *ctime();
struct tm *localtime();
static char _result[512];

/*
 * default date format:
 */
char	DFLT[] = "%a %b %e %T %Y\n";

/*
 * nl_ascxtime -- international version of asctime
 *
 * SYNOPSIS:
 *	char *
 *	nl_ascxtime(tp, fmt)
 *	struct tm *tp;
 *	char *fmt;
 *
 * DESCRIPTION:
 *	nl_ascxtime is specified in the X/OPEN guide.
 *
 * RETURNS:
 *	time converted to string.
 */
char *
nl_ascxtime(tp, fmt)
struct tm *tp;
char *fmt;
{
	char *cp;
	cp = &_result[0];
	if (!strcmp(fmt,"")) {
		fmt = nl_langinfo(D_T_FMT);	
		if (!strcmp(fmt,"") )
			fmt = DFLT;	
	}
	strftime(cp , 512 , fmt, tp);
	return(cp);
}

/*
 * nl_cxtime -- international version of ctime
 *
 * SYNOPSIS:
 *	char *
 *	nl_cxtime(clock, fmt)
 *	long *clock;
 *	char *fmt;
 *
 * DESCRIPTION:
 *	nl_cxtime is specified in the X/OPEN guide.
 *
 * RETURNS:
 *	time as string
 */
char *
nl_cxtime(clock, fmt)
long *clock;
char *fmt;
{
	return(nl_ascxtime(gmtime(clock),fmt));
}
