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. Image for the cookie policy date

Avoid using Timezones and dst in the Schedule

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



7 Replies

KK Karthigeyan Krishnamurthi Syncfusion Team April 5, 2017 08:40 AM UTC

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 



DS dsapo April 6, 2017 08:16 PM UTC

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




KK Karthigeyan Krishnamurthi Syncfusion Team April 7, 2017 04:01 PM UTC

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 
  



DS dsapo April 12, 2017 03:54 PM UTC

Thanks Karthigeyan  for the explanation.


SE Sellakumar Syncfusion Team April 13, 2017 05:43 PM UTC

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


LE Leon July 7, 2017 06:40 PM UTC

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.



KK Karthigeyan Krishnamurthi Syncfusion Team July 10, 2017 04:28 AM UTC

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



Loader.
Up arrow icon