Hebrew Dates v1.0.3
Based on feedback from KosherJava (on the v1.0.2. release announcement), I've enhanced the currentHebrewDate() API in the Hebrew Dates plugin. It now accepts parameters to control how the date is printed.
Usage
HebrewDate provides an API, hebrewDateCurrent($dateFormat,$location) that can be used to display the current Hebrew Date in your favorite theme. If called with no parameters (or an illegal combination of parameters), it displays the current Hebrew Date according to the Character Set configuration above. By setting $dateFormat to a valid PHP date format, and $location to either "before" or "after" (including the quotation marks), it will display the secular day as well ($location controls the placement of the Hebrew Date).
Alternatively, $dateFormat can be set to the special value of "date_format", in which case it will use the default wordpress formatting.
Finally, $dateFormat can be set to the special value of "default". In this case, the $location parameter is ignored, and the function produces the same value that the_time() produces within The Loop.
Samples
In the legal cases, it functions according to the rules above. In the illegal cases, it returns the default value (same as if it receives no arguments)
Legal: hebrewDateCurrent(): כ"ב תמוז תשס"ח
Legal: hebrewDateCurrent("r","before"): כ"ב תמוז תשס"ח-Thu, 24 Jul 2008 10:44:31 -0500
Legal: hebrewDateCurrent("r","after"): Thu, 24 Jul 2008 10:44:31 -0500-כ"ב תמוז תשס"ח
Illegal: hebrewDateCurrent("r"): כ"ב תמוז תשס"ח
Illegal: hebrewDateCurrent("","after"): כ"ב תמוז תשס"ח
Illegal: hebrewDateCurrent("date_format"): כ"ב תמוז תשס"ח
Legal: hebrewDateCurrent("date_format","after"): July 24, 2008-כ"ב תמוז תשס"ח
Legal: hebrewDateCurrent("F y H:m","after"): July 08 10:07-כ"ב תמוז תשס"ח
Legal: hebrewDateCurrent("default"): כ"ב תמוז תשס"ח - July 24, 2008
The new version is 1.0.3, and is available at the Hebrew Dates release page.
כ"ז שבט תשס"ז - February 14, 2007 at 10:09 pm
Looks great.
<?php if (function_exists('hebrewDateCurrent')) {hebrewDateCurrent("default");} ?> is much easier to use.
י"ב אדר תשס"ז - March 1, 2007 at 4:48 pm
Mike,
I've just started using your version of Hebrew Date. And it works like a charm, but I have a question. I've chosen to display the Gregorian Date and the Hebrew Date. But I also want to use your hebrewDateCurrent-function. However, I can't get it to just display the hebrew date (i'm using my own plugin for the normal spelling). Is there anyway to make it do that?
Lehitra'ot,
Jacob
י"ב אדר תשס"ז - March 1, 2007 at 4:55 pm
Sure:
hebrewDateCurrent()with no arguments!י"ב אדר תשס"ז - March 1, 2007 at 5:25 pm
Mike,
My mistake. Without arguments, that function displays the same as my own. But what I want is it to display the current date in full hebrew. Like if you set the options for that plugin to 'Hebrew months' and without the use of Arabic numbers.
The problem is that I want that kinda display only when using the hebrewDateCurrent() and not under the titles of posts. So, I cannot use the options for that.
I hope this explanation is somewhat clearer…
י"ב אדר תשס"ז - March 1, 2007 at 5:38 pm
Gotcha. In other words, you want to have a separate set of options for the formatted HebrewDate from hebrewDateCurrent (distinct from those used by the wrapper for post & comment dates).
Shouldn't be a big deal, but I'm kinda busy at the moment. I'm also working on rewriting much of the code; if you don't see a post from me by, say, Tuesday (post Purim), feel free to bug me again
י"ב אדר תשס"ז - March 1, 2007 at 5:43 pm
Thanks Mike! A separate set of options would be the preferred thing to have, yes. I'll wait for the new code. As for updating code, I've decided that my plugin could also use a make-over, so, besided the small fix I've added today, I'm going to expand it a little…
Lehitra'ot
י"ב אדר תשס"ז - March 1, 2007 at 5:44 pm
[...] a more comprehensive plugin like this, I would recommend Hebrew Dates 1.0.3 by Mike Miller. Posted in PHP (No Ratings Yet) Loading [...]
י"ט אדר תשס"ז - March 8, 2007 at 12:50 pm
Bug bug
Just kiddin', I'll see the code when you have time to finish it…
י"ט אדר תשס"ז - March 8, 2007 at 12:56 pm
Glad you remembered, and no, I didn't forget.
That said, it's going to be a (hopefully short) while, though. I have one or two personal things going on these days that are taking up most of my time, and I'm a little reluctant to add too much more new code before cleaning up some of the cruft that's there now.
י"ט אדר תשס"ז - March 8, 2007 at 1:59 pm
Fair enough
Tonight is my night off, so if I feel like it, I'll see if can do something with my own plugin, using ofcourse some of yours
ו' סיון תשס"ז - May 22, 2007 at 2:30 am
Mike,
You might want to have a look at the enhancements I recently made to the Jewish date code in PhpGedView. Have a look at http://svn.sourceforge.net/viewvc/phpgedview/trunk/phpGedView/includes/functions_date_hebrew.php?sortby=date&view=log
The main change was to use a geresh and gershayim instead of single and double quotes. There are many issues that can come up when using quotes within code, and this solves some of them. Also removed was the span wrapper. The geresh and gershayim use also resolves some directionality issues.
ט' סיון תשס"ז - May 25, 2007 at 6:47 am
You might want to have a quick look at the Writing Secure WordPress Plugins article. Not sure how applicable it is to the Hebrew date plugin.
ד' ניסן תשס"ח - April 8, 2008 at 5:02 pm
[...] a more comprehensive plugin like this, I would recommend Hebrew Dates 1.0.3 by Mike Miller. <?php /* Plugin Name: Joodse Datum Plugin URI: http://www.jacobfresco.nl [...]