@q
@program cmd-laston 
1 9999 d
i
( laston.muf, by Scotfox, 11-June-1993. )
( Lets you find out how long ago someone was on-line.  In conjunction with )
(   record-last-site, lets wizards see where someone last connected from. )
( Usage: "last <player>" )
( Properties: @set yourself = _block_last:yes to prevent anyone from seeing )
(   when you were last connected. )
: last-help
    me @ "\"last playername\" tells you the last time that player was connected.  \"last #block\" makes it so nobody else can use 'last' on you.  \"last #unblock\" lets 'last' work on you again." notify
;
: last-time ( name dbref -- name dbref time time )
    dup "@/laston" getpropstr dup if atoi dup exit then
    pop dup timestamps pop rot rot pop pop dup
;
: how-long-ago  ( seconds )
    systime swap - dup 60 < if pop "(under a minute ago)" exit then
    60 / "(" swap  ( string minutes )
    ( 60 * 24 * 28 = 40320, about the number of minutes in a moon cycle )
    dup 40320 > if
        dup 40320 / intostr " moons " strcat rot swap strcat swap
        40320 % then
    ( 60 * 24 = 1440, the number of minutes in a day )
    dup 1440 > if
        dup 1440 / intostr " days " strcat rot swap strcat swap
        1440 % then
    ( 60 minutes in an hour )
    dup 60 > if
        dup 60 / intostr " hours " strcat rot swap strcat swap
        60 % then
    intostr " minutes ago)" strcat strcat
;
: last-on
    dup "" strcmp not if pop last-help exit then
    dup "#block" stringcmp not if
        me @ "_block_last" "yes" 0 addprop
        me @ "Now nobody can see when you were last connected." notify
        pop exit then
    dup "#unblock" stringcmp not if
        me @ "_block_last" remove_prop
        me @ "Now anyone can see when you were last connected." notify
        pop exit then
    dup .pmatch
    dup #-1 dbcmp if
        pop pop me @ "I don't know anyone by that name." notify exit then
    ( name dbref )
    swap pop dup name swap  ( get the exact name )
    ( name dbref )
    dup awake? over "D" flag? not and if swap " is online right now" strcat
    else dup "_block_last" getpropstr .yes? over "d" flag? or if
        over "'s last-connection information isn't public" strcat
        me @ "W" flag? not if
            "." strcat me @ swap notify pop pop exit then
        ", but since you're a wizard..." strcat me @ swap notify then
        last-time ( name dbref time time )
          " last left the game on %A, %B %e, %Y, at %I:%M %p %Z " swap timefmt
        ( name dbref time string )
        4 rotate swap strcat
        over how-long-ago strcat swap pop then
    ( name dbref string )
    me @ "W" flag? 3 pick "G" flag? not and if
    over "+/host" getpropstr
        dup "" strcmp if " from " swap strcat strcat else pop then then
    "." strcat me @ swap notify
    pop
;
.
c
q