Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@khellang
Copy link
Member

@tarekgh
Copy link
Member

tarekgh commented Jun 13, 2018

@khellang thanks for submitting the PR. I'll try to take a look soon. meanwhile, could you please try to submit a PR in corefx for adding tests to the introduced APIs? I know we'll not be able to merge the corefx PR before merging this coreclr PR and getting the updated coreclr package to corefx. but it will be nice to have this ready and run the tests against your private bits. https://github.com/dotnet/corefx/blob/8e842fa29e14694cca96c6e39a38199c55a3a02e/Documentation/project-docs/developer-guide.md#testing-with-private-coreclr-bits

private const long MaxMillis = (long)DaysTo10000 * MillisPerDay;

internal const int MinYear = 1;
internal const int MaxYear = 9999;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal const int MaxYear = 9999; [](start = 7, length = 35)

This is already defined in https://github.com/dotnet/coreclr/blob/master/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs#L26

I would suggest to either define MinYear there too or let the Gregorian calendar use the ones defined here. I mean at the end we need to have these constants defined in one place

return ToDateTime(year, GetWeeksInYear(year), DayOfWeek.Sunday);
}

// From https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year. [](start = 11, length = 64)

would be good to add the comment:

The long years, with 53 weeks in them, can be described by any of the following equivalent definitions:

any year starting on Thursday (dominical letter D or DC) and any leap year starting on Wednesday (ED)
any year ending on Thursday (D, ED) and any leap year ending on Friday (DC)
years in which 1 January and 31 December (in common years) or either (in leap years) are Thursdays
All other week-numbering years are short years and have 52 weeks.

@khellang
Copy link
Member Author

@tarekgh Thanks for being so quick to review this!

could you please try to submit a PR in corefx for adding tests to the introduced APIs?

I will. Have a set of tests ready to go 😊

throw new ArgumentOutOfRangeException(nameof(week), SR.ArgumentOutOfRange_Week_ISO);
}

if ((int)dayOfWeek < 0 || (int)dayOfWeek > 6)
Copy link
Member

@tarekgh tarekgh Jun 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if ((int)dayOfWeek < 0 || (int)dayOfWeek > 6) [](start = 11, length = 46)

should we support the value 7 for Sunday too? I mean 0 and 7 is Sunday.

I can see the scenario of someone getting the data from some source and just cast the value to DayOfWeek.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. We won't be able to reuse the existing exception message (ArgumentOutOfRange_DayOfWeek):

The DayOfWeek enumeration must be in the range 0 through 6.

Copy link
Member

@tarekgh tarekgh Jun 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. We won't be able to reuse the existing exception message (ArgumentOutOfRange_DayOfWeek):

Why? what I am trying to Say, if someone passed dayOfWeek = 7 to us, we'll treat it as Sunday. so we'll not throw. I don't think this affects the exception thrown for other cases. right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we can document the behavior. also, we can have a new exception message as needed too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright. Let's also accept 7 😄

@tarekgh
Copy link
Member

tarekgh commented Jun 13, 2018

@khellang thanks again for getting the implementation ready. other than my comments, LGTM

@khellang
Copy link
Member Author

@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test

@tarekgh tarekgh added this to the 3.0 milestone Jun 13, 2018
@tarekgh tarekgh merged commit 79b8f94 into dotnet:master Jun 13, 2018
dotnet-bot pushed a commit to dotnet/corert that referenced this pull request Jun 14, 2018
* Added ISOWeek to System.Globalization

* Revert DateTime changes. Use constants from GregorianCalendar instead.

* Add more comments

* Also allow 7 as value for day of week

* Add note about ISO week-numbering year parameters

* Add note about allowing 7 for day of week

Signed-off-by: dotnet-bot <[email protected]>
jkotas pushed a commit to dotnet/corert that referenced this pull request Jun 14, 2018
* Added ISOWeek to System.Globalization

* Revert DateTime changes. Use constants from GregorianCalendar instead.

* Add more comments

* Also allow 7 as value for day of week

* Add note about ISO week-numbering year parameters

* Add note about allowing 7 for day of week

Signed-off-by: dotnet-bot <[email protected]>
@khellang khellang deleted the iso-week branch June 14, 2018 06:00
dotnet-bot pushed a commit to dotnet/corefx that referenced this pull request Jun 15, 2018
* Added ISOWeek to System.Globalization

* Revert DateTime changes. Use constants from GregorianCalendar instead.

* Add more comments

* Also allow 7 as value for day of week

* Add note about ISO week-numbering year parameters

* Add note about allowing 7 for day of week

Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>
stephentoub pushed a commit to dotnet/corefx that referenced this pull request Jun 15, 2018
* Added ISOWeek to System.Globalization

* Revert DateTime changes. Use constants from GregorianCalendar instead.

* Add more comments

* Also allow 7 as value for day of week

* Add note about ISO week-numbering year parameters

* Add note about allowing 7 for day of week

Signed-off-by: dotnet-bot-corefx-mirror <[email protected]>
@karelz karelz added the Hackathon Issues picked for Hackathon label Jun 18, 2018
@paulomorgado
Copy link

Isn't ISOWeek a violation of the framework naming guidelines?

@danmoseley
Copy link
Member

Capitalization was noted in review : https://github.com/dotnet/corefx/issues/28933#issuecomment-392873426

@paulomorgado
Copy link

Sorry @danmosemsft, I as on the phonw.

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* Added ISOWeek to System.Globalization

* Revert DateTime changes. Use constants from GregorianCalendar instead.

* Add more comments

* Also allow 7 as value for day of week

* Add note about ISO week-numbering year parameters

* Add note about allowing 7 for day of week


Commit migrated from dotnet/coreclr@79b8f94
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Globalization Hackathon Issues picked for Hackathon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants