summaryrefslogtreecommitdiff
path: root/cups/string.c
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2014-05-22 13:54:15 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2014-05-22 13:54:15 +0000
commit554aa7b74970cc720302f38c819a309a5a6ede68 (patch)
tree00034ea1c955312bae68667e5a5c3b0fce920f28 /cups/string.c
parentcf3d4dd6dc3e66f48c6d6453843ffa3eebe7a499 (diff)
Dates in non-UTF-8 locales did not display correctly (STR #4388)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11889 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'cups/string.c')
-rw-r--r--cups/string.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/cups/string.c b/cups/string.c
index ce5d9e987..19d1224f4 100644
--- a/cups/string.c
+++ b/cups/string.c
@@ -20,10 +20,7 @@
*/
#define _CUPS_STRING_C_
-#include "string-private.h"
-#include "debug-private.h"
-#include "thread-private.h"
-#include "array.h"
+#include "cups-private.h"
#include <stddef.h>
#include <limits.h>
@@ -145,6 +142,39 @@ _cupsStrAlloc(const char *s) /* I - String */
/*
+ * '_cupsStrDate()' - Return a localized date for a given time value.
+ *
+ * This function works around the locale encoding issues of strftime...
+ */
+
+char * /* O - Buffer */
+_cupsStrDate(char *buf, /* I - Buffer */
+ size_t bufsize, /* I - Size of buffer */
+ time_t timeval) /* I - Time value */
+{
+ struct tm *dateval; /* Local date/time */
+ char temp[1024]; /* Temporary buffer */
+ _cups_globals_t *cg = _cupsGlobals(); /* Per-thread globals */
+
+
+ if (!cg->lang_default)
+ cg->lang_default = cupsLangDefault();
+
+ dateval = localtime(&timeval);
+
+ if (cg->lang_default->encoding != CUPS_UTF8)
+ {
+ strftime(temp, sizeof(temp), "%c", dateval);
+ cupsCharsetToUTF8((cups_utf8_t *)buf, temp, (int)bufsize, cg->lang_default->encoding);
+ }
+ else
+ strftime(buf, bufsize, "%c", dateval);
+
+ return (buf);
+}
+
+
+/*
* '_cupsStrFlush()' - Flush the string pool.
*/