PDA

View Full Version : Find the Day of the Week


TobyKanoby
2006-11-09, 10:57 PM
I try to write a program to backup my drawings on fridays after 4:00pm. The function 'cdata' may help find time after 4:00pm but not if day is friday. I write a small test program to find the day of the week. It may be not best way to do it. Any suggestions welcome.

(defun DayOfWeek (/ Today DayNumber FileOpen TempFile)
(setq TempFile (vl-filename-mktemp))
(setq FileOpen (open TempFile "w"))
(write-line (rtos (getvar "CDATE") 2 0) FileOpen)
(close FileOpen)
(setq DayNumber (nth 2 (vl-file-systime TempFile)))
(setq Today (nth DayNumber (list "" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday")))
Today
)

Opie
2006-11-09, 11:08 PM
A quick test on my machine seems to work for Fridays.

rkmcswain
2006-11-09, 11:16 PM
I write a small test program to find the day of the week. It may be not best way to do it. Any suggestions welcome.


This is a bit shorter.


(menucmd "M=$(edtime,$(getvar,date),DDDD)")

TobyKanoby
2006-11-09, 11:25 PM
Very much shorter. Thanks