holidays_sv 0.0.2 copy "holidays_sv: ^0.0.2" to clipboard
holidays_sv: ^0.0.2 copied to clipboard

discontinuedreplaced by: almanac_sv

A Dart/Flutter package for calculating Swedish public holidays (röda dagar), bank-free days, flag days, and ISO-8601 week numbers.

holidays_sv #

A Flutter/Dart package for calculating and retrieving Swedish holidays, red days (röda dagar), and bank-free days (bankfria dagar).

Features #

  • Calculate the exact date for Easter Sunday (Påskdagen) using the Computus algorithm.
  • Get all official Swedish red days (röda dagar).
  • Get all Swedish bank-free days (days where banks and offices are closed, such as Midsummer Eve and Christmas Eve).
  • Look up specific dates to see if they are holidays.

Getting started #

Add the dependency to your pubspec.yaml:

dependencies:
  holidays_sv: ^0.0.1

Usage #

Import the package:

import 'package:holidays_sv/holidays_sv.dart';

Get all holidays for a year #

final allHolidays = HolidaysSv.getAllHolidays(2024);
for (var holiday in allHolidays) {
  print('${holiday.date}: ${holiday.name}');
}

Get bank-free days (Bankfria dagar) #

Bank-free days are days when banks and most offices are closed. This includes all official red days, plus Christmas Eve, New Year's Eve, Midsummer Eve, and Easter Eve.

Note: Saturdays and Sundays are inherently bank-free, but this method only returns the specifically named holidays that fall on weekdays or are important eves.

final bankFreeDays = HolidaysSv.getBankFreeDays(2024);

Get official red days (Röda dagar) #

final redDays = HolidaysSv.getRedDays(2024);

Check if a specific date is a holiday #

final today = DateTime.now();
final holidayInfo = HolidaysSv.getHolidayInfo(today);

if (holidayInfo != null) {
  print('Today is ${holidayInfo.name}!');
  if (holidayInfo.isBankFreeDay) print('Banks are closed.');
  if (holidayInfo.isFlagDay) print('Remember to raise the flag!');
} else {
  print('Today is just a regular day.');
}

Properties of SwedishHoliday #

  • date: The DateTime of the holiday (time is set to 00:00:00).
  • name: The name in Swedish (e.g., "Midsommarafton").
  • isRedDay: true if it's an official public holiday.
  • isBankFreeDay: true if banks and offices are typically closed.
  • isFlagDay: true if it is an official Swedish flag day.

Helper Methods #

Week Numbers (Veckonummer) #

In Sweden, ISO-8601 week numbers are heavily used. You can easily get the week number for any DateTime:

final today = DateTime.now();
print('Vi är nu i vecka ${today.weekNumber}');

Half-days and Squeeze Days (Halvdagar / Klämdagar) #

Union contracts in Sweden often stipulate that the day before a red day is a half-day. You can easily check this:

final today = DateTime.now();
if (HolidaysSv.isDayBeforeRedDay(today)) {
  print('Imorgon är det röd dag! Slutar vi vid lunch idag?');
}

if (HolidaysSv.isRedDay(today)) {
  print('Idag är det en röd dag (inklusive alla vanliga söndagar).');
}
0
likes
160
points
152
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Dart/Flutter package for calculating Swedish public holidays (röda dagar), bank-free days, flag days, and ISO-8601 week numbers.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on holidays_sv