tcp_date_timeval(?Date, ?Timeval)

This predicate is used to convert between the time format supplied by library(date) and the timeval/2 representation. At least one of the arguments must be ground. The parameter Date is of the form date(Year,Month,Day,Hour,Minute,Second).

library(date) has facilities for portraying time. tcp_date_timeval/2 can be used with library(date) for portrayal:

     :-use_module(library(addportray), [add_portray/1]).
     :-use_module(library(date), [time_stamp/3]).
     :-use_module(library(tcp), [tcp_date_timeval/2]).
     :-initialization add_portray(portray_timeval).
     portray_timeval(timeval(Seconds, MicroSeconds)):-
         tcp_date_timeval(Date,timeval(Seconds, MicroSeconds)),
         time_stamp(Date,'%y %02n %M %02d %W %02c:%02i:', Stamp),
         Date=date(_, _, _, _, _, S),
         X is (S * 1.0e6 + MicroSeconds) / 1.0e6,
         (X < 10 -> write(0) ; true),
         format('~2f', X).

Which would result in the following:

         | ?- tcp_now(X).
         X = 1989 03 March 01 Wednesday 17:09:58.12