]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar: rename zeller-congruence to (day-of-week).
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 10 Dec 2020 22:37:16 +0000 (14:37 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 10 Dec 2020 22:37:16 +0000 (14:37 -0800)
basis/calendar/calendar-docs.factor
basis/calendar/calendar.factor
basis/calendar/format/format.factor
extra/project-euler/019/019.factor

index 7899175e5fb0807e7ca2b9995ca941f6acc6a5db..a48af67e8eaff5ae0a53e8c55778704ecf5213eb 100644 (file)
@@ -356,9 +356,9 @@ HELP: ago
     }
 } ;
 
-HELP: zeller-congruence
+HELP: (day-of-week)
 { $values { "year" integer } { "month" integer } { "day" integer } { "n" integer } }
-{ $description "An implementation of an algorithm that computes the day of the week given a date. Days are indexed starting from Sunday, which is index 0." }
+{ $description "An implementation of the Zeller's congruence algorithm that computes the day of the week given a date. Days are indexed starting from Sunday, which is index 0." }
 { $notes "User code should use the " { $link day-of-week } " word, which takes a " { $snippet "timestamp" } " instead of integers." } ;
 
 HELP: days-in-year
index da666f14bac0fc70b1ef8ce409d86313f02f34bc..e5d821bddc3d0a0376151531814dfd03244fe6fb 100644 (file)
@@ -370,7 +370,7 @@ M: timestamp <=> [ >gmt tuple-slots ] compare ;
 : same-day? ( ts1 ts2 -- ? )
     [ >gmt slots{ year month day } ] same? ;
 
-: zeller-congruence ( year month day -- n )
+: (day-of-week) ( year month day -- n )
     ! Zeller Congruence
     ! http://web.textfiles.com/computers/formulas.txt
     ! good for any date since October 15, 1582
@@ -381,7 +381,7 @@ M: timestamp <=> [ >gmt tuple-slots ] compare ;
     ] dip 1 + + 7 mod ;
 
 : day-of-week ( timestamp -- n )
-    >date< zeller-congruence ;
+    >date< (day-of-week) ;
 
 : (week-number) ( timestamp -- [0,53] )
     [ day-of-year ] [ day-of-week [ 7 ] when-zero ] bi - 10 + 7 /i ;
index 56d249844a9622382702ab5e040fe771239e03e5..38e0a202b25c1f1fa4024866423a205b6ee6cab2 100644 (file)
@@ -76,7 +76,7 @@ M: timestamp day.
     day-abbreviations2 " " join print ;
 
 : days. ( year month -- )
-    [ 1 zeller-congruence dup [ "   " write ] times ]
+    [ 1 (day-of-week) dup [ "   " write ] times ]
     [ (days-in-month) ] 2bi [1,b] [
         [ day. ] [ + 7 mod zero? [ nl ] [ bl ] if ] bi
     ] with each nl ;
index fc9cdacad794ee00615395fef42884e1dff3c297..116b04eb293d1135e5733f0d38870694e4051f16 100644 (file)
@@ -27,12 +27,12 @@ IN: project-euler.019
 ! --------
 
 ! Use Zeller congruence, which is implemented in the "calendar" module
-! already, as "zeller-congruence ( year month day -- n )" where n is
+! already, as "(day-of-week) ( year month day -- n )" where n is
 ! the day of the week (Sunday is 0).
 
 : euler019 ( -- answer )
     1901 2000 [a,b] [
-        12 [1,b] [ 1 zeller-congruence ] with map
+        12 [1,b] [ 1 (day-of-week) ] with map
     ] map concat [ 0 = ] count ;
 
 ! [ euler019 ] 100 ave-time