]> code.delx.au - gnu-emacs-elpa/blob - packages/notes-mode/strftime.c
Add notes-mode.
[gnu-emacs-elpa] / packages / notes-mode / strftime.c
1
2 /*
3 * strftime.c
4 * $Id: strftime.c,v 1.4 1999/01/28 19:26:29 johnh Exp $
5 *
6 * Copyright (C) 1996 by John Heidemann.
7 * Comments to <johnh@isi.edu>.
8 *
9 * This file is under the Gnu Public License, version 2.
10 * For details see the COPYING which accompanies this distribution.
11 *
12 */
13
14 #include <time.h>
15
16 void
17 usage()
18 {
19 printf ("usage: strftime format epoch_time\n");
20 printf ("\tThis program exists because Perl's POSIX loads in 880ms\n");
21 printf ("\twhile this program can run in ~20ms,\n");
22 printf ("\tand because some NT users find Perl's POSIX lacks strftime.\n");
23 exit (1);
24 }
25
26 main(argc, argv)
27 int argc;
28 char **argv;
29 {
30 #define SLEN 1024
31 char s[SLEN];
32 struct tm *tm;
33 time_t time;
34
35 if (argc != 3)
36 usage();
37 time = atol(argv[2]); /* sigh. Hope int==time_t */
38 tm = localtime(&time);
39 strftime(s, SLEN, argv[1], tm);
40 printf ("%s\n", s);
41 }