linux上月日期,linux – 日期命令为12月31日提供了错误的周数

当我试图获得12月31日的周数时,它会返回1.当我得到12月30日的周数时,我得到52 —这就是我所期望的.星期一是正确的.这是在运行Ubuntu的RPI上.

$date -d "2018-12-30T1:58:55" +"%V%a"

52Sun

$date -d "2018-12-31T1:58:55" +"%V%a"

01Mon

没有时间字符串的相同问题

$date -d "2018-12-31" +"%V%a"

01Mon

解决方法:

这将给你一个星期一开始的ISO周.

The ISO week date system is effectively a leap week calendar system that is part of the ISO 8601 date and time standard issued by the International Organization for Standardization (ISO) since 1988 (last revised in 2004) and, before that, it was defined in ISO (R) 2015 since 1971. It is used (mainly) in government and business for fiscal years, as well as in timekeeping. This was previously known as “Industrial date coding”. The system specifies a week year atop the Gregorian calendar by defining a notation for ordinal weeks of the year.

An ISO week-numbering year (also called ISO year informally) has 52 or 53 full weeks. That is 364 or 371 days instead of the usual 365 or 366 days. The extra week is sometimes referred to as a leap week, although ISO 8601 does not use this term.

Weeks start with Monday. Each week’s year is the Gregorian year in which the Thursday falls. The first week of the year, hence, always contains 4 January. ISO week year numbering therefore slightly deviates from the Gregorian for some days close to 1 January.

如果要将12/31显示为第52周,则应使用%U,它不使用ISO标准:

$date -d "2018-12-31T1:58:55" +"%V%a"

01Mon

$date -d "2018-12-31T1:58:55" +"%U%a"

52Mon

标签:linux,date,command-line

来源: https://codeday.me/bug/20190808/1625038.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值