-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add TimeZone class #108
Add TimeZone class #108
Conversation
Could you share test failure details? Link is inaccessible. |
Thanks for your contribution! Sorry, I had intended to share the failed test, but didn't get around yet. Anyway, here it is:
That's running the tests on Ubuntu 18.04; the tests succeed on Windows. I haven't looked yet if this is caused by Linux/Windows difference, or if it is caused by using a different ICU version. |
I changed the test because number of timezones varies depending on ICU version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r2.
Reviewable status: 1 of 4 files reviewed, 4 unresolved discussions (waiting on @j-troc)
source/icu.net/Timezone/Timezone.cs, line 15 at r2 (raw file):
public string ID => zoneID; public TimeZone(string id)
missing documentation
source/icu.net/Timezone/Timezone.cs, line 37 at r2 (raw file):
{ string str = en.Next(); while (str != null)
this List building from SafeEnumeratorHandle is used couple times, is there a utility method doing exactly that, maybe put this code into private method?
source/icu.net/Timezone/Timezone.cs, line 51 at r2 (raw file):
/// <summary> /// Returns an enumeration over system TimeZones with the given filter conditions.
space at the end of the line
source/icu.net/Timezone/USystemTimeZoneType.cs, line 4 at r2 (raw file):
using System.Collections.Generic; using System.Linq; using System.Text;
none of these namespaces is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 4 files at r1.
Reviewable status: 2 of 4 files reviewed, 4 unresolved discussions (waiting on @j-troc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 4 files at r1.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @j-troc)
These changes build on my machine. What is the build error? |
Sorry, I was travelling. There was a hick-up on the server. I restarted the build and now it passed. |
Does the code need changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 4 files at r3.
Reviewable status: all files reviewed, 15 unresolved discussions (waiting on @j-troc)
source/icu.net/Timezone/Timezone.cs, line 14 at r3 (raw file):
/// Returns TimeZone's ID. /// </summary> public string ID => zoneID;
I think I'd prefer to rename this to Id
(lowercase d)
source/icu.net/Timezone/Timezone.cs, line 17 at r3 (raw file):
ID
nitpick: replace ID with <paramref name="id"/>
source/icu.net/Timezone/Timezone.cs, line 19 at r3 (raw file):
"id">IDthe
nitpick: Remove "ID" and tab character after it.
source/icu.net/Timezone/Timezone.cs, line 79 at r3 (raw file):
} private static List<TimeZone> CreateTimeZoneList(Func<Tuple<SafeEnumeratorHandle, ErrorCode>> enumeratorSource)
This method could return IEnumerable<TimeZone>
as well.
source/icu.net/Timezone/Timezone.cs, line 83 at r3 (raw file):
List<TimeZone> timeZones = new List<TimeZone>(); (SafeEnumeratorHandle en, ErrorCode ec) = enumeratorSource();
Please rename the variable names to something a bit less cryptic, e.g. enumerator
and errorCode
.
source/icu.net/Timezone/Timezone.cs, line 87 at r3 (raw file):
try { string str = en.Next();
Rename to something less cryptic, e.g. timezoneId
source/icu.net/Timezone/Timezone.cs, line 109 at r3 (raw file):
var timeZoneName = NativeMethods.GetUnicodeString((ptr, length) => { length = NativeMethods.ucal_getDefaultTimeZone(ptr, length, out ErrorCode err);
Shouldn't we check the error code? I.e. add the line ExceptionFromErrorCode.ThrowIfError(ec)
?
source/icu.net/Timezone/Timezone.cs, line 159 at r3 (raw file):
return NativeMethods.GetUnicodeString((ptr, length) => { length = NativeMethods.ucal_getWindowsTimeZoneId(id, ptr, length, out ErrorCode err);
Shouldn't we check the error code? I.e. add the line ExceptionFromErrorCode.ThrowIfError(ec)
?
source/icu.net/Timezone/Timezone.cs, line 176 at r3 (raw file):
return NativeMethods.GetUnicodeString((ptr, length) => { length = NativeMethods.ucal_getTimeZoneIDForWindowsId(winId, region, ptr, length, out ErrorCode err);
Shouldn't we check the error code? I.e. add the line ExceptionFromErrorCode.ThrowIfError(ec)
?
source/icu.net.tests/TimeZoneTests.cs, line 71 at r3 (raw file):
Assert.GreaterOrEqual(timezones.Count(), 4); Assert.AreEqual(1, timezones.Count(tz => tz.ID == "Atlantic/Azores")); Assert.AreEqual(1, timezones.Count(tz => tz.ID == "America/Scoresbysund"));
It might make sense to check the other two zones as well.
source/icu.net.tests/TimeZoneTests.cs, line 78 at r3 (raw file):
{ var expected = new TimeZone("AST"); TimeZone.SetDefault(expected);
This test is identical to DefaultTimeoneTest()
above. You could change it to use the .NET TimeZoneInfo
class for getting the expected timezone:
var expected = TimeZoneInfo.Local;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reminder. A few small suggestions.
Reviewable status: all files reviewed, 15 unresolved discussions (waiting on @j-troc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 4 files reviewed, 11 unresolved discussions (waiting on @ermshiperete and @wiertel)
source/icu.net/Timezone/Timezone.cs, line 15 at r2 (raw file):
Previously, wiertel (Piotr Szydełko) wrote…
missing documentation
Done.
source/icu.net/Timezone/Timezone.cs, line 37 at r2 (raw file):
Previously, wiertel (Piotr Szydełko) wrote…
this List building from SafeEnumeratorHandle is used couple times, is there a utility method doing exactly that, maybe put this code into private method?
Done.
source/icu.net/Timezone/Timezone.cs, line 51 at r2 (raw file):
Previously, wiertel (Piotr Szydełko) wrote…
space at the end of the line
Done.
source/icu.net/Timezone/Timezone.cs, line 14 at r3 (raw file):
Previously, ermshiperete (Eberhard Beilharz) wrote…
I think I'd prefer to rename this to
Id
(lowercase d)
Done.
source/icu.net/Timezone/Timezone.cs, line 79 at r3 (raw file):
Previously, ermshiperete (Eberhard Beilharz) wrote…
This method could return
IEnumerable<TimeZone>
as well.
Done.
source/icu.net/Timezone/Timezone.cs, line 109 at r3 (raw file):
Previously, ermshiperete (Eberhard Beilharz) wrote…
Shouldn't we check the error code? I.e. add the line
ExceptionFromErrorCode.ThrowIfError(ec)
?
Errors are chcecked inside GetUnicodeString method so there's no need to duplicate that.
source/icu.net/Timezone/Timezone.cs, line 159 at r3 (raw file):
Previously, ermshiperete (Eberhard Beilharz) wrote…
Shouldn't we check the error code? I.e. add the line
ExceptionFromErrorCode.ThrowIfError(ec)
?
Errors are chcecked inside GetUnicodeString method so there's no need to duplicate that.
source/icu.net/Timezone/Timezone.cs, line 176 at r3 (raw file):
Previously, ermshiperete (Eberhard Beilharz) wrote…
Shouldn't we check the error code? I.e. add the line
ExceptionFromErrorCode.ThrowIfError(ec)
?
Errors are chcecked inside GetUnicodeString method so there's no need to duplicate that.
source/icu.net/Timezone/USystemTimeZoneType.cs, line 4 at r2 (raw file):
Previously, wiertel (Piotr Szydełko) wrote…
none of these namespaces is used
Done.
source/icu.net.tests/TimeZoneTests.cs, line 71 at r3 (raw file):
Previously, ermshiperete (Eberhard Beilharz) wrote…
It might make sense to check the other two zones as well.
Done.
source/icu.net.tests/TimeZoneTests.cs, line 78 at r3 (raw file):
Previously, ermshiperete (Eberhard Beilharz) wrote…
This test is identical to
DefaultTimeoneTest()
above. You could change it to use the .NETTimeZoneInfo
class for getting the expected timezone:var expected = TimeZoneInfo.Local;
Value returned by TimeZoneInfo.Local will be different based on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r4.
Dismissed @wiertel from 4 discussions.
Reviewable status: complete! all files reviewed, all discussions resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r5.
Reviewable status: complete! all files reviewed, all discussions resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved
Thanks @j-troc ! |
This change is