remove calendar-backend and use os
							parent
							
								
									393f77715c
								
							
						
					
					
						commit
						28d804d2c4
					
				| 
						 | 
				
			
			@ -1,5 +1,4 @@
 | 
			
		|||
USING: kernel ;
 | 
			
		||||
USING: kernel system ;
 | 
			
		||||
IN: calendar.backend
 | 
			
		||||
 | 
			
		||||
SYMBOL: calendar-backend
 | 
			
		||||
HOOK: gmt-offset calendar-backend ( -- hours minutes seconds )
 | 
			
		||||
HOOK: gmt-offset os ( -- hours minutes seconds )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,17 +1,12 @@
 | 
			
		|||
USING: alien alien.c-types arrays calendar.backend
 | 
			
		||||
kernel structs math unix.time namespaces ;
 | 
			
		||||
 | 
			
		||||
kernel structs math unix.time namespaces system ;
 | 
			
		||||
IN: calendar.unix
 | 
			
		||||
 | 
			
		||||
TUPLE: unix-calendar ;
 | 
			
		||||
 | 
			
		||||
T{ unix-calendar } calendar-backend set-global
 | 
			
		||||
 | 
			
		||||
: get-time ( -- alien )
 | 
			
		||||
    f time <uint> localtime ;
 | 
			
		||||
 | 
			
		||||
: timezone-name ( -- string )
 | 
			
		||||
    get-time tm-zone ;
 | 
			
		||||
 | 
			
		||||
M: unix-calendar gmt-offset ( -- hours minutes seconds )
 | 
			
		||||
M: unix gmt-offset ( -- hours minutes seconds )
 | 
			
		||||
    get-time tm-gmtoff 3600 /mod 60 /mod ;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,8 @@
 | 
			
		|||
USING: calendar.backend namespaces alien.c-types
 | 
			
		||||
USING: calendar.backend namespaces alien.c-types system
 | 
			
		||||
windows windows.kernel32 kernel math combinators ;
 | 
			
		||||
IN: calendar.windows
 | 
			
		||||
 | 
			
		||||
TUPLE: windows-calendar ;
 | 
			
		||||
 | 
			
		||||
T{ windows-calendar } calendar-backend set-global
 | 
			
		||||
 | 
			
		||||
M: windows-calendar gmt-offset ( -- hours minutes seconds )
 | 
			
		||||
M: windows gmt-offset ( -- hours minutes seconds )
 | 
			
		||||
    "TIME_ZONE_INFORMATION" <c-object>
 | 
			
		||||
    dup GetTimeZoneInformation {
 | 
			
		||||
        { [ dup TIME_ZONE_ID_INVALID = ] [ win32-error-string throw ] }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue