Repository navigation
implement valid week string - #19559
Conversation
|
Heads up! This PR modifies the following files:
|
| [[week\] stepDown method support on input 'week' element] | ||
| expected: FAIL | ||
|
|
||
| [[week\] The value must be a value that is a valid global date and time string] |
There was a problem hiding this comment.
not caused by this PR, since datetime has not implemented
| [week.html] | ||
| type: testharness | ||
| [2014 has 52 weeks: Value should be empty] | ||
| [Value >= min attribute] |
There was a problem hiding this comment.
min, max have not implemented
| ] | ||
|
|
||
| [[package]] | ||
| name = "chrono" |
There was a problem hiding this comment.
Use to get the weekday of the data
KiChjang
left a comment
There was a problem hiding this comment.
Just a couple of small nits! r=me after you make those changes.
| } | ||
|
|
||
| fn is_leap_year(year: u32) -> bool { | ||
| if year % 400 == 0 || (year % 4 == 0 && year % 100 != 0) { |
There was a problem hiding this comment.
The if here is unnecessary, you can just return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0).
| } | ||
| } | ||
|
|
||
| fn is_leap_year(year: u32) -> bool { |
There was a problem hiding this comment.
Perhaps make this #[inline] as well?
| fn max_week_in_year(year: u32) -> u32 { | ||
| match Utc.ymd(year as i32, 1, 1).weekday() { | ||
| Weekday::Thu => 53, | ||
| Weekday::Wed => { |
There was a problem hiding this comment.
Weekday::Wed if is_leap_year(year) => 53| } | ||
|
|
||
| // Step 5, 6 | ||
| let week = iterator.next().ok_or(())?; |
There was a problem hiding this comment.
We also need to ensure that there are no more items left to iterate on the iterator after this line. This is in fact step 10 of the spec.
There was a problem hiding this comment.
fix step 10 in the following
|
@KiChjang Please check. |
| } | ||
|
|
||
| // Step 10 | ||
| if iterator.next().is_some() || &value[(value.len() - 1)..] == "-" { |
There was a problem hiding this comment.
The last character match here is not necessary, since split produces an empty string for each - it encounters. https://play.rust-lang.org/?gist=e50b834be9123f860f52b5762c2e07d8&version=stable
|
@KiChjang fixed. |
|
@bors-servo r+ Thanks! |
|
📌 Commit 54c6028 has been approved by |
implement valid week string <!-- Please describe your changes on the following line: --> implement valid week string part of #19172 r? @KiChjang --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19559) <!-- Reviewable:end -->
|
💔 Test failed - linux-rel-css |
|
@bors-servo retry |
|
⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-wpt, mac-dev-unit, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt3, windows-msvc-dev are reusable. Rebuilding only linux-rel-css, mac-rel-css1, mac-rel-wpt2, mac-rel-wpt4... |
|
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Upstreamed from servo/servo#19559 [ci skip]
implement valid week string
part of #19172
r? @KiChjang
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is