/**
* @author cjh, 15-08-06 16:08:40
*
* 获取预约时间label的text,超过当天的显示yyyy.mm.dd HH:mm - yyyy.mm.dd HH:mm
*
* @parma projectStartTime:项目开始时间
* @parma totalTIme:项目总时长
* @return 时间内容
*/
+(NSString *)_getProjectTimeLableText:(NSString *)projectStartTime withTotalTime:(int)totalTime
{
//格式化时间
NSDateFormatter *fomatter = [[NSDateFormatter alloc] init];
[fomatter setDateFormat:@"YYYY.MM.dd HH:mm"];
NSDate *bookingDate = [fomatter dateFromString:projectStartTime];
NSString *endDateStr = [Tool convertTimeMs:bookingDate withIntervalHour:totalTime];
NSString *startDateStr = [fomatter stringFromDate:bookingDate];
//开始、结束时间
NSDate *startDate = [fomatter dateFromString:projectStartTime];
NSDate *endDate = [fomatter dateFromString:endDateStr];
//计算两个时间之间年、月、日相隔的数,用来判断页面中的时间如何显示
NSInteger apartDay =[endDate getDay] - [startDate getDay];
NSInteger apartMonth = [endDate getMonth] - [startDate getMonth];
NSInteger apartYear = [endDate getYear] - [startDate getYear];
NSString *projectTimeLabelText= @"";
//跨月
if(apartDay != 0 || apartMonth != 0)
{
//跨年
if(apartYear != 0)
{
projectTimeLabelText = [NSString stringWithFormat:@"%@ - %@",[projectStartTime stringByReplacingOccurrencesOfString:@"-" withString:@"."],endDateStr];
}
//跨月后天
else
{
projectTimeLabelText = [NSString stringWithFormat:@"%@ - %02ld.%02ld %02d:%02d",startDateStr,(long)[endDate getMonth],(long)[endDate getDay],[endDate getHour],[endDate getMinute]];
}
}
//跨时
else
{
projectTimeLabelText = [NSString stringWithFormat:@"%@-%02d:%02d",startDateStr,[endDate getHour],[endDate getMinute]];
}
return projectTimeLabelText;
}