amiga-tz/example/adjust.c

62 lines
1.4 KiB
C

#include <stdio.h>
#include <proto/exec.h>
#include <clib/dos_protos.h>
#include "clib/timezone.h"
#include "inline/timezone.h"
struct Library *TimezoneBase;
void show()
{
time_t rawtime;
struct tm *info;
struct tm tmp;
char buffer[80];
int daylight;
long timezone;
long altzone;
char** tzname;
time(&rawtime);
info = localtime_r(&rawtime,&tmp);
strftime(buffer,80,"%+", info);
printf("%s\n", buffer);
daylight = daylight_c();
timezone = timezone_c();
altzone = altzone_c();
tzname = tzname_c();
printf("daylight (est): %d\n", daylight);
printf("timezone: %ld\n", timezone);
printf("altzone: %ld\n", altzone);
printf("tzname[0]: %s\n", tzname[0]);
printf("tzname[1]: %s\n", tzname[1]);
}
void set(char *tz)
{
printf("--------------------------------------------\n");
show();
SetVar((STRPTR)TZVARIABLE, (STRPTR)tz, strlen(tz) + 1, GVF_GLOBAL_ONLY);
tzset();
printf("----------------- tzset --------------------\n");
show();
printf("--------------------------------------------\n");
}
int main()
{
TimezoneBase = OpenLibrary("timezone.library", 3L);
if (!TimezoneBase) {
printf("Cannot open timezone library.\n");
return 5;
}
set("Europe/Copenhagen");
set("Europe/Moscow");
set("Europe/Copenhagen");
CloseLibrary(TimezoneBase);
return 0;
}