]>
cvs.zerfleddert.de Git - micropolis/blob - src/tclx/src/tclxclck.c
4 * Contains the TCL time and date related commands.
5 *-----------------------------------------------------------------------------
6 * Copyright 1992 Karl Lehenbauer and Mark Diekhans.
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation for any purpose and without fee is hereby granted, provided
10 * that the above copyright notice appear in all copies. Karl Lehenbauer and
11 * Mark Diekhans make no representations about the suitability of this
12 * software for any purpose. It is provided "as is" without express or
14 *-----------------------------------------------------------------------------
15 * $Id: tclXclock.c,v 2.0 1992/10/16 04:50:28 markd Rel $
16 *-----------------------------------------------------------------------------
24 *-----------------------------------------------------------------------------
27 * Implements the TCL getclock command:
31 * Standard TCL results.
33 *-----------------------------------------------------------------------------
36 Tcl_GetclockCmd (clientData
, interp
, argc
, argv
)
37 ClientData clientData
;
43 Tcl_AppendResult (interp
, tclXWrongArgs
, argv
[0], (char *) NULL
);
46 sprintf (interp
->result
, "%ld", time ((long *) NULL
));
51 *-----------------------------------------------------------------------------
54 * Implements the TCL fmtclock command:
55 * fmtclock clockval [format] [GMT|{}]
58 * Standard TCL results.
60 *-----------------------------------------------------------------------------
63 Tcl_FmtclockCmd (clientData
, interp
, argc
, argv
)
64 ClientData clientData
;
72 struct tm
*timeDataPtr
;
75 if ((argc
< 2) || (argc
> 4)) {
76 Tcl_AppendResult (interp
, tclXWrongArgs
, argv
[0],
77 " clockval [format] [GMT|{}]", (char *) NULL
);
81 if (Tcl_GetLong (interp
, argv
[1], &clockVal
) != TCL_OK
)
83 if ((argc
== 4) && (argv
[3][0] != '\0')) {
84 if (!STREQU (argv
[3], "GMT")) {
85 Tcl_AppendResult (interp
, "expected \"GMT\" or {} got \"",
86 argv
[3], "\"", (char *) NULL
);
92 if ((argc
>= 3) && (argv
[2][0] != '\0'))
95 format
= "%a %b %d %X %Z %Y";
98 timeDataPtr
= gmtime (&clockVal
);
100 timeDataPtr
= localtime (&clockVal
);
102 fmtError
= strftime (interp
->result
, TCL_RESULT_SIZE
, format
,
105 Tcl_AppendResult (interp
, "error formating time", (char *) NULL
);