aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1993-06-05 09:13:19 +0000
committerRichard M. Stallman1993-06-05 09:13:19 +0000
commit1ea40ac2be74095dc367c97c5540fd6c501c212c (patch)
tree09354c878374e54b70d23deb9793d8097da5f481
parentd51c3cdaa56970d43c2ebba01a8eb41af323d3ed (diff)
downloademacs-1ea40ac2be74095dc367c97c5540fd6c501c212c.tar.gz
emacs-1ea40ac2be74095dc367c97c5540fd6c501c212c.zip
(gnus-current-time-zone): New function, which tries
current-time-zone, and if that fails falls back on gnus-local-timezone. (gnus-inews-date): Use it. (gnus-inews-valid-date): New optional args TIME (default now) and ZONE (default GMT). (gnus-inews-buggy-date): New optional arg TIME (default now).
-rw-r--r--lisp/gnuspost.el55
1 files changed, 33 insertions, 22 deletions
diff --git a/lisp/gnuspost.el b/lisp/gnuspost.el
index 91233809c55..904cfc3ddf1 100644
--- a/lisp/gnuspost.el
+++ b/lisp/gnuspost.el
@@ -691,31 +691,42 @@ domain is undefined, the domain name is got from it."
691 (error "Cannot understand current-time-string: %s." date)) 691 (error "Cannot understand current-time-string: %s." date))
692 )) 692 ))
693 693
694(defun gnus-current-time-zone (time)
695 "The local time zone in effect at TIME, or nil if not known."
696 (let ((z (and (fboundp 'current-time-zone) (current-time-zone now))))
697 (if (and z (car z)) z gnus-local-timezone)))
698
694(defun gnus-inews-date () 699(defun gnus-inews-date ()
695 "Date string of today. 700 "Date string of today.
696If the variable gnus-local-timezone is non-nil, valid date will be 701If `current-time-zone' works, or if `gnus-local-timezone' is set correctly,
697generated in terms of RFC822. Otherwise, buggy date in which time 702this yields a date that conforms to RFC 822. Otherwise a buggy date will
698zone is ignored will be generated. If you are using with Cnews, you 703be generated; this might work with some older news servers."
699must use valid date." 704 (let* ((now (and (fboundp 'current-time) (current-time)))
700 (cond (gnus-local-timezone 705 (zone (gnus-current-time-zone now)))
701 ;; Gnus can generate valid date. 706 (if zone
702 (gnus-inews-valid-date)) 707 (gnus-inews-valid-date now zone)
703 (t 708 ;; No timezone info.
704 ;; No timezone info. 709 (gnus-inews-buggy-date now))))
705 (gnus-inews-buggy-date)) 710
706 )) 711(defun gnus-inews-valid-date (&optional time zone)
707 712 "A date string that represents TIME and conforms to the Usenet standard.
708(defun gnus-inews-valid-date () 713TIME is optional and defaults to the current time.
709 "Date string of today represented in GMT. 714Some older versions of Emacs always act as if TIME is nil.
710Local timezone is specified by the variable gnus-local-timezone." 715The optional argument ZONE specifies the local time zone (default GMT)."
711 (timezone-make-date-arpa-standard 716 (timezone-make-date-arpa-standard
712 (current-time-string) gnus-local-timezone "GMT")) 717 (if (fboundp 'current-time)
713 718 (current-time-string time)
714(defun gnus-inews-buggy-date () 719 (current-time-string))
715 "Buggy date string of today. Time zone is ignored, but fast." 720 zone "GMT"))
716 ;; Insert buggy date (time zone is ignored), but I don't worry about 721
717 ;; it since inews will rewrite it. 722(defun gnus-inews-buggy-date (&optional time)
718 (let ((date (current-time-string))) 723 "A buggy date string that represents TIME; this ignores the time zone
724and does not conform to the Usenet standard, but it sometimes works anyway.
725TIME is optional and defaults to the current time.
726Some older versions of Emacs always act as if TIME is nil."
727 (let ((date (if (fboundp 'current-time)
728 (current-time-string time)
729 (current-time-string))))
719 (if (string-match "^[^ ]+ \\([^ ]+\\)[ ]+\\([0-9]+\\) \\([0-9:]+\\) [0-9][0-9]\\([0-9][0-9]\\)" 730 (if (string-match "^[^ ]+ \\([^ ]+\\)[ ]+\\([0-9]+\\) \\([0-9:]+\\) [0-9][0-9]\\([0-9][0-9]\\)"
720 date) 731 date)
721 (concat (substring date (match-beginning 2) (match-end 2)) ;Day 732 (concat (substring date (match-beginning 2) (match-end 2)) ;Day