zoukankan      html  css  js  c++  java
  • 根据数字对应星期几

    第一种:

    NSString *week  = @“2”

    NSString *Weekday =  [self passWeek:week];

     

    + (NSString *)passWeek:(NSString *)week {

        if ([week containsString:@"1"]) {

            week = [week stringByReplacingOccurrencesOfString: @"1" withString:@"周一"];

        }    else if ([week containsString:@"2"]) {

            week = [week stringByReplacingOccurrencesOfString:@"2" withString:@"周二"];

        }  else  if ([week containsString:@"3"]) {

            week = [week stringByReplacingOccurrencesOfString:@"3" withString:@"周三"];

        }   else  if ([week containsString:@"4"]) {

            week = [week stringByReplacingOccurrencesOfString:@"4" withString:@"周四"];

        }  else if ([week containsString:@"5"]) {

            week = [week stringByReplacingOccurrencesOfString:@"5" withString:@"周五"];

        }   else  if ([week containsString:@"6"]) {

            week = [week stringByReplacingOccurrencesOfString:@"6" withString:@"周六"];

        }   else if ([week containsString:@"7"]) {

            week = [week stringByReplacingOccurrencesOfString:@"7" withString:@"周日"];

        }

        return week;

    }

     

    第二种:

    NSString *week  = @“2,3,4”

    NSString *Weekday =  [self passWeek:week];

     

    + (NSString *)passWeek:(NSString *)week {

        if ([week containsString:@"1"]) {

            week = [week stringByReplacingOccurrencesOfString: @"1" withString:@"周一"];

        }  

       if ([week containsString:@"2"]) {

            week = [week stringByReplacingOccurrencesOfString:@"2" withString:@"周二"];

        }

       if ([week containsString:@"3"]) {

            week = [week stringByReplacingOccurrencesOfString:@"3" withString:@"周三"];

        }  

       if ([week containsString:@"4"]) {

            week = [week stringByReplacingOccurrencesOfString:@"4" withString:@"周四"];

        }

       if ([week containsString:@"5"]) {

            week = [week stringByReplacingOccurrencesOfString:@"5" withString:@"周五"];

        }  

        if ([week containsString:@"6"]) {

            week = [week stringByReplacingOccurrencesOfString:@"6" withString:@"周六"];

        }  

        if ([week containsString:@"7"]) {

            week = [week stringByReplacingOccurrencesOfString:@"7" withString:@"周日"];

        }

        return week;

    }

  • 相关阅读:
    Anoconda管理Python版本 | Python
    VSCode用以Python开发的配置 | VSCode
    不联网的情况下安装python环境 | Python(转)
    批量按要求修改文件名
    [OpenLayers] 控件系列之SelectFeature同时支持hover与click
    python使用suds调用webservice接口
    【转载】eMBMS知识点汇总(概念/应用场景/工作原理/标准进程/发展现状)
    处理器分类
    3GPP Release 4G-5G 演进
    浅谈css中一个元素如何在其父元素居中显示
  • 原文地址:https://www.cnblogs.com/chenzq12/p/6213676.html
Copyright © 2011-2022 走看看