Skip to content

implement valid week string - #19559

Merged
bors-servo merged 1 commit into
servo:masterfrom
tigercosmos:t1
Dec 17, 2017
Merged

bors-servo merged 1 commit into
servo:masterfrom
tigercosmos:t1

Conversation

@tigercosmos

@tigercosmos tigercosmos commented Dec 14, 2017 •

Copy link
Copy Markdown
Contributor

implement valid week string
part of #19172

r? @KiChjang


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • There are tests for these changes

This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/lib.rs, components/script/Cargo.toml, components/script/dom/htmlinputelement.rs, components/script/dom/bindings/str.rs
  • @fitzgen: components/script/lib.rs, components/script/Cargo.toml, components/script/dom/htmlinputelement.rs, components/script/dom/bindings/str.rs
  • @KiChjang: components/script/lib.rs, components/script/Cargo.toml, components/script/dom/htmlinputelement.rs, components/script/dom/bindings/str.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Dec 14, 2017
[[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]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

min, max have not implemented

Comment thread Cargo.lock
]

[[package]]
name = "chrono"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Use to get the weekday of the data

@KiChjang KiChjang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a couple of small nits! r=me after you make those changes.

Comment thread components/script/dom/bindings/str.rs Outdated
}

fn is_leap_year(year: u32) -> bool {
if year % 400 == 0 || (year % 4 == 0 && year % 100 != 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps make this #[inline] as well?

Comment thread components/script/dom/bindings/str.rs Outdated
fn max_week_in_year(year: u32) -> u32 {
match Utc.ymd(year as i32, 1, 1).weekday() {
Weekday::Thu => 53,
Weekday::Wed => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Weekday::Wed if is_leap_year(year) => 53

}

// Step 5, 6
let week = iterator.next().ok_or(())?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fix step 10 in the following

@KiChjang KiChjang added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Dec 16, 2017
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Dec 16, 2017
@tigercosmos

Copy link
Copy Markdown
Contributor Author

@KiChjang Please check.

Comment thread components/script/dom/bindings/str.rs Outdated
}

// Step 10
if iterator.next().is_some() || &value[(value.len() - 1)..] == "-" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@tigercosmos

Copy link
Copy Markdown
Contributor Author

@KiChjang fixed.

@KiChjang

Copy link
Copy Markdown
Contributor

@bors-servo r+

Thanks!

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 54c6028 has been approved by KiChjang

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Dec 17, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 54c6028 with merge 8798e49...

bors-servo pushed a commit that referenced this pull request Dec 17, 2017
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 -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-css

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Dec 17, 2017
@tigercosmos

Copy link
Copy Markdown
Contributor Author

@bors-servo retry

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ 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...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ 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
Approved by: KiChjang
Pushing 8798e49 to master...

@bors-servo
bors-servo merged commit 54c6028 into servo:master Dec 17, 2017
@bors-servo bors-servo mentioned this pull request Dec 17, 2017
3 of 5 tasks
@tigercosmos
tigercosmos deleted the t1 branch December 17, 2017 12:13
jdm pushed a commit to web-platform-tests/wpt that referenced this pull request Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-tests-failed The changes caused existing tests to fail.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants