-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path19.ss
More file actions
19 lines (16 loc) · 675 Bytes
/
19.ss
File metadata and controls
19 lines (16 loc) · 675 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#lang scheme
(require srfi/19)
(let loop ([first-of-the-month-sundays 0]
[today (date->time-utc
;; Midnight (at the beginning of) January 1, 1901,
;; UTC.
(make-date 0 0 0 0 1 1 1901 0))])
(let ((date (time-utc->date today)))
(if (< 2000 (date-year date))
first-of-the-month-sundays
(loop (+ first-of-the-month-sundays
(if (and
(zero? (date-week-day date)) ;Sunday?
(= 1 (date-day date)) ;1st of the month?
) 1 0))
(add-duration today (make-time 'time-duration 0 (* 24 60 60)))))))