]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar: fix nth-day-this-month to mutate.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Dec 2020 05:17:45 +0000 (21:17 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Dec 2020 05:17:45 +0000 (21:17 -0800)
basis/calendar/calendar.factor

index fa53268264294b98d82f49f9961ccb17c0751e9b..a510e8ade8da4fb09076529416f74b2a5488ed7e 100644 (file)
@@ -566,8 +566,9 @@ M: integer last-day-of-year 12 31 <date> ;
     <rotated> nth days (time+) drop ;
 
 :: nth-day-this-month ( timestamp n day -- timestamp )
-    timestamp clone start-of-month day day-this-week
-    dup timestamp [ month>> ] same?
+    timestamp clone
+    timestamp start-of-month day day-this-week
+    [ [ month>> ] same? ] keep swap
     [ 1 weeks (time+) drop ] unless
     n [ weeks (time+) drop ] unless-zero ;