libs-base/Testing/nstimezone.m

44 lines
1.3 KiB
Mathematica
Raw Permalink Normal View History

/* Test time zone code. */
#include <stdio.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSDate.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSTimeZone.h>
#include <Foundation/NSCalendarDate.h>
int
main ()
{
NSTimeZone *system;
NSTimeZone *other;
NSCalendarDate *date;
CREATE_AUTORELEASE_POOL(pool);
GSPrintf(stdout, @"GMT time zone %x\n",
[NSTimeZone timeZoneWithAbbreviation:@"GMT"]);
GSPrintf(stdout, @"System time zone\n");
system = [NSTimeZone systemTimeZone];
GSPrintf(stdout, @" %@\n\n", [system description]);
GSPrintf(stdout, @"Local time zone:\n %@\n\n",
[[NSTimeZone localTimeZone] description]);
GSPrintf(stdout, @"Time zone for PST (from dict):\n %@\n",
[[NSTimeZone abbreviationDictionary] objectForKey: @"PST"]);
GSPrintf(stdout, @"Time zones for PST (from map):\n %@\n",
[[[NSTimeZone abbreviationMap] objectForKey: @"PST"] description]);
other = [NSTimeZone timeZoneWithAbbreviation: @"CEST"];
GSPrintf(stdout, @"Time zone for CEST:\n %@\n", other);
date = [[NSCalendarDate alloc] initWithString:@"09/04/2003 17:58:45 CEST"
calendarFormat:@"%m/%d/%Y %H:%M:%S %Z"];
GSPrintf(stdout, @"Date in CEST:\n %@\n", date);
RELEASE(pool);
return 0;
}