cobaltgrid / airac-calculator
AIRAC日期信息的PHP库
v2.0.1
2023-07-30 11:42 UTC
Requires
- php: ^8.1
Requires (Dev)
- larapack/dd: 1.*
- laravel/pint: ^1.10
- phpunit/phpunit: ^8.2|^9.0
- symfony/css-selector: ^4.3
- symfony/dom-crawler: ^4.3
README
airac-calculator
是一个无依赖的PHP库,用于解析和计算AIRAC(航空信息规范与控制)周期。
AIRAC周期在航空业中用于标准化操作信息的重大修订,如航空图、频率、程序等。每个周期持续28天,每年有13个周期(在某些情况下可能有14个)。周期有两个关键、独特的属性;生效日期和4位周期代码。
该包已通过EUROCONTROL AIRAC日期数据库验证。
需求
- PHP 8.1及以上(已测试至PHP 8.3)
许可
airac-calculator遵循MIT许可证,可在包根目录下的LICENSE
文件中找到。
安装
最简单的方法是通过composer安装
$ composer require cobaltgrid/airac-calculator
用法
如果您正在使用Composer
<?php // Include the composer autoloader require('../vendor/autoload.php'); // Import the class use CobaltGrid\AIRACCalculator\AIRACCycle;
所有功能都在AIRACCycle
类中执行。以下提供了可用方法的文档。
创建周期
// Getting the AIRAC cycle effective at a specific date AIRACCycle::forDate(new DateTime('2023-07-29')); // Getting the AIRAC cycle from an **exact** effective date AIRACCycle::fromEffectiveDate(new DateTime('2023-07-13')); // Getting the AIRAC cycle from a cycle code AIRACCycle::fromCycleCode('2308'); // Getting from a serial (a serial is the number of cycles since the AIRAC epoch) AIRACCycle::fromSerial(1619); // Getting the current effective AIRAC AIRACCycle::current(); // Getting the next AIRAC to become effective AIRACCycle::next(); // Getting the previous AIRAC AIRACCycle::previous();
获取周期信息
$cycle = AIRACCycle::current(); // Get the 4-digit AIRAC cycle code (string) $cycle->getCycleCode(); // 2308 // Gets the number of the cycle in it's year, starting at 1 (i.e. the first cycle is ordinal 1, second is 2, etc.) (int) $cycle->getOrdinal(); // 1 // Returns the date the cycle became/becomes effective (DateTime) $cycle->getEffectiveDate(); // DateTime Instance // Returns the serial (number of cycles since AIRAC epoch) (int) $cycle->getSerial(); // 1619 // Returns the next cycle from this one (AIRACCycle) $cycle->nextCycle(); // AIRACCycle Instance // Returns the previous cycle from this one (AIRACCycle) $cycle->previousCycle(); // AIRACCycle Instance
测试
代码库使用PHP单元测试进行测试。
$ ./vendor/bin/phpunit