Minix current time

1.2k views Asked by At

How to write current time in printf on Minix 3.2.1?
I try to use gmtime like below but it gives error on time(&nowtime).

#include <sys/time.h>
#include <time.h>

struct tm *now;
time_t nowtime;
time(&nowtime);
now=gmtime(&nowtime);

printf("TIME is NOW %s",now);

Moreover, I try to recall that in kernel (/usr/src/kernel/main.c) because I need that time on the booting of minix to say when the kernel process is finished and switch to user.

I take some errors on above code like when rebuild the kernel like below;

enter image description here

1

There are 1 answers

5
TonyB On

Not that familiar with minix, but it is similar to Unix & Linux, so maybe something from that platform may be present on minix... so A couple of approaches

  • Run a man on ctime

  • the man page on Linux's time() command contains this example code (which you may have to modify for minix, but it shows how to use asctime() localtime() and time() ):

      #include <stdio.h>
      #include <time.h>
    
      int main(void)
      {
          time_t result;
    
          result = time(NULL);
          printf("%s%ju secs since the Epoch\n",
              asctime(localtime(&result)),
                  (uintmax_t)result);
          return(0);
      }