home screen - nsrivastav/iPhone GitHub Wiki
switch (appdelegate.strip_index ) {
case 1:
[ schedule_label_in_strip removeFromSuperview];
schedule_label_in_strip = [[UITextView alloc] initWithFrame:CGRectMake(-5 , 70, 100.0,40.0)];
schedule_label_in_strip.editable = NO;
schedule_label_in_strip.textAlignment = UITextAlignmentCenter;
// Fetching start_date_local from Database for Strip 1:
NSString *start_date_from_Db_1 = [pillboxDb select_start_date_from_schedule:appdelegate.strip_index];
// loop to get the hour component for strip 1:
if ([start_date_from_Db_1 length] >= 2 ) {
hours_strip = [start_date_from_Db_1 substringWithRange: NSMakeRange (10, 6)];
hours_value = [hours_strip substringWithRange:NSMakeRange(0,3)];
minute_value = [hours_strip substringWithRange:NSMakeRange(3,3)];
hours_int = [hours_value intValue];
}
// checking for AM or PM values for strip 1:
if (hours_int > 11) {
hours_int = hours_int-12;
NSString *hour = [NSString stringWithFormat:@"%d", hours_int];
if ([hour isEqualToString:@"10"] || [hour isEqualToString:@"11"] ) {
schedule_label_in_strip.text = [NSString stringWithFormat:@"NEXT: \n%@%@PM",hour,minute_value];
}
else {
schedule_label_in_strip.text = [NSString stringWithFormat:@"NEXT: \n0%@%@PM",hour,minute_value];
}
}
else{
NSLog(@"the hour strip is %@",hours_strip);
if (hours_strip == nil) {
schedule_label_in_strip.text = @" ";
}
else {
schedule_label_in_strip.text = [NSString stringWithFormat:@"NEXT: \n%@AM",hours_strip];
}
}
if ([start_date_from_Db_1 isEqualToString:@" "]) {
schedule_label_in_strip.text = @" ";
}
schedule_label_in_strip.backgroundColor = [UIColor clearColor];
schedule_label_in_strip.font = [UIFont fontWithName:@"Helvetica" size:12];
[self.view addSubview:schedule_label_in_strip];
break;