KosherDev | Blog about kosher programming

TAG | date

Nov 3, 2009 - ט"ז חשון תש"ע

Hebrew Date plugin + jq theme

I really want to thank kosherjava.com for a wonderful plug-in to display Hebrew date of posts.
I found that this plug-in does not correctly work with the theme selected for this blog jq.
It corrupted date display area fully.
I added to hebrewdate.php the following code to get timestamp from jq date format.

//first we change jq date format to more readable.
if (preg_match('/(.*)\s?
([0-9][0-9]?)<\/p>/',$content)) //list of posts
        $date_preg=preg_replace('/(.*)\s?
([0-9][0-9]?)<\/p>/','\1/\2/00/00/00',$content);
elseif (preg_match('/(.*)\s([0-9][0-9]?),\s20([0-9][0-9])/',$content)) //single post
        $date_preg=preg_replace('/(.*)\s([0-9][0-9]?),\s20([0-9][0-9])/','\1/\3/\2/00/00/00',$content);
elseif (preg_match('/.*[0-9]{4}/',$content)) { //archive display
        $date_preg=preg_replace('/(.*)\s[0-9]{2}([0-9]{2})/','\1/\2/1/00/00/00',$content);
        $informat = '%B/%y/%d/%H/%M/%S';
        $isArchiveFormat = true;
}else return $content;

//define format of the previously created string
$informat = '%b/%y/%d/%H/%M/%S';
//convert string to array of date/time data
$ftime = strptime($date_preg,$informat);
// create timestamp
$unxTimestamp = mktime(
                    $ftime['tm_hour'],
                    $ftime['tm_min'],
                    $ftime['tm_sec'],
                    1 ,
                    $ftime['tm_yday'] + 1,
                   $ftime['tm_year'] + 1900
                 );
//$pdate is timestamp
$pdate=$unxTimestamp;
//comment old string of $pdate definition.
//      $pdate = strtotime(str_replace("","",$content)); //WP-Admin adds a break tag for display purposes which we have to strip out.

You can see correct date in Gregorian and Jewish style on a left side.

UPD: Thanks to KosherJava.com, I absolutely forgot about date format for comments – fixed.

Popularity: 20% [?]

, , Hide

Find it!

Theme Design by devolux.org