iOS根据所得到的开始时间计算结束的时间
来源:互联网 发布:设计手机主题软件 编辑:程序博客网 时间:2024/06/05 15:03
/** * @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;}
0 0
- iOS根据所得到的开始时间计算结束的时间
- 根据传入的时间,自动计算规则时间(如:包期时段的开始时间和结束时间)
- python计算程序开始到程序结束的运行时间和程序运行的CPU时间
- 计算结束时间与开始时间的相差的天数:
- java根据开始时间结束时间计算中间间隔日期
- 根据开始和结束时间,计算出该时间段每个星期的开始和结束时间
- JAVA如何根据jsp页面时间(开始到结束时间)和checkbox选择不同的多少出现不同的曲线
- 根据开始时间结束时间,开始的经纬度结束的经纬度,按照一定的时间频率生成坐标点。
- Java根据开始时间和结束时间返回时间段内的时间集合
- 根据开始时间和结束时间返回时间段内的时间集合
- 本周的开始时间和结束时间
- 根据开始时间、结束时间检索
- php取得一天的开始到结束的时间戳
- 记录WebView从开始加载到渲染结束的时间
- 图片根据数据库的时间(开始时间与结束时间)与本地时间相比,在网页上显示。
- 根据开始时间、结束时间得到两个时间段内所有的日期
- 【java】根据开始时间、结束时间得到两个时间段内所有的日期
- 关于两个时间控件开始时间到结束时间的问题(含中文设置)
- junit集成maven。 No SecurityManager accessible to the calling code, either bound to the org.apache.shir
- 自定义控件让TextView的drawableLeft与文本一起居中显示
- 十道海量数据处理面试题与十个方法大总结
- 数据结构(17)双向链表
- 最好最易懂的Git教学——分享“好麻烦部落格”Git教学(1)
- iOS根据所得到的开始时间计算结束的时间
- 获得Android设备的唯一序列号
- 网络通信--UDP
- HDU 2571(命运)动态规划-数塔问题
- HDU 1232 畅通工程
- 转化率预估
- 串结构练习——字符串匹配
- tp框架where条件查询数据库
- LeetCode-23 Merge k Sorted Lists