定制 hostlink/hk-public-holiday 二次开发

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

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

hostlink/hk-public-holiday

最新稳定版本:1.0.1

Composer 安装命令:

composer require hostlink/hk-public-holiday

包简介

README 文档

README

This library provides functionality to check Hong Kong public holidays and manage holiday data caching.

Installation

To install the library, use Composer:

composer require hostlink/hk-public-holiday

Usage

Initialization

To initialize the Holiday class, you can specify the language (en, tc, sc) and an optional cache instance.

use HostLink\Calendar\Holiday;

//en: English, tc: Traditional Chinese, sc: Simplified Chinese
$holiday = new Holiday("en");

Methods

clearCache()

Clears the cached holiday data.

$holiday->clearCache();

getData()

Fetches the holiday data. If the data is not cached, it will download it from the internet and cache it for one month.

$data = $holiday->getData();

isHoliday(string $date): bool

Checks if a given date is a holiday.

$isHoliday = $holiday->isHoliday("2023-12-25");

getRange(string $from, string $to)

Gets the holidays within a specified date range.

$holidays = $holiday->getRange("2023-01-01", "2023-12-31");

Example

use HostLink\Calendar\Holiday;

$holiday = new Holiday("en");

// Check if a specific date is a holiday
if ($holiday->isHoliday("2023-12-25")) {
    echo "It's a holiday!";
} else {
    echo "It's not a holiday.";
}

// Get holidays within a date range
$holidays = $holiday->getRange("2023-01-01", "2023-12-31");
foreach ($holidays as $holiday) {
    echo $holiday["date"] . ": " . $holiday["name"] . "\n";
}

License

This project is licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-12