#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <err.h>
#include <locale.h>

#define BUF_SIZE 200

int
main(int argc, char *argv[])
{
    time_t t;
    struct tm *loc;
    char buf[BUF_SIZE];

    if (setlocale(LC_ALL, "") == NULL)
        errx(EXIT_FAILURE, "setlocale");

    t = time(NULL);

    printf("ctime() of time() value is: %s", ctime(&t));

    loc = localtime(&t);
    if (loc == NULL)
        errx(EXIT_FAILURE, "localtime");

    printf("asctime() of local time is: %s", asctime(loc));

    if (strftime(buf, BUF_SIZE, "%A, %d %B %Y, %H:%M:%S %Z", loc) == 0)
        errx(EXIT_FAILURE, "strfime");

    printf("strftime() of local time is: %s\n", buf);

    exit(EXIT_SUCCESS);
}
