]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar: simplify am/pm.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Dec 2020 05:48:55 +0000 (21:48 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Dec 2020 05:48:55 +0000 (21:48 -0800)
basis/calendar/calendar.factor

index b791e0a0fa90457add8055ba1d6b91b1d869b381..a95baf990ec0c2711e80b28b0d95457824132e08 100644 (file)
@@ -768,10 +768,10 @@ CONSTANT: weekday-offsets { 0 0 1 2 3 4 5 }
     [ midnight ] dip >>hour ;
 
 : am ( timestamp n -- timestamp )
-    1 12 [a,b] check-interval dup 12 = [ drop 0 ] when o'clock ;
+    1 12 [a,b] check-interval 12 mod o'clock ;
 
 : pm ( timestamp n -- timestamp )
-    1 12 [a,b] check-interval dup 12 = [ drop 0 ] when 12 + o'clock ;
+    1 12 [a,b] check-interval 12 mod 12 + o'clock ;
 
 : time-since-midnight ( timestamp -- duration )
     instant swap >time< set-time ;