]>
cvs.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 *-----------------------------------------------------------------------------
39 ClientData clientData
,
47 struct tm
*timeDataPtr
;
50 if ((argc
< 2) || (argc
> 4)) {
51 Tcl_AppendResult (interp
, tclXWrongArgs
, argv
[0],
52 " dateString [GMT|{}] [baseclock]", (char *) NULL
);
56 if (Tcl_GetLong (interp
, argv
[3], &baseClock
) != TCL_OK
)
61 if ((argc
> 2) && (argv
[2][0] != '\0')) {
62 if (!STREQU (argv
[2], "GMT")) {
63 Tcl_AppendResult (interp
, "invalid argument: expected `GMT', ",
64 "got : `", argv
[2], "'", (char *) NULL
);
67 zone
= 0; /* Zero minutes from GMT */
69 timeDataPtr
= localtime (&baseClock
);
71 * Get the minutes east of GMT.
74 zone
= -(timeDataPtr
->tm_gmtoff
/ 60);
76 #ifdef TCL_TIMEZONE_VAR
79 #if !defined(TCL_TM_GMTOFF) && !defined(TCL_TIMEZONE_VAR)
80 zone
= timeDataPtr
->tm_tzadj
/ 60;
84 clockVal
= Tcl_GetDate (argv
[1], baseClock
, zone
);
86 Tcl_AppendResult (interp
, "Unable to convert date-time string \"",
87 argv
[1], "\"", (char *) NULL
);
90 sprintf (interp
->result
, "%ld", clockVal
);