Sample 2 生まれてから何日生きてきたか? ― 2011/06/12 22:08
本日のみに変更
---- 以下 サンプル
//
// main.m
// nowDay_sample
//
// Created by 鈴木 重則 on 11/06/12.
// Copyright 2011 none. All rights reserved.
//
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int count,count1,count2;
// NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// my brith day
NSCalendarDate *theDate1 = [NSCalendarDate
dateWithString:@"Sunday, 13 June 1957, 00:32 AM"
calendarFormat:@"%A, %d %B %Y, %I:%M %p"];
NSLog([NSString stringWithFormat:@" %d",[theDate1 dayOfCommonEra]]);
count1 = [theDate1 dayOfCommonEra];
// now time
NSDate *theDate2;
theDate2 = [NSCalendarDate calendarDate];
count2 = theDate2;
NSLog([theDate2 description]);
count2 = [theDate2 dayOfCommonEra];
count = count2 - count1;
NSLog(@" count day = %d, Year = %d",count,count/365);
// insert code here...
//NSLog(@"Hello, World!");
[pool drain];
return 0;
}
---- 以下 サンプル
//
// main.m
// nowDay_sample
//
// Created by 鈴木 重則 on 11/06/12.
// Copyright 2011 none. All rights reserved.
//
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int count,count1,count2;
// NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
// my brith day
NSCalendarDate *theDate1 = [NSCalendarDate
dateWithString:@"Sunday, 13 June 1957, 00:32 AM"
calendarFormat:@"%A, %d %B %Y, %I:%M %p"];
NSLog([NSString stringWithFormat:@" %d",[theDate1 dayOfCommonEra]]);
count1 = [theDate1 dayOfCommonEra];
// now time
NSDate *theDate2;
theDate2 = [NSCalendarDate calendarDate];
count2 = theDate2;
NSLog([theDate2 description]);
count2 = [theDate2 dayOfCommonEra];
count = count2 - count1;
NSLog(@" count day = %d, Year = %d",count,count/365);
// insert code here...
//NSLog(@"Hello, World!");
[pool drain];
return 0;
}
コメントをどうぞ
※メールアドレスとURLの入力は必須ではありません。 入力されたメールアドレスは記事に反映されず、ブログの管理者のみが参照できます。
※なお、送られたコメントはブログの管理者が確認するまで公開されません。
※投稿には管理者が設定した質問に答える必要があります。