- NSDateFormatter strange behavior
- NSDateFormatter *df = [[NSDateFormatter alloc] init];
- [df setDateFormat:@"yyyy-MM-dd"];
- - (void)connectionDidFinishLoading:(NSURLConnection *)connection
- {
- // do something with the data
- // receivedData is declared as a method instance elsewhere
- NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]);
- NSString *json_string = [[NSString alloc] initWithData:receivedData
- encoding:NSUTF8StringEncoding];
- NSDictionary* datos = [parser objectWithString:json_string error:nil];
- [connection release];
- [receivedData release];
- [parser release];
- [json_string release];
- NSArray* data = [datos objectForKey:kRootKey];
- cierres = [[NSMutableArray alloc] initWithCapacity:data.count];
- NSDateFormatter *df = [[NSDateFormatter alloc] init];
- [df setDateFormat:@"yyyy-MM-dd"];
- for (int i = 0; i < data.count; i++)
- {
- NSDictionary* object = [data objectAtIndex:i];
- NSLog(@"Parser: %@, Aper: %@, Cierre: %@", [object objectForKey:kFederacionKey], [object objectForKey:kAperturaKey], [object objectForKey:kCierreKey]);
- NSString* fedName = [object objectForKey:kFederacionKey];
- NSDate* aperDate = [df dateFromString: [object objectForKey:kAperturaKey]];
- NSDate* cierreDate = [df dateFromString: [object objectForKey:kCierreKey]];
- CierreData* cierreData =
- [[CierreData alloc] initWithFederationName:fedName
- openDate:aperDate
- andCloseDate:cierreDate];
- [cierres addObject:cierreData];
- [cierreData release];
- }
- [delegate dataReceived];
- }
- NSDateFormatter *formater=[[NSDateFormatter alloc]init];
- [formater setDateFormat:@"yyyy-MM-dd h:mm:ss a"];
- [formater setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT"]];
- NSDate *now1 = [formater dateFromString:[NSString stringWithFormat:@"%@ 11:07:00 PM",[[arrdate objectAtIndex:i]valueForKey:@"date"]]];
- NSLog(@"%@",now1);
- NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
- NSTimeZone *timezone = [NSTimeZone timeZoneWithName:@"Europe/Madrid"];
- [dateFormatter setDateFormat:@"yyyy-MM-dd"];
- [dateFormatter setTimeZone:timezone];