Changeset 6736 for lang/vim

Show
Ignore:
Timestamp:
02/15/08 18:30:26 (10 months ago)
Author:
mattn
Message:

lang/vim/calendar/calendar.vim:
fixed problem of week number on 03/01/2008.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/vim/calendar/calendar.vim

    r3719 r6736  
    33" File: calendar.vim 
    44" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com> 
    5 " Last Change: Wed, 25 Jul 2007 
    6 " Version: 1.6 
     5" Last Change: Fri, 15 Feb 2008 
     6" Version: 1.7 
    77" Thanks: 
     8"     Per Winkvist                  : bug fix 
    89"     Serge (gentoosiast) Koksharov : bug fix 
    910"     Vitor Antunes                 : bug fix 
     
    5354"       show horizontal calendar ... 
    5455" ChangeLog: 
     56"     1.7  : bug fix, week number was broken on 2008. 
    5557"     1.6  : added calendar_begin action. 
    5658"            added calendar_end action. 
    5759"     1.5  : bug fix, fixed ruler formating with strpart. 
    5860"            bug fix, using winfixheight. 
    59 "     1.4a : bug fix, week numbenr was broken on 2005. 
     61"     1.4a : bug fix, week number was broken on 2005. 
    6062"            added calendar_today action. 
    6163"            bug fix, about wrapscan. 
     
    302304" GetLatestVimScripts: 52 1 :AutoInstall: calendar.vim 
    303305 
    304 let g:calendar_version = "1.6" 
     306let g:calendar_version = "1.7" 
    305307if &compatible 
    306308  finish 
     
    504506  "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
    505507  " remember today 
    506   " divide strftime('%d') by 1 so as to get "1, 2,3 .. 9" instead of "01, 02, 03 .. 09" 
     508  " divide strftime('%d') by 1 so as to get "1,2,3 .. 9" instead of "01, 02, 03 .. 09" 
    507509  let vtoday = strftime('%Y').strftime('%m').strftime('%d') 
    508510 
     
    557559    if vmnth == 1 
    558560      let vmdays = 31 
    559       let vparam = 0 
     561      let vparam = 1 
    560562      let vsmnth = 'Jan' 
    561563    elseif vmnth == 2 
    562564      let vmdays = 28 
    563       let vparam = 31 
     565      let vparam = 32 
    564566      let vsmnth = 'Feb' 
    565567    elseif vmnth == 3 
    566568      let vmdays = 31 
    567       let vparam = 59 
     569      let vparam = 60 
    568570      let vsmnth = 'Mar' 
    569571    elseif vmnth == 4 
    570572      let vmdays = 30 
    571       let vparam = 90 
     573      let vparam = 91 
    572574      let vsmnth = 'Apr' 
    573575    elseif vmnth == 5 
    574576      let vmdays = 31 
    575       let vparam = 120 
     577      let vparam = 121 
    576578      let vsmnth = 'May' 
    577579    elseif vmnth == 6 
    578580      let vmdays = 30 
    579       let vparam = 151 
     581      let vparam = 152 
    580582      let vsmnth = 'Jun' 
    581583    elseif vmnth == 7 
    582584      let vmdays = 31 
    583       let vparam = 181 
     585      let vparam = 182 
    584586      let vsmnth = 'Jul' 
    585587    elseif vmnth == 8 
    586588      let vmdays = 31 
    587       let vparam = 212 
     589      let vparam = 213 
    588590      let vsmnth = 'Aug' 
    589591    elseif vmnth == 9 
    590592      let vmdays = 30 
    591       let vparam = 243 
     593      let vparam = 244 
    592594      let vsmnth = 'Sep' 
    593595    elseif vmnth == 10 
    594596      let vmdays = 31 
    595       let vparam = 273 
     597      let vparam = 274 
    596598      let vsmnth = 'Oct' 
    597599    elseif vmnth == 11 
    598600      let vmdays = 30 
    599       let vparam = 304 
     601      let vparam = 305 
    600602      let vsmnth = 'Nov' 
    601603    elseif vmnth == 12 
    602604      let vmdays = 31 
    603       let vparam = 334 
     605      let vparam = 335 
    604606      let vsmnth = 'Dec' 
    605607    else 
     
    607609      return 
    608610    endif 
     611    if vyear % 400 == 0 
     612      if vmnth == 2 
     613        let vmdays = 29 
     614      elseif vmnth >= 3 
     615        let vparam = vparam + 1 
     616      endif 
     617    elseif vyear % 100 == 0 
     618      if vmnth == 2 
     619        let vmdays = 28 
     620      endif 
     621    elseif vyear % 4 == 0 
     622      if vmnth == 2 
     623        let vmdays = 29 
     624      elseif vmnth >= 3 
     625        let vparam = vparam + 1 
     626      endif 
     627    endif 
    609628 
    610629    " calc vnweek of the day 
    611630    if vnweek == -1 
    612       let vnweek = ( vyear * 365 ) + vparam + 1 
     631      let vnweek = ( vyear * 365 ) + vparam 
    613632      let vnweek = vnweek + ( vyear/4 ) - ( vyear/100 ) + ( vyear/400 ) 
    614       if vmnth < 3 && vyear % 4 == 0 
     633      if vyear % 4 == 0 
    615634        if vyear % 100 != 0 || vyear % 400 == 0 
    616635          let vnweek = vnweek - 1 
     
    618637      endif 
    619638      let vnweek = vnweek - 1 
    620     endif 
    621     if vmnth == 2 
    622       if vyear % 400 == 0 
    623         let vmdays = 29 
    624       elseif vyear % 100 == 0 
    625         let vmdays = 28 
    626       elseif vyear % 4 == 0 
    627         let vmdays = 29 
    628       endif 
    629639    endif 
    630640 
     
    644654    elseif exists('g:calendar_weeknm') 
    645655      " if given g:calendar_weeknm, show week number(ref:ISO8601) 
    646       let viweek = (vparam + 1) / 7 
    647       let vfweek = (vparam + 1) % 7 
     656      let viweek = vparam / 7 
     657      let vfweek = vparam % 7 
    648658      if vnweek == 0 
    649659        let vfweek = vfweek - 7 
     
    670680      endif 
    671681      let vcolumn = vcolumn + 5 
    672       if ((vyear % 4 == 0 && vmnth >= 3) || (vyear-1) % 4 == 0) 
    673         let viweek = viweek + 1 
    674       endif 
    675682    endif 
    676683 
     
    12161223"***************************************************************** 
    12171224function! s:CalendarHelp() 
     1225  echohl None 
     1226  echo 'Calendar version ' . g:calendar_version 
    12181227  echohl SpecialKey 
    12191228  echo '<s-left>  : goto prev month'