comparison lisp/calendar/calendar.el @ 20429:ad8d3c6d3d94

(calendar-day-name): Truncate properly when multibyte.
author Karl Heuer <kwzh@gnu.org>
date Mon, 08 Dec 1997 01:46:34 +0000
parents f767d29550d7
children d179de7ad92e
comparison
equal deleted inserted replaced
20428:7351dc9f1c94 20429:ad8d3c6d3d94
2311 (- mon2 mon1))) 2311 (- mon2 mon1)))
2312 2312
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.
2315 If WIDTH is non-nil, return just the first WIDTH characters of the name. 2315 If WIDTH is non-nil, return just the first WIDTH characters of the name.
2316 If ABSOLUTE is non-nil, then DATE is actual the day-of-the-week 2316 If ABSOLUTE is non-nil, then DATE is actually the day-of-the-week
2317 rather than a date." 2317 rather 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"])
2332 2326
2333 (defvar calendar-month-name-array 2327 (defvar calendar-month-name-array