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

int main(void)
{
    char outstr[200];
    time_t t;
    struct tm *tmp;
    char *fmt = "%Y-%m-%d %a %A %g %G %u %V %w";

    t = 1009756800;

    tmp = localtime(&t);
    if (tmp == NULL) {
        perror("localtime");
        exit(EXIT_FAILURE);
    }

    if (strftime(outstr, sizeof(outstr), fmt, tmp) == 0) {
        fprintf(stderr, "strftime returned 0");
        exit(EXIT_FAILURE);
    }

    printf("Format string is \"%s\"\n", fmt);
    printf("Result string is \"%s\"\n", outstr);
    printf("Expected was     \"2001-12-31 Mon Monday 02 2002 1 01 1\"\n");
    exit(EXIT_SUCCESS);
}

