use standardised locale for testing

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32606 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-03-16 14:01:09 +00:00
parent 8bea71efa9
commit 20f1317464
4 changed files with 239 additions and 102 deletions

View file

@ -4,31 +4,32 @@
#import <Foundation/NSString.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSUserDefaults.h>
#import <Foundation/NSTimeZone.h>
#include "./western.h"
@interface NSCalendarDate(TestAdditions)
-(BOOL) testDateValues: (int)y : (int)m : (int)d : (int)h : (int)i : (int)s;
@end
@implementation NSCalendarDate(TestAdditions)
-(BOOL) testDateValues: (int)y : (int)m : (int)d : (int)h : (int)i : (int)s
{
{
return (y == [self yearOfCommonEra] && m == [self monthOfYear]
&& d == [self dayOfMonth] && h == [self hourOfDay]
&& i == [self minuteOfHour] && s == [self secondOfMinute]);
}
@end
int main()
{
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *val1, *val2;
NSCalendarDate *date1, *date2;
NSDictionary *locale;
NSTimeZone *tz;
val1 = @"1999-12-31 23:59:59";
val1 = @"1999-12-31 23:59:59";
val2 = @"%Y-%m-%d %H:%M:%S";
/* Y2K checks */
date1 = [NSCalendarDate calendarDate];
PASS(date1 != nil && [date1 isKindOfClass: [NSCalendarDate class]],
@ -37,109 +38,117 @@ int main()
date1 = [NSCalendarDate dateWithString: val1 calendarFormat: val2];
PASS(date1 != nil, "+dateWithString:calendarFormat: works");
locale = [NSDictionary dictionaryWithObjectsAndKeys:
[NSArray arrayWithObjects:
@"Sun", @"Mon", @"Tue", @"Wed", @"Thu", @"Fri", @"Sat",
nil], NSShortWeekDayNameArray,
nil];
locale = westernLocale();
date1 = [NSCalendarDate dateWithString: @"Fri Oct 27 08:41:14GMT 2000"
calendarFormat: nil
locale: locale];
PASS(date1 != nil,
"+dateWithString:calendarFormat:locale: with nil format works");
date1 = [NSCalendarDate dateWithString: @"1999-12-31 23:59:"
calendarFormat: val2];
date1 = [NSCalendarDate dateWithString: @"1999-12-31 23:59:"
calendarFormat: val2
locale: locale];
PASS(date1 == nil,
"+dateWithString:calendarFormat:locale: objects to missing seconds");
date1 = [NSCalendarDate dateWithString: @"1999-12-31 23::00"
calendarFormat: val2];
date1 = [NSCalendarDate dateWithString: @"1999-12-31 23::00"
calendarFormat: val2
locale: locale];
PASS(date1 == nil,
"+dateWithString:calendarFormat:locale: objects to missing minutes");
date1 = [NSCalendarDate dateWithString: @"1999-12-31 :00:00"
calendarFormat: val2];
date1 = [NSCalendarDate dateWithString: @"1999-12-31 :00:00"
calendarFormat: val2
locale: locale];
PASS(date1 == nil,
"+dateWithString:calendarFormat:locale: objects to missing hours");
date1 = [NSCalendarDate dateWithString: @"1999-12-00 00:00:00"
calendarFormat: val2];
date1 = [NSCalendarDate dateWithString: @"1999-12-00 00:00:00"
calendarFormat: val2
locale: locale];
PASS(date1 == nil,
"+dateWithString:calendarFormat:locale: objects to zero day");
date1 = [NSCalendarDate dateWithString: @"1999-00-01 00:00:00"
calendarFormat: val2];
date1 = [NSCalendarDate dateWithString: @"1999-00-01 00:00:00"
calendarFormat: val2
locale: locale];
PASS(date1 == nil,
"+dateWithString:calendarFormat:locale: objects to zero month");
date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"];
date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"
locale: locale];
PASS(date1 == nil,
"+dateWithString:calendarFormat:locale: objects to missing timezone");
date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00 this_is_a_ridiculously_long_timezone_name_and_is_in_fact_designed_to_exceed_the_one_hundred_and_twenty_bytes_temporary_data_buffer_size_used_within_the_gnustep_base_method_which_parses_it"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"];
date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00 this_is_a_ridiculously_long_timezone_name_and_is_in_fact_designed_to_exceed_the_one_hundred_and_twenty_bytes_temporary_data_buffer_size_used_within_the_gnustep_base_method_which_parses_it"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"
locale: locale];
PASS(date1 == nil,
"+dateWithString:calendarFormat:locale: objects to long timezone");
date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00 GMT+0100"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"];
date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00 GMT+0100"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"
locale: locale];
PASS(date1 != nil,
"+dateWithString:calendarFormat:locale: handles GMT+0100 timezone");
date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00 GMT-0100"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"];
date1 = [NSCalendarDate dateWithString: @"1999-12-31 00:00:00 GMT-0100"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"
locale: locale];
PASS(date1 != nil,
"+dateWithString:calendarFormat:locale: handles GMT-0100 timezone");
date1 = [NSCalendarDate dateWithString:
@"1999-12-31 00:00:00 Africa/Addis_Ababa"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"];
@"1999-12-31 00:00:00 Africa/Addis_Ababa"
calendarFormat: @"%Y-%m-%d %H:%M:%S %Z"
locale: locale];
PASS(date1 != nil,
"+dateWithString:calendarFormat:locale: handles Africa/Addis_Ababa");
date1 = [NSCalendarDate dateWithString: @"1999-12-31 23:59:59"
calendarFormat: val2];
date1 = [NSCalendarDate dateWithString: @"1999-12-31 23:59:59"
calendarFormat: val2
locale: locale];
PASS([date1 testDateValues: 1999 : 12 : 31 : 23 : 59 : 59],
"date check with %s", [[date1 description] cString]);
date2 = [date1 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2000 : 01 : 01 : 00 : 00 : 00],
PASS([date2 testDateValues: 2000 : 01 : 01 : 00 : 00 : 00],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2000 : 01 : 01 : 00 : 00 : 01],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2000 : 01 : 01 : 01 : 00 : 01],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 1999 : 12 : 31 : 23 : 00 : 01],
"date check with %s", [[date2 description] cString]);
/* Y2K is a leap year checks */
date2 = [NSCalendarDate dateWithString: @"2000-2-28 23:59:59"
calendarFormat: val2];
date2 = [NSCalendarDate dateWithString: @"2000-2-28 23:59:59"
calendarFormat: val2
locale: locale];
PASS([date2 testDateValues: 2000 : 02 : 28 : 23 : 59 : 59],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2000 : 02 : 29 : 00 : 00 : 00],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2000 : 02 : 29 : 00 : 00 : 01],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2000 : 02 : 29 : 01 : 00 : 01],
@ -149,38 +158,39 @@ int main()
months: 0 days: 0 hours: -2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2000 : 02 : 28 : 23 : 00 : 01],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 5 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2000 : 02 : 29 : 04 : 00 : 01],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 1
months: 0 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2001 : 03 : 01 : 04 : 00 : 01],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: -1 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2001 : 02 : 28 : 04 : 00 : 01],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 1
months: 0 days: 1 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 03 : 01 : 04 : 00 : 01],
"date check with %s", [[date2 description] cString]);
/* 2004 is a year leap check */
date2 = [NSCalendarDate dateWithString: @"2004-2-28 23:59:59"
calendarFormat: val2];
date2 = [NSCalendarDate dateWithString: @"2004-2-28 23:59:59"
calendarFormat: val2
locale: locale];
PASS([date2 testDateValues: 2004 : 02 : 28 : 23 : 59 : 59],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2004 : 02 : 29 : 00 : 00 : 00],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2004 : 02 : 29 : 00 : 00 : 01],
@ -194,14 +204,15 @@ int main()
months: 0 days: 0 hours: -2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2004 : 02 : 28 : 23 : 00 : 01],
"date check with %s", [[date2 description] cString]);
/* 2100 is not a leap year */
date2 = [NSCalendarDate dateWithString: @"2100-2-28 23:59:59"
calendarFormat: val2];
calendarFormat: val2
locale: locale];
PASS([date2 testDateValues: 2100 : 02 : 28 : 23 : 59 : 59],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2100 : 03 : 01 : 00 : 00 : 00],
@ -219,12 +230,13 @@ int main()
months: 0 days: 0 hours: -2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2100 : 02 : 28 : 23 : 00 : 01],
"date check with %s", [[date2 description] cString]);
/* daylight savings time checks */
[NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: @"GB"]];
date2 = [NSCalendarDate dateWithString: @"2002-3-31 00:30:00"
calendarFormat: val2];
calendarFormat: val2
locale: locale];
PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00],
"date check with %s", [[date2 description] cString]);
@ -232,7 +244,7 @@ int main()
months: 0 days: 0 hours: 1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 03 : 31 : 02 : 30 : 00],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00],
@ -242,7 +254,7 @@ int main()
months: 0 days: 0 hours: 2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 03 : 31 : 02 : 30 : 00],
"date check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00],
@ -252,18 +264,19 @@ int main()
PASS([date2 testDateValues: 2002 : 03 : 30 : 23 : 30 : 00],
"date check with %s", [[date2 description] cString]);
/* End daylight savings checks */
/* Seconds calculation checks */
date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00"
calendarFormat: val2];
calendarFormat: val2
locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date second calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: -1];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 29 : 59],
"date second calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
@ -276,15 +289,16 @@ int main()
/* Minutes calculation checks */
date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00"
calendarFormat: val2];
calendarFormat: val2
locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date minute calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: -1 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 29 : 00],
"date minute calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 1 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
@ -297,15 +311,16 @@ int main()
/* Hour calculation checks */
date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00"
calendarFormat: val2];
calendarFormat: val2
locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date hour calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 26 : 23 : 30 : 00],
"date hour calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
@ -315,18 +330,19 @@ int main()
months: 0 days: 0 hours: 2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 02 : 30 : 00],
"date hour calculation check with %s", [[date2 description] cString]);
/* Days calculation checks */
date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00"
calendarFormat: val2];
calendarFormat: val2
locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date day calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: -1 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 26 : 00 : 30 : 00],
"date day calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 0 days: 1 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
@ -339,15 +355,16 @@ int main()
/* Months calculation checks */
date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00"
calendarFormat: val2];
calendarFormat: val2
locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date month calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: -1 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 9 : 27 : 00 : 30 : 00],
"date month calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 0
months: 1 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
@ -360,15 +377,16 @@ int main()
/* Years calculation checks */
date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00"
calendarFormat: val2];
calendarFormat: val2
locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date year calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: -1
months: 0 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2001 : 10 : 27 : 00 : 30 : 00],
"date year calculation check with %s", [[date2 description] cString]);
date2 = [date2 dateByAddingYears: 1
months: 0 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],

View file

@ -3,45 +3,53 @@
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSString.h>
#import <Foundation/NSUserDefaults.h>
#include "./western.h"
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSTimeInterval time1, time2, time3, time4, time5, time6, time7, time8, time9;
NSCalendarDate *date1;
NSMutableDictionary *m;
NSDictionary *locale;
m = [[[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]
mutableCopy] autorelease];
[m setObject: [NSArray arrayWithObjects: @"am", @"pm", nil]
forKey: NSAMPMDesignation];
locale = westernLocale();
time1 = [[NSCalendarDate dateWithString: @"Nov 20 02 01:54:22"
calendarFormat: @"%b %d %y %H:%M:%S"]
calendarFormat: @"%b %d %y %H:%M:%S"
locale: locale]
timeIntervalSinceReferenceDate];
time2 = [[NSCalendarDate dateWithString: @"Nov 20 02 02:54:22"
calendarFormat: @"%b %d %y %H:%M:%S"]
calendarFormat: @"%b %d %y %H:%M:%S"
locale: locale]
timeIntervalSinceReferenceDate];
time3 = [[NSCalendarDate dateWithString: @"Nov 20 02 03:54:22"
calendarFormat: @"%b %d %y %H:%M:%S"]
calendarFormat: @"%b %d %y %H:%M:%S"
locale: locale]
timeIntervalSinceReferenceDate];
time4 = [[NSCalendarDate dateWithString: @"Nov 20 02 04:54:22"
calendarFormat: @"%b %d %y %H:%M:%S"]
calendarFormat: @"%b %d %y %H:%M:%S"
locale: locale]
timeIntervalSinceReferenceDate];
time5 = [[NSCalendarDate dateWithString: @"Nov 20 02 05:54:22"
calendarFormat: @"%b %d %y %H:%M:%S"]
calendarFormat: @"%b %d %y %H:%M:%S"
locale: locale]
timeIntervalSinceReferenceDate];
time6 = [[NSCalendarDate dateWithString: @"Nov 20 02 06:54:22"
calendarFormat: @"%b %d %y %H:%M:%S"]
calendarFormat: @"%b %d %y %H:%M:%S"
locale: locale]
timeIntervalSinceReferenceDate];
time7 = [[NSCalendarDate dateWithString: @"Nov 20 02 07:54:22"
calendarFormat: @"%b %d %y %H:%M:%S"]
calendarFormat: @"%b %d %y %H:%M:%S"
locale: locale]
timeIntervalSinceReferenceDate];
time8 = [[NSCalendarDate dateWithString: @"Nov 20 02 08:54:22"
calendarFormat: @"%b %d %y %H:%M:%S"]
calendarFormat: @"%b %d %y %H:%M:%S"
locale: locale]
timeIntervalSinceReferenceDate];
time9 = [[NSCalendarDate dateWithString: @"Nov 20 02 09:54:22"
calendarFormat: @"%b %d %y %H:%M:%S"]
calendarFormat: @"%b %d %y %H:%M:%S"
locale: locale]
timeIntervalSinceReferenceDate];
PASS ((time1 < time2 && time2 < time3 && time3 < time4 && time4 < time5
@ -50,16 +58,17 @@ int main()
date1 = [NSCalendarDate dateWithString: @"Nov 29 06 12:00am"
calendarFormat: @"%b %d %y %H:%M%p"
locale: m];
locale: locale];
PASS(date1 != nil && [date1 hourOfDay] == 0, "12:00am is midnight");
date1 = [NSCalendarDate dateWithString: @"Nov 29 06 12:00pm"
calendarFormat: @"%b %d %y %H:%M%p"
locale: m];
locale: locale];
PASS(date1 != nil && [date1 hourOfDay] == 12, "12:00pm is noon");
date1 = [NSCalendarDate dateWithString: @"Nov 29 06 01:25:38"
calendarFormat: @"%b %d %y %H:%M:%S"];
calendarFormat: @"%b %d %y %H:%M:%S"
locale: locale];
PASS([date1 timeIntervalSinceReferenceDate] + 1 == [[date1 addTimeInterval:1]
timeIntervalSinceReferenceDate],
"-addTimeInterval: works on a NSCalendarDate parsed with no timezone");
@ -70,9 +79,9 @@ int main()
NSString *dateString = @"2006-04-22 22:22:22:901";
NSString *dateString2 = @"2006-04-2 22:22:22:901";
NSCalendarDate *date = [NSCalendarDate
dateWithString:dateString calendarFormat:fmt];
dateWithString:dateString calendarFormat:fmt locale:locale];
NSCalendarDate *date2 = [NSCalendarDate
dateWithString:dateString2 calendarFormat:fmt2];
dateWithString:dateString2 calendarFormat:fmt2 locale:locale];
NSLog(@"%@\n%@", dateString, [date descriptionWithCalendarFormat:fmt]);
PASS([dateString isEqual: [date descriptionWithCalendarFormat:fmt]],
"formatting milliseconds works");

View file

@ -4,7 +4,8 @@
#import <Foundation/NSCalendarDate.h>
#import <Foundation/NSString.h>
#import <Foundation/NSTimeZone.h>
#import <Foundation/NSUserDefaults.h>
#include "./western.h"
int main()
{
@ -13,7 +14,8 @@ int main()
NSMutableDictionary *myLocale;
NSCalendarDate *myBirthday;
NSCalendarDate *anotherDay;
myLocale = [NSMutableDictionary new];
myLocale = westernLocale();
tmpArray = [NSMutableArray new];
[tmpArray addObject: @"Gen"];

View file

@ -0,0 +1,108 @@
#import "Foundation/NSArray.h"
#import "Foundation/NSDictionary.h"
#import "Foundation/NSString.h"
#import "Foundation/NSUserDefaults.h"
/* Function to return a standardised locale dictionary.
*/
static NSMutableDictionary *
westernLocale()
{
NSArray *ampm;
NSArray *long_day;
NSArray *long_month;
NSArray *short_day;
NSArray *short_month;
NSArray *earlyt;
NSArray *latert;
NSArray *hour_names;
NSArray *ymw_names;
ampm = [NSArray arrayWithObjects: @"AM", @"PM", nil];
short_month = [NSArray arrayWithObjects:
@"Jan",
@"Feb",
@"Mar",
@"Apr",
@"May",
@"Jun",
@"Jul",
@"Aug",
@"Sep",
@"Oct",
@"Nov",
@"Dec",
nil];
long_month = [NSArray arrayWithObjects:
@"January",
@"February",
@"March",
@"April",
@"May",
@"June",
@"July",
@"August",
@"September",
@"October",
@"November",
@"December",
nil];
short_day = [NSArray arrayWithObjects:
@"Sun",
@"Mon",
@"Tue",
@"Wed",
@"Thu",
@"Fri",
@"Sat",
nil];
long_day = [NSArray arrayWithObjects:
@"Sunday",
@"Monday",
@"Tuesday",
@"Wednesday",
@"Thursday",
@"Friday",
@"Saturday",
nil];
earlyt = [NSArray arrayWithObjects:
@"prior",
@"last",
@"past",
@"ago",
nil];
latert = [NSArray arrayWithObjects: @"next", nil];
ymw_names = [NSArray arrayWithObjects: @"year", @"month", @"week", nil];
hour_names = [NSArray arrayWithObjects:
[NSArray arrayWithObjects: @"0", @"midnight", nil],
[NSArray arrayWithObjects: @"12", @"noon", @"lunch", nil],
[NSArray arrayWithObjects: @"10", @"morning", nil],
[NSArray arrayWithObjects: @"14", @"afternoon", nil],
[NSArray arrayWithObjects: @"19", @"dinner", nil],
nil];
return [NSMutableDictionary dictionaryWithObjectsAndKeys:
ampm, NSAMPMDesignation,
long_month, NSMonthNameArray,
long_day, NSWeekDayNameArray,
short_month, NSShortMonthNameArray,
short_day, NSShortWeekDayNameArray,
@"DMYH", NSDateTimeOrdering,
[NSArray arrayWithObject: @"tomorrow"], NSNextDayDesignations,
[NSArray arrayWithObject: @"nextday"], NSNextNextDayDesignations,
[NSArray arrayWithObject: @"yesterday"], NSPriorDayDesignations,
[NSArray arrayWithObject: @"today"], NSThisDayDesignations,
earlyt, NSEarlierTimeDesignations,
latert, NSLaterTimeDesignations,
hour_names, NSHourNameDesignations,
ymw_names, NSYearMonthWeekDesignations,
nil];
}