实现通过年和周的参数获取本周始末日期。(其中每年1月1号,所在的周会算在去年中去。也就是本年第一周从本年第一个周一开始)
def zhou(y,z)
da=y.to_s
firstdata=da+"-01-01"#本年的一月一号
tian=z*7+(8-firstdata.to_time.wday) #N周就有N*7天,再加上每年1月1号是周几的差天
mon=0
for i in 1..12#每年12个月
mon=mon+1 #处于第几个月
mont_date=days_in_month(i, year = y)#本年本月有几天
tian=tian-mont_date
if tian<0||tian==0 #如果剩余天数比i月天数少
tian=tian+mont_date #则不减断开
break
end
end
da=da+"-"+mon.to_s+"-"+tian.to_s #年+月+日(字符串通过to_time变为时间格式天)
@start_time=da.to_time.beginning_of_week.to_formatted_s(:db) #本天所在周始
@end_time=da.to_time.end_of_week.to_formatted_s(:db)#本周周末
end
分享到:
相关推荐
计算每个月自然周的开始结束时间,返回值为每个周 第一天和最后一天的时间戳 数组
夏俊峰案始末.doc
08年次贷危机的始末.pptx
这些参数可以通过特殊的测量设备和方法来获取,以构建线路的电气模型,这对于分析线路的电气特性、计算暂态响应以及故障诊断至关重要。 总的来说,220kV线路参数试验是电力系统运行维护中不可或缺的一环。准确的...
通信行业周观点报告详细讨论了共建共享方案的发展及其对运营商投资的潜在影响。共建共享方案指的是在通信行业内部,运营商之间共享基础设施、网络设备等资源以降低成本、提高效率的一种合作方式。该方案已逐步深入到...
这篇“煮饺子事件始末”的描述,实际上是一篇生动的范文,通过个人经历来传递了一个关于专注和细心的寓言。 首先,事件的起因是主人公对美食的渴望,尤其是对茴香馅饺子的热爱。这体现了人对食物的情感,以及在日常...
标题“红鞋底商标争议始末”暗示了文档涉及一个围绕“红鞋底”这一特定设计元素或标识的商标权争议案件。描述中的内容是对文档标题的重复,没有提供额外信息。 基于提供的部分内容,可以推断出本文档可能涉及知识...
20210213-国泰君安-国际比较:美股漂亮50始末之鉴.pdf
通过数字化管理和远程监控,可以实时获取电机运行状态,及时发现并解决问题。 此外,对于从事电子政务的相关人员来说,理解这些基本的电气知识和测试方法至关重要。他们需要了解如何正确使用测试仪,以便在日常工作...
【亚马逊“误入”云计算始末】这篇文章讲述了亚马逊如何从一个在线零售商逐步发展成为云计算市场的领导者。在描述中,我们看到云计算的概念虽然被广泛提及,但很多人对其具体含义仍然模糊不清。亚马逊的云计算之路...
北京大学的人事制度改革在2003年5月引发了广泛的讨论和关注。这一方案的提出旨在改革传统的教师聘任和职务晋升制度,以适应不断变化的教育环境和提高教学质量。改革的核心内容包括六个主要方面: 1. 教员实行聘任制...
【蒙牛中国航天员专用牛奶策划方案始末】 在2002年至2022年间,蒙牛乳业成功策划并执行了一项极具影响力的品牌战略——成为“中国航天员专用牛奶”的供应商。这一策划案背后的故事揭示了蒙牛如何巧妙地结合国家重大...
我们这里来获取今天所在星期的始末日期,我们可以通过 (new Date).getDay() 来获取今天是星期几,然后再通过这个减去或者加上一定的天数,就是这个星期的开始日期和结束日期。 function getWeekStartAndEnd() { ...
通过以上的方法和步骤,可以有效地判断出电动机定子绕组的始末端,确保电动机能够正常启动和运行。在实际工作中,维护人员应该熟悉这些方法,并在安全的前提下进行操作,以确保电动机的稳定性和可靠性。
农夫山泉危机公关始末.pptx
炫富女郭美美事件始末.doc
初中语文文摘历史黄花岗起义始末
它引入了基于图形的操作环境,用户可以通过直观的窗口、图标和按钮进行操作,大大简化了原本复杂的命令行输入。此外,Windows 3.0还提供了多任务处理、资源共享以及与设备无关的功能,打破了DOS对内存管理的限制,...
为了解决这一问题,各国政府和业界开始倡导共建共享的理念,即不同运营商共同投资建设网络基础设施,通过共享基站、频率等资源,减少重复建设,节约成本,同时提高网络覆盖和质量。 二、共建共享的实施步骤 1. **...
亲身经历的局域网arp攻击事件始末