wapa5pow / holiday_jp-dart

Get holidays in Japan.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

holiday_jp-dart

Pub Version test latest_holiday_jp

🎌 Japanese holiday for Dart

This library uses holiday_jp as Japanese holiday dataset.

Example

import 'package:holiday_jp/holiday_jp.dart' as holiday_jp;
import 'package:intl/intl.dart';

final _formatter = DateFormat('yyyy-MM-dd');

void main(List<String> arguments) {
  final marineDay = DateTime.utc(2020, 7, 23);

  final holiday = holiday_jp.getHoliday(marineDay);
  if (holiday == null) {
    throw Exception('holiday mus not be null');
  }
  print('${holiday.date} is ${holiday.nameEn} in Japan.\n');

  final isMarineDayHoliday = holiday_jp.isHoliday(marineDay);
  print(
      'The question whether Marine Day is holiday or not is $isMarineDayHoliday.\n');

  final start = DateTime.utc(2022, 1, 1);
  final end = DateTime.utc(2022, 1, 15);
  final holidays = holiday_jp.between(start, end);
  print(
      'Holidays between ${_formatter.format(start)} and ${_formatter.format(end)} are the followings.');
  for (final holiday in holidays) {
    print('- ${holiday.date} is ${holiday.nameEn}');
  }
}

Tools

To update generated holiday file, run the following.

./tool/update_holidays.sh

About

Get holidays in Japan.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Dart 99.9%Language:Shell 0.1%