]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar: Rename internal word, add days-until
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 30 Dec 2021 20:42:23 +0000 (14:42 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 30 Dec 2021 20:42:23 +0000 (14:42 -0600)
Fixes #752

basis/calendar/calendar.factor

index e7caa89d323fd833519ecd2579f73b4cc2f101d1..213cc6ac34fefb2be7fdf5e49b5baa7e364ed0fd 100644 (file)
@@ -41,7 +41,7 @@ TUPLE: timestamp
 <<
 CONSTANT: day-counts { 0 31 28 31 30 31 30 31 31 30 31 30 31 }
 >>
-CONSTANT: days-until $[ day-counts cum-sum0 ]
+CONSTANT: cumulative-day-counts $[ day-counts cum-sum0 ]
 
 PRIVATE>
 
@@ -345,7 +345,7 @@ M: timestamp <=> [ >gmt tuple-slots ] compare ;
     [ slots{ year month } ] same? ;
 
 :: (day-of-year) ( year month day -- n )
-    month days-until nth day + {
+    month cumulative-day-counts nth day + {
         [ year leap-year? ]
         [ month 3 >= ]
     } 0&& [ 1 + ] when ;
@@ -464,6 +464,7 @@ M: duration time-
 
 : hence ( duration -- timestamp ) now swap time+ ;
 : ago ( duration -- timestamp ) now swap time- ;
+: days-until ( time -- n ) now time- duration>days ;
 
 GENERIC: days-in-year ( obj -- n )