Comments (10)
Yes, I have a pending PR at #53879, we'll test it against Google's codebase to see how breaking the fix is consideredd !
from angular.
FYI added a link to a reproduction in StackBlitz - just the simple code that generates the table in the description screenshot.
from angular.
Quick investigation, this issue happens every year where Dec 31st is a sunday.
Looks like there is a bug in our algorithm.
from angular.
It looks like to boil down to: What do we consider the start of the week ?
Should it be sunday like in the US ? Or should it be monday like defined by ISO 8106.
Angular currently implements the former.
Repro : https://stackblitz.com/edit/angular-zcyztw?file=src%2Fmain.ts
from angular.
Also I wanted to add about this topic:
I believe the definition of the week numbering year / end of week is unclear in the framework : Is it ISO based or Locale based ?
In the case of date-fns
, it has 2 functions getISOWeek()
and getWeek()
. The Former is ISO
based while the latter is Locale
based. luxon
has the same distinctions : kkkk
is the ISO week year, iiii
is the locale week year.
In both cases Angular has a bug, the concept of week is neither locale based (the dedicated function doesn't rely on a locale or the dedicated function we have getLocaleFirstDayOfWeek
) nor ISO based (is assumes the week starts on Sunday).
from angular.
Thanks @JeanMeche for looking into this.
Good catch on the "local" vs "ISO" week year - I didn't even notice local options in formatting and assumed week years was entirely from an ISO perspective.
- Using the "local week numbering year" in both
date-fns
andluxon
matches whatDatePipe
is doing if I use the US locale (which is where I am) - which makes sense considering you're saying Angular is using the US-type definition of "start of week = Sunday". - Using other locales like French (👍), though, matches the ISO week year as expected, since the start of the week is Monday.
Not that I have much say in how you all proceed, but I guess it seems like Angular is all about honoring the locale of the browser/system, so maybe defaulting to "local" week behavior for day of week, week number and week-numbering year makes the most sense?
I guess it would make sense to have formatting string options for both the "local" and "ISO" week items also?
from angular.
Maybe I spoke to soon - it looks like there is still a discrepancy in how date-fns
and luxon
handle local week years versus DatePipe
.
Added the local week year's to the repro link, and right in 2020 you can see they differ from the DatePipe
...but I was thinking since Angular
was assuming Sunday as the start of week, they'd match. 🤔
Also discovered another online tool that works well for ad-hoc comparison of the "local" vs "ISO" week numbers and years: https://www.calendar-12.com/week_number. Basically let's you see the "north american" version where the week starts on Sunday, vs the "ISO"/everyone else version where the week starts on Monday.
from angular.
Supposing you're in the US, you locale is en-US
.
For this locale, if at least 1 day of the week is the next year, the week is from next year (new Intl.Locale('en-US').weekInfo.minimalDays
on Chrome browsers, or check the CLDR).
So for locale week year this is correct (and anguar is wrong by mixin ISO (thursday bases the weekyear) and week starting on Sunday).
from angular.
@JeanMeche Thanks again. So it sounds like you have all the info you need to adjust how Angular is calculating ISO weeks and week years?
from angular.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
from angular.
Related Issues (20)
- Type for @NgModule.imports is not compatible with recommended standalone group export HOT 1
- Disable dev tools by code? HOT 1
- Make font of the documentation bigger HOT 1
- Future of fake timer testing in a zoneless world
- Angular.dev Playground is broken HOT 1
- Angular SSR don't render HOT 8
- Angular.dev doesn't cover Resolvers or how to fetch dynamic data
- Angular.dev show v0 instead of the latest version v17 HOT 6
- NullInjectorError in combination with standAlone is very unclear? HOT 3
- Router Outlet won't work if router link is in ngTemplate HOT 2
- NullInjectorError: No provider for Firestore2! HOT 1
- angular.dev: youtube embeds are being blocked on firefox HOT 1
- reading required signal input from effect causes error NG0950 when done inside structural directive creating an embedded view after promise resolves HOT 5
- withComponentInputBinding doesn't work as excepted with input signals HOT 1
- Angular 17 @for has memory leak HOT 2
- Reactive forms directives should be standalone HOT 1
- Rename Change detection "Default"
- `swPush.requestSubscription` never resolves on Arc browser (mac os) HOT 1
- AngularGPT
- Recursive template with @defer HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular.