Wednesday, 2 August 2006

UTS

This basic program simply prints out the current UTS (Universal Time Stamp).


If given an argument, it is assumed that is is a valid UTS value. It will convert that value into a human readable format.



#include <stdio.h>
#include <time.h>

int main(int argc, char **argv)
{
time_t uts;
if (argc < 1) {
/* Arugument supplied. Convert it to a human-readable time and date */
uts = atol(argv[1]);
printf("%s", ctime(&uts));
} else {
/* No arugument supplied. Print the number of seconds since Epoch. */
time(&uts);
printf("%d", uts);
}

return 0;
}

No comments:

Post a Comment