About Tempus Calendar
I've been thinking about open sourcing a program I made in 2023. It's called Tempus Calendar. It's a graphical calendar application where you can input your longitude and latitude and it will automatically calculate sunrise, sunset, dusk, and dawn times, and it's able to display Gregorian, Jewish, Islamic, and Julian calendars. It will also calculate prayer times for Judaism and Islam, and the weekly/daily scriptural readings for Catholicism and Judaism.
The reason I haven't announced it yet, and have been putting this off, is because daylight savings works well on Windows, but there's no support for it on Linux yet, and that's primarily because Windows has an actual API that will tell you the exact days in the person's local time zone when daylight savings changes and by how much. Linux has no standard api for this, afaik.
So while the program theoretically can run on Linux, the times will be messed up by up to 1 hour depending on your time zone and when daylight savings occurs.
I would like to fix this *before* I release the program as open source, but I need someone to point me in a direction where I can get time zone information on Linux with minimal file parsing, and that is NOT "America/Chicago". It needs the actual days of when daylight starts and stops, and the daylight offsets for the person's local time zone. And I don't really want to have to integrate a timezone database directly into the program.
May 13 ยท 8 weeks ago
3 Comments โ
๐ stack ยท May 13 at 20:59:
โ https://naggum.no/lugm-time.html
๐ clseibold [OP] ยท May 13 at 21:08:
@stack Not trying to be mean, but none of that is relevant to what I asked. Let me clarify, the program already does all the necessary calculations for all of the features except daylight savings on Linux, in particular. I just need a library that either parses/looks up the tz database on linux, or stores its own tz data so that I can query it for the daylight savings days and offsets for linux, specifically.
I have no patience for implementing this crap myself when Linux should have had a proper API for this to begin with.
๐ stack ยท May 14 at 17:36:
Not trying to be mean either, but asking for someone to provide you with a "library" to do something trivial is a sign of -- how should I put it -- a lack of effort or style? (but you are in good -- or at least, vast -- company).
Let me ChatGPT a ten-liner solution for you (showing my own lack of effort on this topic):
int main() { time_t now = time(NULL); struct tm tm_info; localtime_r(&now, &tm_info); int initial_isdst = tm_info.tm_isdst; printf("Starting DST status: %d\n", initial_isdst);
// Scan forward up to 1 year for (int days = 1; days <= 365; days++) { time_t future = now + days * 86400; localtime_r(&future, &tm_info); if (tm_info.tm_isdst != initial_isdst) { char buf[64]; strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", &tm_info); printf("DST change detected on: %s (isdst=%d)\n", buf, tm_info.tm_isdst); break; } } return 0; }
I am sure a coding genius (such as yourself) can easily adapt this to their needs. Or perhaps do even better than ChatGPT using "coding skills".
P.S. This is in C, of course -- (Bubble editor seems to have mangled != and <=).
Source