mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #25494 - pshaughn:leadingzeroes, r=jdm
Make sure input value=12:30:01 doesn't turn into 12:30:1 Fixed convert_valid_normalized_local_date_and_time_string to add the mandatory leading 0 before seconds values that needed it, added tests to see that various-length strings with zeroes in them would roundtrip properly. --- <!-- 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] These changes fix #25493 <!-- Either: --> - [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. -->
This commit is contained in:
commit
da75ef25a7
3 changed files with 70 additions and 0 deletions
|
@ -474,7 +474,15 @@ impl DOMString {
|
|||
"{:04}-{:02}-{:02}T{:02}:{:02}",
|
||||
year, month, day, hour, minute
|
||||
);
|
||||
} else if second < 10.0 {
|
||||
// we need exactly one leading zero on the seconds,
|
||||
// whatever their total string length might be
|
||||
self.0 = format!(
|
||||
"{:04}-{:02}-{:02}T{:02}:{:02}:0{}",
|
||||
year, month, day, hour, minute, second
|
||||
);
|
||||
} else {
|
||||
// we need no leading zeroes on the seconds
|
||||
self.0 = format!(
|
||||
"{:04}-{:02}-{:02}T{:02}:{:02}:{}",
|
||||
year, month, day, hour, minute, second
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue