1/*
2 * Copyright (c) 2002-3, Intel Corporation. All rights reserved.
3 * Created by:  salwan.searty REMOVE-THIS AT intel DOT com
4 * This file is licensed under the GPL license.  For the full content
5 * of this license, see the COPYING file at the top level of this
6 * source tree.
7
8The asctime() function shall convert the broken-down time in the structure pointed to by timeptr into a string in the form: Sun Sep 16 01:03:52 1973\n\0
9
10
11
12 */
13
14#define WEEKDAY 0
15#define MONTH 8
16#define MONTHDAY 16
17#define HOUR 1
18#define MINUTE 3
19#define SECOND 52
20#define YEAR 73
21
22#include <string.h>
23#include <time.h>
24#include <stdio.h>
25#include <stdlib.h>
26#include <unistd.h>
27#include "posixtest.h"
28
29int main()
30{
31	struct tm time_ptr;
32
33	char expected[26];
34	char* real;
35
36	char wday_name[7][3] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
37
38	char mon_name[12][3] = {
39		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
40		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
41	};
42
43	time_ptr.tm_wday = WEEKDAY;
44	time_ptr.tm_mon = MONTH;
45	time_ptr.tm_mday = MONTHDAY;
46	time_ptr.tm_hour = HOUR;
47	time_ptr.tm_min = MINUTE;
48	time_ptr.tm_sec = SECOND;
49	time_ptr.tm_year = YEAR;
50
51	real = asctime(&time_ptr);
52
53	sprintf(expected, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
54	        wday_name[time_ptr.tm_wday],
55	        mon_name[time_ptr.tm_mon],
56	        time_ptr.tm_mday, time_ptr.tm_hour,
57	        time_ptr.tm_min, time_ptr.tm_sec,
58	        1900 + time_ptr.tm_year);
59
60	printf("real = %s\n", real);
61	printf("expected = %s\n", expected);
62
63	if (strcmp(real, expected) != 0) {
64		perror("asctime did not return the correct value\n");
65	        printf("Got %s\n", real);
66	        printf("Expected %s\n", expected);
67		return PTS_FAIL;
68	}
69
70	printf("Test PASSED\n");
71	return PTS_PASS;
72}
73
74