Fl_Calendar

50 views
Skip to first unread message

Francois Arrona

unread,
Mar 31, 2021, 2:31:19 AM3/31/21
to fltk.general

Hello,

I'm using the Fl_Calendar widget and face a strange behaviour :
For march, if the system date is march 27 2021, everything is OK. If the system date is march 28, it does not display the cell for march 28. It displays march 27 (saturday) and march 29 (sunday, which is wrong).
Then if system date is march 29, it does only display the week from 22 to28 (and forget the previous weeks).
I will try to fix it, and if someone already did it, it could be nice :)

Jer'


Francois Arrona

unread,
Mar 31, 2021, 3:25:09 AM3/31/21
to fltk.general
I had a look about Fl_Calendar.
In fact, I downloaded a source version found on a github. I don't use the FLEK version of Fl_Calendar.
So, I have two options now :

- integrating flek and its calendar widget
- fix the problem I face on the Fl_Calendar I already integrated.

Albrecht Schlosser

unread,
Mar 31, 2021, 9:14:54 AM3/31/21
to fltkg...@googlegroups.com
On 3/31/21 8:31 AM Francois Arrona wrote:
> I'm using the Fl_Calendar widget and face a strange behaviour :
> For march, if the system date is march 27 2021, everything is OK. If the
> system date is march 28, it does not display the cell for march 28. It
> displays march 27 (saturday) and march 29 (sunday, which is wrong).
> Then if system date is march 29, it does only display the week from 22
> to28 (and forget the previous weeks).

I can confirm this odd behavior with Nikita Egorov's Fl_Calendar widget
from:

https://github.com/nikego/Fl_Calendar

As someone else suspected, it might have to do with daylight saving
changes. Similar issues appear around end of October.

I just did a quick test but did not investigate further.

What I found so far: at daylight savings change time in spring
*sometimes* the day of the change is missing or the widget displays
dates of Feb instead of Mar.

At the change time in autumn the date (Sunday) is shown twice (in this
year Oct 31 is shown as Sun and Mon) and the following dates move one
weekday further.

The next month is shown correctly.

See for instance attached image (Mar 28 is missing).
Fl_Calendar.png

Anon Mouse

unread,
Mar 31, 2021, 9:31:21 AM3/31/21
to fltkg...@googlegroups.com
https://github.com/nikego/Fl_Calendar 
As someone else suspected, it might have to do with daylight saving
changes. Similar issues appear around end of October.

A quick glance at Nikita's code shows:

#define SECSPERDAY (60 * 60 * 24)

Day calculations in update_table() are performed by adding SECSPERDAY as delta seconds and using localtime() to find the date. This will be thrown off by time changes.

lifeatt...@gmail.com

unread,
Mar 31, 2021, 9:58:21 AM3/31/21
to fltk.general
The FLEK version 0.2 doesn't have the same bug. It uses a table of days-per-month and standard leap year calculation. It's not a single class though, and one method suggests that dates before 1970 and after 2035 are not supported.

re: Nikita's version, I note that Russia seems not to use time adjustments like Daylight Savings Time ...

Bill Spitzak

unread,
Mar 31, 2021, 12:13:08 PM3/31/21
to fltkg...@googlegroups.com
A real quick fix is to add 12 hours to the time so it figures out what day contains noon+n*24 rather than midnight+n*24, which will not change when daylight savings time turns on/off.

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/8d2138a0-4709-4e1c-910b-fd9c27a90e88n%40googlegroups.com.

Francois Arrona

unread,
Mar 31, 2021, 8:40:22 PM3/31/21
to fltk.general
Yeah
I tried the fix proposed by spitzak. It seems to work.
Thanks everybody for comments.

Jer'

anmol....@gmail.com

unread,
May 5, 2021, 9:26:09 AM5/5/21
to fltk.general
Is that
auto m = e_mon + SECSPERDAY * 7;
to
auto m = e_mon + SECSPERDAY * 7 + SECSPERDAY /2;

I dont quite understand the code, so any other changes ?

On Thursday, April 1, 2021 at 6:10:22 AM UTC+5:30  wrote:
Yeah
I tried the fix proposed by spitzak. It seems to work.
Thanks everybody for comments.

Jer'

Le mercredi 31 mars 2021 à 18:13:08 UTC+2, spitzak a écrit :
A real quick fix is to add 12 hours to the time so it figures out what day contains noon+n*24 rather than midnight+n*24, which will not change when daylight savings time turns on/off.

On Wed, Mar 31, 2021 at 6:58 AM :
Reply all
Reply to author
Forward
0 new messages