diff options
| author | Kevin B Kenny <kennykb@acm.org> | 2003-05-18 19:48:25 (GMT) | 
|---|---|---|
| committer | Kevin B Kenny <kennykb@acm.org> | 2003-05-18 19:48:25 (GMT) | 
| commit | a7ae75e85360445c96accf3acfc542dbe4e60519 (patch) | |
| tree | 51b5e23a67cd4e57f7e7c0df5dd394a956f99f28 /unix/tclUnixTime.c | |
| parent | b8ab7934b3d5103f68277fb3671b30d22876303c (diff) | |
| download | tcl-a7ae75e85360445c96accf3acfc542dbe4e60519.zip tcl-a7ae75e85360445c96accf3acfc542dbe4e60519.tar.gz tcl-a7ae75e85360445c96accf3acfc542dbe4e60519.tar.bz2 | |
	* compat/strftime.c:  Modified TclpStrftime to return its
	* generic/tclClock.c: result in UTF-8 encoding, and removed
	* mac/tclMacTime.c:   the conversion from system encoding to
	* unix/tclUnixTime.c: UTF-8 from [clock format]. Needed to
	* win/tclWinTime.c:   avoid double conversion of the timezone
	                      name on Windows systems. [Bug 624408]
Diffstat (limited to 'unix/tclUnixTime.c')
| -rw-r--r-- | unix/tclUnixTime.c | 33 | 
1 files changed, 23 insertions, 10 deletions
| diff --git a/unix/tclUnixTime.c b/unix/tclUnixTime.c index fc72f35..77af9b1 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.15 2002/07/19 12:31:10 dkf Exp $ + * RCS: @(#) $Id: tclUnixTime.c,v 1.16 2003/05/18 19:48:27 kennykb Exp $   */  #include "tclInt.h" @@ -308,22 +308,26 @@ TclpGetDate(time, useGMT)   *	and also ignore the useGMT parameter.   *   * Results: - *	The normal strftime result. + *	Returns the number of Unicode code points in the result string. + *   *   * Side effects: - *	None. + *	Stores the converted time in the buffer designated by the + *	's' parameter.   *   *----------------------------------------------------------------------   */  size_t  TclpStrftime(s, maxsize, format, t, useGMT) -    char *s; -    size_t maxsize; -    CONST char *format; -    CONST struct tm *t; -    int useGMT; +    char *s;			/* Buffer to receive the formatted string */ +    size_t maxsize;		/* Allocated length of the buffer */ +    CONST char *format;		/* Format to use for the conversion */ +    CONST struct tm *t;		/* Time to convert */ +    int useGMT;			/* Flag == 1 if converting in UTC */  { +    Tcl_DString utf8Buffer; +    size_t status;      if (format[0] == '%' && format[1] == 'Q') {  	/* Format as a stardate */  	sprintf(s, "Stardate %2d%03d.%01d", @@ -332,9 +336,18 @@ TclpStrftime(s, maxsize, format, t, useGMT)  			(365 + IsLeapYear((t->tm_year + TM_YEAR_BASE)))),  		(((t->tm_hour * 60) + t->tm_min)/144));  	return(strlen(s)); +    } else { +	setlocale(LC_TIME, ""); +	status = strftime(s, maxsize, format, t); +	if ( status > 0 ) { +	    Tcl_DStringInit ( &utf8Buffer ); +	    Tcl_ExternalToUtfDString( NULL, s, status, &utf8Buffer ); +	    strcpy( s, Tcl_DStringValue( &utf8Buffer ) ); +	    Tcl_DStringFree( &utf8buffer ); +	} +	return status;      } -    setlocale(LC_TIME, ""); -    return strftime(s, maxsize, format, t); +  }  /* | 
