Skip to content

Instantly share code, notes, and snippets.

@seanblanchfield
Created July 29, 2021 14:27
Show Gist options
  • Save seanblanchfield/4df78d73c85b149133615c7953894076 to your computer and use it in GitHub Desktop.
Save seanblanchfield/4df78d73c85b149133615c7953894076 to your computer and use it in GitHub Desktop.
Google calendar public holiday names by country
# Complete mapping of ISO 3166 2-letter country codes to descriptions used in Google calendar URLs, accurate as of 29 July 2021.
iso_to_gcal_description = {
"ad": "ad",
"ae": "ae",
"af": "af",
"ag": "ag",
"ai": "ai",
"al": "al",
"am": "am",
"ao": "ao",
"ar": "ar",
"as": "as",
"at": "austrian",
"au": "australian",
"aw": "aw",
"az": "az",
"ba": "ba",
"bb": "bb",
"bd": "bd",
"be": "be",
"bf": "bf",
"bg": "bulgarian",
"bh": "bh",
"bi": "bi",
"bj": "bj",
"bl": "bl",
"bm": "bm",
"bn": "bn",
"bo": "bo",
"br": "brazilian",
"bs": "bs",
"bt": "bt",
"bw": "bw",
"by": "by",
"bz": "bz",
"ca": "canadian",
"cd": "cd",
"cf": "cf",
"cg": "cg",
"ch": "ch",
"ci": "ci",
"ck": "ck",
"cl": "cl",
"cm": "cm",
"cn": "china",
"co": "co",
"cr": "cr",
"cu": "cu",
"cv": "cv",
"cw": "cw",
"cy": "cy",
"cz": "czech",
"de": "german",
"dj": "dj",
"dk": "danish",
"dm": "dm",
"do": "do",
"dz": "dz",
"ec": "ec",
"ee": "ee",
"eg": "eg",
"er": "er",
"es": "spain",
"et": "et",
"fi": "finnish",
"fj": "fj",
"fk": "fk",
"fm": "fm",
"fo": "fo",
"fr": "french",
"ga": "ga",
"gb": "uk",
"gd": "gd",
"ge": "ge",
"gf": "gf",
"gg": "gg",
"gh": "gh",
"gi": "gi",
"gl": "gl",
"gm": "gm",
"gn": "gn",
"gp": "gp",
"gq": "gq",
"gr": "greek",
"gt": "gt",
"gu": "gu",
"gw": "gw",
"gy": "gy",
"hk": "hong_kong",
"hn": "hn",
"hr": "croatian",
"ht": "ht",
"hu": "hungarian",
"id": "indonesian",
"ie": "irish",
"il": "jewish",
"im": "im",
"in": "indian",
"iq": "iq",
"ir": "ir",
"is": "is",
"it": "italian",
"je": "je",
"jm": "jm",
"jo": "jo",
"jp": "japanese",
"ke": "ke",
"kg": "kg",
"kh": "kh",
"ki": "ki",
"km": "km",
"kn": "kn",
"kp": "kp",
"kr": "south_korea",
"kw": "kw",
"ky": "ky",
"kz": "kz",
"la": "la",
"lb": "lb",
"lc": "lc",
"li": "li",
"lk": "lk",
"lr": "lr",
"ls": "ls",
"lt": "lithuanian",
"lu": "lu",
"lv": "latvian",
"ly": "ly",
"ma": "ma",
"mc": "mc",
"md": "md",
"me": "me",
"mf": "mf",
"mg": "mg",
"mh": "mh",
"mk": "mk",
"ml": "ml",
"mm": "mm",
"mn": "mn",
"mo": "mo",
"mp": "mp",
"mq": "mq",
"mr": "mr",
"ms": "ms",
"mt": "mt",
"mu": "mu",
"mv": "mv",
"mw": "mw",
"mx": "mexican",
"my": "malaysia",
"mz": "mz",
"na": "na",
"nc": "nc",
"ne": "ne",
"ng": "ng",
"ni": "ni",
"nl": "dutch",
"no": "norwegian",
"np": "np",
"nr": "nr",
"nz": "new_zealand",
"om": "om",
"pa": "pa",
"pe": "pe",
"pf": "pf",
"pg": "pg",
"ph": "philippines",
"pk": "pk",
"pl": "polish",
"pm": "pm",
"pr": "pr",
"pt": "portuguese",
"pw": "pw",
"py": "py",
"qa": "qa",
"re": "re",
"ro": "romanian",
"rs": "rs",
"ru": "russian",
"rw": "rw",
"sa": "saudiarabian",
"sb": "sb",
"sc": "sc",
"sd": "sd",
"se": "swedish",
"sg": "singapore",
"sh": "sh",
"si": "slovenian",
"sk": "slovak",
"sl": "sl",
"sm": "sm",
"sn": "sn",
"so": "so",
"sr": "sr",
"ss": "ss",
"st": "st",
"sv": "sv",
"sx": "sx",
"sy": "sy",
"sz": "sz",
"tc": "tc",
"td": "td",
"tg": "tg",
"th": "th",
"tj": "tj",
"tl": "tl",
"tm": "tm",
"tn": "tn",
"to": "to",
"tr": "turkish",
"tt": "tt",
"tv": "tv",
"tw": "taiwan",
"tz": "tz",
"ua": "ukrainian",
"ug": "ug",
"us": "usa",
"uy": "uy",
"uz": "uz",
"va": "va",
"vc": "vc",
"ve": "ve",
"vg": "vg",
"vi": "vi",
"vn": "vietnamese",
"vu": "vu",
"wf": "wf",
"ws": "ws",
"xk": "xk",
"ye": "ye",
"yt": "yt",
"za": "sa",
"zm": "zm",
"zw": "zw",
}
# Any ISO 639 2-letter language code.
iso_langs = ["en"]
# Calendar name is in the format:
# "{lang}.{calendar_description}#[email protected]"
# Calendar URL is in the form (where "calendar_name" is URL-quoted):
# https://calendar.google.com/calendar/ical/{calendar_name}/public/basic.ics
# Example URL to google calendar ical feed:
import requests
lang = 'en'
country = 'fr'
calendar_name = requests.utils.quote(f"{lang}.{gcal_name}#[email protected]")
calendar_url = f"https://calendar.google.com/calendar/ical/{calendar_name}/public/basic.ics"
calendar_req = requests.get(calendar_url)
if calendar_req.status == 200:
print(calendar_req.text) # This could be parsed with the icalendar library
@mrdc
Copy link

mrdc commented Dec 23, 2024

Hi, what is gcal_name variable? It's missing in the code.

How to fix:
gcal_name = iso_to_gcal_description.get(country, country)

@cbugk
Copy link

cbugk commented Mar 13, 2025

In addition to those listed, I've found following to exist yet return an empty items list (with the sole reason of them being listed in https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes)

{
    "aq": "aq",
    "ax": "ax",
    "bq": "bq",
    "bv": "bv",
    "cc": "cc",
    "cx": "cx",
    "eh": "eh",
    "gs": "gs",
    "hm": "hm",
    "io": "io",
    "nf": "nf",
    "nu": "nu",
    "pn": "pn",
    "ps": "ps",
    "sj": "sj",
    "tf": "tf",
    "tk": "tk",
    "um": "um",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment