56 lines
1.8 KiB
C
56 lines
1.8 KiB
C
//--------------------------------------------------------------------------//
|
|
// This file is in the public domain. //
|
|
//--------------------------------------------------------------------------//
|
|
#include <stdio.h>
|
|
#include <exec/memory.h>
|
|
#include <exec/execbase.h>
|
|
#include <exec/libraries.h>
|
|
//--------------------------------------------------------------------------//
|
|
#include "tzversion.h"
|
|
#include "clib/timezone.h"
|
|
#include "inline/timezone.h"
|
|
//--------------------------------------------------------------------------//
|
|
const char *vers = "\0$VER: TimeZoneInfo" AMIGA_VERSION;
|
|
//--------------------------------------------------------------------------//
|
|
struct Library *TimezoneBase = NULL;
|
|
//--------------------------------------------------------------------------//
|
|
|
|
int main(const int argc, char *argv[])
|
|
{
|
|
struct tm tm;
|
|
struct offset {
|
|
int hours, mins;
|
|
} offset;
|
|
|
|
time_t now ;
|
|
char* loc;
|
|
|
|
TimezoneBase = (struct Library*)OpenLibrary((STRPTR)"timezone.library", 0);
|
|
if (!TimezoneBase) {
|
|
printf("Cannot open timezone library.\n");
|
|
return 5;
|
|
}
|
|
|
|
now = time(NULL);
|
|
localtime_r(&now, &tm);
|
|
|
|
offset.hours = tm.tm_gmtoff / 60 / 60;
|
|
offset.mins = tm.tm_gmtoff / 60 - offset.hours * 60;
|
|
loc = tzlocation();
|
|
|
|
FPrintf(Output(), (STRPTR)"Location is %s\n", loc);
|
|
FPrintf(Output(), (STRPTR)"Time zone is %s\n", tm.tm_zone);
|
|
FPrintf(Output(), (STRPTR)"GMT offset is %ld hours and %ld minutes.\n", offset.hours, offset.mins);
|
|
|
|
if (tm.tm_isdst) {
|
|
FPrintf(Output(), (STRPTR)"It is daylight-saving time.\n");
|
|
} else {
|
|
FPrintf(Output(), (STRPTR)"It is not daylight-saving time.\n");
|
|
}
|
|
|
|
CloseLibrary(TimezoneBase);
|
|
return 0;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------//
|