NSDate NSCalendarDate NSObject NSDate NSCalendarDate NSDate NSCalendarDate NSDate NSCalendar NSDate date NSDate *d = [ NSDate date ]; // NSDate : + (i



Similar documents
●70974_100_AC009160_KAPヘ<3099>ーシス自動車約款(11.10).indb

橡Taro9-生徒の活動.PDF

関 数


改訂版 :基本的な文字化の原則(Basic Transcription System for Japanese: BTSJ)


★分冊3-説明資料PDF用/02-PDF個別

™ƒŒì„³001†`028.pwd

76

' % % &! #


康乘聡子(P105‐121)/康乘聡子 p105‐121

‡Æ‡Ý‡©457_01-12

REALV5_A4…p_Ł\1_4A_OCF

untitled

「都市から地方への人材誘致・移住促進に関する調査」

<91498EE88CA D815B2E786C73>

〔 大 会 役 員 〕

橡本体資料+参考条文.PDF

Lecture on

2

10/ / /30 3. ( ) 11/ 6 4. UNIX + C socket 11/13 5. ( ) C 11/20 6. http, CGI Perl 11/27 7. ( ) Perl 12/ 4 8. Windows Winsock 12/11 9. JAV

クエリの作成が楽になるUDF


untitled

-34-

index View Controller

fp.gby



パターン化されたロジックのコンポーネント化

EQUIUM EQUIUM S5010 1

1-18

2 KH Coder KH Coder KH Coder KH Coder

Lecture 3 Slides (January 12, 2010)

防衛関係費/防衛関係費


60周年記念 記念誌/扉・扉裏・中扉・資料扉・名簿扉


特別プログラム

8 浜根知恵(p191‐203)204白/p191‐203

★表紙-背幅5.5mm/表紙

SBI損保の自動車保険 重要事項説明書


表紙(背幅8.5mm)/背幅8.5mm

2

_ZEI-1022_fiÁŁÊ−雿-’‘Ä


1 鵜澤幸弘(p7‐26)/性同一障害 p7‐26

広報あつぎ-1月15日号-1面12.indd

A4_元


本文/YAY180B


S \1.E4


本文(縦)/YAZ149T


アベノミクス2年目を迎える2014年の日本経済

untitled


コーディング基準.PDF

EPSON PX-G920 基本操作ガイド

Java

2

第168回日本胸部外科学会関東甲信越地方会要旨集


Kanji

Objective-C Objective-C C Toolbox API Cocoa Objective-C Java Carbon API C API Objective-C Java Pure Java Java AppleScript Java Objective-C Project Bui

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç

日阪_NVAC0407.qxd

スタートアップガイド_応用編

presen.gby

Transcription:

2002.7.30 ( 1 st Edition ) - 1 -

NSDate NSCalendarDate NSObject NSDate NSCalendarDate NSDate NSCalendarDate NSDate NSCalendar NSDate date NSDate *d = [ NSDate date ]; // NSDate : + (id) date : init date NSDate *d = [ [ [ NSDate alloc ] init ] autorelease ]; // datewithtimeintervalsincenow : initwithtimeintervalsincenow : NSTimeInterval NSDate* d = [ NSDate datewithtimeintervalsincenow : 3*60 ]; // 3-2 -

NSDate : + (NSDate *) datewithtimeintervalsincenow : (NSTimeInterval) sec sec : : datewithstring : initwithstring : +0900 +0900 NSDate* d = [ NSDate datewithstring : @"2001-03-24 10:45:32 +0900" ]; NSDate : + (NSDate *) datewithstring : (NSString *) stime stime : "YYYY-MM-DD hh:mm:ss +HHMM" : YYYY - MM - DD - : hh - mm - ss - : +or- - (GMT) +- : HH - (GMT ) MM - (GMT ) : stime NSDate NSDate " yesterday "" sunday " NSDate NSDate : + datewithnaturallanguagestring : (NSString *) string string : "yesterday" : null yesterday yesterday morning sunday last sunday 8.13 5:20-3 -

sunday next xxx last xxx : : morning : 10:00 noon : 12:00 lunch : 12:00 dinner : 19:00 tomorrow : yesterday : sun, mon.. : ( ex. "next sun" ) sunday, monday.. : ( ex. "next sunday" ) NSDate addtimeinterval : NSDate NSDate NSDate *d1 = [ xxxx ]; // NSDate *d2 = [ d1 addtimeinterval : 60*60 ]; // d1 1 NSDate : - (id) addtimeinterval : (NSTimeInterval) sec sec : : NSDate NSDate addtimeinterval : alloc retain NSDate *d = [ NSDate date ]; // d = [ d addtimeinterval : 60*60 ]; // 1 ( ) - 4 -

NSDate timeintervalsincedate : NSDate *d1 = [ NSDate date ]; // NSDate *d2 = [ d1 addtimeinterval : 60*60 ]; // 1 NSTimeInterval ti = [ d1 timeintervalsincedate : d2 ]; // d1 - d2 = -3600 d1 - d2 timeintervalsincedate : NSDate : - (NSTimeInterval) timeintervalsincedate : (NSDate *) anotherdate anotherdate : : - anotherdate compare : NSComparisonResult NSDate *d1 = [ NSDate date ]; // NSDate *d2 = [ d1 addtimeinterval : 60*60 ]; // 1 switch( [ d1 compare : d2 ] ) { case NSOrderedAscending : NSLog( @"d1 < d2" ); break; // case NSOrderedSame : NSLog( @"d1 = d2" ); break; case NSOrderedDescending : NSLog( @"d1 > d2" ); break; } NSDate : - (NSComparisonResult) compare : (NSDate *) anotherdate anotherdate : : < anotherdate NSOrderedAscending : = anotherdate NSOrderedSame : > anotherdate NSOrderedDescending isequaltodate : - 5 -

if ( [ d1 isequaltodate : d2 ] ) NSLog( @"d1 = d2" ); NSDate : - (BOOL) isequaltodate : (NSDate *) anotherdate anotherdate : : YES NO earlierdate : laterdate : NSDate *d1 = [ NSDate date ]; // NSDate *d2 = [ d1 addtimeinterval : 60*60 ]; // 1 NSDate *d3 = [ d1 earlierdate : d2 ]; // d3 <- d1 NSDate *d4 = [ d1 laterdate : d2 ]; // d4 <- d2 NSDate : - (NSDate *) earlierdate : (NSDate *) anotherdate anotherdate : : NSDate : - (NSDate *) laterdate : (NSDate *) anotherdate anotherdate : : distantfuture distantpast NSDate *dfuture = [ NSDate distantfuture ]; // 4001-01-02 00:00:00 GMT NSDate *dpasr = [ NSDate distantpast ]; // 0001-01-17 00:00:00 GMT - 6 -

NSDate : - (NSDate *) distantfuture : ( 4001-01-02 00:00:00 GMT ) NSDate : - (NSDate *) distantpast : ( 0001-01-17 00:00:00 GMT ) - 7 -

NSCalendarDate NSDate NSDate calendardate NSDate date NSCalendarDate *cd = [ NSCalendarDate calendardate ]; NSCalendarDate : + (id) calendardate : NSDate NSCalendarDate datewithyear : month : day : hour : minute : second : timezone : nil NSCalendarDate *cd = [ NSCalendarDate datewithyear : 2002 month : 4 day : 20 hour : 1 minute : 0 second : 0 timezone : nil ]; - 8 -

NSCalendarDate : - (id) datewithyear : (int ) year month : (unsigned ) month day : (unsigned ) day hour : (unsigned ) hour minute : (unsigned ) minute second : (unsigned ) second timezone : (NSTimeZone *) timezone year : month : day : hour : minute : second : timezone : nil : NSDate NSCalendarDate NSCalendarDate *cd = [ NSCalendar calendardate ]; int iyear = [ cd yearofcommonera ]; // ( ) int imonth = [ cd monthofyear ]; // ( 1-12 ) int iday = [ cd dayofmonth ]; // ( 1-31 ) int idayy = [ cd dayofyear ]; // 1 1 ( 1-366 ) int idayc = [ cd dayofcommonera ]; // int iweek = [ cd dayofweek ]; // ( 0 = Sunday.. 6 = Saturday ) int ihour = [ cd hourofday ]; // ( 0-23 ) int iminute = [ cd minuteofhour ]; // ( 0-59 ) int isecond = [ cd secondofminute ]; // ( 0-59 ) NSCalendarDate : - (int) yearofcommonera : int iyear = [ [ NSDate calendardate ] yearofcommonera ]; // - 9 -

NSCalendarDate : - (int) monthofyear : ( 1-12 ) int imonth = [ [ NSDate calendardate ] monthofyear ]; // NSCalendarDate : - (int) dayofmonth : ( 1-31 ) int iday = [ [ NSDate calendardate ] dayofmonth ]; // NSCalendarDate : 1 1 - (int) dayofyear : 1 1 ( 1-366 ) int iday = [ [ NSDate calendardate ] dayofyear]; // 1.1 NSCalendarDate : - (int) dayofcommonera : ( 1 - ) int iday = [ [ NSDate calendardate ] dayofcommonera ]; // NSCalendarDate : - (int) dayofweek : ( 0 - Sunday... 6 - Saturday ) int iweek = [ [ NSDate calendardate ] dayofweek ]; // - 10 -

NSCalendarDate : - (int) hourofday : ( 0-23 ) int ihour = [ [ NSDate calendardate ] hourofday ]; // NSCalendarDate : - (int) minuteofhour : ( 0-59 ) int iminute = [ [ NSDate calendardate ] minuteofhour ]; // NSCalendarDate : - (int) secondofminute : ( 0-59 ) int isecond = [ [ NSDate calendardate ] secondofminute ]; // NSCalendarDate datebyaddingyears : months : days : hours : minutes : seconds : - 11 -

NSCalendarDate : - (NSCalendarDate *) datebyaddingyears : (int) year months : (int) month days : (int) day hours : (int) hour minutes : (int) minute seconds : (int) second year : month : day : hour : minute : second : : NSCalendarDate *now = [ NSCalendarDate calendardate ]; // NSCalendarDate *firstday; // 1 NSCalendarDate *lastday; // firstday = [ NSCalendarDate datewithyear : [ now yearofcommonera ] month : [ now monthofyear ] day : 1 hour : 0 minute : 0 second : 0 timezone : nil ]; // 1 lastday = [ firstday datebyaddingyears : 0 months : +1 // 1 days : -1 // 1 hours : 0 minutes : 0 seconds : 0 ]; NSLog( @"%d (%@)", [ lastday dayofmonth ], lastday ); calendardate datewithyear : month : day : hour : minute : second : timezone : - 12 -

NSCalendarDate NSTimeZone NSTimeZone : + (NSTimeZone *) timezonewithname : (NSString *) sname sname : ex. "JST" : NSTimeZone : + (NSTimeZone *) timezoneforsecondsfromgmt : (int) sec sec : 60x60x9 = 32400 : NSTimeZone : + (NSTimeZone *) localtimezone : NSCalendarDate *cd1 = [ NSCalendarDate calendardate ]; NSCalendarDate *cd2 = [ NSCalendarDate calendardate ]; [ cd1 settimezone : [ NSTimeZone timezoneforsecondsfromgmt : 0 ] ]; // GMT [ cd2 settimezone : [ NSTimeZone timezonewithname : @"JST" ] ]; // JST NSLog( @"cd1 = %@", cd1 ); // ex. "cd1 = 2002-06-27 06:56:19 +0000" NSLog( @"cd2 = %@", cd2 ); // ex. "cd2 = 2002-06-27 15:56:19 +0900" - 13 -

CalendarImage NSAttributedString NSMutableAttributedString 1. HTML NSMutableString 2. HTMLNSAttributedString 3. NSAttributedString NSCalendarDate *curtime = [ NSCalendarDate calendardate ]; // int iyear = [ curtime yearofcommonera ]; int imon = [ curtime monthofyear ]; NSString *shtml; NSAttributedString *as; // HTML shtml = [ NSString stringwithformat : @"<FONT FACE=Helvetica><B>%d</B> %d</font>", iyear, imon ]; // as = [ [ [ NSAttributedString alloc ] initwithhtml : [ shtml datausingencoding : NSASCIIStringEncoding ] documentattributes : nil ] autorelease ]; - 14 -

NSAttributedString initwithhtml : documentattributes : NSAttributedString : HTML - (id) initwithhtml : (NSData *) data documentattributes : (NSDictionary **) docatt data : HTML docattr : nil : thismonth CalendarImage.h #import <Cocoa/Cocoa.h> @interface CalendarImage : NSObject { } + (NSImage *) thismonth; // @end CalendarImage.m #import "CalendarImage.h" @implementation CalendarImage + (NSImage *) thismonth { NSCalendarDate *now = [ NSCalendarDate calendardate ]; // NSCalendarDate *topdate; // 1 NSCalendarDate *enddate; // NSMutableString *shtml; // HTML NSAttributedString *ascal; // NSImage *imgcal; // - 15 -

calendardate CalendarImage.m > thismonth... int iyear = [ now yearofcommonera ]; // int imonth = [ now monthofyear ]; // topdate = [ NSCalendarDate datewithyear : iyear month : imonth day : 1 hour : 0 minute : 0 second : 0 timezone : nil ]; // 1 enddate = [ topdate datebyaddingyears : 0 months : +1 days : -1 hours : 0 minutes : 0 seconds : 0 ]; // CalendarImage.m > thismonth... { ///// HTML ///// int itopweek; // 1 int itoday = [ now dayofmonth ]; // int iendday = [ enddate dayofmonth ]; // int i, iweek; shtml = [ NSMutableString stringwithformat : @"<pre><font size=4><b>%d %d</b></font><br>", iyear, imonth ]; // CalendarImage.m > thismonth... itopweek = [ topdate dayofweek ]; for ( i = 0 ; i < itopweek ; i++ ) // [ shtml appendstring : @" " ]; - 16 -

itopweek CalendarImage.m > thismonth... iweek = itopweek; for ( i = 1 ; i <= iendday ; i++ ) { // if ( iweek == 0 ) { [ shtml appendstring : @"<font color=red>" ]; } if ( iweek == 6 ) { [ shtml appendstring : @"<font color=blue>" ]; } if ( itoday == i ) { [ shtml appendstring : @"<u><font color=green>" ]; } [ shtml appendstring : [ NSString stringwithformat : @"%2d", i ] ]; if ( itoday == i ) { [ shtml appendstring : @"</font></u>" ]; } if ( iweek == 6 ) { [ shtml appendstring : @"</font>" ]; } if ( iweek == 0 ) { [ shtml appendstring : @"</font>" ]; } [ shtml appendstring : @" " ]; // iweek iweek CalendarImage.m > thismonth... iweek++; if ( iweek == 7 ) { // iweek = 0; [ shtml appendstring : @"<br>" ]; } } // [ shtml appendstring : @"</pre>" ]; } iweek iweek <br> <pre> - 17 -

CalendarImage.m > thismonth... { ///// & ///// NSSize sizecal; // ascal= [ [ [ NSAttributedString alloc ] initwithhtml : [ shtml datausingencoding : NSASCIIStringEncoding ] documentattributes : nil ] autorelease ]; CalendarImage.m > thismonth... sizecal = [ ascal size ]; // imgcal = [ [ [ NSImage alloc ] initwithsize : sizecal ] autorelease ]; [ imgcal lockfocus ]; [ ascal drawatpoint : NSMakePoint( 0, 0 ) ]; // [ imgcal unlockfocus ]; } return( imgcal ); } size NSImage drawatpoint : - 18 -