Print this page
4378 Clean up %C in *time() functions
438 need documentation for strftime %s flag
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libc/port/gen/cftime.c
+++ new/usr/src/lib/libc/port/gen/cftime.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 + * Copyright (c) 2014 Gary Mills
24 + *
23 25 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 26 * Use is subject to license terms.
25 27 */
26 28
27 29 /* Copyright (c) 1988 AT&T */
28 30 /* All Rights Reserved */
29 31
30 -#pragma ident "%Z%%M% %I% %E% SMI"
31 -
32 32 /*
33 33 * This routine converts time as follows. The epoch is 0000 Jan 1
34 34 * 1970 GMT. The argument time is in seconds since then. The
35 35 * localtime(t) entry returns a pointer to an array containing:
36 36 *
37 37 * seconds (0-59)
38 38 * minutes (0-59)
39 39 * hours (0-23)
40 40 * day of month (1-31)
41 41 * month (0-11)
42 42 * year
43 43 * weekday (0-6, Sun is 0)
44 44 * day of the year
45 45 * daylight savings flag
46 46 *
47 47 * The routine corrects for daylight saving time and will work in
48 48 * any time zone provided "timezone" is adjusted to the difference
49 49 * between Greenwich and local standard time (measured in seconds).
50 50 *
51 51 * ascftime(buf, format, t) -> where t is produced by localtime
52 52 * and returns a ptr to a character
53 53 * string that has the ascii time in
54 54 * the format specified by the format
55 55 * argument (see date(1) for format
56 56 * syntax).
57 57 *
58 58 * cftime(buf, format, t) -> just calls ascftime.
59 59 *
60 60 *
61 61 *
62 62 */
63 63
64 64 #include "lint.h"
65 65 #include <mtlib.h>
66 66 #include <stddef.h>
67 67 #include <time.h>
68 68 #include <limits.h>
69 69 #include <stdlib.h>
70 70 #include <thread.h>
71 71 #include <synch.h>
72 72
73 73 int
74 74 cftime(char *buf, char *format, const time_t *t)
75 75 {
76 76 struct tm res;
77 77 struct tm *p;
78 78
79 79 p = localtime_r(t, &res);
80 80 if (p == NULL) {
81 81 *buf = '\0';
82 82 return (0);
83 83 }
↓ open down ↓ |
42 lines elided |
↑ open up ↑ |
84 84 /* LINTED do not use ascftime() */
85 85 return (ascftime(buf, format, p));
86 86 }
87 87
88 88 int
89 89 ascftime(char *buf, const char *format, const struct tm *tm)
90 90 {
91 91 /* Set format string, if not already set */
92 92 if (format == NULL || *format == '\0')
93 93 if (((format = getenv("CFTIME")) == 0) || *format == 0)
94 - format = "%C";
94 + format = "%+";
95 95
96 96 return ((int)strftime(buf, LONG_MAX, format, tm));
97 97 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX