- Home
- Forum
- React - EJ 2
- Customize StartDate and EndDate query parameters
Customize StartDate and EndDate query parameters
Hello folks,
I use scheduler to show events in specified time zone:
<ScheduleComponent timezone='Europe/London' />
And I expect that StartDate and EndDate query parameters would be sent in the same timezone: https://{api-url}?StartDate=2023-08-22T23:00:00.000Z&EndDate=2023-08-23T23:00:00.000Z
But when my PC in, say, Coordinated Universal time with minus 9 hours offset the request looks like: https://{api-url}?StartDate=2023-08-23T09:00:00.000Z&EndDate=2023-08-24T09:00:00.000Z
My backend doesn't know about browser timezone. Could you please tell me how can I make StartDate and EndDate parameters to be dependent on time zone parameter which I pass to schedule instead of browser timezone?
Dear Syncfution team, we consider this as a bug and we made a fix on our side by overriding part of your query building functionality:
import { Predicate } from '@syncfusion/ej2-data';
import { Data } from '@syncfusion/ej2-schedule/src/schedule/actions/data'
import { zonedTimeToUtc } from 'date-fns-tz'
Data.prototype.generateQuery = function (startDate, endDate) {
var query = this["query"].clone();
if (this["parent"] && this["parent"].eventSettings.includeFiltersInQuery && startDate && endDate) {
var dateQuery = this.getStartEndQuery(startDate, endDate);
var recurrenceQuery = new Predicate(this["parent"].eventFields.recurrenceRule, 'notequal', null).and(new Predicate(this["parent"].eventFields.recurrenceRule, 'notequal', ''));
return query.where(dateQuery.or(recurrenceQuery));
}
const timeZone = this["parent"].timezone;
if (startDate) {
query.addParams('StartDate', (timeZone ? zonedTimeToUtc(startDate, timeZone) : startDate).toISOString());
}
if (endDate) {
query.addParams('EndDate', (timeZone ? zonedTimeToUtc(endDate, timeZone) : endDate).toISOString());
}
return query;
};
We'd appreciate if you fix it on your side in one of closest releases.
Cheers,
Ivan
Hi Ivan,
Your reported problem “The start and end dates' time zone is being passed incorrectly” is considered as a bug. The fix for this defect will be included in our upcoming weekly patch release, which is expected to be rolled out by first week of September 2023. You can track the status of the fix at the following link:
Regards,
Swathi Ravi
Thank you, guys.
Regards,
Ivan
Hi Ivan,
Regards,
Satheesh Kumar B
Hi Ivan,
We are glad to announce that our Essential Studio 2023 Volume 3 release v23.1.36 is rolled out and is available for download under the following link.
The fix for the issue “The start and end dates' time zone is being passed incorrectly” has been included in our volume 3 release v23.1.36. Upgrade to the latest version to resolve the issue.
Sample: https://stackblitz.com/edit/ej2-react-schedule-start-end-timezone?file=package.json,index.js
Regards,
Satheesh
- 5 Replies
- 3 Participants
-
IP Ivan Pohorilyi
- Aug 23, 2023 09:06 AM UTC
- Sep 22, 2023 01:37 PM UTC