kilofox/ephemeris

千狐天文历

v0.1.1 2021-04-27 11:16 UTC

This package is auto-updated.

Last update: 2024-11-14 06:58:09 UTC


README

📅 千狐天文历是一款利用天文算法实现中国农历与公历无表查询的日历产品,可用于西元前1000年至西元3000年期间的日期转换。

Installing

$ composer require kilofox/ephemeris

Usage

use Kilofox\Ephemeris\Calendar;

$calendar = new Calendar;

// 阳历转阴历
$result = $calendar->solar2lunar(2021, 3, 19);

// 阴历转阳历
$result = $calendar->lunar2solar(2021, 2, 7);

结果:

array (
  'lunar_year' => 2021,
  'lunar_month' => 2,
  'lunar_day' => 7,
  'lunar_year_chinese' => '二零二一',
  'lunar_month_chinese' => '二月',
  'lunar_day_chinese' => '初七',
  'cstb_year' => '辛丑',
  'cstb_month' => '辛卯',
  'cstb_day' => '丙寅',
  'is_leap' => true,
)

array (
  'solar_year' => 2021,
  'solar_month' => 3,
  'solar_day' => 19,
  'solar_hour' => 18,
  'solar_minute' => 21,
  'solar_second' => 7,
)

更多 API 见源码。

Reference