]>
git.zerfleddert.de Git - micropolis/blob - src/tclx/src/tclxcclk.c
4 * Contains the TCL convertclock command. This is in a module seperate
5 * from clock so that it can be excluded, along with the yacc generated code,
6 * since its rather large.
7 *-----------------------------------------------------------------------------
8 * Copyright 1992 Karl Lehenbauer and Mark Diekhans.
10 * Permission to use, copy, modify, and distribute this software and its
11 * documentation for any purpose and without fee is hereby granted, provided
12 * that the above copyright notice appear in all copies. Karl Lehenbauer and
13 * Mark Diekhans make no representations about the suitability of this
14 * software for any purpose. It is provided "as is" without express or
16 *-----------------------------------------------------------------------------
17 * $Id: tclXcnvclock.c,v 2.1 1992/11/07 22:23:03 markd Exp $
18 *-----------------------------------------------------------------------------
26 *-----------------------------------------------------------------------------
28 * Tcl_ConvertclockCmd --
29 * Implements the TCL convertclock command:
30 * convertclock dateString [GMT|{}]
33 * Standard TCL results.
35 *-----------------------------------------------------------------------------
38 Tcl_ConvertclockCmd (clientData
, interp
, argc
, argv
)
39 ClientData clientData
;
46 struct tm
*timeDataPtr
;
49 if ((argc
< 2) || (argc
> 4)) {
50 Tcl_AppendResult (interp
, tclXWrongArgs
, argv
[0],
51 " dateString [GMT|{}] [baseclock]", (char *) NULL
);
55 if (Tcl_GetLong (interp
, argv
[3], &baseClock
) != TCL_OK
)
60 if ((argc
> 2) && (argv
[2][0] != '\0')) {
61 if (!STREQU (argv
[2], "GMT")) {
62 Tcl_AppendResult (interp
, "invalid argument: expected `GMT', ",
63 "got : `", argv
[2], "'", (char *) NULL
);
66 zone
= 0; /* Zero minutes from GMT */
68 timeDataPtr
= localtime (&baseClock
);
70 * Get the minutes east of GMT.
73 zone
= -(timeDataPtr
->tm_gmtoff
/ 60);
75 #ifdef TCL_TIMEZONE_VAR
78 #if !defined(TCL_TM_GMTOFF) && !defined(TCL_TIMEZONE_VAR)
79 zone
= timeDataPtr
->tm_tzadj
/ 60;
83 clockVal
= Tcl_GetDate (argv
[1], baseClock
, zone
);
85 Tcl_AppendResult (interp
, "Unable to convert date-time string \"",
86 argv
[1], "\"", (char *) NULL
);
89 sprintf (interp
->result
, "%ld", clockVal
);