Next: , Previous: AT commands, Up: Extended Guile examples



3.2.2 Every second Sunday

To run my-program on the second Sunday of every month, a Guile script like the following should suffice (it is left as an exercise to the student to understand how this works!).

     (job (lambda (current-time)
            (let* ((next-month (next-month-from current-time))
                   (first-day (tm:wday (localtime next-month)))
                   (second-sunday (if (eqv? first-day 0)
                                      8
                                      (- 14 first-day))))
              (+ next-month (* 24 60 60 second-sunday))))
          "my-program")