精华内容
下载资源
问答
  • 输入一用户指定的日期,输出这日期一年的第几周的第天。
  • 一年几周

    千次阅读 2016-08-01 15:33:05
    2016年第一周几号开始:据出国留学网万年历可知,2016年的第一天周五(1月日),第一周末1月3日,第一周一1月4日(农历十一月廿二)。因此,2016年第一从1月4号开始。  2016年有多少周末  从2016年...
    2016年第一周几号开始:据出国留学网万年历可知,2016年的第一天是周五(1月日),第一个周末是1月3日,第一个周一是1月4日(农历十一月廿二)。因此,2016年第一周从1月4号开始

      2016年有多少周末

      从2016年得1月1日是星期五可以得出,

      2016年最后两天是星期五和星期六。

      所以,2016年有53个星期六,52个星期天。

      2016年有多少周

      2016年为闰年,一年366天,366天 = 52周多2天。

      延伸阅读

      中国为什么把七日一周叫“一星期”呢

      光绪三十一年(1905),清廷宣布停止乡试、会试,废除延续了一千多年的科举制度,成立“学部”,袁嘉谷即奉命调入学部筹建编译图书局,后任该局首任局长。编译图书局下设编书课、译书课,任务是研究编写“统一国之用”的官定各种教材。各种教科书的编写中自然会遇到一个“新名词”该怎么处理的问题。1909年,编译图书局设立了一个新机构统一规范教科书中的名词术语。袁嘉谷亲自参加了这个馆的工作,主持制定了很多统一的名称。把七日一周制定为中国自己的“星期”,就是在袁嘉谷主持下制定的。

      现在世界各国通用一星期七天的制度。这个制度最早由君士坦丁大帝(Constantine the Great)制定。他在公元321年3月7日正式宣布7天为一周,这个制度一直沿用至今。

      一周七天的英文名称是Sunday(星期日), Monday(星期一), Tuesday(星期二), Wednesday(星期三), Thursday(星期四), Friday(星期五), Saturday(星期六), 。

      这些名称最早起源于古巴比伦(Babylon)。公元前7至6世纪,巴比伦人便有了星期制。他们把一个月分为4周,每周有7天,即一个星期。

      古巴比伦人建造七星坛祭祀星神。七星坛分7层,每层有一个星神,从上到下依此为日、月、火、水、木、金、土7个神。7神每周各主管一天,因此每天祭祀一个神,每天都以一个神来命名:太阳神沙马什主管星期日,称日耀日;月神辛主管星期一,称月耀日;火星神涅尔伽主管星期二,称火耀日;水星神纳布主管星期三,称水耀日;木星神马尔都克主管星期四,liuxue86.com称木耀日;金星神伊什塔尔主管星期五,称金耀日;土星神尼努尔达主管星期六,称土耀日。

      古巴比伦人创立的星期制,首先传到古希腊、古罗马等地。

      古罗马人用他们自己信仰的神的名字来命名1周7天:Sun\'s-day(太阳神日),Moon\'s-day(月亮神日),Mars\'s-day(火星神日),Mercury\'s-day(水星神日),Jupiter\'s-day(木星神日),Venus\'-day(金星神日),Saturn\'s-day(土星神日)。这其个名称传到不列颠后,盎格鲁-撒克逊人又用他们自己的信仰的神的名字改造了其中4个名称,以Tuesday 、Wednesday、Thursday、Friday 分别取代Mars\'s-day 、Mercury\'s-day 、Jupiter\'s-day 、Venus\'-day。 Tuesday来源于Tiu,是盎格鲁-撒克逊人的战神;Wednesday来源于Woden,是最高的神,也称主神;Thursday来源于Thor,是雷神;Friday来源于Frigg,是爱情女神。这样就形成了今天英语中的1周7天的名称:Sunday(太阳神日),Monday(月亮神日),Tuesday(战神日),Wednesday(主神日),Thursday(雷神日),Friday(爱神日),Saturday(土神日)。

    展开全文
  • java中获取日期属于哪一年的第几周

    千次阅读 2018-12-06 11:26:49
    在设计数据模型的时候需要用到年份+周数作为唯一索引,于是就需要判断一日期属于哪一年的第几周,本来问题很简单的,但是会涉及到跨年的问题,例如以周一作为一星期的开始,那么2018-12-30日星期日,属于2018...

    在设计数据模型的时候需要用到年份+周数作为唯一索引,于是就需要判断一个日期是属于哪一年的第几周,本来问题很简单的,但是会涉及到跨年的问题,例如以周一作为一个星期的开始,那么2018-12-30日星期日,属于2018年的第52周,而2018-12-31日星期一,就属于2019年的第1周,因此,只用一个日期属于第几周来判断是会有问题的,下面这个方法里面返回了年份与第几周,可以满足要求。

    public static Map<String,Integer> getWeekAndYear(String date) {
            Map<String,Integer> result =  new HashMap<String,Integer>();
            Calendar cal = Calendar.getInstance();
    
            --设置一周的开始,默认是周日,这里设置成星期一
            cal.setFirstDayOfWeek(Calendar.MONDAY);
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat formatMon = new SimpleDateFormat("MM");
            SimpleDateFormat formatYear = new SimpleDateFormat("yyyy");
            Date d = null;
            try {
                d = format.parse(date);
            } catch (ParseException e) {
                e.printStackTrace();
            }
    
            cal.setTime(d);
            int month = Integer.valueOf(formatMon.format(d));
            int year = Integer.valueOf(formatYear.format(d));
            
            int week = cal.get(Calendar.WEEK_OF_YEAR);
            result.put("week", week);
            if(week == 1 && month == 12){
                result.put("year", year + 1);
            }else{
    
                result.put("year", year);
            }
            
            return result;
        }

     

    展开全文
  • 最近接了一项目,其中有一需求用php获取一年几周以及每周开始日期和接触日期。在网上找些资料没有合适的,于是自己做了一份,下面通过两种方式实现PHP获取一年几周以及每周开始日期和结束日期 代码一: <...
  • 今天有一功能点需要按照日历上面的日期来进行一些数据的计算工作,在计算之前我需要将每一天属于一年52里面的第几周和周几计算出来,在计算之前我还需要有一年内的所有天的日期,整体的思路十分清晰的,实现...

         今天有一个功能点是需要按照日历上面的日期来进行一些数据的计算工作,在计算之前我需要将每一天属于一年52周里面的第几周和周几计算出来,在计算之前我还需要有一年内的所有天的日期,整体的思路是十分清晰的,实现流程也没有特别复杂的地方,主要就是要细致一点,好了,不多说了,具体实现如下:
     

    #!usr/bin/env python
    # encoding:utf-8
    from __future__ import division
    
    """
    __Author__:沂水寒城
    功能: python生成指定年份所有的天,并计算每天属于一年的第几周和周几
    """
    
    
    import time
    import datetime
    
    month_list = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
    month_day_dict = {
        "01": 31,
        "02": 28,
        "03": 31,
        "04": 30,
        "05": 31,
        "06": 30,
        "07": 31,
        "08": 31,
        "09": 30,
        "10": 31,
        "11": 30,
        "12": 31,
    }
    
    
    def string2Datetime(timestamp, format="%Y-%m-%d %H:%M:%S"):
        """
        把字符串转成datetime
        """
        return datetime.datetime.strptime(timestamp, format)
    
    
    def judgeRunYear(year=2019):
        """
        判断是否是闰年
        """
        if (year % 100 != 0 and year % 4 == 0) or (year % 100 == 0 and year % 400 == 0):
            return True
        else:
            return False
    
    
    def generateMonthDays(month_day_dict, year="2017", month="03"):
        """
        生成指定年份、月份中的所有日期
        """
        day_num = month_day_dict[month]
        day_date_list = []
        for i in range(1, day_num + 1):
            one = str(i)
            if len(one) == 1:
                one = "0" + one
            day_date_list.append(year + "-" + month + "-" + one)
        return day_date_list
    
    
    def genenrateYearDays(year=2019):
        """
        生成一年中所有的日期
        """
        res_list = []
        if judgeRunYear(year=year):
            month_day_dict["02"] = 29
        for one_mon in month_list:
            one_mon_day = generateMonthDays(month_day_dict, year=str(year), month=one_mon)
            res_list += one_mon_day
        return res_list
    
    
    def singleDateHandle(day="2019-07-19", format="%Y-%m-%d"):
        """
        单日处理
        """
        T = string2Datetime(day, format=format)
        weekDay = T.weekday() + 1
        weekNum = T.isocalendar()[1]
        return weekDay, weekNum
    
    
    def genenrateYearDaysWeek(year=2019):
        """
        计算生成一年中每一天属于 第几周  周几
        """
        year_day_list = genenrateYearDays(year=year)
        for one_day in year_day_list:
            weekDay, weekNum = singleDateHandle(day=one_day)
            print("{0} is:  {1}th week, {2}th day.".format(one_day, weekNum, weekDay))
    
    
    if __name__ == "__main__":
        genenrateYearDaysWeek(year=2019)
    

          我们以2019年为例,看一下计算结果,输出如下:
     

    2019-01-01 is:  1th week, 2th day.
    2019-01-02 is:  1th week, 3th day.
    2019-01-03 is:  1th week, 4th day.
    2019-01-04 is:  1th week, 5th day.
    2019-01-05 is:  1th week, 6th day.
    2019-01-06 is:  1th week, 7th day.
    2019-01-07 is:  2th week, 1th day.
    2019-01-08 is:  2th week, 2th day.
    2019-01-09 is:  2th week, 3th day.
    2019-01-10 is:  2th week, 4th day.
    2019-01-11 is:  2th week, 5th day.
    2019-01-12 is:  2th week, 6th day.
    2019-01-13 is:  2th week, 7th day.
    2019-01-14 is:  3th week, 1th day.
    2019-01-15 is:  3th week, 2th day.
    2019-01-16 is:  3th week, 3th day.
    2019-01-17 is:  3th week, 4th day.
    2019-01-18 is:  3th week, 5th day.
    2019-01-19 is:  3th week, 6th day.
    2019-01-20 is:  3th week, 7th day.
    2019-01-21 is:  4th week, 1th day.
    2019-01-22 is:  4th week, 2th day.
    2019-01-23 is:  4th week, 3th day.
    2019-01-24 is:  4th week, 4th day.
    2019-01-25 is:  4th week, 5th day.
    2019-01-26 is:  4th week, 6th day.
    2019-01-27 is:  4th week, 7th day.
    2019-01-28 is:  5th week, 1th day.
    2019-01-29 is:  5th week, 2th day.
    2019-01-30 is:  5th week, 3th day.
    2019-01-31 is:  5th week, 4th day.
    2019-02-01 is:  5th week, 5th day.
    2019-02-02 is:  5th week, 6th day.
    2019-02-03 is:  5th week, 7th day.
    2019-02-04 is:  6th week, 1th day.
    2019-02-05 is:  6th week, 2th day.
    2019-02-06 is:  6th week, 3th day.
    2019-02-07 is:  6th week, 4th day.
    2019-02-08 is:  6th week, 5th day.
    2019-02-09 is:  6th week, 6th day.
    2019-02-10 is:  6th week, 7th day.
    2019-02-11 is:  7th week, 1th day.
    2019-02-12 is:  7th week, 2th day.
    2019-02-13 is:  7th week, 3th day.
    2019-02-14 is:  7th week, 4th day.
    2019-02-15 is:  7th week, 5th day.
    2019-02-16 is:  7th week, 6th day.
    2019-02-17 is:  7th week, 7th day.
    2019-02-18 is:  8th week, 1th day.
    2019-02-19 is:  8th week, 2th day.
    2019-02-20 is:  8th week, 3th day.
    2019-02-21 is:  8th week, 4th day.
    2019-02-22 is:  8th week, 5th day.
    2019-02-23 is:  8th week, 6th day.
    2019-02-24 is:  8th week, 7th day.
    2019-02-25 is:  9th week, 1th day.
    2019-02-26 is:  9th week, 2th day.
    2019-02-27 is:  9th week, 3th day.
    2019-02-28 is:  9th week, 4th day.
    2019-03-01 is:  9th week, 5th day.
    2019-03-02 is:  9th week, 6th day.
    2019-03-03 is:  9th week, 7th day.
    2019-03-04 is:  10th week, 1th day.
    2019-03-05 is:  10th week, 2th day.
    2019-03-06 is:  10th week, 3th day.
    2019-03-07 is:  10th week, 4th day.
    2019-03-08 is:  10th week, 5th day.
    2019-03-09 is:  10th week, 6th day.
    2019-03-10 is:  10th week, 7th day.
    2019-03-11 is:  11th week, 1th day.
    2019-03-12 is:  11th week, 2th day.
    2019-03-13 is:  11th week, 3th day.
    2019-03-14 is:  11th week, 4th day.
    2019-03-15 is:  11th week, 5th day.
    2019-03-16 is:  11th week, 6th day.
    2019-03-17 is:  11th week, 7th day.
    2019-03-18 is:  12th week, 1th day.
    2019-03-19 is:  12th week, 2th day.
    2019-03-20 is:  12th week, 3th day.
    2019-03-21 is:  12th week, 4th day.
    2019-03-22 is:  12th week, 5th day.
    2019-03-23 is:  12th week, 6th day.
    2019-03-24 is:  12th week, 7th day.
    2019-03-25 is:  13th week, 1th day.
    2019-03-26 is:  13th week, 2th day.
    2019-03-27 is:  13th week, 3th day.
    2019-03-28 is:  13th week, 4th day.
    2019-03-29 is:  13th week, 5th day.
    2019-03-30 is:  13th week, 6th day.
    2019-03-31 is:  13th week, 7th day.
    2019-04-01 is:  14th week, 1th day.
    2019-04-02 is:  14th week, 2th day.
    2019-04-03 is:  14th week, 3th day.
    2019-04-04 is:  14th week, 4th day.
    2019-04-05 is:  14th week, 5th day.
    2019-04-06 is:  14th week, 6th day.
    2019-04-07 is:  14th week, 7th day.
    2019-04-08 is:  15th week, 1th day.
    2019-04-09 is:  15th week, 2th day.
    2019-04-10 is:  15th week, 3th day.
    2019-04-11 is:  15th week, 4th day.
    2019-04-12 is:  15th week, 5th day.
    2019-04-13 is:  15th week, 6th day.
    2019-04-14 is:  15th week, 7th day.
    2019-04-15 is:  16th week, 1th day.
    2019-04-16 is:  16th week, 2th day.
    2019-04-17 is:  16th week, 3th day.
    2019-04-18 is:  16th week, 4th day.
    2019-04-19 is:  16th week, 5th day.
    2019-04-20 is:  16th week, 6th day.
    2019-04-21 is:  16th week, 7th day.
    2019-04-22 is:  17th week, 1th day.
    2019-04-23 is:  17th week, 2th day.
    2019-04-24 is:  17th week, 3th day.
    2019-04-25 is:  17th week, 4th day.
    2019-04-26 is:  17th week, 5th day.
    2019-04-27 is:  17th week, 6th day.
    2019-04-28 is:  17th week, 7th day.
    2019-04-29 is:  18th week, 1th day.
    2019-04-30 is:  18th week, 2th day.
    2019-05-01 is:  18th week, 3th day.
    2019-05-02 is:  18th week, 4th day.
    2019-05-03 is:  18th week, 5th day.
    2019-05-04 is:  18th week, 6th day.
    2019-05-05 is:  18th week, 7th day.
    2019-05-06 is:  19th week, 1th day.
    2019-05-07 is:  19th week, 2th day.
    2019-05-08 is:  19th week, 3th day.
    2019-05-09 is:  19th week, 4th day.
    2019-05-10 is:  19th week, 5th day.
    2019-05-11 is:  19th week, 6th day.
    2019-05-12 is:  19th week, 7th day.
    2019-05-13 is:  20th week, 1th day.
    2019-05-14 is:  20th week, 2th day.
    2019-05-15 is:  20th week, 3th day.
    2019-05-16 is:  20th week, 4th day.
    2019-05-17 is:  20th week, 5th day.
    2019-05-18 is:  20th week, 6th day.
    2019-05-19 is:  20th week, 7th day.
    2019-05-20 is:  21th week, 1th day.
    2019-05-21 is:  21th week, 2th day.
    2019-05-22 is:  21th week, 3th day.
    2019-05-23 is:  21th week, 4th day.
    2019-05-24 is:  21th week, 5th day.
    2019-05-25 is:  21th week, 6th day.
    2019-05-26 is:  21th week, 7th day.
    2019-05-27 is:  22th week, 1th day.
    2019-05-28 is:  22th week, 2th day.
    2019-05-29 is:  22th week, 3th day.
    2019-05-30 is:  22th week, 4th day.
    2019-05-31 is:  22th week, 5th day.
    2019-06-01 is:  22th week, 6th day.
    2019-06-02 is:  22th week, 7th day.
    2019-06-03 is:  23th week, 1th day.
    2019-06-04 is:  23th week, 2th day.
    2019-06-05 is:  23th week, 3th day.
    2019-06-06 is:  23th week, 4th day.
    2019-06-07 is:  23th week, 5th day.
    2019-06-08 is:  23th week, 6th day.
    2019-06-09 is:  23th week, 7th day.
    2019-06-10 is:  24th week, 1th day.
    2019-06-11 is:  24th week, 2th day.
    2019-06-12 is:  24th week, 3th day.
    2019-06-13 is:  24th week, 4th day.
    2019-06-14 is:  24th week, 5th day.
    2019-06-15 is:  24th week, 6th day.
    2019-06-16 is:  24th week, 7th day.
    2019-06-17 is:  25th week, 1th day.
    2019-06-18 is:  25th week, 2th day.
    2019-06-19 is:  25th week, 3th day.
    2019-06-20 is:  25th week, 4th day.
    2019-06-21 is:  25th week, 5th day.
    2019-06-22 is:  25th week, 6th day.
    2019-06-23 is:  25th week, 7th day.
    2019-06-24 is:  26th week, 1th day.
    2019-06-25 is:  26th week, 2th day.
    2019-06-26 is:  26th week, 3th day.
    2019-06-27 is:  26th week, 4th day.
    2019-06-28 is:  26th week, 5th day.
    2019-06-29 is:  26th week, 6th day.
    2019-06-30 is:  26th week, 7th day.
    2019-07-01 is:  27th week, 1th day.
    2019-07-02 is:  27th week, 2th day.
    2019-07-03 is:  27th week, 3th day.
    2019-07-04 is:  27th week, 4th day.
    2019-07-05 is:  27th week, 5th day.
    2019-07-06 is:  27th week, 6th day.
    2019-07-07 is:  27th week, 7th day.
    2019-07-08 is:  28th week, 1th day.
    2019-07-09 is:  28th week, 2th day.
    2019-07-10 is:  28th week, 3th day.
    2019-07-11 is:  28th week, 4th day.
    2019-07-12 is:  28th week, 5th day.
    2019-07-13 is:  28th week, 6th day.
    2019-07-14 is:  28th week, 7th day.
    2019-07-15 is:  29th week, 1th day.
    2019-07-16 is:  29th week, 2th day.
    2019-07-17 is:  29th week, 3th day.
    2019-07-18 is:  29th week, 4th day.
    2019-07-19 is:  29th week, 5th day.
    2019-07-20 is:  29th week, 6th day.
    2019-07-21 is:  29th week, 7th day.
    2019-07-22 is:  30th week, 1th day.
    2019-07-23 is:  30th week, 2th day.
    2019-07-24 is:  30th week, 3th day.
    2019-07-25 is:  30th week, 4th day.
    2019-07-26 is:  30th week, 5th day.
    2019-07-27 is:  30th week, 6th day.
    2019-07-28 is:  30th week, 7th day.
    2019-07-29 is:  31th week, 1th day.
    2019-07-30 is:  31th week, 2th day.
    2019-07-31 is:  31th week, 3th day.
    2019-08-01 is:  31th week, 4th day.
    2019-08-02 is:  31th week, 5th day.
    2019-08-03 is:  31th week, 6th day.
    2019-08-04 is:  31th week, 7th day.
    2019-08-05 is:  32th week, 1th day.
    2019-08-06 is:  32th week, 2th day.
    2019-08-07 is:  32th week, 3th day.
    2019-08-08 is:  32th week, 4th day.
    2019-08-09 is:  32th week, 5th day.
    2019-08-10 is:  32th week, 6th day.
    2019-08-11 is:  32th week, 7th day.
    2019-08-12 is:  33th week, 1th day.
    2019-08-13 is:  33th week, 2th day.
    2019-08-14 is:  33th week, 3th day.
    2019-08-15 is:  33th week, 4th day.
    2019-08-16 is:  33th week, 5th day.
    2019-08-17 is:  33th week, 6th day.
    2019-08-18 is:  33th week, 7th day.
    2019-08-19 is:  34th week, 1th day.
    2019-08-20 is:  34th week, 2th day.
    2019-08-21 is:  34th week, 3th day.
    2019-08-22 is:  34th week, 4th day.
    2019-08-23 is:  34th week, 5th day.
    2019-08-24 is:  34th week, 6th day.
    2019-08-25 is:  34th week, 7th day.
    2019-08-26 is:  35th week, 1th day.
    2019-08-27 is:  35th week, 2th day.
    2019-08-28 is:  35th week, 3th day.
    2019-08-29 is:  35th week, 4th day.
    2019-08-30 is:  35th week, 5th day.
    2019-08-31 is:  35th week, 6th day.
    2019-09-01 is:  35th week, 7th day.
    2019-09-02 is:  36th week, 1th day.
    2019-09-03 is:  36th week, 2th day.
    2019-09-04 is:  36th week, 3th day.
    2019-09-05 is:  36th week, 4th day.
    2019-09-06 is:  36th week, 5th day.
    2019-09-07 is:  36th week, 6th day.
    2019-09-08 is:  36th week, 7th day.
    2019-09-09 is:  37th week, 1th day.
    2019-09-10 is:  37th week, 2th day.
    2019-09-11 is:  37th week, 3th day.
    2019-09-12 is:  37th week, 4th day.
    2019-09-13 is:  37th week, 5th day.
    2019-09-14 is:  37th week, 6th day.
    2019-09-15 is:  37th week, 7th day.
    2019-09-16 is:  38th week, 1th day.
    2019-09-17 is:  38th week, 2th day.
    2019-09-18 is:  38th week, 3th day.
    2019-09-19 is:  38th week, 4th day.
    2019-09-20 is:  38th week, 5th day.
    2019-09-21 is:  38th week, 6th day.
    2019-09-22 is:  38th week, 7th day.
    2019-09-23 is:  39th week, 1th day.
    2019-09-24 is:  39th week, 2th day.
    2019-09-25 is:  39th week, 3th day.
    2019-09-26 is:  39th week, 4th day.
    2019-09-27 is:  39th week, 5th day.
    2019-09-28 is:  39th week, 6th day.
    2019-09-29 is:  39th week, 7th day.
    2019-09-30 is:  40th week, 1th day.
    2019-10-01 is:  40th week, 2th day.
    2019-10-02 is:  40th week, 3th day.
    2019-10-03 is:  40th week, 4th day.
    2019-10-04 is:  40th week, 5th day.
    2019-10-05 is:  40th week, 6th day.
    2019-10-06 is:  40th week, 7th day.
    2019-10-07 is:  41th week, 1th day.
    2019-10-08 is:  41th week, 2th day.
    2019-10-09 is:  41th week, 3th day.
    2019-10-10 is:  41th week, 4th day.
    2019-10-11 is:  41th week, 5th day.
    2019-10-12 is:  41th week, 6th day.
    2019-10-13 is:  41th week, 7th day.
    2019-10-14 is:  42th week, 1th day.
    2019-10-15 is:  42th week, 2th day.
    2019-10-16 is:  42th week, 3th day.
    2019-10-17 is:  42th week, 4th day.
    2019-10-18 is:  42th week, 5th day.
    2019-10-19 is:  42th week, 6th day.
    2019-10-20 is:  42th week, 7th day.
    2019-10-21 is:  43th week, 1th day.
    2019-10-22 is:  43th week, 2th day.
    2019-10-23 is:  43th week, 3th day.
    2019-10-24 is:  43th week, 4th day.
    2019-10-25 is:  43th week, 5th day.
    2019-10-26 is:  43th week, 6th day.
    2019-10-27 is:  43th week, 7th day.
    2019-10-28 is:  44th week, 1th day.
    2019-10-29 is:  44th week, 2th day.
    2019-10-30 is:  44th week, 3th day.
    2019-10-31 is:  44th week, 4th day.
    2019-11-01 is:  44th week, 5th day.
    2019-11-02 is:  44th week, 6th day.
    2019-11-03 is:  44th week, 7th day.
    2019-11-04 is:  45th week, 1th day.
    2019-11-05 is:  45th week, 2th day.
    2019-11-06 is:  45th week, 3th day.
    2019-11-07 is:  45th week, 4th day.
    2019-11-08 is:  45th week, 5th day.
    2019-11-09 is:  45th week, 6th day.
    2019-11-10 is:  45th week, 7th day.
    2019-11-11 is:  46th week, 1th day.
    2019-11-12 is:  46th week, 2th day.
    2019-11-13 is:  46th week, 3th day.
    2019-11-14 is:  46th week, 4th day.
    2019-11-15 is:  46th week, 5th day.
    2019-11-16 is:  46th week, 6th day.
    2019-11-17 is:  46th week, 7th day.
    2019-11-18 is:  47th week, 1th day.
    2019-11-19 is:  47th week, 2th day.
    2019-11-20 is:  47th week, 3th day.
    2019-11-21 is:  47th week, 4th day.
    2019-11-22 is:  47th week, 5th day.
    2019-11-23 is:  47th week, 6th day.
    2019-11-24 is:  47th week, 7th day.
    2019-11-25 is:  48th week, 1th day.
    2019-11-26 is:  48th week, 2th day.
    2019-11-27 is:  48th week, 3th day.
    2019-11-28 is:  48th week, 4th day.
    2019-11-29 is:  48th week, 5th day.
    2019-11-30 is:  48th week, 6th day.
    2019-12-01 is:  48th week, 7th day.
    2019-12-02 is:  49th week, 1th day.
    2019-12-03 is:  49th week, 2th day.
    2019-12-04 is:  49th week, 3th day.
    2019-12-05 is:  49th week, 4th day.
    2019-12-06 is:  49th week, 5th day.
    2019-12-07 is:  49th week, 6th day.
    2019-12-08 is:  49th week, 7th day.
    2019-12-09 is:  50th week, 1th day.
    2019-12-10 is:  50th week, 2th day.
    2019-12-11 is:  50th week, 3th day.
    2019-12-12 is:  50th week, 4th day.
    2019-12-13 is:  50th week, 5th day.
    2019-12-14 is:  50th week, 6th day.
    2019-12-15 is:  50th week, 7th day.
    2019-12-16 is:  51th week, 1th day.
    2019-12-17 is:  51th week, 2th day.
    2019-12-18 is:  51th week, 3th day.
    2019-12-19 is:  51th week, 4th day.
    2019-12-20 is:  51th week, 5th day.
    2019-12-21 is:  51th week, 6th day.
    2019-12-22 is:  51th week, 7th day.
    2019-12-23 is:  52th week, 1th day.
    2019-12-24 is:  52th week, 2th day.
    2019-12-25 is:  52th week, 3th day.
    2019-12-26 is:  52th week, 4th day.
    2019-12-27 is:  52th week, 5th day.
    2019-12-28 is:  52th week, 6th day.
    2019-12-29 is:  52th week, 7th day.
    2019-12-30 is:  1th week, 1th day.
    2019-12-31 is:  1th week, 2th day.

            出来了结果怎么核实呢?我们直接看今天的日期就好了,如下所示:

          我们分别截取了系统时间和程序输出时间,可以看到周几这个结果是正确的,至于第几周感兴趣的话可以对照系统时间数一数就好了,我验证过了是没有问题。 

    展开全文
  • ///  /// 计算某年第一的天数  ///  /// 某年中的一时间  ///  public static int DaysInFirstweekInYear(DateTime dt)  {  DateTime FirstDate = Convert.ToDate

        

           /// <summary>

            /// 计算某年第一周的天数
            /// </summary>
            /// <param name="dt">某年中的一个时间</param>
            /// <returns></returns>
            public static int DaysInFirstweekInYear(DateTime dt)
            {
                DateTime FirstDate = Convert.ToDateTime(string.Format("{0}-1-1", dt.Year));
                int DayOfWeekInYear = DayOfWeek(FirstDate);
                int DaysInFirstWeek = 8 - DayOfWeekInYear;
                return DaysInFirstWeek;
            }

            /// <summary>
            /// 一年中的第几周
            /// </summary>
            /// <param name="dt"></param>
            /// <returns></returns>
            public static int WeekOfYear(DateTime dt)
            {
                int days = DaysInFirstweekInYear(dt);
                int dayofyear = dt.DayOfYear;
                if (dayofyear < days) return 1;
                else
                {
                    int week2 = (int)Math.Ceiling((double)(dayofyear - days) / (double)7);
                    return week2 + 1;
                }
            }
            /// <summary>
            /// 传入某一天,输出这一周的起始日期
            /// </summary>
            /// <param name="dt"></param>
            /// <returns></returns>
            public static DateTime[] DatesIncludeDay(DateTime dt)
            {
                DateTime[] dts = new DateTime[2];
                int dayofweek = DayOfWeek(dt);
                dts[0] = dt.AddDays(1 - dayofweek);
                dts[1] = dt.AddDays(7 - dayofweek);
                return dts;
            }
            /// <summary>
            /// 计算星期几,转换为数字
            /// </summary>
            /// <param name="dt">某天的日期</param>
            /// <returns></returns>
            public static int DayOfWeek(DateTime dt)
            {
                string strDayOfWeek = dt.DayOfWeek.ToString().ToLower();
                int intDayOfWeek = 0;
                switch (strDayOfWeek)
                {
                    case "monday":
                        intDayOfWeek = 1;
                        break;
                    case "tuesday":
                        intDayOfWeek = 2;
                        break;
                    case "wednesday":
                        intDayOfWeek = 3;
                        break;
                    case "thursday":
                        intDayOfWeek = 4;
                        break;
                    case "friday":
                        intDayOfWeek = 5;
                        break;
                    case "saturday":
                        intDayOfWeek = 6;
                        break;
                    case "sunday":
                        intDayOfWeek = 7;
                        break;
                }
                return intDayOfWeek;

            }




    调用:

        DateTime dt = Convert.ToDateTime("2013-1-6");
        Dictionary<string, DateTime> dict = new Dictionary<string, DateTime>();
        dict.Add("0001", DateTime.Now.AddDays(-100));
        dict.Add("0002", DateTime.Now.AddDays(-99));
        dict.Add("0003", DateTime.Now.AddDays(-98));
        dict.Add("0004", DateTime.Now.AddDays(-97));
        dict.Add("0005", DateTime.Now.AddDays(-96));
        dict.Add("0006", DateTime.Now.AddDays(-95));
        dict.Add("0007", DateTime.Now.AddDays(-94));
        dict.Add("0008", DateTime.Now.AddDays(-93));
        dict.Add("0009", DateTime.Now.AddDays(-92));
        dict.Add("0010", DateTime.Now.AddDays(-91));
        dict.Add("0011", DateTime.Now.AddDays(-90));
        dict.Add("0012", DateTime.Now.AddDays(-89));
        dict.Add("0013", DateTime.Now.AddDays(-88));
        dict.Add("0014", DateTime.Now.AddDays(-87));
        dict.Add("0015", DateTime.Now.AddDays(-86));
        dict.Add("0016", DateTime.Now.AddDays(-85));
        dict.Add("0017", DateTime.Now.AddDays(0));
        dict.Add("0018", DateTime.Now.AddDays(1));
        dict.Add("0019", DateTime.Now.AddDays(2));
        string str = "";
        foreach(KeyValuePair<string,DateTime> kv in dict)
        {
            DateTime[] dts = Common.OperateText.DatesIncludeDay(kv.Value);
            str = str + string.Format("{0},第{1}周,时间{2:yyyy-MM-dd},本周从{3:yyyy-MM-dd}到{4:yyyy-MM-dd} <br/>",kv.Key,Common.OperateText.WeekOfYear(kv.Value),kv.Value,dts[0],dts[1]);
        }

    Response.Write(str);


    效果:


    展开全文
  • 所以用函数把一的开始/结束日期算出来,下面程序代码:以下为转载,来源至百度搜索说明一下,我这里以星期日作为一的开始思路如下:首先要计算今天离元旦相差多少天,然后除以7就得出今天离元旦多少星期了...
  • ld_tmp=date(em_1.text) ls_week = string(weekno(ld_tmp)) 现在输出的格式:1 如何得到输出的格式:01
  • http://blog.sina.com.cn/s/blog_65a8ab5d01017n56.html 转载于:https://www.cnblogs.com/Seeulater/p/3962406.html
  • -- DDD该天在一年内的第多少天 ,dd月内的 ,d在一内第天 --获取当前时间内第天 select to_char(sysdate, 'd') from dual;
  • 今天碰到了在MOSS中判断一日期是一年之中的第几周的问题,由于以前对Excel比较熟悉的缘故,开始直接想了一函数用WeekNum()来判断,但是写进去发现MOSS不能识别它,于是用上了最古老的方法,函数如下:=INT((A7...
  • 例题:输入某年某月某日,判断这一天一年的第天 程序分析:以2020年8月8日为例,应该先把前两月的加起来,然后再加上5天即本年的第天,特殊情况,闰年且输入月份大于3时需考虑多加一天。 代码如下 #...
  • 有这样一公式,可以计算任意一年的某一天星期,公式如下: S=X-1+(X-1)/4-(X-1)/100+(X-1)/400+C 其中: X年数(如2004); C为元旦起到要算的哪天的总天数; S/7的余数为星期(0为周日,1为1……) .....
  • 一年总结

    2015-04-07 16:28:49
    现在的工作了一年几个周,在此记录下自己这一年的变化吧。 站在我自己的角度,其实这一年成长不大,只学会了基本的linux操作命令,学会了安装系统,学会了写简单的小脚本,其他的就没什么了。想想一年其实可以...
  • 最近的一的时间一直忙于现场笔试了,在线笔试也都没怎做,真好今天收到了一算是比较期待的offer吧,就不想出去跑了,留在酒店休息休息,突然发现今天我 居然有5笔试,索性就做吧,早上10:00-12:004399和...
  • 是一年招聘时

    2011-10-17 17:27:34
    一年不如一年啊[@more@]订会议室,联系HR,出题,批卷,发名单,写...求爷爷告奶奶请每个人都要支持,一下来没睡几个小时,成绩出来真寒心,一年不如一年,人才的标准不一样了吧。 学术?开发?方案?外语?有一...
  • 是一年517

    2011-05-19 17:23:00
    有人提醒我今天世界...回忆起若干年以前,每年的5.17前后几周神经都紧绷的:提前几周停工把系统整稳定一点配合运营商封网;过了这一天之后封网解除,又要赶之前被耽误的进度。现在已经差不多忘了这日子了。
  • 可以计算并列出每一周和其所对应的时间段,可以求出当前系统时间,可以求出当前日期属于今年的第几个周(也可以通过修改关键参数求出当前日期当前月份的第几个周),内有详细解释。
  • 自从高中毕业后,每年过年我们个人都要聚一次的,只有去年因为疫情的原因没能搞起来。 上午我第一到的,便照例在星巴克等他们。我每次和人有约,都喜欢在一明确的地点碰头,不喜欢定那种很宽泛的词汇,...
  • 则有:此年有53星期二(即最后一天为星期二),则此年的元旦应星期二.而已知当年元旦不是星期二,可知假设不成立.故该年为润年. 对于润年有:最后一天为星期二,则元旦只能星期一. 当年为润年,又...
  •  天之前,媒体在上海和北京以“走向世界,走向文明”主题座谈会的形式提前为老庆生。语言学家、上海《咬文嚼字》主编郝铭鉴在发言中表示了遗憾:“语言在老面前显得匮乏。古人有云:七十古稀,八十九十称耄耋...
  • 2008年1月1日为星期二,判断2008年是否为闰年,输入任意一月份,打印该年该月的日历,要求按排齐,星期一排第一列。 分析 第一:考察的就是闰年的判断。 - 1、能整除400的。 year%400==0 - 2、能整除4同时...
  • 是一年暑假时~

    2012-07-18 00:24:08
    暑假前一段时间学校里面课程设计搞了好几周,两星期的数电课程设计还有两星期的数据结构课程设计……好痛苦的搞完了…… 然后就是有一暑期社会实践,前天一直在做,明天也要做~一关于“农民工三融入”...
  • 淘宝一年

    2010-07-24 00:34:00
    今天在围脖上写了自己快要淘宝一年陈的一点小感想,有几个同学回复了一下,自己觉得还是有很多想说的想写的,趁着夜深人静,记录下来。明年3月就是阿里5年陈了,但在淘宝还是一年陈,经历了三个阿里系的公司,希望...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 446
精华内容 178
关键字:

一年是几个周