zoukankan      html  css  js  c++  java
  • 时钟计时器

     NSString *camera_clock;

        if (camera_clock == nil||![camera_clock containsString:@":"]||![camera_clock containsString:@"-"]) {

            return;

        }

        NSString *time = [camera_clock componentsSeparatedByString:@" "][1];

        NSString *date = [camera_clock componentsSeparatedByString:@" "][0];

        int timeT = [[time componentsSeparatedByString:@":"][0] intValue];

        int timeM = [[time componentsSeparatedByString:@":"][1] intValue];

        int timeS = [[time componentsSeparatedByString:@":"][2] intValue];

        int totalCount = timeT*60*60 + timeM*60 + timeS + 1;

        timeS = totalCount%60;

        timeM = totalCount%3600/60;

        timeT = totalCount/3600;

        int dateY = [[date componentsSeparatedByString:@"-"][0] intValue];

        int dateM = [[date componentsSeparatedByString:@"-"][1] intValue];

        int dateD = [[date componentsSeparatedByString:@"-"][2] intValue];

        

        if (timeT == 24) {

            timeT = 0;

            dateD += 1;

            if (dateD == 32) {

                dateD = 1;

                dateM += 1;

                if (dateM == 13) {

                    dateM = 1;

                    dateY += 1;

                }

            }else if(dateD == 31 && ((dateM == 4)||(dateM == 6)||(dateM == 9)||(dateM == 11))){

                dateD = 1;

                dateM += 1;

            }else if(dateD == 30 && dateM == 2){

                

                dateD = 1;

                dateM = 3;

            }else if(dateD == 29 && dateM == 2){

                if (dateY/4 != 0 || (dateY/400 != 0 && dateY/400 == 0)){

                    dateM = 3;

                    dateD = 1;

                }

            }

        }

        camera_clock = [NSString stringWithFormat:@"%d-%02d-%02d %02d:%02d:%02d",dateY,dateM,dateD,timeT,timeM,timeS];

    提高技能如同提升自信心。
  • 相关阅读:
    Queue Aizu
    Stack Aizu
    Stack Aizu
    Shell Sort Aizu
    Shell Sort Aizu
    Stable Sort Aizu
    VS2013下.Net Framework4配置FineUI4.14
    VS2013下.Net Framework4配置FineUI4.14
    Ubuntu-14.04.1 desktop安装时遇到的小问题
    Ubuntu-14.04.1 desktop安装时及安装后遇到的小问题
  • 原文地址:https://www.cnblogs.com/chims-liu-touch/p/8930100.html
Copyright © 2011-2022 走看看