Day of the week: Difference between revisions

Obj-C
(→‎{{header|python}}: improve efficiency)
(Obj-C)
Line 107:
Sun Dec 25 00:00:00 CST 2089
Sun Dec 25 00:00:00 CST 2095</pre>
 
=={{header|Objective-C}}==
 
<objc>#import <Foundation/Foundation.h>
 
int main()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSUInteger i;
for(i=2008; i<2121; i++)
{
NSCalendarDate *d = [[NSCalendarDate alloc]
initWithYear: i
month: 12
day: 25
hour: 0 minute: 0 second:0
timeZone: [NSTimeZone timeZoneWithAbbreviation:@"CET"] ];
if ( [d dayOfWeek] == 0 )
{
printf("25 Dec %d is Sunday\n", i);
}
[d release];
}
[pool release];
return 0;
}</objc>
 
Output:
 
<pre>
25 Dec 2011 is Sunday
25 Dec 2016 is Sunday
25 Dec 2022 is Sunday
25 Dec 2033 is Sunday
25 Dec 2039 is Sunday
25 Dec 2044 is Sunday
25 Dec 2050 is Sunday
25 Dec 2061 is Sunday
25 Dec 2067 is Sunday
25 Dec 2072 is Sunday
25 Dec 2078 is Sunday
25 Dec 2089 is Sunday
25 Dec 2095 is Sunday
25 Dec 2101 is Sunday
25 Dec 2107 is Sunday
25 Dec 2112 is Sunday
25 Dec 2118 is Sunday
</pre>
 
 
=={{header|UNIX Shell}}==