]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar: Simplify ymd>ordinal a bit.
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 4 Nov 2020 05:52:45 +0000 (23:52 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 4 Nov 2020 23:38:46 +0000 (17:38 -0600)
basis/calendar/calendar.factor

index 691018bab0bea4e2d3e18724c833b823e5a47816..6187538d3a4847981d43afa8acddb5dfccdcc813 100644 (file)
@@ -594,10 +594,9 @@ M: timestamp december clone 12 >>month ;
 ! Find a better algorithm.
 : ymd>ordinal ( year month day -- ordinal )
     [ leap-year? dup -2 -3 ? ]
-    [ tuck dup 3 < [ 12 + ] when [ 1 - 30 * ] [ 1 + .6 * floor ] bi + ]
+    [ dup 3 < [ 12 + ] when [ 1 - 30 * ] [ 1 + .6 * floor ] bi + ]
     [ ] tri* + + >integer
-    rot 366 365 ?
-    rot 3 < [ - ] [ drop ] if ;
+    swap 367 366 ? mod ;
 
 : timestamp>year-dates ( timestamp -- seq )
     [ beginning-of-year >date< julian-day-number ]