From: SMTP%"davis@pacific.mps.ohio-state.edu" 9-AUG-1993 08:59:01.73 To: EVERHART CC: Subj: Re: Week of Year X-Newsgroups: comp.os.vms From: davis@pacific.mps.ohio-state.edu ("John E. Davis") Subject: Re: Week of Year In-Reply-To: DAHMS@ifk20.mach.uni-karlsruhe.de's message of 6 Aug 1993 22:11:23 GMT Message-Id: Sender: news@pacific.mps.ohio-state.edu Nntp-Posting-Host: pacific.mps.ohio-state.edu Reply-To: davis@pacific.mps.ohio-state.edu (John E. Davis) Organization: "Dept. of Physics, The Ohio State University" Date: Sat, 7 Aug 1993 22:00:13 GMT Lines: 69 To: Info-VAX@kl.sri.com X-Gateway-Source-Info: USENET In article <23ukub$pmd@nz12.rz.uni-karlsruhe.de> DAHMS@ifk20.mach.uni-karlsruhe.de (Heribert Dahms) writes: It gives day-of-the-week, but we want week-of-the-year 8-) My 0.92 of my JED editor can po up a window containing a 3 month calendar for and 3 month period for any date. E.g. Dec 1999 Jan 2000 Feb 2000 S M Tu W Th F S S M Tu W Th F S S M Tu W Th F S 1 2 3 4 1 1 2 3 4 5 5 6 7 8 9 10 11 2 3 4 5 6 * 8 6 7 8 9 10 11 12 12 13 14 15 16 17 18 9 10 11 12 13 14 15 13 14 15 16 17 18 19 19 20 21 22 23 24 25 16 17 18 19 20 21 22 20 21 22 23 24 25 26 26 27 28 29 30 31 23 24 25 26 27 28 29 27 28 29 30 31 It uses algorithms to calculate the day of week, day of year, and leap year. You can always use a combination of them to find the week of the year---- off top of my head, something like: (day_of_year + day_of_week for Jan 1) / 7 Although the algorithms are written in infix S-Lang (editor extension language)), they should be readable (That is my claim, anyway). ( [year] =year . not(year mod 4) and (year mod 100) { return (1) } if . return (not (year mod 400)) ) leap_year_p ( [month day year] =year =day =month [d] . d = 31 * ( month - 1 ) + day . month > 2 { . d = d - (month * 4 + 23) / 10 . leap_year_p (year) { ++d } if } if . return (d) ) cal_day_number ( [month day year] =year =day =month [c delta n a b] . n = cal_day_number(month, day, year) --year . a = n + year + year/4 . c = year/100 * 3, b = 0 . c mod 4 { b = 1 } if . return ((a - (b + c/4)) mod 7) ) cal_day_of_week I translated these algorithms from Emacs Lisp code and modified them to aoid integer arithmetic overflow on 16 bit machines (MSDOS). -- _____________ #___/John E. Davis\_________________________________________________________ # # internet: davis@amy.tch.harvard.edu # bitnet: davis@ohstpy # office: 617-735-6746 #