This is a migrated thread and some comments may be shown as answers.
DayView start/end time on Android is off.
2 Answers 29 Views
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 2
Tim asked on 29 May 2017, 09:46 AM

Hi,

I cannot figure out how Android treats Start time and End time. No matter what I do, the appointment is always shown with a 2 hours offset compared to the time I've added.

An event going from 9:00 - 10:00 is shown 11:00 - 12:00. 

I've tried using specifying the date time kind to etc, local, unspecified - but to no avail.

I'm running with gmt+1 settings on my dev android phone.

ps. iOS does not have this problem. It has others though.

 

2 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 31 May 2017, 12:52 PM
Hello Tim,

Thank you for contacting us.

The offset you see in the appointment dates is caused by the selected Timezone of your device/emulator. The android calendar assumes that the appointment date is in UTC format and converts it to your local timezone. I've logged a Bug Report in our backlog to fix the problem - you can check the public item here - link

As a workaround to your issue I can offer you two solutions:

1. When creating new events, after you create the correct start and end date objects set them to UTC format. That way the event will be displayed correctly in the DayView. The negative side of that approach is that your Appointment object will hold the dates in UTC format. Here is a quick code snipped that set the dates in UTC:

var startDate = new DateTime(2017, 5, 31, 9, 15, 0);
var Appointment = new Appointment
{
     StartDate = startDate.ToUniversalTime()
};


2. The second approach is to create custom CalendarRenderer where you will have access to the native control and you can change the TimeFormat from "LOCAL" to "UTC". I'm posting simple implementation of CustomCalendarRenderer that should solve your problem:


public class CustomCalendarRenderer : CalendarRenderer
{
    public override bool TrySetViewMode(CalendarViewMode view, bool isAnimated)
    {
        if (view == CalendarViewMode.Day)
        {
            this.Control.DayView.DayEventsViewStyle.TimeLabelFormat.TimeZone = TimeZone.GetTimeZone("UTC");
        }
 
        return base.TrySetViewMode(view, isAnimated);
    }
}

 

Here are a few links about custom renderers in Xamarin:


I hope I've been helpful.


Regards,
Nikolay
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Tim
Top achievements
Rank 2
answered on 31 May 2017, 01:06 PM

Hi Mark,

 

Thanks!

The calendar feature I'm working on is still some time away from being released.

I'll track the bug report and wait a while for the fix.

Asked by
Tim
Top achievements
Rank 2
Answers by
Nikolay
Telerik team
Tim
Top achievements
Rank 2
Share this question
or