aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Heuer1997-12-08 01:46:34 +0000
committerKarl Heuer1997-12-08 01:46:34 +0000
commited80a8e438420af031178a08c5dad5770cc9a2ef (patch)
tree1373b017296e1fac8734213ffffe5be2e58409de
parentea4496e6c5677a14100f3dc021cbd2d451d36839 (diff)
downloademacs-ed80a8e438420af031178a08c5dad5770cc9a2ef.tar.gz
emacs-ed80a8e438420af031178a08c5dad5770cc9a2ef.zip
(calendar-day-name): Truncate properly when
multibyte.
-rw-r--r--lisp/calendar/calendar.el14
1 files changed, 4 insertions, 10 deletions
diff --git a/lisp/calendar/calendar.el b/lisp/calendar/calendar.el
index 0713482bfd7..140759f9d86 100644
--- a/lisp/calendar/calendar.el
+++ b/lisp/calendar/calendar.el
@@ -2313,19 +2313,13 @@ If optional NODAY is t, does not ask for day, but just returns
2313(defun calendar-day-name (date &optional width absolute) 2313(defun calendar-day-name (date &optional width absolute)
2314 "Returns a string with the name of the day of the week of DATE. 2314 "Returns a string with the name of the day of the week of DATE.
2315If WIDTH is non-nil, return just the first WIDTH characters of the name. 2315If WIDTH is non-nil, return just the first WIDTH characters of the name.
2316If ABSOLUTE is non-nil, then DATE is actual the day-of-the-week 2316If ABSOLUTE is non-nil, then DATE is actually the day-of-the-week
2317rather than a date." 2317rather than a date."
2318 (let ((string (aref calendar-day-name-array 2318 (let ((string (aref calendar-day-name-array
2319 (if absolute date (calendar-day-of-week date))))) 2319 (if absolute date (calendar-day-of-week date)))))
2320 (if width 2320 (cond ((null width) string)
2321 (let ((i 0) (result "") (pos 0)) 2321 (enable-multibyte-characters (truncate-string-to-width string width))
2322 (while (< i width) 2322 (t (substring string 0 width)))))
2323 (let ((chartext (char-to-string (sref string pos))))
2324 (setq pos (+ pos (length chartext)))
2325 (setq result (concat result chartext)))
2326 (setq i (1+ i)))
2327 result)
2328 string)))
2329 2323
2330(defvar calendar-day-name-array 2324(defvar calendar-day-name-array
2331 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"]) 2325 ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"])