]> gitweb.factorcode.org Git - factor.git/commitdiff
calendar: speed up time+.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Dec 2020 16:51:04 +0000 (08:51 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 11 Dec 2020 16:51:04 +0000 (08:51 -0800)
Rename >local-time to >local.

basis/calendar/calendar-docs.factor
basis/calendar/calendar.factor
basis/io/files/info/windows/windows.factor

index 7dff091c5ec903ef4897ca7137786b2e82753281..22b565cacd322a9b3395690ddda784ff92d1f459 100644 (file)
@@ -271,12 +271,12 @@ HELP: convert-timezone
     }
 } ;
 
-HELP: >local-time
+HELP: >local
 { $values { "timestamp" timestamp } }
 { $description "Converts the " { $snippet "timestamp" } " to the timezone of your computer." }
 { $examples
     { $example "USING: accessors calendar kernel prettyprint ;"
-               "now now-gmt >local-time [ gmt-offset>> ] same? ."
+               "now now-gmt >local [ gmt-offset>> ] same? ."
                "t"
     }
 } ;
@@ -291,17 +291,17 @@ HELP: >gmt
     }
 } ;
 
-HELP: local-time
+HELP: local
 { $values { "timestamp" timestamp } }
 { $description "Set the time zone to the computer's local timezone." }
-{ $notes "The time is not converted, if you want that then call " { $link >local-time } "." } ;
+{ $notes "The time is not converted, if you want that then call " { $link >local } "." } ;
 
 HELP: gmt
 { $values { "timestamp" timestamp } }
 { $description "Set the time zone to GMT." }
 { $notes "The time is not converted, if you want that then call " { $link >gmt } "." } ;
 
-{ local-time >local-time gmt >gmt convert-timezone } related-words
+{ local >local gmt >gmt convert-timezone } related-words
 
 HELP: duration*
 { $values { "obj1" object } { "obj2" object } { "obj3" object } }
@@ -511,7 +511,7 @@ ARTICLE: "calendar" "Calendar"
 }
 "Time zones:"
 { $subsections
-    >local-time
+    >local
     >gmt
     convert-timezone
 }
index 40d1812ded94f5faa80e1a9caef2640c7fb5b270..a91421f8fd486e1436f567954b3c875dd921a01d 100644 (file)
@@ -194,10 +194,10 @@ GENERIC: +second ( timestamp x -- timestamp )
 
 : /rem ( f n -- q r )
     ! q is positive or negative, r is positive from 0 <= r < n
-    [ /mod ] keep over 0 < [ + [ -1 + ] dip ] [ drop ] if ;
+    [ /mod ] keep over 0 < [ + [ -1 + ] dip ] [ drop ] if ; inline
 
 : float>whole-part ( float -- int float )
-    [ floor >integer ] keep over - ;
+    [ floor >integer ] keep over - ; inline
 
 : adjust-leap-year ( timestamp -- timestamp )
     dup
@@ -214,41 +214,40 @@ M: real +year
     12 /rem [ 1 - 12 ] when-zero swap ; inline
 
 M: integer +month
-    over month>> + months/years [ >>month ] dip +year ;
+    [ over month>> + months/years [ >>month ] dip +year ] unless-zero ;
 
 M: real +month
     float>whole-part swapd average-month * +day swap +month ;
 
 M: integer +day
-    over >date< julian-day-number + julian-day-number>date
-    [ >>year ] [ >>month ] [ >>day ] tri* ;
+    [ over >date< julian-day-number + julian-day-number>date set-date ] unless-zero ;
 
 M: real +day
     float>whole-part swapd 24 * +hour swap +day ;
 
 : hours/days ( n -- hours days )
-    24 /rem swap ;
+    24 /rem swap ; inline
 
 M: integer +hour
-    over hour>> + hours/days [ >>hour ] dip +day ;
+    [ over hour>> + hours/days [ >>hour ] dip +day ] unless-zero ;
 
 M: real +hour
     float>whole-part swapd 60 * +minute swap +hour ;
 
 : minutes/hours ( n -- minutes hours )
-    60 /rem swap ;
+    60 /rem swap ; inline
 
 M: integer +minute
-    over minute>> + minutes/hours [ >>minute ] dip +hour ;
+    [ over minute>> + minutes/hours [ >>minute ] dip +hour ] unless-zero ;
 
 M: real +minute
     float>whole-part swapd 60 * +second swap +minute ;
 
 : seconds/minutes ( n -- seconds minutes )
-    60 /rem swap >integer ;
+    60 /rem swap ; inline
 
 M: number +second
-    over second>> + seconds/minutes [ >>second ] dip +minute ;
+    [ over second>> + seconds/minutes [ >>second ] dip +minute ] unless-zero ;
 
 : (time+) ( timestamp duration -- timestamp )
     {
@@ -307,13 +306,13 @@ DEFER: time-
 : gmt ( timestamp -- timestamp )
     instant >>gmt-offset ; inline
 
-: local-time ( timestamp -- timestamp )
+: local ( timestamp -- timestamp )
     gmt-offset-duration >>gmt-offset ; inline
 
 : convert-timezone ( timestamp duration -- timestamp )
     [ over gmt-offset>> time- (time+) ] [ >>gmt-offset ] bi ;
 
-: >local-time ( timestamp -- timestamp )
+: >local ( timestamp -- timestamp )
     gmt-offset-duration convert-timezone ;
 
 : >gmt ( timestamp -- timestamp )
index 731f815b402b474d26948c27cb2a65b8354936f5..15829af3ac96441977bceeb02756f56219adb623 100644 (file)
@@ -227,7 +227,7 @@ M: windows file-systems
         { FILETIME FILETIME FILETIME }
         [ GetFileTime win32-error=0/f ]
         with-out-parameters
-        [ FILETIME>timestamp >local-time ] tri@
+        [ FILETIME>timestamp >local ] tri@
     ] with-destructors ;
 
 : set-file-times ( path timestamp/f timestamp/f timestamp/f -- )