Bug 2361270
Summary: | Invalid week number for date +%U | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Leslie Satenstein <satensteinl> |
Component: | coreutils | Assignee: | Lukáš Zaoral <lzaoral> |
Status: | NEW --- | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | low | Docs Contact: | |
Priority: | unspecified | ||
Version: | 42 | CC: | admiller, alebastr89, jamartis, kdudka, kzak, lzaoral, nixuser, ovasik, p, svashisht, vmihalko |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | --- | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | Type: | --- | |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Leslie Satenstein
2025-04-20 21:01:09 UTC
I don't see a bug here: $ \cal -w -m April 2025 Mo Tu We Th Fr Sa Su 14 1 2 3 4 5 6 15 7 8 9 10 11 12 13 16 14 15 16 17 18 19 20 17 21 22 23 24 25 26 27 18 28 29 30 $ \cal -w -s April 2025 Su Mo Tu We Th Fr Sa 14 1 2 3 4 5 15 6 7 8 9 10 11 12 16 13 14 15 16 17 18 19 17 20 21 22 23 24 25 26 18 27 28 29 30 $ date --help | grep 'week number' %g last two digits of year of ISO week number (ambiguous; 00-99); see %G %G year of ISO week number; normally useful only with %V %U week number of year, with Sunday as first day of week (00..53) %V ISO week number, with Monday as first day of week (01..53) %W week number of year, with Monday as first day of week (00..53) date(1) documents that its Sunday based week numbers are zero based. So if you want Sunday as first day of week, and 1 based, you need: $ echo $(($(date +%U -d 2025-04-20) + 1)) 17 First of all We have cal -w to show the week number, and it shows week 17, Is cal using the regular rule for week number, that begins on Sunday? YES. Gnome's graphical calendar with week number option selected showing 17 YES. Website: https://www.saturdaygift.com/current-week-number shows week 17, (Review Jan 1, 2025 therein). But date +%U is showing a week number that does not match, even though date +%U, has Sunday as the beginning week. Checking with other individuals (Fedoraforum.org), they see date %+U returning 16, as wrong. Perhaps the date algorithm is right, but the description for +%U is inadequate, ie incomplete. It should include something like. Date +%U uses the first Sunday of the year to begin counting weeks. If the man page is revised to include the preceding line, then confusion/errors will be avoided. I have switched to using ISO +%V as the method. Please reconsider this bug report as a request to add "Date +%U uses the first Sunday of the year to begin counting weeks." and for +%V Date +%V https://en.wikipedia.org/wiki/ISO_week_date#Relation_with_the_Gregorian_calendar I have no qualms about date +%V The issue I have is the following today, Sunday, May 4,2025 weekdate shown in the gnome date shows week 19. (ISO week 19 starts today) date +%U shows 18 (as documentation shows monday as ISO week) date +%V shows 18 (as Sunday is the first day of the week). So do I have to do a date +1 with %U to get the ISO weekno that starts with Sunday? Again Gnome's date shows weekno as 19 but not date +%V or date +%U I forgot to mention cal -w shows 19 |