Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nirokay/holidapi
HolidAPI - holiday api. Collection of wrappers for holiday APIs to use in your Nim code.
https://github.com/nirokay/holidapi
api api-wrapper apis holiday holiday-api holidayapi holidays holidays-api lib library nim nim-lang nimble
Last synced: about 1 month ago
JSON representation
HolidAPI - holiday api. Collection of wrappers for holiday APIs to use in your Nim code.
- Host: GitHub
- URL: https://github.com/nirokay/holidapi
- Owner: nirokay
- License: gpl-3.0
- Created: 2024-07-02T08:07:59.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-07-24T11:06:28.000Z (6 months ago)
- Last Synced: 2024-07-25T09:26:43.877Z (6 months ago)
- Topics: api, api-wrapper, apis, holiday, holiday-api, holidayapi, holidays, holidays-api, lib, library, nim, nim-lang, nimble
- Language: Nim
- Homepage:
- Size: 74.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= HolidAPI
== About
_HolidAPI_ (pronounced: _"Holiday-P-I"_, haha get it?), is a wrapper for multiple APIs serving information about holidays.
== Installation
`nimble install holidapi`
== Currently supported countries
See `./COUNTRIES.adoc` for a list of supported countries.
You do not see your country in this list? Help us by expanding the API wrappers! :D
== Examples
```nim
import std/[strformat]
import holidapi/api/nagerdatelet
holidays: seq[Holiday] = SouthKorea.getHolidays(2024, bothNames)
# `bothNames` will get the english and local name of the holiday
# example:
#
# - South Korea: New Year's Day (새해)
# - France: New Year's Day (Jour de l'an)
# - Russia: New Year's Day (Новый год)for holiday in holidays:
echo &"{holiday.name} is on the " & holiday.dateTime.format("yyyy-MM-dd") &
&" and goes on for " & $holiday.duration.inDays() & " day(s)!"```
```nim
# European holiday API
import std/[strformat]
import holidapi/api/openholidaysapilet
holidaysInEnglish: seq[Holiday] = Netherlands.getHolidays(2024)
holidaysInDutch {.used.}: seq[Holiday] = Netherlands.getHolidays(2024, Dutch)for holiday in holidaysInEnglish:
echo &"{holiday.name} is on the " & holiday.dateTime.format("yyyy-MM-dd") &
&" and goes on for " & $holiday.duration.inDays() & " day(s)!"
```
```nim
# Alternative German API
import std/[strformat]
import holidapi/api/feiertageapilet response: OrderedTable[GermanState, seq[Holiday]] = getAllHolidays(2024)
for state, holidays in response:
echo &"Holidays for state {state}:"
for i, holiday in holidays:
echo &"{i}: {holiday.name}"
```See `./src/holidapi/types.nim` for documentation on the `Holiday` type.
== Contributions
Contributions are always welcome, especially expanding the list of supported countries/regions!
== Licence
This project is distributed under the `GPL-3.0` licence.