加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

德尔福 – 获得年度最佳成绩

发布时间:2020-12-15 04:16:14 所属栏目:大数据 来源:网络整理
导读:Delphi Xe,Win 7,系统TimeZone UTC 4:0,系统中一周的第一天 – 星期一,时间与time. windows.com同步 在标准组件Delphi Win32的调色板中有组件MonthCalendar,其属性为WeekNubers = true(显示周数),date = now,第一天 – 星期一. 显示19号码(今天) – 星期43
Delphi Xe,Win 7,系统TimeZone UTC 4:0,系统中一周的第一天 – 星期一,时间与time. windows.com同步

在标准组件Delphi Win32的调色板中有组件MonthCalendar,其属性为WeekNubers = true(显示周数),date = now,第一天 – 星期一.

显示19号码(今天) – 星期43号.

我通过dateutils.WeekOfTheYear(now)=请求号码返回42.

来源(0.5 Mb)http://www.sendspace.com/file/yuz6ko

通过组件MonthCalendar的初始代码判断 – 就像所有它都是真的(即使不暴露一周的第一天,它从系统参数中获取值).

并在询问WeekOfTheYear它被告知,所有被认为也是标准的ISO应用,但数字不重合:(

无论如何,我不明白,一周消失 – 如果要查看日历,应该是43,如果考虑,那个星期53和去年的第一个问题……

顺便说一下,2011年1月1日的WeekOfTheYear也会回来52但是应该返回1 …

为什么区别和哪里是正确的?

解决方法

两种结果都是正确的,区别在于因为 DateUtils.WeekOfTheYear功能使用了一周的ISO 8601标准定义.也就是说,一周被认为是在星期一开始,在星期日结束.

请查看此explanation关于ISO 8601格式的周数.

If 1 January is on a Monday,Tuesday,Wednesday or Thursday,it is in
week 01. If 1 January is on a Friday,Saturday or Sunday,it is in
week 52 or 53 of the previous year (there is no week 00). 28 December
is always in the last week of its year.

此外,DateUtils.WeekOfTheYear功能的Embarcadero在线帮助说

….if the first calendar day of the year is a Friday,Saturday,or
Sunday,then for the first three,two,or one days of the calendar
year,WeekOfTheYear returns the last week of the previous year.
Similarly,if the last calendar day of the year is a Monday,
or Wednesday,then for the last one,or three days of the
calendar year,WeekOfTheYear returns 1 (the first week of the next
calendar year).

因此,01-01-2011本周六是本周被认为是上一年的第52周.

这也解释了为什么今天(19-10-2011)返回的周数是42而不是43.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读