File: date.clp

package info (click to toggle)
clips 6.21-6.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 7,956 kB
  • ctags: 8,731
  • sloc: ansic: 97,932; makefile: 1,406; sh: 189
file content (26 lines) | stat: -rw-r--r-- 730 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
; This is the date function 
; for reasons of computational simplicity, the date is represented
; as an integer which represents days since jan 1 1900.

; because CLIPS does not capture the return of system calls, the intermediate
; value is stored in a file.
(deffunction get-now ()
	(system "date '+%y%t%j' > datefile.dat")
	(open "datefile.dat" datefile "r")
	(bind ?year (read datefile))
	(bind ?day (read datefile))
	(close datefile)
	( +(div ?year 4) (* ?year 365)  ?day)
)

(deffunction elapsed-time (?date)
	(- (get-now) ?date))

; is date more than 6 mo ago?
(deffunction six-months (?date)
	(< 180 (elapsed-time ?date)))

; is date more than 5 years ago?
(deffunction five-years (?date)
	(< 1826 (elapsed-time ?date)))