amiga-tz/example/strptime.c

31 lines
784 B
C

#include <stdio.h> // printf
#include <string.h> // memset
//#include <time.h> // POSIX include file
#include "clib/timezone.h" // strptime, asctime
#include "inline/timezone.h"
#include <proto/exec.h> // OpenLibrary, CloseLibrary
struct Library *TimezoneBase;
int main()
{
struct tm tm;
memset(&tm, 0, sizeof(struct tm));
TimezoneBase = OpenLibrary("timezone.library", 3L);
if (!TimezoneBase) {
printf("Cannot open timezone library.\n");
return 5;
}
printf(
"strptime with args '2000-12-13 14:15:16', "
"'%%Y-%%m-%%d %%H:%%M:%%S'\n");
strptime("2000-12-13 14:15:16", "%Y-%m-%d %H:%M:%S", &tm);
printf("Time is %s", asctime(&tm));
CloseLibrary(TimezoneBase);
return 0;
}