File tree 5 files changed +18
-10
lines changed
5 files changed +18
-10
lines changed Original file line number Diff line number Diff line change
1
+ import CalendarDate from "./CalendarDate.js" ;
2
+
3
+ /**
4
+ * Returns a UTC timestamp representing today
5
+ * @public
6
+ */
7
+ const getTodayUTCTimestamp = primaryCalendarType => CalendarDate . fromLocalJSDate ( new Date ( ) , primaryCalendarType ) . valueOf ( ) / 1000 ;
8
+
9
+ export default getTodayUTCTimestamp ;
Original file line number Diff line number Diff line change 1
1
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js" ;
2
2
import CalendarDate from "@ui5/webcomponents-localization/dist/dates/CalendarDate.js" ;
3
3
import modifyDateBy from "@ui5/webcomponents-localization/dist/dates/modifyDateBy.js" ;
4
- import getRoundedTimestamp from "@ui5/webcomponents-localization/dist/dates/getRoundedTimestamp .js" ;
4
+ import getTodayUTCTimestamp from "@ui5/webcomponents-localization/dist/dates/getTodayUTCTimestamp .js" ;
5
5
import DateComponentBase from "./DateComponentBase.js" ;
6
6
7
7
/**
@@ -52,7 +52,7 @@ class CalendarPart extends DateComponentBase {
52
52
* @protected
53
53
*/
54
54
get _timestamp ( ) {
55
- let timestamp = this . timestamp !== undefined ? this . timestamp : getRoundedTimestamp ( ) ;
55
+ let timestamp = this . timestamp !== undefined ? this . timestamp : getTodayUTCTimestamp ( this . _primaryCalendarType ) ;
56
56
if ( timestamp < this . _minTimestamp || timestamp > this . _maxTimestamp ) {
57
57
timestamp = this . _minTimestamp ;
58
58
}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { getFeature } from "@ui5/webcomponents-base/dist/FeaturesRegistry.js";
2
2
import CalendarDate from "@ui5/webcomponents-localization/dist/dates/CalendarDate.js" ;
3
3
import modifyDateBy from "@ui5/webcomponents-localization/dist/dates/modifyDateBy.js" ;
4
4
import getRoundedTimestamp from "@ui5/webcomponents-localization/dist/dates/getRoundedTimestamp.js" ;
5
+ import getTodayUTCTimestamp from "@ui5/webcomponents-localization/dist/dates/getTodayUTCTimestamp.js" ;
5
6
import ValueState from "@ui5/webcomponents-base/dist/types/ValueState.js" ;
6
7
import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js" ;
7
8
import {
@@ -373,14 +374,12 @@ class DatePicker extends DateComponentBase {
373
374
* @protected
374
375
*/
375
376
get _calendarTimestamp ( ) {
376
- let millisecondsUTC ;
377
377
if ( this . value && this . _checkValueValidity ( this . value ) ) {
378
- millisecondsUTC = this . dateValueUTC . getTime ( ) ;
379
- } else {
380
- millisecondsUTC = new Date ( ) . getTime ( ) ;
378
+ const millisecondsUTC = this . dateValueUTC . getTime ( ) ;
379
+ return getRoundedTimestamp ( millisecondsUTC ) ;
381
380
}
382
381
383
- return getRoundedTimestamp ( millisecondsUTC ) ;
382
+ return getTodayUTCTimestamp ( this . _primaryCalendarType ) ;
384
383
}
385
384
386
385
/**
Original file line number Diff line number Diff line change 1
1
import RenderScheduler from "@ui5/webcomponents-base/dist/RenderScheduler.js" ;
2
2
import CalendarDate from "@ui5/webcomponents-localization/dist/dates/CalendarDate.js" ;
3
3
import modifyDateBy from "@ui5/webcomponents-localization/dist/dates/modifyDateBy.js" ;
4
- import getRoundedTimestamp from "@ui5/webcomponents-localization/dist/dates/getRoundedTimestamp .js" ;
4
+ import getTodayUTCTimestamp from "@ui5/webcomponents-localization/dist/dates/getTodayUTCTimestamp .js" ;
5
5
6
6
// Styles
7
7
import DateRangePickerCss from "./generated/themes/DateRangePicker.css.js" ;
@@ -104,7 +104,7 @@ class DateRangePicker extends DatePicker {
104
104
* @override
105
105
*/
106
106
get _calendarTimestamp ( ) {
107
- return this . _firstDateTimestamp || getRoundedTimestamp ( ) ;
107
+ return this . _firstDateTimestamp || getTodayUTCTimestamp ( this . _primaryCalendarType ) ;
108
108
}
109
109
110
110
/**
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ <h3>Islamic Calendar</h3>
97
97
< h3 > Buddhist Calendar</ h3 >
98
98
< div class ="snippet ">
99
99
< div class ="datepicker-width ">
100
- < ui5-calendar primary-calendar-type ='Buddhist '> </ ui5-calendarr >
100
+ < ui5-calendar primary-calendar-type ='Buddhist '> </ ui5-calendar >
101
101
</ div >
102
102
</ div >
103
103
< pre class ="prettyprint lang-html "> < xmp >
You can’t perform that action at this time.
0 commit comments