|
1 /* |
|
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * FUNCTION |
|
16 * <<ctime>>---convert time to local and format as string |
|
17 * INDEX |
|
18 * ctime |
|
19 * ANSI_SYNOPSIS |
|
20 * #include <time.h> |
|
21 * char *ctime(time_t <[clock]>); |
|
22 * char *ctime_r(time_t <[clock]>, char *<[buf]>); |
|
23 * TRAD_SYNOPSIS |
|
24 * #include <time.h> |
|
25 * char *ctime(<[clock]>) |
|
26 * time_t <[clock]>; |
|
27 * char *ctime_r(<[clock]>, <[buf]>) |
|
28 * time_t <[clock]>; |
|
29 * char *<[buf]>; |
|
30 * Convert the time value at <[clock]> to local time (like <<localtime>>) |
|
31 * and format it into a string of the form |
|
32 * . Wed Jun 15 11:38:07 1988\n\0 |
|
33 * (like <<asctime>>). |
|
34 * RETURNS |
|
35 * A pointer to the string containing a formatted timestamp. |
|
36 * PORTABILITY |
|
37 * ANSI C requires <<ctime>>. |
|
38 * <<ctime>> requires no supporting OS subroutines. |
|
39 * |
|
40 * |
|
41 */ |
|
42 |
|
43 |
|
44 |
|
45 #include <time.h> |
|
46 #include <sys/reent.h> |
|
47 |
|
48 #ifndef _REENT_ONLY |
|
49 |
|
50 /** |
|
51 Convert time_t value to string. |
|
52 Converts tim_p to a string containing time |
|
53 and date adjusted to local time zone in readable format. |
|
54 @return A pointer to the string containing the date |
|
55 and time information in readable format. |
|
56 The string pointed is statically allocated |
|
57 and shared by ctime and asctime functions. |
|
58 Each time one of these functions is called |
|
59 the content of the string is overwritten. |
|
60 @param tim_p pointer to a time_t value, |
|
61 usually returned by time function. |
|
62 */ |
|
63 EXPORT_C char * |
|
64 ctime (const time_t * tim_p) |
|
65 { |
|
66 return ctime_r (tim_p, _REENT->_asctime); |
|
67 } |
|
68 |
|
69 #endif |