amiga-tz/example/gmtime.c

32 lines
704 B
C

#include <stdio.h>
#include <proto/exec.h>
#include "clib/timezone.h"
#include "inline/timezone.h"
#define BST (+1)
#define CCT (+8)
struct Library *TimezoneBase;
int main ()
{
time_t rawtime;
struct tm *info;
TimezoneBase = OpenLibrary("timezone.library", 3L);
if (!TimezoneBase) {
printf("Cannot open timezone library.\n");
return 5;
}
time(&rawtime);
info = gmtime(&rawtime);
printf("Current world clock:\n");
printf("London (Fixed BST = GMT +1) : %2d:%02d\n", (info->tm_hour+BST)%24, info->tm_min);
printf("China (Fixed CCT = GMT +8) : %2d:%02d\n", (info->tm_hour+CCT)%24, info->tm_min);
CloseLibrary(TimezoneBase);
return 0;
}