Skip to content
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

implement valid week string #19559

Merged
merged 1 commit into from Dec 17, 2017
Merged

implement valid week string #19559

merged 1 commit into from Dec 17, 2017

Conversation

@tigercosmos
Copy link
Collaborator

tigercosmos commented Dec 14, 2017

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

highfive commented Dec 14, 2017

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
@@ -30,6 +30,9 @@
[[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]

This comment has been minimized.

@tigercosmos

tigercosmos Dec 14, 2017

Author Collaborator

not caused by this PR, since datetime has not implemented

@@ -1,20 +1,13 @@
[week.html]
type: testharness
[2014 has 52 weeks: Value should be empty]
[Value >= min attribute]

This comment has been minimized.

@tigercosmos

tigercosmos Dec 14, 2017

Author Collaborator

min, max have not implemented

@@ -358,6 +358,15 @@ dependencies = [
"libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "chrono"

This comment has been minimized.

@tigercosmos

tigercosmos Dec 14, 2017

Author Collaborator

Use to get the weekday of the data

Copy link
Member

KiChjang left a 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) {

This comment has been minimized.

@KiChjang

KiChjang Dec 15, 2017

Member

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 {

This comment has been minimized.

@KiChjang

KiChjang Dec 15, 2017

Member

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 => {

This comment has been minimized.

@KiChjang

KiChjang Dec 15, 2017

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

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

This comment has been minimized.

@KiChjang

KiChjang Dec 15, 2017

Member

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.

This comment has been minimized.

@tigercosmos

tigercosmos Dec 16, 2017

Author Collaborator

fix step 10 in the following

@tigercosmos
Copy link
Collaborator Author

tigercosmos commented Dec 16, 2017

@KiChjang Please check.

}

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

This comment has been minimized.

@KiChjang

KiChjang Dec 17, 2017

Member

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
Collaborator Author

tigercosmos commented Dec 17, 2017

@KiChjang fixed.

@KiChjang
Copy link
Member

KiChjang commented Dec 17, 2017

@bors-servo r+

Thanks!

@bors-servo
Copy link
Contributor

bors-servo commented Dec 17, 2017

📌 Commit 54c6028 has been approved by KiChjang

@bors-servo
Copy link
Contributor

bors-servo commented Dec 17, 2017

Testing commit 54c6028 with merge 8798e49...

bors-servo added 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
Contributor

bors-servo commented Dec 17, 2017

💔 Test failed - linux-rel-css

@tigercosmos
Copy link
Collaborator Author

tigercosmos commented Dec 17, 2017

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented Dec 17, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Dec 17, 2017

@bors-servo bors-servo merged commit 54c6028 into servo:master Dec 17, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Dec 17, 2017
3 of 5 tasks complete
@tigercosmos tigercosmos deleted the tigercosmos:t1 branch Dec 17, 2017
jdm added 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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.