4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 2014 Gary Mills
25 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
26 * Use is subject to license terms.
29 /* Copyright (c) 1988 AT&T */
30 /* All Rights Reserved */
33 * This routine converts time as follows. The epoch is 0000 Jan 1
34 * 1970 GMT. The argument time is in seconds since then. The
35 * localtime(t) entry returns a pointer to an array containing:
43 * weekday (0-6, Sun is 0)
45 * daylight savings flag
47 * The routine corrects for daylight saving time and will work in
48 * any time zone provided "timezone" is adjusted to the difference
49 * between Greenwich and local standard time (measured in seconds).
51 * ascftime(buf, format, t) -> where t is produced by localtime
52 * and returns a ptr to a character
53 * string that has the ascii time in
54 * the format specified by the format
55 * argument (see date(1) for format
58 * cftime(buf, format, t) -> just calls ascftime.
74 cftime(char *buf
, char *format
, const time_t *t
)
79 p
= localtime_r(t
, &res
);
84 /* LINTED do not use ascftime() */
85 return (ascftime(buf
, format
, p
));
89 ascftime(char *buf
, const char *format
, const struct tm
*tm
)
91 /* Set format string, if not already set */
92 if (format
== NULL
|| *format
== '\0')
93 if (((format
= getenv("CFTIME")) == 0) || *format
== 0)
96 return ((int)strftime(buf
, LONG_MAX
, format
, tm
));