定制 rik0253/moon-phase 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rik0253/moon-phase

Composer 安装命令:

composer require rik0253/moon-phase

包简介

It gives moon-phases according to date given.

README 文档

README

MoonPhase is a PHP class for calculating the phase of the Moon, and other related variables. It is based on Moontool for Windows. Moon Rise/Set time is based on (https://dxprog.com/entry/calculate-moon-rise-and-set-in-php) .

Installation

composer require rik0253/moon-phase

Usage

Create an instance of the class by 'new Moonphase('YYYY-MM-DD');', supplying a date for when you want to determine the moon phase (if you don't then the current time will be used). You can then use the following class functions to access the properties of the object:

  • phase(): get the terminator phase angle as a fraction of a full circle (i.e., 0 to 1). Both 0 and 1 correspond to a New Moon, and 0.5 corresponds to a Full Moon.
  • getMoonData('illumination'): get the illuminated fraction of the Moon (0 = New, 1 = Full).
  • getMoonData('age'): get the age of the Moon, in days.
  • getMoonData('distance'): get the distance of the Moon from the centre of the Earth (kilometres).
  • getMoonData('diameter'): get the angular diameter subtended by the Moon as seen by an observer at the centre of the Earth (degrees).
  • getMoonData('sundistance'): get the distance to the Sun (kilometres).
  • getMoonData('sundiameter'): get the angular diameter subtended by the Sun as seen by an observer at the centre of the Earth (degrees).
  • getPhaseData('new_moon'): get the time of the last New Moon (DateTime).
  • getPhaseData('next_new_moon'): get the time of the next New Moon (DateTime).
  • getPhaseData('full_moon'): get the time of the Full Moon in the current lunar cycle (DateTime).
  • getPhaseData('next_full_moon'): get the time of the next Full Moon in the current lunar cycle (DateTime).
  • getPhaseData('first_quarter'): get the time of the first quarter in the current lunar cycle (DateTime).
  • getPhaseData('next_first_quarter'): get the time of the next first quarter in the current lunar cycle (DateTime).
  • getPhaseData('last_quarter'): get the time of the last quarter in the current lunar cycle (DateTime).
  • getPhaseData('next_last_quarter'): get the time of the next last quarter in the current lunar cycle (DateTime).
  • getPhaseName(): get the phase name.

New Usage

Now you can get the moon rise and set time in unix timestamp. You just need to access the property of the object:

  • getMoonTimes('latitude','logitude'): get the time of moon rise and moon set (Unix timestamp).

Example

//create an instance of the class, and use the current time
$moon = new Moonphase('1990-04-21');
$age = round($moon->get('age'), 1);
$stage = $moon->phase() < 0.5 ? 'waxing' : 'waning';
$distance = round($moon->get('distance'), 2);
$next = $moon->getPhaseData('next_new_moon');
$phaseName = $moon->getPhaseName();
echo "The moon is currently $age days old, and is therefore $stage. ";
echo "It is $distance km from the centre of the Earth. ";
echo "The next new moon is at $next.";
//To get the moon rise/set time
$moonTime = getMoonTimes(22.5655,88.3653);
echo "Moon rise at ".date('Y-m-d H:i A',strtotime($moonTime->moonrise));	
echo "Moon set at ".date('Y-m-d H:i A',strtotime($moonTime->moonset));	

Help

For bugs/enhancements, feel free to either raise an issue or pull request in GitHub, or contact me.

统计信息

  • 总下载量: 53
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固