Plugin Directory

Changeset 3302159


Ignore:
Timestamp:
05/28/2025 11:17:47 AM (10 months ago)
Author:
hatul
Message:

v2.0.5

Location:
wordpress-hebrew-date
Files:
10 added
2 edited

Legend:

Unmodified
Added
Removed
  • wordpress-hebrew-date/trunk/heb_date.php

    r3039402 r3302159  
    44Plugin URI: https://hatul.info/hebdate/
    55Description: Convert dates in wordpress to Hebrew dates.
    6 Version: 2.0.4.1
     6Version: 2.0.5
    77Author: Hatul
    88Author URI: https://hatul.info
     
    276276    }
    277277
    278     //if the time after the sunset return tommrow
    279     function sunset($date){
    280         $date = mysql2date("H-i-s-j-n-Y", $date);
    281         list($hour, $min, $sec, $day, $mon, $year) = explode('-', $date);
    282         $suninfo = date_sun_info(mktime($hour, $min, 0, $day, $mon, $year), get_option('latitude'), get_option('longitude'));
    283        
    284         if (! $suninfo){
     278        //if the time after the sunset return tomorrow
     279    function sunset($date) {
     280        $dt = new DateTime($date, wp_timezone());
     281
     282        $lat = get_option('latitude');
     283        $lng = get_option('longitude');
     284
     285        if (! $lat || ! $lng) {
    285286            return $date;
    286287        }
    287288
    288         $sunset = date('H:i', $suninfo['sunset']);
    289         list($sunset_h, $sunset_m) = explode(':', $sunset);
    290 
    291         if ($hour > $sunset_h || ($hour == $sunset_h && $min > $sunset_m)){
    292             $date = gregoriantojd($mon, $day, $year) + 1;
    293             $date = jdtogregorian($date);
    294             list($mon, $day, $year) = explode('/', $date);
    295         }
    296         $date = $hour . ':' . $min . ':' . $sec . ' ' . $year . '-' . $mon . '-' . $day;
    297        
    298         return apply_filters('hebdate_sunset', $date);
     289        $suninfo = date_sun_info($dt->getTimestamp(), $lat, $lng);
     290        if (! $suninfo || ! isset($suninfo['sunset'])) {
     291            return $date;
     292        }
     293
     294        $sunset = new DateTime();
     295        $sunset->setTimestamp($suninfo['sunset']);
     296        $sunset->setTimezone(wp_timezone());
     297
     298        if ($dt > $sunset) {
     299            $dt->modify('+1 day');
     300        }
     301
     302        return apply_filters('hebdate_sunset', $dt->format('Y-m-d H:i:s'));
    299303    }
    300304
  • wordpress-hebrew-date/trunk/readme.txt

    r3282613 r3302159  
    44Tags: hebrew, date, jewish
    55Requires at least: 2.0
    6 Tested up to: 6.8
    7 Stable tag: 2.0.4.1
     6Tested up to: 6.1
     7Stable tag: 2.0.5
    88
    99Convert dates in wordpress to Hebrew dates.
     
    3434
    3535== Changelog ==
     36= 2.0.5 =
     37* Fix sunset bug
    3638= 2.0.4 =
    3739* Update date_sunset to date_sunset
Note: See TracChangeset for help on using the changeset viewer.