-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui5-date-*): adapt date and time controls to timezone feature (#…
…8610) Adapting the date and time controls to the timezone feature, allowing the controls to present date in different timezones. Adaptation is done by using the UI5Date object provided by ui5. Can be tested either via html tag: <script data-ui5-config type="application/json"> { "language": "EN", "timezone" : "Pacific/Apia" } </script> or by adding a query parameter to the url: ?sap-ui-timezone=XXXX The timezone identifiers format is the one used in IANA timezone database. Related to: #8461
- Loading branch information
1 parent
b589486
commit 1acae01
Showing
27 changed files
with
298 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | ||
<meta charset="utf-8"> | ||
|
||
<script> | ||
// delete Document.prototype.adoptedStyleSheets; | ||
</script> | ||
<link rel="stylesheet" type="text/css" href="./styles/TimePicker.css"> | ||
<script data-ui5-config type="application/json"> | ||
{ | ||
"language": "EN", | ||
"timezone" : "Pacific/Apia" | ||
} | ||
</script> | ||
|
||
<script src="%VITE_BUNDLE_PATH%" type="module"></script> | ||
|
||
|
||
</head> | ||
<body class="timepicker1auto"> | ||
|
||
<div class="samples"> | ||
<div class="sample-box-1"> | ||
<ui5-time-picker id="timePickerNow" value="now" format-pattern="HH:mm:ss"></ui5-time-picker> | ||
<br> | ||
</div> | ||
<div class="sample-box-1"> | ||
<ui5-date-picker id="datePickerNow" value="now" format-pattern="dd/MM/yyyy"></ui5-date-picker> | ||
<br> | ||
</div> | ||
<div class="sample-box-1"> | ||
<ui5-datetime-picker id="dateTimePickerNow" value="now" format-pattern="dd/MM/yyyy HH:mm:ss"></ui5-datetime-picker> | ||
<br> | ||
</div> | ||
<div class="sample-box-1"> | ||
<ui5-calendar id="calendar1"></ui5-calendar> | ||
<br> | ||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { assert } from "chai"; | ||
|
||
describe("Calendar general interaction", () => { | ||
before(async () => { | ||
await browser.url(`test/pages/DateControlsWithTimezone.html`); | ||
}); | ||
|
||
it("The date is with the correct offset in date picker", async () => { | ||
|
||
const datePicker = await browser.$("#datePickerNow"); | ||
const datePickerValue = await datePicker.shadow$("ui5-input").getValue(); | ||
const now = new Date(); | ||
const offset = now.getTimezoneOffset(); | ||
now.setMinutes(now.getMinutes() + offset); | ||
now.setHours(now.getHours() + 13); | ||
const datePickerValues = datePickerValue.split("/"); | ||
|
||
assert.strictEqual(now.getDate(), Number(datePickerValues[0]), "Date is correct"); | ||
assert.strictEqual(now.getMonth(), Number(datePickerValues[1] - 1), "Month is correct"); // Month is -1 because JSDate starts months count from 0 | ||
assert.strictEqual(now.getFullYear(), Number(datePickerValues[2]), "Year is correct"); | ||
}); | ||
|
||
it("The time is with the correct offset in time picker", async () => { | ||
|
||
const timePicker = await browser.$("#timePickerNow"); | ||
const timePickerValue = await timePicker.shadow$("ui5-input").getValue(); | ||
const now = new Date(); | ||
const offset = now.getTimezoneOffset(); | ||
now.setMinutes(now.getMinutes() + offset); | ||
now.setHours(now.getHours() + 13); | ||
const timePickerValues = timePickerValue.split(":"); | ||
|
||
assert.strictEqual(now.getHours(), Number(timePickerValues[0]), "Hour is correct"); | ||
assert.strictEqual(now.getMinutes(), Number(timePickerValues[1]), "Minute is correct"); | ||
}); | ||
|
||
it("The date and time is with the correct offset in datetime picker", async () => { | ||
|
||
const dateTimePicker = await browser.$("#dateTimePickerNow"); | ||
const dateTimePickerValue = await dateTimePicker.shadow$("ui5-input").getValue(); | ||
const now = new Date(); | ||
const offset = now.getTimezoneOffset(); | ||
now.setMinutes(now.getMinutes() + offset); | ||
now.setHours(now.getHours() + 13); | ||
const dateTimePickerValues = dateTimePickerValue.split(" "); | ||
const datePickerValues = dateTimePickerValues[0].split("/"); | ||
const timePickerValues = dateTimePickerValues[1].split(":"); | ||
|
||
assert.strictEqual(now.getDate(), Number(datePickerValues[0]), "Date is correct"); | ||
assert.strictEqual(now.getMonth(), Number(datePickerValues[1] - 1), "Month is correct"); // Month is -1 because JSDate starts months count from 0 | ||
assert.strictEqual(now.getFullYear(), Number(datePickerValues[2]), "Year is correct"); | ||
assert.strictEqual(now.getHours(), Number(timePickerValues[0]), "Hour is correct"); | ||
assert.strictEqual(now.getMinutes(), Number(timePickerValues[1]), "Minute is correct"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.