- (list (read-string "Length of delay (units in [mhdwMY]): "
- gnus-delay-default-delay)))
- (let (num unit days deadline)
- (unless (string-match "\\([0-9]+\\)\\s-*\\([mhdwMY]\\)" delay)
- (error "Malformed delay `%s'" delay))
- (setq num (match-string 1 delay))
- (setq unit (match-string 2 delay))
- ;; Start from seconds, then multiply into needed units.
- (setq num (string-to-number num))
- (cond ((string= unit "Y")
- (setq delay (* num 60 60 24 365)))
- ((string= unit "M")
- (setq delay (* num 60 60 24 30)))
- ((string= unit "w")
- (setq delay (* num 60 60 24 7)))
- ((string= unit "d")
- (setq delay (* num 60 60 24)))
- ((string= unit "h")
- (setq delay (* num 60 60)))
- (t
- (setq delay (* num 60))))
- (setq deadline (message-make-date
- (seconds-to-time (+ (time-to-seconds (current-time))
- delay))))
+ (list (read-string
+ "Target date (YYYY-MM-DD), time (hh:mm), or length of delay (units in [mhdwMY]): "
+ gnus-delay-default-delay)))
+ ;; Allow spell checking etc.
+ (run-hooks 'message-send-hook)
+ (let (num unit days year month day hour minute deadline)
+ (cond ((string-match
+ "\\([0-9][0-9][0-9]?[0-9]?\\)-\\([0-9]+\\)-\\([0-9]+\\)"
+ delay)
+ (setq year (string-to-number (match-string 1 delay))
+ month (string-to-number (match-string 2 delay))
+ day (string-to-number (match-string 3 delay)))
+ (setq deadline
+ (message-make-date
+ (encode-time 0 0 ; second and minute
+ gnus-delay-default-hour
+ day month year))))
+ ((string-match "\\([0-9]+\\):\\([0-9]+\\)" delay)
+ (setq hour (string-to-number (match-string 1 delay))
+ minute (string-to-number (match-string 2 delay)))
+ ;; Use current time, except...
+ (setq deadline (apply 'vector (decode-time)))
+ ;; ... for minute and hour.
+ (aset deadline 1 minute)
+ (aset deadline 2 hour)
+ ;; Convert to seconds.
+ (setq deadline (gnus-float-time (apply 'encode-time
+ (append deadline nil))))
+ ;; If this time has passed already, add a day.
+ (when (< deadline (gnus-float-time))
+ (setq deadline (+ 86400 deadline))) ; 86400 secs/day
+ ;; Convert seconds to date header.
+ (setq deadline (message-make-date
+ (seconds-to-time deadline))))
+ ((string-match "\\([0-9]+\\)\\s-*\\([mhdwMY]\\)" delay)
+ (setq num (match-string 1 delay))
+ (setq unit (match-string 2 delay))
+ ;; Start from seconds, then multiply into needed units.
+ (setq num (string-to-number num))
+ (cond ((string= unit "Y")
+ (setq delay (* num 60 60 24 365)))
+ ((string= unit "M")
+ (setq delay (* num 60 60 24 30)))
+ ((string= unit "w")
+ (setq delay (* num 60 60 24 7)))
+ ((string= unit "d")
+ (setq delay (* num 60 60 24)))
+ ((string= unit "h")
+ (setq delay (* num 60 60)))
+ (t
+ (setq delay (* num 60))))
+ (setq deadline (message-make-date
+ (seconds-to-time (+ (gnus-float-time) delay)))))
+ (t (error "Malformed delay `%s'" delay)))