aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/gnuspost.el
diff options
context:
space:
mode:
authorRichard M. Stallman <[email protected]>1993-06-05 09:13:19 +0000
committerRichard M. Stallman <[email protected]>1993-06-05 09:13:19 +0000
commit1ea40ac2be74095dc367c97c5540fd6c501c212c (patch)
tree09354c878374e54b70d23deb9793d8097da5f481 /lisp/gnuspost.el
parentd51c3cdaa56970d43c2ebba01a8eb41af323d3ed (diff)
(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).
Diffstat (limited to 'lisp/gnuspost.el')
-rw-r--r--lisp/gnuspost.el55
1 files changed, 33 insertions, 22 deletions
diff --git a/lisp/gnuspost.el b/lisp/gnuspost.el
index 91233809c5..904cfc3ddf 100644
--- a/lisp/gnuspost.el
+++ b/lisp/gnuspost.el
@@ -691,31 +691,42 @@ domain is undefined, the domain name is got from it."
(error "Cannot understand current-time-string: %s." date))
))
+(defun gnus-current-time-zone (time)
+ "The local time zone in effect at TIME, or nil if not known."
+ (let ((z (and (fboundp 'current-time-zone) (current-time-zone now))))
+ (if (and z (car z)) z gnus-local-timezone)))
+
(defun gnus-inews-date ()
"Date string of today.
-If the variable gnus-local-timezone is non-nil, valid date will be
-generated in terms of RFC822. Otherwise, buggy date in which time
-zone is ignored will be generated. If you are using with Cnews, you
-must use valid date."
- (cond (gnus-local-timezone
- ;; Gnus can generate valid date.
- (gnus-inews-valid-date))
- (t
- ;; No timezone info.
- (gnus-inews-buggy-date))
- ))
-
-(defun gnus-inews-valid-date ()
- "Date string of today represented in GMT.
-Local timezone is specified by the variable gnus-local-timezone."
+If `current-time-zone' works, or if `gnus-local-timezone' is set correctly,
+this yields a date that conforms to RFC 822. Otherwise a buggy date will
+be generated; this might work with some older news servers."
+ (let* ((now (and (fboundp 'current-time) (current-time)))
+ (zone (gnus-current-time-zone now)))
+ (if zone
+ (gnus-inews-valid-date now zone)
+ ;; No timezone info.
+ (gnus-inews-buggy-date now))))
+
+(defun gnus-inews-valid-date (&optional time zone)
+ "A date string that represents TIME and conforms to the Usenet standard.
+TIME is optional and defaults to the current time.
+Some older versions of Emacs always act as if TIME is nil.
+The optional argument ZONE specifies the local time zone (default GMT)."
(timezone-make-date-arpa-standard
- (current-time-string) gnus-local-timezone "GMT"))
-
-(defun gnus-inews-buggy-date ()
- "Buggy date string of today. Time zone is ignored, but fast."
- ;; Insert buggy date (time zone is ignored), but I don't worry about
- ;; it since inews will rewrite it.
- (let ((date (current-time-string)))
+ (if (fboundp 'current-time)
+ (current-time-string time)
+ (current-time-string))
+ zone "GMT"))
+
+(defun gnus-inews-buggy-date (&optional time)
+ "A buggy date string that represents TIME; this ignores the time zone
+and does not conform to the Usenet standard, but it sometimes works anyway.
+TIME is optional and defaults to the current time.
+Some older versions of Emacs always act as if TIME is nil."
+ (let ((date (if (fboundp 'current-time)
+ (current-time-string time)
+ (current-time-string))))
(if (string-match "^[^ ]+ \\([^ ]+\\)[ ]+\\([0-9]+\\) \\([0-9:]+\\) [0-9][0-9]\\([0-9][0-9]\\)"
date)
(concat (substring date (match-beginning 2) (match-end 2)) ;Day