]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar: no need to use sequences.rotated.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Dec 2020 17:56:35 +0000 (09:56 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Dec 2020 17:56:35 +0000 (09:56 -0800)
basis/calendar/calendar.factor

index a91421f8fd486e1436f567954b3c875dd921a01d..c34871a7a91723a7ff5e826e90f01d5aded83b69 100644 (file)
@@ -3,8 +3,7 @@
 USING: accessors arrays classes.tuple combinators
 combinators.short-circuit kernel literals math math.functions
 math.intervals math.order math.parser math.statistics sequences
-sequences.rotated slots.syntax splitting system vocabs
-vocabs.loader ;
+slots.syntax splitting system vocabs vocabs.loader ;
 FROM: math.ranges => [a..b) ;
 IN: calendar
 
@@ -559,8 +558,8 @@ M: integer last-day-of-year 12 31 <date> ;
     day-offset days (time+) ;
 
 : closest-day ( timestamp n -- timestamp )
-    { 0 1 2 3 -3 -2 -1 } pick day-of-week 7 swap -
-    <rotated> nth days (time+) ;
+    [ dup day-of-week 7 swap - ] [ + 7 mod ] bi*
+    { 0 1 2 3 -3 -2 -1 } nth days (time+) ;
 
 :: nth-day-this-month ( timestamp n day -- timestamp )
     timestamp clone