]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/windows/time/time.factor
arm.64.factor: extra semicolon removed
[factor.git] / basis / windows / time / time.factor
index e63834d3695801278f3a78f6234cf6ec564c59ab..7f1bd2d5bfecad1f2a51182a33cdaf155ee45c54 100644 (file)
@@ -1,37 +1,32 @@
 ! Copyright (C) 2007 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: alien alien.c-types kernel math windows windows.kernel32
-namespaces calendar math.bitwise ;
+! See https://factorcode.org/license.txt for BSD license.
+USING: accessors alien alien.c-types calendar calendar.private
+classes.struct kernel math math.bitwise namespaces
+windows.errors windows.handles windows.kernel32 windows.types ;
 IN: windows.time
 
 : >64bit ( lo hi -- n )
-    32 shift bitor ;
+    32 shift bitor ; inline
 
-: windows-1601 ( -- timestamp )
-    1601 1 1 0 0 0 instant <timestamp> ;
+: windows-1601 ( -- timestamp ) 1601 <year-gmt> ;
 
 : FILETIME>windows-time ( FILETIME -- n )
-    [ FILETIME-dwLowDateTime ]
-    [ FILETIME-dwHighDateTime ]
-    bi >64bit ;
+    [ dwLowDateTime>> ] [ dwHighDateTime>> ] bi >64bit ;
 
 : windows-time>timestamp ( n -- timestamp )
-    10000000 /i seconds windows-1601 swap time+ ;
+    [ windows-1601 ] dip 10,000,000 /i +second ;
 
 : windows-time ( -- n )
-    "FILETIME" <c-object> [ GetSystemTimeAsFileTime ] keep
+    FILETIME new [ GetSystemTimeAsFileTime ] keep
     FILETIME>windows-time ;
 
 : timestamp>windows-time ( timestamp -- n )
-    #! 64bit number representing # of nanoseconds since Jan 1, 1601 (UTC)
-    >gmt windows-1601 (time-) 10000000 * >integer ;
+    ! 64bit number representing # of nanoseconds since Jan 1, 1601 (UTC)
+    >gmt windows-1601 (time-) 10,000,000 * >integer ;
 
 : windows-time>FILETIME ( n -- FILETIME )
-    "FILETIME" <c-object>
-    [
-        [ [ 32 bits ] dip set-FILETIME-dwLowDateTime ]
-        [ [ -32 shift ] dip set-FILETIME-dwHighDateTime ] 2bi
-    ] keep ;
+    [ FILETIME new ] dip
+    [ 32 bits >>dwLowDateTime ] [ -32 shift >>dwHighDateTime ] bi ;
 
 : timestamp>FILETIME ( timestamp -- FILETIME/f )
     dup [ >gmt timestamp>windows-time windows-time>FILETIME ] when ;