diff options
Diffstat (limited to 'unix/tclUnixTime.c')
-rw-r--r-- | unix/tclUnixTime.c | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/unix/tclUnixTime.c b/unix/tclUnixTime.c index b330d84..02a1570 100644 --- a/unix/tclUnixTime.c +++ b/unix/tclUnixTime.c @@ -9,7 +9,7 @@ * 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.2 1998/09/14 18:40:18 stanton Exp $ + * RCS: @(#) $Id: tclUnixTime.c,v 1.3 1999/03/10 05:52:53 stanton Exp $ */ #include "tclInt.h" @@ -234,3 +234,61 @@ TclpGetTime(timePtr) timePtr->sec = tv.tv_sec; timePtr->usec = tv.tv_usec; } + +/* + *---------------------------------------------------------------------- + * + * TclpGetDate -- + * + * This function converts between seconds and struct tm. If + * useGMT is true, then the returned date will be in Greenwich + * Mean Time (GMT). Otherwise, it will be in the local time zone. + * + * Results: + * Returns a static tm structure. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +struct tm * +TclpGetDate(time, useGMT) + TclpTime_t time; + int useGMT; +{ + const time_t *tp = (const time_t *)time; + + if (useGMT) { + return gmtime(tp); + } else { + return localtime(tp); + } +} + +/* + *---------------------------------------------------------------------- + * + * TclStrftime -- + * + * On Unix, we can safely call the native strftime implementation. + * + * Results: + * The normal strftime result. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +size_t +TclStrftime(s, maxsize, format, t) + char *s; + size_t maxsize; + const char *format; + const struct tm *t; +{ + return strftime(s, maxsize, format, t); +} |