Update.
[glibc.git] / time / date.c
blobb809e6d632b073a9ac77e570917465b95411e928
1 /* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
19 #include <stddef.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <time.h>
25 /* Prints the date in the form "Day Mon dd hh:mm:ss ZZZ yyyy\n".
26 A simple test for localtime and strftime. */
27 int
28 main (argc, argv)
29 int argc;
30 char **argv;
32 time_t t = time (NULL);
33 struct tm *tp = localtime (&t);
34 char good = tp != NULL;
36 if (good)
38 char buf[BUFSIZ];
39 good = strftime (buf, sizeof (buf), "%a %b %d %X %Z %Y", tp);
40 if (good)
41 puts (buf);
42 else
43 perror ("strftime");
45 else
46 perror ("localtime");
48 return good ? EXIT_SUCCESS : EXIT_FAILURE;