-
Notifications
You must be signed in to change notification settings - Fork 431
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
[JA DateTimeV2] Merged refinements #2950
Conversation
swiftDay++; | ||
} | ||
|
||
var pastDate1 = pastDate.AddDays(swiftDay); |
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.
Maybe rename to pastDateAlt as it's an alternative resolution?
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.
done
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.
Mostly good. One minor comment and a request for future code for perf.
var start = timex.IndexOf(Constants.TimeTimexPrefix) + 1; | ||
var end = timex.IndexOf(Constants.TimeTimexConnector); | ||
end = end > 0 ? end : timex.Length; | ||
var hourStr = timex.Substring(start, end - start); |
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.
From now on, let's try to write such functions using Spans, to avoid creating a lot of small string objects garbage collected all the time. Please open an issue to refactor existing Timex parsing code to do the same.
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.
@aitelint Please ACK this comment. Thanks.
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.
@tellarin, issue created
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.
@tellarin, the problem is that net462 does not support parsing of spans, so we would need to convert the span back to string when passing it to int.TryParse
public static Tuple<int, int> ParseHoursFromTimePeriodTimex(string timex) | ||
{ | ||
int hour1 = 0, hour2 = 0; | ||
var timeList = timex.Split(Constants.TimexSeparator[0]); |
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.
Same.
All test cases pass.
Added support for the 30-hour clock form (commonly used in Japanese) and relative test cases in DateTimeParser, DateTimePeriodParser, MergedParser, TimeParser and TimePeriodParser.
Modified test cases:
In DateParser:
In MergedExtractor: