We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Avoid using Timezones and dst in the Schedule

Thread ID:

Created:

Updated:

Platform:

Replies:

129809 Apr 4,2017 05:00 PM Jul 10,2017 12:28 AM ASP.NET Core 7
loading
Tags: Schedule
dsapo
Asked On April 4, 2017 05:00 PM

Hi Support:

We are facing several issues with the timezone handling, because we used the datetimes from the Schedule table in different parts of the web site.

Would be possible to avoid completely using timezone and dst in the Schedule control, so when you create an appointment for example as 2:00 PM, is stored in the database as 2:00 PM without any UTC conversion.

If thats not possible, what would be the correct approach to work with UTC and DST when you have user around the world.  Should every user will have to define their UTC and DST in our system, because using the Schedule control ?

Appreciate any guidance or best practices about this topic.

Thanks

David



Karthigeyan Krishnamurthi [Syncfusion]
Replied On April 5, 2017 04:40 AM

Hi David, 
 
Thank you for contacting Syncfusion support. 
 
To render an appointment as same as the time given in data base, we suggest you to set apply-time-offset to false and for the same we have prepared the sample which can be download from the below location. Kindly view the below code example used in the sample. 
 
<Code> 
<ej-schedule id="Schedule1" width="100%" height="525px" create="onCreate" current-date="new DateTime(2014, 12, 5)"> 
    <e-appointment-settings apply-time-offset="false" id="Id" subject='"Subject"' start-time='"StartTime"' end-time='"EndTime"' all-day='"AllDay"' recurrence='"Recurrence"' recurrence-rule='"RecurrenceRule"'> 
        <e-datamanager url="Home/GetData" crud-url="Home/Batch" adaptor="UrlAdaptor"></e-datamanager> 
    </e-appointment-settings> 
</ej-schedule> 
</Code> 
 
 
Regards, 
Karthigeyan 


dsapo
Replied On April 6, 2017 04:16 PM

Hi Karthigeyan:

Our situation is that we need to store the  database datetimes equals to the datetimes selected in the appointment view.  Currently the database is showing the datetime with an timezone offset.  In the Schedule is fine, but we need to keep the same datetime in the database.

Any idea.

Thanks again

David



Karthigeyan Krishnamurthi [Syncfusion]
Replied On April 7, 2017 12:01 PM

Hi David 
  
Thanks for your update. 
 
By default, in Asp.Net Core sample, appointments are saving at 0 UTC when the CRUD operation is performed. For example, if an appointment is saved at 2-3 PM (with system timezone as UTC +5.30) in Scheduler, appointment will be retrieved as 8.30-9.30 AM (with UTC 0) at controller function before saving it in data-base. System timezone is then added with an appointment duration (converted to 2-3 PM) and sent to the Scheduler source from controller. In Scheduler default addition of system timeznoe is prevented by setting apply-time-offset to false, therefore finally appointment is rendered at 2-3 PM in Scheduler. Due to these behaviors, it is not possible to achieve your requirement. 
 
Regards, 
Karthigeyan 
  


dsapo
Replied On April 12, 2017 11:54 AM

Thanks Karthigeyan  for the explanation.

Sellakumar [Syncfusion]
Replied On April 13, 2017 01:43 PM

Hi David, 
 

We are glad to hear this from you. Kindly let us know, if you need any further assistance on this. 

 

Regards, 

Sellakumar K

Leon
Replied On July 7, 2017 02:40 PM

I have a similar requirement what I did ti get it working is to change the code in the controller: in my case i am using central time for illustration but yu can make it a variable:

                if (param.action == "insert")

                {

                    var value = param.value;

                    foreach (var fieldName in value.GetType().GetProperties())

                    {

                        var newName = fieldName.ToString().Split(null);

                        if (newName[1] == "Id") result = (_context.Process.ToList().Count > 0 ? _context.Process.ToList().Max(p => p.Id) : 1) + 1;

                        else if (newName[1] == "StartDate" || newName[1] == "EndDate") {

                                    DateTime dateTimeUtc = Convert.ToDateTime(fieldName.GetValue(value));

                                    DateTime dateCstTime = TimeZoneInfo.ConvertTime(dateTimeUtc, TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"));

                                    result = dateCstTime;

                         }

                        else result = fieldName.GetValue(value);

                        fieldName.SetValue(process, result);

                    }

                    _context.Process.Add(process);

                }

In the client side

<ej-schedule id="Schedule1" width="100%" height="525px" time-zone="UTC -06:00" ....


<e-appointment-settings apply-time-offset="false" ....


With these changes the data in the client side and in the server will always be in sync and in "Central Time" in this case. I am not sure if it will help you, but it works for me.


Karthigeyan Krishnamurthi [Syncfusion]
Replied On July 10, 2017 12:28 AM

Hi Juan,  
 
We are happy to hear that your issue has been resolved. 
 
Regards, 
Karthigeyan 



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;