mikeage.net Logo
mikeage.net/2007/02/14/hebrew-dates-v103/

mikeage.net @ כ"ב תמוז תשס"ח

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.

13 Responses to “Hebrew Dates v1.0.3”

  1. KosherJava Said:

    Looks great.
    <?php if (function_exists('hebrewDateCurrent')) {hebrewDateCurrent("default");} ?> is much easier to use.

  2. Jacob Said:

    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

  3. Mike Miller Said:

    Sure: hebrewDateCurrent() with no arguments!

  4. Jacob Said:

    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…

  5. Mike Miller Said:

    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 ;)

  6. Jacob Said:

    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

  7. Update plugin: Jewish Date 0.3 : jacobfresco.nl Posted (PB):

    [...] a more comprehensive plugin like this, I would recommend Hebrew Dates 1.0.3 by Mike Miller. Posted in PHP (No Ratings Yet)  Loading [...]

  8. Jacob Fresco Said:

    if you don't see a post from me by, say, Tuesday (post Purim), feel free to bug me again

    Bug bug ;-) Just kiddin', I'll see the code when you have time to finish it…

  9. Mike Miller Said:

    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.

  10. Jacob Fresco Said:

    Fair enough :D 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 ;-)

  11. KosherJava Said:

    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.

  12. KosherJava Said:

    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.

  13. Jewish Date 0.3: Posted (PB):

    [...] 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 [...]

Leave a Reply

Verification Image

Please type the letters you see in the picture. This field is case-insensitive, and valid letters are A-Z (no numbers)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Quicktags:

Quick Map
Content +
Personal +
Archives +
Site Stuff +
RBS Weather +
Search +
New Images
Visitors
Clustermap
Blogroll

Valid XHTML 1.1!
Printer Friendly Page
 

Last Modified: September 04, 2006 @ 09:11 CST