summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixTime.c
diff options
context:
space:
mode:
authorericm <ericm>2000-01-14 22:15:51 (GMT)
committerericm <ericm>2000-01-14 22:15:51 (GMT)
commit35d4ffd9a74d652788b42a6c8300dbf3c2a62eb6 (patch)
treebe858120ee7933f92e52d0b4138f6d4636c6f151 /unix/tclUnixTime.c
parent72978d2b3dc58e62e08e27987a2ad2fbe01e04d9 (diff)
downloadtcl-35d4ffd9a74d652788b42a6c8300dbf3c2a62eb6.zip
tcl-35d4ffd9a74d652788b42a6c8300dbf3c2a62eb6.tar.gz
tcl-35d4ffd9a74d652788b42a6c8300dbf3c2a62eb6.tar.bz2
* unix/tclUnixTime.c: New clock format format.
* compat/strftime.c: New clock format format. * generic/tclGetDate.y: New clock scan format.
Diffstat (limited to 'unix/tclUnixTime.c')
-rw-r--r--unix/tclUnixTime.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/unix/tclUnixTime.c b/unix/tclUnixTime.c
index c1a9161..9990aad 100644
--- a/unix/tclUnixTime.c
+++ b/unix/tclUnixTime.c
@@ -9,11 +9,13 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixTime.c,v 1.6 1999/07/22 01:26:19 redman Exp $
+ * RCS: @(#) $Id: tclUnixTime.c,v 1.7 2000/01/14 22:15:52 ericm Exp $
*/
#include "tclInt.h"
#include "tclPort.h"
+#define TM_YEAR_BASE 1900
+#define IsLeapYear(x) ((x % 4 == 0) && (x % 100 != 0 || x % 400 == 0))
/*
*-----------------------------------------------------------------------------
@@ -295,5 +297,14 @@ TclpStrftime(s, maxsize, format, t)
CONST char *format;
CONST struct tm *t;
{
+ if (format[0] == '%' && format[1] == 'Q') {
+ /* Format as a stardate */
+ sprintf(s, "Stardate %2d%03d.%01d",
+ (((t->tm_year + TM_YEAR_BASE) + 377) - 2323),
+ (((t->tm_yday + 1) * 1000) /
+ (365 + IsLeapYear((t->tm_year + TM_YEAR_BASE)))),
+ (((t->tm_hour * 60) + t->tm_min)/144));
+ return(strlen(s));
+ }
return strftime(s, maxsize, format, t);
}