Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localized YearWeek #110

Open
marcospassos opened this issue Sep 30, 2018 · 1 comment
Open

Localized YearWeek #110

marcospassos opened this issue Sep 30, 2018 · 1 comment
Labels

Comments

@marcospassos
Copy link

marcospassos commented Sep 30, 2018

We have a use case where we need a type-safe way of representing a localized week in an application. That object is pretty much the same of YearWeek, except that the first day and the minimal number of days varies.

Is there support for implementing such temporal?

I thought initially to implement a LocalizedYearWeek, with some factory methods such as LocalizedYearWeek.of(int year, int week, WeekDefinition weekDefinition). The class WeekDefinition is merely a value object that defines the first day and the minimal number of days of a week, that can also work as a factory of WeekFields.

Introducing a WeekDefinitionQuery would provide an interoperability layer between week objects, e.g. YearWeek.from(LocalizedYearWeek.of(2018, 1, WeekDefinition.ISO)) or LocalizedYearWeek.from(YearWeek.of(2018, 1)).

I would be happy to provide a PR if welcome.

@jodastephen
Copy link
Member

It seems reasonable to add a LocalizedYearWeek class, partly as I don't see any other way to do it. I don't see the need for a WeekDefinition though, just pass in an instance of WeekFields.

I'm not sure how you could convert between instances of year-week classes without a date. You'd have to decide how the weeks align, which I don't think you can reasonably do (unless both follow ISO week rules).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants