6.32 Keeping track of Time

ms ( n –  ) facility-ext “ms”
ns ( d –  ) gforth-1.0 “ns”
time&date ( – nsec nmin nhour nday nmonth nyear  ) facility-ext “time-and-date”

Report the current time of day. Seconds, minutes and hours are numbered from 0. Months are numbered from 1.

>time&date&tz ( udtime – nsec nmin nhour nday nmonth nyear fdst ndstoff c-addrtz utz ) gforth-1.0 “to-time-and-date”

Convert time in seconds since 1.1.1970 0:00Z to the current time of day. Seconds, minutes and hours are numbered from 0. Months are numbered from 1.

utime ( – dtime ) gforth-0.5 “utime”

Report the current time in microseconds since some epoch. Use #1000000 um/mod nip to convert to seconds

ntime ( – dtime ) gforth-1.0 “ntime”

Report the current time in nanoseconds since some epoch.

cputime ( – duser dsystem ) gforth-0.5 “cputime”

duser and dsystem are the respective user- and system-level CPU times used since the start of the Forth system (excluding child processes), in microseconds (the granularity may be much larger, however). On platforms without the getrusage call, it reports elapsed time (since some epoch) for duser and 0 for dsystem.