overtrue / chinese-calendar

:date: 中国农历(阴历)与阳历(公历)转换与查询工具
MIT License
524 stars 109 forks source link

feat: 增加时柱计算、增加时辰显示及统一输出类型 #12

Closed consatan closed 6 years ago

consatan commented 6 years ago

为以下三方法增加 $hour 参数,用于计算时柱和显示时辰 solar($year, $month, $day, $hour = null) solar2lunar($year, $month, $day, $hour = null) lunar($year, $month, $day, $isLeapMonth = false, $hour = null)

$calendar = new Calendar();
echo var_export($calendar->solar(1988, 6, 12, 8), true);
// output
array (
  'lunar_year' => '1988',
  'lunar_month' => '04',
  'lunar_day' => '28',
  'lunar_hour' => '08',
  'lunar_year_chinese' => '一九八八',
  'lunar_month_chinese' => '四月',
  'lunar_day_chinese' => '廿八',
  'lunar_hour_chinese' => '辰时',
  'ganzhi_year' => '戊辰',
  'ganzhi_month' => '戊午',
  'ganzhi_day' => '戊戌',
  'ganzhi_hour' => '丙辰',
  'animal' => '龙',
  'term' => NULL,
  'is_leap' => false,
  'gregorian_year' => '1988',
  'gregorian_month' => '6',
  'gregorian_day' => '12',
  'gregorian_hour' => '08',
  'week_no' => 0,
  'week_name' => '星期日',
  'is_today' => false,
  'constellation' => '双子',
)

$hour 参数为 null 时, 返回的数组中 ganzhi_hour,lunar_hour,lunar_hour_chinese 属性为 null