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

[mhc:01908] mhc2palm で最後の月曜日をあつかう



定期的なミーティングで
   月の最後の月曜日
というのが追加になったのですが
mhc2plamが失敗します。

ファイルはこんなかんじです。
    X-SC-Subject: 会議
    X-SC-Location: 
    X-SC-Day: 
    X-SC-Time: 10:00-11:00
    X-SC-Category: 
    X-SC-Priority: 
    X-SC-Cond: last Mon
    X-SC-Duration: 20040531-
    X-SC-Alarm: 

とりあえずのパッチをつくりました。
#このパッチには mhc2palm -Aと-Bオプションが追加されています。

---begin
Index: mhc2palm.in
===================================================================
RCS file: /cvsroot/mhc/mhc2palm.in,v
retrieving revision 1.6
diff -p -c -r1.6 mhc2palm.in
*** mhc2palm.in	2001/09/13 05:15:17	1.6
--- mhc2palm.in	2004/05/17 09:59:00
*************** require 'mhc-schedule'
*** 21,27 ****
  
  def usage
    print '
! usage: mhc2palm [-a | -i] [-n] [-d dev] [-r dir] [YYYYMMDD-yyyymmdd]
  
    mhc2palm -- Add/Copy mhc articles to a palm.
  
--- 21,27 ----
  
  def usage
    print '
! usage: mhc2palm [-a | -i] [-n] [-d dev] [-r dir] [-A mon] [-B mon] [YYYYMMDD-yyyymmdd]
  
    mhc2palm -- Add/Copy mhc articles to a palm.
  
*************** usage: mhc2palm [-a | -i] [-n] [-d dev] 
*** 35,40 ****
--- 35,42 ----
               default value is /dev/pilot
      -r dir : Set repository directory of the mhc.
               ~/Mail/schedule
+     -A mon : XXX
+     -B mon : XXX
  
      YYYYMMDD-yyyymmdd : set a start and end date of scanning mhc.
                          if omitted, scan from 3 months ago to
*************** end
*** 69,74 ****
--- 71,77 ----
  $flag_verbose = false
  $flag_noharm, $flag_append, $flag_install = false, false, false
  $flag_device, $flag_from, $flag_to = '/dev/pilot', nil, nil
+ $flag_before, $flag_after = -3, 3
  $flag_dir = File .expand_path("~/Mail/schedule")
  
  while ARGV .length > 0
*************** while ARGV .length > 0
*** 87,92 ****
--- 90,101 ----
    when '-r'
      ARGV .shift
      $flag_dir = ARGV[0]
+   when '-A'
+     ARGV .shift
+     $flag_after = ARGV[0] . to_i
+   when '-B'
+     ARGV .shift
+     $flag_before = - (ARGV[0] . to_i)
    when /^(\d{8})-(\d{8})$/
      $flag_from, $flag_to = MhcDate .new($1), MhcDate .new($2)
    else
*************** while ARGV .length > 0
*** 95,102 ****
    ARGV .shift
  end
  
! $flag_from = MhcDate .new .m_succ!(-3) if !$flag_from
! $flag_to   = MhcDate .new .m_succ!(+3) if !$flag_to
  
  usage() if !($flag_append || $flag_install) || ($flag_append && $flag_install)
  
--- 104,112 ----
    ARGV .shift
  end
  
! usage() if ($flag_before >= $flag_after)
! $flag_from = MhcDate .new .m_succ!($flag_before) if !$flag_from
! $flag_to   = MhcDate .new .m_succ!($flag_after) if !$flag_to
  
  usage() if !($flag_append || $flag_install) || ($flag_append && $flag_install)
  
Index: ruby-ext/lib/mhc-date.rb
===================================================================
RCS file: /cvsroot/mhc/ruby-ext/lib/mhc-date.rb,v
retrieving revision 1.6
diff -p -c -r1.6 mhc-date.rb
*** ruby-ext/lib/mhc-date.rb	2004/01/12 10:24:38	1.6
--- ruby-ext/lib/mhc-date.rb	2004/05/17 09:59:00
*************** class MhcDate
*** 59,65 ****
    include Comparable
  
    D_TABLE  = [0, 306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275]
!   O_LABEL  = %w(1st 2nd 3rd 4th 5th last)
    M_LABEL  = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
    W_LABEL  = %w(Sun Mon Tue Wed Thu Fri Sat)
    W_JLABEL = %w(日 月 火 水 木 金 土)
--- 59,65 ----
    include Comparable
  
    D_TABLE  = [0, 306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275]
!   O_LABEL  = %w(1st 2nd 3rd 4th 5th Last)
    M_LABEL  = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
    W_LABEL  = %w(Sun Mon Tue Wed Thu Fri Sat)
    W_JLABEL = %w(日 月 火 水 木 金 土)
Index: ruby-ext/lib/mhc-palm.rb
===================================================================
RCS file: /cvsroot/mhc/ruby-ext/lib/mhc-palm.rb,v
retrieving revision 1.9
diff -p -c -r1.9 mhc-palm.rb
*** ruby-ext/lib/mhc-palm.rb	2003/10/29 12:48:13	1.9
--- ruby-ext/lib/mhc-palm.rb	2004/05/17 09:59:00
*************** class PilotApptRecord < PilotRecord
*** 509,515 ****
    ## 01       -- by date
    ## duration_b - duration_e まで
    ##
!   ## ord  .. 0 - 4 の整数 1st, 2nd, 3rd, 4th, Last に対応
    ## wek  .. 0 - 6 の整数 Sun, ... ,Sat            に対応
    ##
    def set_monthly_by_day(beg, fin, freq, ord, wek)
--- 509,515 ----
    ## 01       -- by date
    ## duration_b - duration_e まで
    ##
!   ## ord  .. 0 - 5 の整数 1st, 2nd, 3rd, 4th, 5th, Last に対応
    ## wek  .. 0 - 6 の整数 Sun, ... ,Sat            に対応
    ##
    def set_monthly_by_day(beg, fin, freq, ord, wek)
*************** class PilotApptRecord < PilotRecord
*** 517,526 ****
      set_frequency(freq)    ## freq     の型チェックもする
  
      ## beg の日付が ord, week を満たしているかのチェックが必要
!     msg = "Type/ange error: (0< ord <4, 0< wek <6) required. (#{ord}, #{wek})"
!     raise msg if !(ord .is_a?(Integer) && 0 <= ord && ord <= 4)
      raise msg if !(wek .is_a?(Integer) && 0 <= wek && wek <= 6)
!     raise msg if !((ord == 4 && beg .o_last?) || (ord < 4  && beg .o == ord))
  
      @repeatDay  = ord * 7 + wek
      @repeatType = 3
--- 517,526 ----
      set_frequency(freq)    ## freq     の型チェックもする
  
      ## beg の日付が ord, week を満たしているかのチェックが必要
!     msg = "Type/Range error: (0< ord <5, 0< wek <6) required. (#{ord}, #{wek})"
!     raise msg if !(ord .is_a?(Integer) && 0 <= ord && ord <= 5)
      raise msg if !(wek .is_a?(Integer) && 0 <= wek && wek <= 6)
!     raise msg if !((ord == 5 && beg .o_last?) || (ord < 5  && beg .o == ord))
  
      @repeatDay  = ord * 7 + wek
      @repeatType = 3
---end


あと気づいたのは、春分の日など
X-SC-Dayベタ書きしてある予定が
2031年まで全部Palmに転送されてしまうことです。

--
鯉江英隆 <hide@xxxxxxxx>