I have read your description about time intervals and rounded up accordingly but for some start end time combinations, the calendar acts unpredictable.
Here in this example:
Start time: 11:10
End time: 19:10
Time interval is set to 10
Although the time difference is divisible by 10, the result can be seen below in the picture.
Hi
GunesYurdakul,
#Regarding [SfCalendar] With custom interval, calendar time precision is incorrect.
Based on the shared details we have checked your requirement and the startHour and endHour values do not give properly. The startHour and endHour types are double, so it considers only double values not hour and minutes values. For example, the 18.25 double value is in time 06.15 PM, here 0.25 is 15 minutes. So, one minute value is 0.0167. we have achieved your requirement by setting the correct start and end hour values in the calendar, please refer to the below code snippets,
Code Snippets:
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Container( child: SfCalendar( view: CalendarView.day, timeSlotViewSettings: const TimeSlotViewSettings( startHour: 11.167, endHour: 19.167, timeInterval: Duration(minutes: 10), timeFormat: 'hh:mm' ), ), ), ); } |
We hope that this helps you. Please let us know if you need further assistance.
Regards,
Muniappan S
Of course, I know that I need to use double values. The problem was rounding. As I see in your example, you rounded to 3 decimal places. That solution worked for me.
If you just assign it to: 11+ (10/60), you will receive the same result as mine.
Thanks for your help!
For the example, I provided in my question your solution worked. I wasn't rounding to 3 decimals as you did.
But I can still reproduce it with different parameters that should actually work.
For example:
5:50 - 5.833
19:00 - 19.0
timeSlotViewSettings: const TimeSlotViewSettings(
startHour: 5.833,
endHour: 19.0,
timeInterval: Duration(minutes: 10),
timeFormat: 'hh:mm'
),
I would appreciate if you could provide me a rule about how to compute double from a TimeOfDay not a rule that works only for one case.
Hi GunesYurdakul,
#Regarding I can still reproduce it with different parameters
As we said in the previous update one minute is equivalent to a 0.0167 double value. For example, if you want to render a start time from 5.50 you need to set the start hour value as (50 * 0.0167 = 5.835). Please use three decimal values to get the exact value. Please refer to the below code snippets for the same,
Code snippets:
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(widget.title),
), body: Container( child: SfCalendar( view: CalendarView.day, timeSlotViewSettings: const TimeSlotViewSettings( startHour: 5.835, endHour: 19.0, timeInterval: Duration(minutes: 10), timeFormat: 'hh:mm' ), ), ), // This trailing comma makes auto-formatting nicer for build methods. ); } |
We hope that this helps you. Please let us know if you need further assistance.
Regards,
Muniappan S