 - ;;;返回指定年份的总天数
- (defun dt-dates (oneyear)
- (if (numberp oneyear)
- (if (= 0 (rem oneyear 4))
- (if (= 0 (rem oneyear 100))
- (if (= 0 (rem oneyear 400))
- 366
- 365
- )
- 366
- )
- 365
- )
- )
- )
- ;;;返回指定年份每个月和对应的天数的关联表
- (defun dt-everyMonth-list (spacYear)
- (list
- (cons 1 31)
- (cons 2
- (if (= 0 (rem spacYear 4))
- (if (= 0 (rem spacYear 100))
- (if (= 0 (rem spacYear 400))
- 29
- 28
- )
- 29
- )
- 28
- )
- )
- (cons 3 31)
- (cons 4 30)
- (cons 5 31)
- (cons 6 30)
- (cons 7 31)
- (cons 8 31)
- (cons 9 30)
- (cons 10 31)
- (cons 11 30)
- (cons 12 31)
- )
- )
- ;;;返回指定日期是当年的第几天
- ;;;spyear 指定年份
- ;;;spmonth 指定月份
- ;;;spdate 指定日期
- (defun dt-nthdate (spyear spmonth spdate / ddList somemon sumdates)
- (if (and (numberp spyear) (numberp spmonth) (numberp spdate))
- (progn
- (setq ddList (dt-everyMonth-list spyear)
- somemon 1
- sumdates 0
- )
- (while (< somemon spmonth)
- (setq sumdates (+ (cdr (assoc somemon ddList)) sumdates)
- somemon (1+ somemon)
- )
- )
- (+ sumdates spdate)
- )
- )
- )
- ;;;两个日期之间的天数
- (defun dt-dist (mList nList / maxyear minyear maxList minList someyear
- sumdate)
- (if (and (numberp (caddr mList)) (numberp (caddr nList)))
- (if (/= (car mList) (car nList))
- (progn
- (setq maxyear (max (car mList) (car nList))
- minyear (min (car mList) (car nList))
- maxList (assoc maxyear (list mList nList))
- minList (assoc minyear (list mList nList))
- )
- (setq someyear (+ minyear 1)
- sumdate 0
- )
- (while (< someyear maxyear)
- (setq sumdate (+ (dt-dates someyear) sumdate)
- someyear (1+ someyear)
- )
- )
- (+ (- (dt-dates minyear)
- (dt-nthdate minyear (cadr minList) (caddr minList))
- )
- sumdate
- (dt-nthdate maxyear (cadr maxList) (caddr maxList))
- )
- )
- (abs (- (dt-nthdate (car mList) (cadr mList) (caddr mList))
- (dt-nthdate (car nList) (cadr nList) (caddr nList))
- )
- )
- )
- )
- )
|