]> gitweb.factorcode.org Git - factor.git/commitdiff
wikipedia: strftime + tests
authorBjörn Lindqvist <bjourne@gmail.com>
Tue, 3 Jan 2017 14:37:53 +0000 (15:37 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Tue, 3 Jan 2017 14:37:53 +0000 (15:37 +0100)
extra/wikipedia/wikipedia-tests.factor [new file with mode: 0644]
extra/wikipedia/wikipedia.factor

diff --git a/extra/wikipedia/wikipedia-tests.factor b/extra/wikipedia/wikipedia-tests.factor
new file mode 100644 (file)
index 0000000..4c9fbbf
--- /dev/null
@@ -0,0 +1,8 @@
+USING: calendar tools.test urls wikipedia.private ;
+IN: wikipedia.tests
+
+{
+    URL" http://en.wikipedia.org/wiki/October_10"
+} [
+    2010 10 10 <date> historical-url
+] unit-test
index 14d33dda2f2cdad3421936ab35de6e87ed7ba4d2..f712f68395647702554fb7d0b424c94dec71125d 100644 (file)
@@ -1,10 +1,10 @@
 ! Copyright (C) 2012 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: accessors ascii assocs calendar colors.constants
-formatting html.entities html.parser html.parser.analyzer
-html.parser.printer http.client io io.styles kernel namespaces
-sequences splitting urls wrap.strings xml xml.data xml.traversal ;
+USING: accessors ascii assocs colors.constants formatting
+html.entities html.parser html.parser.analyzer html.parser.printer
+http.client io io.styles kernel namespaces sequences splitting urls
+wrap.strings xml xml.data xml.traversal ;
 FROM: xml.data => tag? ;
 
 IN: wikipedia
@@ -44,7 +44,7 @@ SYMBOL: language
     children-tags [ item. ] each nl ;
 
 : historical-url ( timestamp -- url )
-    [ month-name ] [ day>> ] bi "%s_%s" sprintf wikipedia-url ;
+    "%B_%d" strftime wikipedia-url ;
 
 : (historical-events) ( timestamp -- seq )
     historical-url http-get nip string>xml "ul" deep-tags-named ;