ctime.c revision a727d47a89ceb54faa3aecb01ab9b1a7961d6a79
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This routine converts time as follows.
* The epoch is 0000 Jan 1 1970 GMT.
* The argument time is in seconds since then.
* The localtime(t) entry returns a pointer to an array
* containing
* seconds (0-59)
* minutes (0-59)
* hours (0-23)
* day of month (1-31)
* month (0-11)
* year-1970
* weekday (0-6, Sun is 0)
* day of the year
* daylight savings flag
*
* The routine corrects for daylight saving
* time and will work in any time zone provided
* "timezone" is adjusted to the difference between
* Greenwich and local standard time (measured in seconds).
* In places like Michigan "daylight" must
* be initialized to 0 to prevent the conversion
* to daylight time.
* There is a table which accounts for the peculiarities
* undergone by daylight time in 1974-1975.
*
* The routine does not work
* in Saudi Arabia which runs on Solar time.
*
* asctime(tvec)
* where tvec is produced by localtime
* returns a ptr to a character string
* that has the ascii time in the form
* Thu Jan 01 00:00:00 1970\n\0
* 01234567890123456789012345
* 0 1 2
*
* ctime(t) just calls localtime, then asctime.
*
* tzset() looks for an environment variable named
* TZ.
* If the variable is present, it will set the external
* variables "timezone", "altzone", "daylight", and "tzname"
* appropriately. It is called by localtime, and
* may also be called explicitly by the user.
*/
#include "lint.h"
#include <mtlib.h>
#include <time.h>
#include <errno.h>
#include <thread.h>
#include <synch.h>
#include "libc.h"
#include "tsd.h"
#define CBUFSIZ 26
static char *
{
cp++;
if (n >= 10)
else
return (cp);
}
/*
* POSIX.1c standard version of the function asctime_r.
* User gets it via static asctime_r from the header file.
*/
char *
{
char *cp;
const char *ncp;
const char *Date = "Day Mon 00 00:00:00 YYYY\n";
const char *Day = "SunMonTueWedThuFriSat";
const char *Month = "JanFebMarAprMayJunJulAugSepOctNovDec";
;
cp++;
/* Only positive, 4-digit years are supported */
return (NULL);
}
cp--;
return (cbuf);
}
/*
* POSIX.1c Draft-6 version of the function asctime_r.
* It was implemented by Solaris 2.3.
*/
char *
{
return (NULL);
}
return (__posix_asctime_r(t, cbuf));
}
char *
{
struct tm *p;
return (NULL);
p = localtime(t);
if (p == NULL)
return (NULL);
return (__posix_asctime_r(p, cbuf));
}
char *
{
return (NULL);
return (__posix_asctime_r(t, cbuf));
}