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

Fix reading Time zone rules using Julian days#17635

Merged
tarekgh merged 6 commits intodotnet:masterfrom
tarekgh:FixTimeZonesWithJulianDaysRule
Apr 19, 2018
Merged

Fix reading Time zone rules using Julian days#17635
tarekgh merged 6 commits intodotnet:masterfrom
tarekgh:FixTimeZonesWithJulianDaysRule

Conversation

@tarekgh
Copy link
Member

@tarekgh tarekgh commented Apr 18, 2018

Fixes #17393

@tarekgh
Copy link
Member Author

tarekgh commented Apr 18, 2018

@eerhardt could you please have a look? thank you.

@dotnet dotnet deleted a comment from dotnet-bot Apr 18, 2018
@dotnet dotnet deleted a comment from dotnet-bot Apr 18, 2018
@dotnet dotnet deleted a comment from dotnet-bot Apr 18, 2018
@tarekgh
Copy link
Member Author

tarekgh commented Apr 18, 2018

@dotnet-bot test this

1 similar comment
@tarekgh
Copy link
Member Author

tarekgh commented Apr 18, 2018

@dotnet-bot test this

@tarekgh
Copy link
Member Author

tarekgh commented Apr 18, 2018

@dotnet/dnceng please check this. it is failed many times for unrelated reasons.

@mmitche
Copy link
Member

mmitche commented Apr 18, 2018

@tarekgh What failed here?

@eerhardt
Copy link
Member

I assume a test is coming in corefx?

month = day = 0;

int index = 0;
bool isLeapYear = true;
Copy link
Member

Choose a reason for hiding this comment

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

Instead of isLeapYear, I'd call this shouldIncludeLeapDay.

Copy link
Member Author

Choose a reason for hiding this comment

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

We may change this or remove it according to what we'll find about the n format

int[] days = isLeapYear ? GregorianCalendarHelper.DaysToMonth366 : GregorianCalendarHelper.DaysToMonth365;

throw new InvalidTimeZoneException(SR.InvalidTimeZone_JulianDayNotSupported);
if (julianDay == 0 || julianDay > days[days.Length - 1])
Copy link
Member

Choose a reason for hiding this comment

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

According to http://man7.org/linux/man-pages/man3/tzset.3.html, julianDay == 0 is valid for the case where the J is not specified.

   n      This specifies the zero-based Julian day with n between 0 and 365.  February 29 is counted in leap years.

Copy link
Member Author

Choose a reason for hiding this comment

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

As we have chatted, I'll try to research how ```n```` format should be used

{
julianDay = julianDay * 10 + (int) (date[index] - '0');
index++;
} while (index < date.Length && ((uint)(date[index] - '0') <= '9'-'0'));
Copy link
Member

Choose a reason for hiding this comment

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

Is it not possible to use int.TryParse here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is possible but my implementation should be more performant.

@tarekgh
Copy link
Member Author

tarekgh commented Apr 18, 2018

@mmitche sorry, it was failing in all legs before I closed the PR, but after re-opening it, looks everything is good.

{
// Jn
// This specifies the Julian day, with n between 1 and 365.February 29 is never counted, even in leap years.
Debug.Assert(!String.IsNullOrEmpty(date));
Copy link
Member

Choose a reason for hiding this comment

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

Another good assert would be that date[0] == 'J', since we are skipping the first char below with int index = 1;

// For example if n is specified as 60, this means in leap year the rule will start at Mar 1,
// while in non leap year the rule will start at Mar 2.
//
// If we need to support n format, we'll have to have a floating adjustment rule support this case.
Copy link
Member

Choose a reason for hiding this comment

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

Should we open an issue for this? or should we wait until we get more feedback to support this format?

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'll open a future issue anyway so we may pro-actively fixing it if we get a chance.

Copy link
Member

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

This looks good - assuming a test is forthcoming in corefx.

Thanks, @tarekgh.

@tarekgh
Copy link
Member Author

tarekgh commented Apr 18, 2018

@mmitche does the OSX build seems right?

https://ci.dot.net/job/dotnet_coreclr/job/master/job/x64_checked_osx10.12_innerloop_flow_prtest/2999/

I am seeing the following and the progress bar is really at the begining.

Started 3 hr 59 min ago
Build has been executing for null on OSX.1012.Amd64.Open-0418105002142-0

@tarekgh
Copy link
Member Author

tarekgh commented Apr 18, 2018

test OSX10.12 x64 Checked Innerloop Build and Test please

@tarekgh tarekgh merged commit 588d287 into dotnet:master Apr 19, 2018
dotnet-bot pushed a commit to dotnet/corefx that referenced this pull request Apr 19, 2018
* Fix reading Time zone rules using Julian days

* Order the condition correctly

* Start searching from month 1 and not 0

* Exclude n Julian format

* fix typo

* Adding the suggested assert

Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
tarekgh added a commit to dotnet/corefx that referenced this pull request Apr 19, 2018
* Fix reading Time zone rules using Julian days

* Order the condition correctly

* Start searching from month 1 and not 0

* Exclude n Julian format

* fix typo

* Adding the suggested assert

Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
@danmoseley
Copy link
Member

@tarekgh does this need to go into 2.1?

@tarekgh
Copy link
Member Author

tarekgh commented Apr 19, 2018

@danmosemsft
I am going to check with the ship room regarding that

dotnet-bot pushed a commit to dotnet/corert that referenced this pull request May 9, 2018
* Fix reading Time zone rules using Julian days

* Order the condition correctly

* Start searching from month 1 and not 0

* Exclude n Julian format

* fix typo

* Adding the suggested assert

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
tarekgh added a commit to dotnet/corert that referenced this pull request May 10, 2018
* Fix reading Time zone rules using Julian days

* Order the condition correctly

* Start searching from month 1 and not 0

* Exclude n Julian format

* fix typo

* Adding the suggested assert

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
@tarekgh tarekgh deleted the FixTimeZonesWithJulianDaysRule branch March 25, 2019 15:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants