Another idea I have is to use timestamp overlays which Org mode already supports. Though it's not a perfect implementation of this feature, I hope it's easy to get started with.
Christian Moe <[email protected]> writes: > Khalid Rafi <[email protected]> writes: > >> Can I track Org habits with an alternate calendar instead of Gregorian, >> such as Islamic calendar? Emacs already supports it. I want to set >> timestamps and repeaters according to that calendar. > > Not out of the box and not easily, I think. Here is an attempt to > outline some possible approaches and considerations. Corrections and > other ideas are very welcome. > > Emacs support for the Islamic calendar is limited. The Emacs calendar > displays Gregorian time, but includes functions for converting specific > dates to and from the Islamic calendar via "absolute" Julian days > according to one method of the several that exist. For example, to find > out that the upcoming Ramadan starts on February 18: > > #+begin_example > (let ((fast-begins '(9 1 1447))) > (calendar-gregorian-from-absolute > (calendar-islamic-to-absolute fast-begins))) > > => (2 18 2026) > #+end_example > > As Panayotis Manganaris observed elsewhere in this thread, the fact > that Org-mode allows putting Emacs diary sexps in timestamps suggests > some ways to access those calendar functions, but I think practical > use would require some kind of simplifying macro. > > As for Org timestamps proper, they are based on Gregorian time and the > ISO-8601 format. > > Assuming that one want to select, view, export, set repeaters for and > operate on Org timestamps according to the Islamic calendar, support > would be needed for: > > 1. Repeaters and operations on timestamps > > Let's take that first, since it strikes me as the main stumbling > block. Everything one does to the timestamp will operate on the > underlying Gregorian representation. For repeaters such as =+1d= or > =+1w=, and operations such as adjusting the date one day > back/forward, this should not matter. For repeaters/adjustments like > =+1m= or =+1y=, results would probably differ from what the user > would expect based on the displayed Islamic date. For example, =[1 > Ramadan 1447 +1y]= will not result in 1 Ramadan 1448 but in the date > one Gregorian year hence). > > To overcome this would require new Org features to make timestamps > and repeaters work according to the logic of non-Gregorian calendars, > which sounds like a complex undertaking. > > Unless and until someone takes on that project, I think people > wanting to use the Islamic calendar in Org as much as possible are > best served by mixed solutions where timestamps can be /entered/ and > /exported/ in Islamic-calendar form, but where Emacs transparently > /displays/ them as Gregorian. > > (While display and export of custom timestamps are controlled by the > same variables, as discussed below, on a per-document basis they can > be controlled separately because =Local Variables:= is needed for > display and =#+BIND:= for export.) > > 2. Entering/selecting Islamic-calendar dates > > This only requires an interactive function to read a date via > `calendar-islamic-read-date' from cal-islam.el, which is part of > Emacs, and insert its Gregorian equivalent as an Org timestamp, > which sounds doable. > > 3. Exporting (and maybe displaying) dates in a custom Islamic-calendar format > > The recommended way of changing how timestamps are displayed and > exported (see [[info:org#Custom time format]]) is to customize the > variables > `org-display-custom-times' and `org-timestamp-custom-formats'. The > latter uses a format understood by `format-time-string' > ([[help:format-time-string]]), which does not include any way to access > Emacs calendar conversions as far as I can see. > > It can use the locale's rendering via the ~%x~ and ~%c~ specifiers, > however, so this might work if there exists a variant of your system > locale with Islamic calendar, e.g. an imaginary variant US English > locale "en-US.utf8@islamic" or similar. I don't have one, and I'm not > quite sure where to find one and install it, but if you do (check > your /usr/share/i18n/SUPPORTED), I can walk you through the steps to > test it. (Note that locales may implement other ways of calculating > the Islamic calendar with results that differ from the Emacs > calendar; I believe there are ar-SA locales with an "umalqura" > calendar using astronomical calculations). > > Otherwise, one way to go would be a feature request to allow a custom > function as the value of `org-timestamp-custom-formats', so we could > use the calendar functions for conversion. This might also be > preferable to the custom-format/locale approach because the results > would be compatible with those of the Emacs calendar. > > Regards, > Christian > -- Khalid Rafi Sent with Emacs
