循环定时器
This commit is contained in:
@@ -185,22 +185,33 @@
|
||||
NSLog(@"------字符串=======%@",unicodeString);
|
||||
return unicodeString;
|
||||
}
|
||||
//时间转四位十六进制 如01:15——> 010f
|
||||
//时间转四位或6位十六进制 如01:15——> 010f
|
||||
+(NSString*)dateStringToHexString:(NSString *)dateString{
|
||||
|
||||
//NSString*hour=[dateString substringWithRange:NSMakeRange(0, 2)];// 0~23 小时
|
||||
NSArray*array=[dateString componentsSeparatedByString:@":"];
|
||||
|
||||
NSRange range=[dateString rangeOfString:@":"];
|
||||
NSString*hour=[dateString substringToIndex:range.location];
|
||||
NSString*hour=@"";
|
||||
if (array.count)
|
||||
{
|
||||
hour=array[0];
|
||||
}
|
||||
// NSString*minite=[dateString substringWithRange:NSMakeRange(3, 2)];// 0~59 分钟
|
||||
NSString*minite=[dateString substringFromIndex:range.location+1];
|
||||
NSString*minite=@"";
|
||||
if (array.count>1)
|
||||
{
|
||||
minite=array[1];
|
||||
}
|
||||
NSString*second=@"";
|
||||
if (array.count>2)
|
||||
{
|
||||
second=array[2];
|
||||
}
|
||||
NSString*hexHour=@"";//
|
||||
NSString*hexMinite=@"";
|
||||
// if ([hour hasPrefix:@"0"]) {
|
||||
// hexHour=[NSString stringWithFormat:@"0%@",[[NSString alloc] initWithFormat:@"%1x",[hour intValue]]];
|
||||
// // NSLog(@"hex0带 %@",hexHour);
|
||||
//
|
||||
//
|
||||
// }else{
|
||||
NSString*hexSecond=@"";
|
||||
|
||||
hexHour=[NSString stringWithFormat:@"%@",[[NSString alloc] initWithFormat:@"%1x",[hour intValue]]];
|
||||
// NSLog(@"hex %@",hexHour);
|
||||
// }
|
||||
@@ -211,6 +222,15 @@
|
||||
hexMinite=[NSString stringWithFormat:@"%@",[[NSString alloc] initWithFormat:@"%1x",[minite intValue]]];;
|
||||
}
|
||||
|
||||
if (second.length)
|
||||
{
|
||||
if ([hexSecond hasPrefix:@"0"]) {
|
||||
hexSecond=[NSString stringWithFormat:@"0%@",[[NSString alloc] initWithFormat:@"%1x",[second intValue]]];
|
||||
}else{
|
||||
hexSecond=[NSString stringWithFormat:@"%@",[[NSString alloc] initWithFormat:@"%1x",[second intValue]]];;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (hexHour.length==1) {
|
||||
hexHour=[NSString stringWithFormat:@"0%@",hexHour];
|
||||
@@ -218,8 +238,15 @@
|
||||
if (hexMinite.length==1) {
|
||||
hexMinite=[NSString stringWithFormat:@"0%@",hexMinite];
|
||||
}
|
||||
if (second.length)
|
||||
{
|
||||
if (hexSecond.length==1) {
|
||||
hexSecond=[NSString stringWithFormat:@"0%@",hexSecond];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NSString*fomatString=[NSString stringWithFormat:@"%@%@",hexHour,hexMinite];
|
||||
NSString*fomatString=[NSString stringWithFormat:@"%@%@%@",hexHour,hexMinite,hexSecond];
|
||||
|
||||
|
||||
return fomatString;
|
||||
@@ -254,11 +281,12 @@
|
||||
}
|
||||
return siWeihexString;
|
||||
}
|
||||
//四位 十六进制转时间 如 010f——> 01:15
|
||||
//四位或6位 十六进制转时间 如 010f——> 01:15
|
||||
+(NSString*)hexStringToDateString:(NSString*)hexString{
|
||||
|
||||
NSString*shiString=@"";
|
||||
NSString*fenString=@"";
|
||||
NSString*miaoString=@"";
|
||||
UInt64 shi =strtoul([[hexString substringWithRange:NSMakeRange(0, 2)] UTF8String], 0, 16);
|
||||
if(shi>23)
|
||||
{
|
||||
@@ -300,8 +328,31 @@
|
||||
];
|
||||
// NSLog(@"str4 %@",fenString);
|
||||
}
|
||||
if (hexString.length>=6)
|
||||
{
|
||||
UInt64 sec =strtoul([[hexString substringWithRange:NSMakeRange(4, 2)] UTF8String], 0, 16);
|
||||
if(sec>59)
|
||||
{
|
||||
sec=59;
|
||||
}
|
||||
|
||||
if (sec<=9) {
|
||||
miaoString=[NSString stringWithFormat:@"0%llu",fen
|
||||
];
|
||||
// NSLog(@"str3 %@",fenString);
|
||||
}else{
|
||||
miaoString=[NSString stringWithFormat:@"%llu",fen
|
||||
];
|
||||
// NSLog(@"str4 %@",fenString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
NSString*formatString=[NSString stringWithFormat:@"%@:%@",shiString,fenString];
|
||||
if (miaoString.length) {
|
||||
[formatString stringByAppendingFormat:@":%@",miaoString];
|
||||
}
|
||||
|
||||
//NSLog(@"str5 %@",formatString);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user