Changeset 2612


Ignore:
Timestamp:
Oct 16, 2011, 2:01:43 AM (4 years ago)
Author:
wmb
Message:

Core - added deferred time&date to kernel so it can be used uniformly.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • forth/kernel/kernel.fth

    r2263 r2612  
    31353135;
    31363136[then]
     3137defer time&date  ( -- s m h d m y )
     3138: now  ( -- s m h )  time&date 3drop  ;
     3139: today  ( -- d m y )  time&date >r >r >r  3drop  r> r> r>  ;
     3140
    31373141
    31383142\ LICENSE_BEGIN
  • forth/kernel/sysio.fth

    r1232 r2612  
    170170;
    171171
     172: l@+  ( adr -- l adr' )  dup l@  swap la1+  ;
     173: sys-time&date  ( -- s m h d m y )
     174   d# 64 syscall retval                     ( adr )
     175   l@+ l@+ l@+ l@+ l@+ l@+ drop  d# 1900 +  ( s m h d m y )
     176;
     177
    172178: install-wrapper-alloc  ( -- )
    173179   \ Don't use "is" in case a relocation map needs to be allocated first
     
    195201   install-wrapper-key
    196202   ['] sys-$getenv is $getenv
     203   ['] sys-time&date is time&date
    197204;
    198205
  • forth/lib/date.fth

    r1 r2612  
    11\ See license at end of file
    2 purpose: Date and Time-of-day access
     2purpose: Date and Time-of-day display
    33
    44decimal
    5 variable tmstruct
    6 : tmfield  \ name  ( offset -- offset' )
    7    create  dup ,  la1+
    8    does> @  tmstruct @ +
    9 ;
    10 
    11 struct   \ tm struct returned by 4.2 localtime call
    12 tmfield tm_sec
    13 tmfield tm_min
    14 tmfield tm_hour
    15 tmfield tm_mday
    16 tmfield tm_mon
    17 tmfield tm_year
    18 tmfield tm_wday
    19 tmfield tm_yday
    20 tmfield tm_isdst
    21 drop
    22 
    23 : (today  ( -- timeval-struct-adr )  64 syscall retval tmstruct !  ;
    24 : today  ( -- day month year)
    25    (today  tm_mday l@   tm_mon  l@ 1+  tm_year l@ 1900 +
    26 ;
    27 : now  ( -- sec min hour )  (today  tm_sec l@  tm_min l@  tm_hour l@  ;
    285: time-zone  ( -- minutes-west-of-GMT)  68 syscall retval  ;
    296: .time-zone  ( -- )   72 syscall retval cscount type  ;
     
    7754: .now  ( -- )  now .time  ;
    7855: .today  ( -- )  today .date  ;
     56
    7957\ LICENSE_BEGIN
    8058\ Copyright (c) 2006 FirmWorks
  • ofw/core/date.fth

    r1 r2612  
    44variable clock-node  ' clock-node  " clock" chosen-variable
    55
    6 : time&date  ( -- s m h d m y )
     6: ofw-time&date  ( -- s m h d m y )
    77   " get-date" clock-node @ ihandle>phandle find-method  if
    88      drop
     
    1313   then
    1414;
    15 : now  ( -- s m h )  time&date 3drop  ;
    16 : today  ( -- d m y )  time&date >r >r >r  3drop  r> r> r>  ;
     15stand-init:
     16   ['] ofw-time&date to time&date
     17;
    1718
    1819headerless
    1920: 2.d  ( n -- )   push-decimal  (.2)  type  pop-base  ;
     21: 4.d  ( n -- )   push-decimal  <# u# u# u# u# u#>  type  pop-base  ;
    2022
    2123headers
    22 : .date  ( d m y -- )   swap 2.d ." /" swap 2.d ." /" d# 100 mod 2.d  ;
     24: .date  ( d m y -- )   4.d ." -" 2.d ." -" 2.d  ;
    2325: .time  ( s m h -- )   2.d ." :" 2.d ." :" 2.d  ;
    2426
  • ofw/core/ofwfw.fth

    r1642 r2612  
    55variable clock-node  ' clock-node  " clock" chosen-variable
    66
    7 : time&date  ( -- s m h d m y )
     7: ofw-time&date  ( -- s m h d m y )
    88   " get-date" clock-node @ ihandle>phandle find-method  if
    99      drop
     
    1414   then
    1515;
    16 : now  ( -- s m h )  time&date 3drop  ;
    17 : today  ( -- d m y )  time&date >r >r >r  3drop  r> r> r>  ;
     16stand-init:
     17   ['] ofw-time&date to time&date
     18;
    1819
    1920headerless
Note: See TracChangeset for help on using the changeset viewer.