[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[mhc:02001] Re: guess error



野口です。

以前、[mhc:01404] でリクエストをしていた下記の件につきまして、

>>    4:00-8:00
>> という時刻に対して、
>>   16:00-08:00
>> となります。4:00 -> 16:00 となる分には問題ないのですが、このような場合
>> に、終了時刻のほうも 12 時間分を加算するようにならないでしょうか。

添付のような変更を加えてみました。
mhc-current-snap20041220 への差分です。

ご検討いただければ幸いです。

# コード的には美しくありません。
-- 
NOGUCHI Yusuke 
nogunogu@xxxxxxxxxxxxxxxxx


*** mhc-guess.el.org	Thu Oct 28 17:39:10 2004
--- mhc-guess.el	Thu Dec 30 19:43:59 2004
***************
*** 495,502 ****
  
  (defun mhc-guess/make-time-from-hhmm 
    (now hh-str mm-str hh-str2 mm-str2 &optional relative)
!   (let ((start (mhc-guess/make-time-from-hhmm2 hh-str mm-str))
! 	(end   (mhc-guess/make-time-from-hhmm2 hh-str2 mm-str2 relative)))
      (cond
       ((null start)
        nil)
--- 495,505 ----
  
  (defun mhc-guess/make-time-from-hhmm 
    (now hh-str mm-str hh-str2 mm-str2 &optional relative)
!   (let (start end revise tmp)
!     (setq tmp (mhc-guess/make-time-from-hhmm2 hh-str mm-str))
!     (setq start (car tmp))
!     (setq revise (cdr tmp))
!     (setq end (car (mhc-guess/make-time-from-hhmm2 hh-str2 mm-str2 relative)))
      (cond
       ((null start)
        nil)
***************
*** 505,526 ****
       (relative
        (cons start (mhc-time+ start end)))
       (t
        (cons start end)))))
  
  (defun mhc-guess/make-time-from-hhmm2 (hh-str mm-str &optional relative)
!   (let (xHH xMM)
      (if (null hh-str)
! 	nil  ;; retun value
  
        (setq xHH (mhc-guess/string-to-int hh-str))
        (if (and (not relative) (< xHH 8)) ;; 8 depends on my life style.
! 	  (setq xHH (+ xHH 12)))
        (setq xMM 
  	    (cond
  	     ((not mm-str)	     0)
! 	   ((string= mm-str "半")    30)
! 	   (t                        (mhc-guess/string-to-int mm-str))))
!       (mhc-time-new xHH xMM t))))
  
  ;;
  ;; make location from string
--- 508,533 ----
       (relative
        (cons start (mhc-time+ start end)))
       (t
+       (if revise
+ 	  (setq end (+ end (* 12 60))))
        (cons start end)))))
  
  (defun mhc-guess/make-time-from-hhmm2 (hh-str mm-str &optional relative)
!   (let (xHH xMM (revice nil))
      (if (null hh-str)
! 	(cons nil revice)  ;; retun value
  
        (setq xHH (mhc-guess/string-to-int hh-str))
        (if (and (not relative) (< xHH 8)) ;; 8 depends on my life style.
! 	  (progn
! 	   (setq xHH (+ xHH 12))
! 	   (setq revice t)))
        (setq xMM 
  	    (cond
  	     ((not mm-str)	     0)
! 	     ((string= mm-str "半")    30)
! 	     (t                        (mhc-guess/string-to-int mm-str))))
!       (cons (mhc-time-new xHH xMM t) revice))))
  
  ;;
  ;; make location from string