特定の値について、次のスニペットは正しい値を返しません。現在の時刻を、電話に保存されている他の 2 つの日付と比較します。それは早い時間に機能しますが、午前2時48分には機能しません...
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en"] autorelease]];
[dateFormatter setDateFormat:@"EEEE HH:mm dd-MM-y"];
NSString *dateString = [dateFormatter stringFromDate:self.fechaInicio];
NSLog(@"La date start es: %@", dateString);
//PRINTS : La date start es: Monday 22:00 05-01-1970
dateString = [dateFormatter stringFromDate:self.fechaFin];
NSLog(@"La Date end es: %@", dateString);
dateString = [dateFormatter stringFromDate:testDate];
//PRINTS : La Date end es: Monday 05:00 05-01-1970
NSLog(@"DAte inside es: %@", dateString);
//PRINTS : DAte inside es: Monday 02:52 05-01-1970
NSLog(@"time interval nicio: %g", [testDate timeIntervalSinceDate:self.fechaInicio]);
//PRINTS : time interval nicio: -68852
NSLog(@"time interval fin: %g", [testDate timeIntervalSinceDate:self.fechaFin]);
//PRINTS : time interval fin: -7652
return ([testDate timeIntervalSinceDate:self.fechaInicio] > 0 &&
[testDate timeIntervalSinceDate:self.fechaFin] < 0);
日付はすべて1970年ですが、平日だけ比較すればいいのでわざと同じ年月日になるようにしています。
真夜中までは何時間も機能しますが、それ以降は機能しないため、かなり迷っています。
ありがとう。