Files
amiga-tz/example/strftime.c
2015-07-30 14:31:18 +02:00

52 lines
1.4 KiB
C

//--------------------------------------------------------------------------//
// This file is in the public domain. //
//--------------------------------------------------------------------------//
#include <stdio.h>
#include <proto/exec.h>
#include "clib/timezone.h"
#include "inline/timezone.h"
struct Library *TimezoneBase;
int main(const int argc, char *argv[])
{
time_t rawtime;
struct tm *info;
char buffer[80];
TimezoneBase = OpenLibrary("timezone.library", 3L);
if (!TimezoneBase) {
printf("Cannot open timezone library.\n");
return 5;
}
time(&rawtime);
info = localtime(&rawtime);
printf("strftime examples.\n\n");
printf("Globalized:\n");
strftime(buffer,80,"%c", info);
printf("%%c :%s\n", buffer);
strftime(buffer,80,"%x", info);
printf("%%x :%s\n", buffer);
strftime(buffer,80,"%X", info);
printf("%%X :%s\n", buffer);
strftime(buffer,80,"%+", info);
printf("%%+ :%s\n", buffer);
printf("\nLocalized:\n");
strftime_l(buffer,80,"%c", info, NULL);
printf("%%c :%s\n", buffer);
strftime_l(buffer,80,"%x", info, NULL);
printf("%%x :%s\n", buffer);
strftime_l(buffer,80,"%X", info, NULL);
printf("%%X :%s\n", buffer);
strftime_l(buffer,80,"%+", info, NULL);
printf("%%+ :%s\n", buffer);
CloseLibrary(TimezoneBase);
return 0;
}