Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By sinasalek on
Hi,
I want to write a hook for Drupal date functions and then a module for supporting different calendars, i'm not a core developer so i need advice.
1.Is this possible?
2.Is such a patch will be accepted by core commiters?
3.If some else has done something similar or if you know a tutorial i will be thankful if you direct me to that.
Regards
Comments
...
[I'm not a Core developer.]
There are two different tasks here:
It's a coincidence: just today I submitted a new module, Holidays, that tries to accomplish the first goal. It's a work in progress and I could certainly use some help here.
You are talking about making Drupal "support different calendars." This wording is very broad. There are several aspects to dates: printing them, entering them, printing them in a month view, representing them in the URL, etc.
It's a broad subject. I don't know what aspect of dates you're most interested in, so I can't elaborate.
Drupal Core itself does very little with dates. It's the two contributed modules, Date and Calendar (and Views), that come into mind when speaking about dates.
Thanks for the reply, Great
Thanks for the reply,
Great Module :),
Actually i'm refering to all of them, just like what users do with Gregorian calendar (Full support)
As you mentioned supporting different calendars requires a layer (something like Date API) between modules and php date functions, so a module can take care of the rest via overriding or extending this layer. date can store as timestamp for compatibility so changing a calendar will become easy.
I'm not sure if Date module only support CCK field or not but since it's not a core module i guess core modules don't use it. so there is no way to support different calendars completely right now (if i'm wrong please correct me).
I will check your module to see if i can add Muslim calendars like Jalali,or Ghamary to it. i already have require algorithms for converting jalali to timestamp or from it.
PS : If we could find some other guys for adding other popular calendars, this module or an api derived from it could be add to core :)
sina.salek.ws
Feel freedom with open source softwares
sina.salek.ws, Software Manager & Lead developer
Feel freedom with open source softwares
...
Great. I haven't yet created a "release" (because I don't want people to complain "hey! but this module does nothing!"), so in the meantime you can browse it via CVS:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/holidays/
The most important file is `NativeCalendar.php'. You can ignore the rest. This is the base abstract class from which all calendars derive. Admittedly, it's a bit disappointing right now. It needs some improvements. Examples:
As you see, there's certainly room for improvement. That's why it's "a work in progress." I'll give CVS access to anybody who wants to help.
(BTW, I use the word "native" to mean "non-Gregorian." It's not that I'm biased; I just don't know of any other word to use.)
My plans for the near-future:
There are different levels of support for native calendars. We can achieve some of them in the near-future. But I'm not so optimistic as to think we will ever achive "full support."
Let's start by improving NativeCalendar and adding some Muslim calendars. I'll be reading material on the subject soon, probably next week.
Hi,
Hi,
It depends on how u implement calendar view, because dates store as timestamp in drupal, if module
wants to communicate with other modules via date i think it should be able to convert selected date to
timestamp.
Completely agree with you and for start they can use default settings provided by module
Yes, they are. guess storing holidays occurring date as array (from,to) can solve it. about showing it, i
don't have any idea right now ;)
Referring to this : http://www.fourmilab.ch/documents/calendar/
Most of popular calendars have day,month,year , but not all of them. i each calendar implementation
should be able to override the way calendar shows. (i don't know if Calendar module allow this kind of manipulation)
Muslim calendars like "Hijir Shamsi(Jalali)","Hijri Ghamari" are like Gregorian calendar , their algorithm is
different but they all represent date with day,month,year,week. the different between them is number of days
per month. which is usually between (1-32).
I have a complete Class for Jalali (Hijri Shamsi) calendar for php, and sure there should be something
similar for "Hijri Ghamari"
additionally you might be interested to have look at following links :
http://en.wikipedia.org/wiki/Islamic_calendar
http://en.wikipedia.org/wiki/Iranian_calendar
Yes i know, even if we implement native calendars completely it takes quite some time for other modules
to start using it! :)
I have also some good news, some one converted the javascript class used for this
http://www.fourmilab.ch/documents/calendar/ to php, and it has converter for almost all of the popular
calnedar systems. it is also available for download : http://codeigniter.com/wiki/Calendar/
i think it can help alot for designing a flexible base class.
And i had a look at your NativeClass and Date Module,
they're not organized yet but two of them are: using Decorator pattern for representing the calendar, and
the other is as i mentioned not all of calendars have only day,month,year. so probably it needs some
major changes if it meant to be real multi calendar.
PS: i think it needs more investigation,
http://en.wikipedia.org/wiki/Calendar#List_of_calendars
http://www.pcworld.com/downloads/file/fid,944-order,1-page,1-c,scheduler...
sina.salek.ws
Feel freedom with open source softwares
sina.salek.ws, Software Manager & Lead developer
Feel freedom with open source softwares
...
Hi.
I appreciate the time you spend with me.
I updated the module a few hours ago (no downloadable 'release' yet, sorry; use CVS). I worked on this yesterday night. I mainly added a GUI so people can see _something_. You can see it in action here:
http://blue.live4all.co.il/~mooffie/cms/holidays
(Note that the calendar is simply shown overlayed on the Gregorian calendar. It might not be acceptable in some cultures, but my intention was to put up a quick demo.)
I added a simple Hijri calendar. It's very simple-minded right now; I just plucked an algorithm somebody left in a comment on PHP's website. Right now I only wanted to demonstrate the ability to support various calendars.
I already implemented that. Example: when you switch to the 'Jewish' calendar a new fieldset will appear: "Settings for this calendar."
(Yeah. I figured that if a calendar doesn't have years we can always have the year as '1'. And if it doens't have months, it will be fixed on '1' here as well. Of course, I might be wrong here --I have yet so study this.)
I'll look into these calendars very soon.
The current scheme isn't perfect. For example, holidays and calendars aren't the same entity. Needs fixing. I have yet to revamp and refine the API; I'll be able to do that only after I study the calendars and links you pointed me to (thanks!).
Yes, I have a lot of studying to do in the following days. I might nag you with some questions ;-)
Hi, Good job, :) (Yeah. I
Hi,
Good job, :)
Good idea, i think it's gonna work for most of calendars . the link i sent you (windows application) has almost all of the active calendars, since it's a working example i think it's a good idea to use it as reference.
Actually i wanted to add multi calendar support to Drupal just like you, but i got busy and postponed it. so i'm glad to see that you're working on the same thing :).
And don't hesitate to ask me if you think i can help ;)
I uploaded my Iranian Calendar (Jalali) class in case you're interested
http://salek.ws/storage/datetime.class.inc.php.txt
Regards
sina.salek.ws
Feel freedom with open source softwares
sina.salek.ws, Software Manager & Lead developer
Feel freedom with open source softwares
Some quotes
Moofie,
Hello
I traced the thread. I also checked http://blue.live4all.co.il/~mooffie/cms/holidays. The main problem, in my opinion, is the lack of locale specific configuration in Drupal. I mean, when the locale changes, all locale-related features should change; for example, language, numeric system, date, time, etc. Is that right?
Is it possible to write a module that does the stated changes? Or, all these provisions should take place in the Drupal's core?
I myself, in order to make Persian (jalali) date system work, changed format_date function in common.inc.
Please let me know if you have any comments about all these.
Kind Regards
Ali Majdzadeh Kohbanani
...
It's not always desirable. There are countries that have a national/religious calendar but use the Gregorian calendar primarily.
Before we come to the Drupal people with a proposal, we need something tangible in our hands. We need to work out the details of this proposal. If you look at my first comment in this discussion you'll see that "integrating it with drupal" comes in the _second_ place. First we need to design something good.
BTW, I'd like to see the 'format_date' you use. You can sent me it privately.
====
I haven't touched that 'holidays' code in months, but I didn't give up on this: I'm very intereseted in this still.
...
Besides, you want to have the choice of, for example, printing the Persian month names in either English script or Persian script. So it's desirable to be able to stay in English locale and nevertheless show Persian dates.
Some ideas
Moofie,
Hi
Thanks for your response.
My reference for locale configuration is Linux itself. When the locale changes (either by the user or by any application) all the locale-related features are changed.
I do agree with the idea of settings for locale-related features but the default behavior in all (Linux-based) systems is as above.
By the way, all (approximately) the locale-related features are display-oriented. For example, in order to show numbers in Persian numeric system, I used a simple function to just map Latin numbers onto their corresponding Persian ones in the Unicode. The same issue exists for the date.
I will send you the code I use. Please let me know how I can contact you.
Kind Regards
Ali Majdzadeh Kohbanani
subscribing!!!!
subscribing!!!!
farsi time and date (shamsi)
hi
do you know how to show time and date in farsi (shamsi)?
regards
peyman
I started a module called
I started a module called Calendar Systems, you might be interested in it.
sina.salek.ws, Software Manager & Lead developer
Feel freedom with open source softwares
very impressive Sina, good
very impressive Sina, good job. I think I stop developing Jalali Date now
interested
subscription