KHolidays 5.109.0
Public Member Functions | Static Public Member Functions | List of all members
KHolidays::HolidayRegion

Represents a holiday region. More...

#include <holidayregion.h>

Public Member Functions

 HolidayRegion (const HolidayRegion &)
 Copy constructor.
 
 HolidayRegion (const QFileInfo &regionFile)
 Creates a new Holiday Region object from a given holiday file.
 
 HolidayRegion (const QString &regionCode=QString())
 Creates a new Holiday Region object for a given standard Region Code.
 
 HolidayRegion (HolidayRegion &&)
 Move constructor.
 
 ~HolidayRegion ()
 Destroys the holidays object.
 
QString countryCode () const
 
QString description () const
 
bool isHoliday (const QDate &date) const
 Checks whether there is any holiday defined for a date.
 
bool isValid () const
 Returns whether the instance contains any holiday data.
 
QString languageCode () const
 
QString name () const
 
HolidayRegionoperator= (const HolidayRegion &)
 Assignment operator.
 
HolidayRegionoperator= (HolidayRegion &&)
 Move Assignment operator.
 
Holiday::List rawHolidays (const QDate &startDate, const QDate &endDate) const
 
Holiday::List rawHolidays (const QDate &startDate, const QDate &endDate, const QString &category) const
 
Holiday::List rawHolidaysWithAstroSeasons (const QDate &date) const
 
Holiday::List rawHolidaysWithAstroSeasons (const QDate &startDate, const QDate &endDate) const
 
Holiday::List rawHolidaysWithAstroSeasons (int calendarYear) const
 
QString regionCode () const
 

Static Public Member Functions

static QString countryCode (const QString &regionCode)
 
static QString defaultRegionCode (const QString &country=QString(), const QString &language=QString())
 
static QString description (const QString &regionCode)
 
static bool isValid (const QString &regionCode)
 
static QString languageCode (const QString &regionCode)
 
static QString name (const QString &regionCode)
 
static QStringList regionCodes ()
 

Detailed Description

Represents a holiday region.

Constructor & Destructor Documentation

◆ HolidayRegion() [1/4]

KHolidays::HolidayRegion::HolidayRegion ( const QString &  regionCode = QString())
explicit

Creates a new Holiday Region object for a given standard Region Code.

Parameters
regionCodeThe code for the Holiday Region. If null or unknown, an empty instance will be created.

◆ HolidayRegion() [2/4]

KHolidays::HolidayRegion::HolidayRegion ( const QFileInfo &  regionFile)
explicit

Creates a new Holiday Region object from a given holiday file.

If file doesn't exist, an empty instance will be created.

Parameters
regionFileThe code for the Holiday Region.

◆ HolidayRegion() [3/4]

KHolidays::HolidayRegion::HolidayRegion ( const HolidayRegion )

Copy constructor.

Since
5.77

◆ HolidayRegion() [4/4]

KHolidays::HolidayRegion::HolidayRegion ( HolidayRegion &&  )

Move constructor.

Since
5.77

◆ ~HolidayRegion()

KHolidays::HolidayRegion::~HolidayRegion ( )

Destroys the holidays object.

Member Function Documentation

◆ countryCode() [1/2]

QString KHolidays::HolidayRegion::countryCode ( ) const
Since
4.5

Return the ISO 3166 country code of the file

May be either just a country code ("US" = USA) or may include a regional identifier ("US-CA" = California). Returns "XX" if not a country.

See https://en.wikipedia.org/wiki/ISO_3166-2

Returns
the full region code of the file

◆ countryCode() [2/2]

static QString KHolidays::HolidayRegion::countryCode ( const QString &  regionCode)
static
Since
4.5

Return the ISO 3166 country code of a given Holiday Region

May be either just a country code ("US" = USA) or may include a regional identifier ("US-CA" = California). Returns "XX" if not a country.

See https://en.wikipedia.org/wiki/ISO_3166-2

Parameters
regionCodeThe code for the Holiday Region.
Returns
the full region code of the file
Warning
This methods is expensive as it involves parsing the corresponding holiday definition file. Prefer HolidayRegion::countryCode().

◆ defaultRegionCode()

static QString KHolidays::HolidayRegion::defaultRegionCode ( const QString &  country = QString(),
const QString &  language = QString() 
)
static
Since
4.6

Return a reasonable default Holiday Region code

If a required country/language is not provided then the current KDE country/language is used.

Parameters
countryThe country or region to find a default Holiday Region for. This can be either an ISO 3166-1 or ISO 3166-2 code.
languageThe language to find a default Holiday Region for
Returns
the full region code of the default file
Warning
This methods is expensive as it involves parsing all holiday definition files.

◆ description() [1/2]

QString KHolidays::HolidayRegion::description ( ) const
Since
4.5

Return the description of the Holiday Region if available

Returns
the description of the Holiday Region

◆ description() [2/2]

static QString KHolidays::HolidayRegion::description ( const QString &  regionCode)
static
Since
4.5

Return the description of a given Holiday Region if available

Returns
the description of the Holiday Region

◆ isHoliday()

bool KHolidays::HolidayRegion::isHoliday ( const QDate &  date) const

Checks whether there is any holiday defined for a date.

◆ isValid() [1/2]

bool KHolidays::HolidayRegion::isValid ( ) const

Returns whether the instance contains any holiday data.

◆ isValid() [2/2]

static bool KHolidays::HolidayRegion::isValid ( const QString &  regionCode)
static
Since
4.5

Returns whether the Region Code is valid.

◆ languageCode() [1/2]

QString KHolidays::HolidayRegion::languageCode ( ) const
Since
4.5

Return the ISO 639-1 language code of the file

May be either just a language code ("en" = US English) or may include a country identifier ("en_GB" = British English).

Returns
the language code of the file

◆ languageCode() [2/2]

static QString KHolidays::HolidayRegion::languageCode ( const QString &  regionCode)
static
Since
4.5

Return the ISO 639-1 language code of a given Holiday Region

May be either just a language code ("en" = US English) or may include a country identifier ("en_GB" = British English).

Parameters
regionCodeThe code for the Holiday Region.
Returns
the language code of the file
Warning
This methods is expensive as it involves parsing the corresponding holiday definition file. Prefer HolidayRegion::languageCode().

◆ name() [1/2]

QString KHolidays::HolidayRegion::name ( ) const
Since
4.5

Return the name of the Holiday Region. This may be a country, region, or type.

Returns
the short name code of the file

◆ name() [2/2]

static QString KHolidays::HolidayRegion::name ( const QString &  regionCode)
static
Since
4.5

Return the name of a given Holiday Region

Parameters
regionCodeThe code for the Holiday Region.
Returns
the name of the Holiday Region

◆ operator=() [1/2]

HolidayRegion & KHolidays::HolidayRegion::operator= ( const HolidayRegion )

Assignment operator.

Since
5.77

◆ operator=() [2/2]

HolidayRegion & KHolidays::HolidayRegion::operator= ( HolidayRegion &&  )

Move Assignment operator.

Since
5.77

◆ rawHolidays() [1/2]

Holiday::List KHolidays::HolidayRegion::rawHolidays ( const QDate &  startDate,
const QDate &  endDate 
) const
Since
5.97

Returns the list of holidays that occur between startDate and endDate.

◆ rawHolidays() [2/2]

Holiday::List KHolidays::HolidayRegion::rawHolidays ( const QDate &  startDate,
const QDate &  endDate,
const QString &  category 
) const
Since
5.95

Returns the list of holidays that occur between startDate and endDate and with category.

◆ rawHolidaysWithAstroSeasons() [1/3]

Holiday::List KHolidays::HolidayRegion::rawHolidaysWithAstroSeasons ( const QDate &  date) const
Since
5.95

Returns the list of holidays that occur on a date.

◆ rawHolidaysWithAstroSeasons() [2/3]

Holiday::List KHolidays::HolidayRegion::rawHolidaysWithAstroSeasons ( const QDate &  startDate,
const QDate &  endDate 
) const
Since
5.95

Returns the list of holidays that occur between startDate and endDate.

◆ rawHolidaysWithAstroSeasons() [3/3]

Holiday::List KHolidays::HolidayRegion::rawHolidaysWithAstroSeasons ( int  calendarYear) const
Since
5.95

Returns the list of holidays that occur in a Gregorian calendar year calendarYear.

◆ regionCode()

QString KHolidays::HolidayRegion::regionCode ( ) const
Since
4.5

Returns the unique Holiday Region code.

Clients should not infer any meaning from the format of the code.

Returns
region code, or null if the instance was constructed with an unknown region

◆ regionCodes()

static QStringList KHolidays::HolidayRegion::regionCodes ( )
static
Since
4.5

Return a list of all available Holiday Region codes.

One of these can then be passed to the constructor for a new HolidayRegion object, or to name() or language() to obtain the name and language of the region.

See also
name()
languageCode()