update for HEAD-2003091401
[reactos.git] / lib / msvcrt / time / wctime.c
1 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
2 /* This file has been modified by DJ Delorie.  These modifications are
3 ** Copyright (C) 1995 DJ Delorie, 24 Kirsten Ave, Rochester NH,
4 ** 03867-2954, USA.
5 */
6
7 /*
8  * Copyright (c) 1987, 1989 Regents of the University of California.
9  * All rights reserved.
10  *
11  * This code is derived from software contributed to Berkeley by
12  * Arthur David Olson of the National Cancer Institute.
13  *
14  * Redistribution and use in source and binary forms are permitted provided
15  * that: (1) source distributions retain this entire copyright notice and
16  * comment, and (2) distributions including binaries display the following
17  * acknowledgement:  ``This product includes software developed by the
18  * University of California, Berkeley and its contributors'' in the
19  * documentation or other materials provided with the distribution and in
20  * all advertising materials mentioning features or use of this software.
21  * Neither the name of the University nor the names of its contributors may
22  * be used to endorse or promote products derived from this software without
23  * specific prior written permission.
24  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
25  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
26  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27  */
28
29 #include <msvcrt/fcntl.h>
30 #include <msvcrt/time.h>
31 #include <windows.h>
32 #include "tzfile.h"
33
34
35 /*
36  * @implemented
37  */
38 wchar_t* _wasctime(const struct tm* timeptr)
39 {
40 #ifdef __GNUC__
41   static const wchar_t wday_name[DAYSPERWEEK][3] = {
42     L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat"
43   };
44   static const wchar_t mon_name[MONSPERYEAR][3] = {
45     L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun",
46     L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"
47   };
48 #else
49   static const wchar_t wday_name[DAYSPERWEEK][4] = {
50     L"Sun", L"Mon", L"Tue", L"Wed", L"Thu", L"Fri", L"Sat"
51   };
52   static const wchar_t mon_name[MONSPERYEAR][4] = {
53     L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun",
54     L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec"
55   };
56 #endif
57   static wchar_t result[26];
58
59   (void)swprintf(result, L"%.3s %.3s%3d %02d:%02d:%02d %d\n",
60          wday_name[timeptr->tm_wday],
61          mon_name[timeptr->tm_mon],
62          timeptr->tm_mday, timeptr->tm_hour,
63          timeptr->tm_min, timeptr->tm_sec,
64          TM_YEAR_BASE + timeptr->tm_year);
65   return result;
66 }
67
68
69 /*
70  * @implemented
71  */
72 wchar_t* _wctime(const time_t* const timep)
73 {
74     return _wasctime(localtime(timep));
75 }