Skip to content

fix(ui5-daypicker): show correct today #1157

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

Merged
merged 1 commit into from
Jan 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/base/src/dates/CalendarDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class CalendarDate {
function isValidDate(date) {
return date && Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date); // eslint-disable-line
}
if (!isValidDate()) {
if (!isValidDate(oJSDate)) {
throw new Error(`Date parameter must be a JavaScript Date object: [${oJSDate}].`);
}
return new CalendarDate(oJSDate.getFullYear(), oJSDate.getMonth(), oJSDate.getDate(), sCalendarType);
Expand Down
4 changes: 1 addition & 3 deletions packages/main/src/DayPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ class DayPicker extends UI5Element {
lastWeekNumber = weekNumber;
}

const isToday = (oCalDate.getDate() === this._currentCalendarDate.getDate())
&& (oCalDate.getMonth() === this._currentCalendarDate.getMonth())
&& (oCalDate.getYear() === this._currentCalendarDate.getYear());
const isToday = oCalDate.isSame(CalendarDate.fromLocalJSDate(new Date(), this._primaryCalendarType));

week.push(day);

Expand Down
56 changes: 56 additions & 0 deletions packages/main/test/pages/i18n-demo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>

<head>
<script>delete Document.prototype.adoptedStyleSheets;</script>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="utf-8">
<title>i18n Demo</title>

<script src="../../webcomponentsjs/webcomponents-loader.js"></script>
<script src="../../resources/bundle.esm.js" type="module"></script>
<script nomodule src="../../resources/bundle.es5.js"></script>

<script>delete Document.prototype.adoptedStyleSheets;</script>

</head>


<body>

<style>
.snippet {
display: flex;
width: 50%;
flex-direction: column;
margin: auto;
margin-top: 200px;
}
</style>

<div class="snippet">

<ui5-datepicker></ui5-datepicker>

<br>
<br>

<!-- <ui5-daypicker></ui5-daypicker> -->


<br>
<br>

<ui5-textarea maxlength="20" show-exceeded-text></ui5-textarea>

<br>
<br>

<span>Martin's cheat sheet</span>

<hr>
mañana, ayer
</div>
</body>

</html>