Skip to content

Commit 2a9a68b

Browse files
committed
Merge pull request #18 from mdorman/date
Fix date handling
2 parents 0d72d69 + 6cc4637 commit 2a9a68b

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

TODO.org

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@
5555
know about =xmlrpc.php=.
5656

5757

58+
* DONE Fix date issues once and for all
59+
Added some tests to make the failure repeatable, then fixed the
60+
issue. The fix is admittedly a hack, but it would appear to be a
61+
reliable one, at least until WP changes its output.

acceptance

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/sh -e
22
IFS= read -r -p 'Please enter blog password: ' PASSWORD
3-
exec emacs -nw -Q -L /usr/share/emacs/site-lisp/org-mode -L . -l ert -l org-blog --eval "(setq org-blog-test-password \"${PASSWORD}\")" --eval '(ert t)'
3+
exec emacs -nw -Q -L /usr/share/emacs/site-lisp/org-mode -L . -l ert -l org-blog --eval '(setq xml-rpc-debug 10)' --eval "(setq org-blog-test-password \"${PASSWORD}\")" --eval '(ert t)'

org-blog-wp.el

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
(defconst org-blog-wp-alist
3636
(list (cons :category "category")
3737
(cons :content "post_content")
38-
(cons :date "post_date")
38+
(cons :date "post_date_gmt")
3939
(cons :description "post_excerpt")
4040
(cons :id "post_id")
4141
(cons :keywords "post_tag")
@@ -67,11 +67,8 @@ sorted."
6767
(org-blog-post-to-wp-add-taxonomy wp "category" v))
6868
((eq :date k)
6969
;; Convert to GMT by adding seconds offset
70-
(cons
71-
(cons "post_date_gmt" (list :datetime
72-
(time-add v
73-
(seconds-to-time (- (car (current-time-zone)))))))
74-
wp))
70+
(let ((gmt (time-add v (seconds-to-time (- (car (current-time-zone)))))))
71+
(cons (cons "post_date_gmt" (list :datetime gmt)) wp)))
7572
((eq :keywords k)
7673
(org-blog-post-to-wp-add-taxonomy wp "post_tag" v))
7774
((eq :title k)
@@ -117,7 +114,7 @@ sorted."
117114
post)
118115
((string= "terms" k)
119116
(org-blog-wp-to-post-handle-taxonomy post v))
120-
((string= "post_date" k)
117+
((string= "post_date_gmt" k)
121118
(cons (cons (car (rassoc k org-blog-wp-alist)) (plist-get v :datetime)) post))
122119
((rassoc k org-blog-wp-alist)
123120
(cons (cons (car (rassoc k org-blog-wp-alist)) v) post))
@@ -260,13 +257,12 @@ call the specified function and return the results."
260257

261258
;;;; Define tests if ert is loaded
262259
(when (featurep 'ert)
263-
(setq xml-rpc-debug 5)
264260
(ert-deftest ob-test-post-to-wp ()
265261
"Transfer from buffers to posts and back again"
266262
(let ((post1-struct '((:blog . "t1b")
267263
(:category "t1c1" "t1c2")
268264
(:content . "<p>\nTest 1 Content</p>\n")
269-
(:date 20738 4432 0 0)
265+
(:date 20738 4432)
270266
(:description . "t1e")
271267
(:id . "1")
272268
(:keywords "t1k1" "t1k2" "t1k3")
@@ -310,7 +306,7 @@ call the specified function and return the results."
310306
("post_date" :datetime
311307
(20738 4432))
312308
("post_date_gmt" :datetime
313-
(20738 18832 0 0))
309+
(20738 4432))
314310
("post_modified" :datetime
315311
(20738 4432))
316312
("post_modified_gmt" :datetime

org-blog.el

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ available in org-blog-alist."
188188
(when (featurep 'ert)
189189
(require 'el-mock)
190190
(setq message-log-max t
191-
test-time (current-time)
192-
xml-rpc-debug 5)
191+
test-time (current-time))
193192
(ert-deftest ob-test-enable-org-blog-mode ()
194193
"Test turning on the org-blog minor mode"
195194
(with-temp-buffer
@@ -308,4 +307,6 @@ works at all, not the content of the post."))
308307
(org-blog-save)
309308
(goto-char (point-max))
310309
(insert "\n\nThis is a little additional text")
311-
(org-blog-save))))))
310+
(let ((pre-save (buffer-string)))
311+
(org-blog-save)
312+
(should (equal pre-save (buffer-string)))))))))

0 commit comments

Comments
 (0)