根据分钟数换算成天/小时/分钟
 
 
#pragma mark - 根據所給的分鐘換算成day--hour--min
- (NSString *)transferToDayHourMin {
? ? NSString *t = self;
? ? if (t == nil || [t isEqual:@""]) {
? ? ? ? return @"--";
? ? } else if ([t intValue] >= 0 && [t intValue] < 60) {
#pragma mark - *m
? ? ? ? NSString *time = [NSString stringWithFormat:@"%@分鐘",t];
? ? ? ? return time;
? ? } else if ([t intValue] % 60 == 0 && [t intValue] < 1440) {
#pragma mark - *h
? ? ? ? NSString *time = [NSString stringWithFormat:@"%d小時",[t intValue] / 60];
? ? ? ? return time;
? ? } else if ([t intValue] > 60 && [t intValue] < 1440) {
#pragma mark -? *h*m
? ? ? ? NSInteger h = [t intValue] / 60;
? ? ? ? NSInteger m = [t intValue] - h * 60;
? ? ? ? NSString *time = [NSString stringWithFormat:@"%ld小時%ld分鐘", (long)h,(long)m];
? ? ? ? return time;
? ? } else if (([t intValue] > 1440 && [t intValue] % 1440 == 0) || [t intValue] % 1440 == 0) {
#pragma mark - *d
? ? ? ? NSInteger d1 = [t intValue] / 1440;
? ? ? ? NSString *time = [NSString stringWithFormat:@"%ld天", d1];
? ? ? ? return time;
? ? } else {
? ? ? ? NSInteger d = [t intValue] / 1440;
? ? ? ? NSInteger h = [t intValue] - d * 1440;
? ? ? ? if (h < 60) {
#pragma mark - *d*m
? ? ? ? ? ? NSString *time = [NSString stringWithFormat:@"%ld天%ld分鐘",d,h];
? ? ? ? ? ? return time;
? ? ? ? } else if (h % 60 == 0) {
#pragma mark - *d*h
? ? ? ? ? ? NSInteger h1 = h / 60;
? ? ? ? ? ? NSString *time = [NSString stringWithFormat:@"%ld天%ld小時",d,h1];
? ? ? ? ? ? return time;
? ? ? ? } else {
#pragma mark -? *d*h*m
? ? ? ? ? ? NSInteger h1= h / 60;
? ? ? ? ? ? NSInteger m = h - h1 * 60;
? ? ? ? ? ? NSString *time = [NSString stringWithFormat:@"%ld天%ld小時%ld分鐘", (long)d,(long)h1,(long)m];
? ? ? ? ? ? return time;
? ? ? ? }
? ? }
}
總結
以上是生活随笔為你收集整理的根据分钟数换算成天/小时/分钟的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: 现代密码学(五)——零知识证明
- 下一篇: 移动学习 AndroidStudio内存
