{"id":1558,"date":"2026-02-27T13:49:18","date_gmt":"2026-02-27T18:49:18","guid":{"rendered":"https:\/\/expoduquebec.com\/calendrier\/"},"modified":"2026-03-13T08:43:14","modified_gmt":"2026-03-13T12:43:14","slug":"fairs-calendar","status":"publish","type":"page","link":"https:\/\/expoduquebec.com\/en\/fairs-calendar\/","title":{"rendered":"Fairs Calendar"},"content":{"rendered":"\n<p>The Association des expositions agricole du Qu\u00e9bec network represents <strong>29 agricultural exhibitions<\/strong> across Quebec, held from June to September. Each one offers its own unique and vibrant program.<\/p>\n\n\n\n<p>Find out here when they will take place!<\/p>\n\n\n\n<div style=\"height:3rem\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n<script src='https:\/\/cdn.jsdelivr.net\/npm\/fullcalendar@6.1.20\/index.global.min.js'><\/script>\n<script src='https:\/\/cdn.jsdelivr.net\/npm\/@fullcalendar\/core@6.1.20\/locales\/fr.global.min.js'><\/script>\n\n\n<script>\n\n\tvar locale = document.documentElement.lang.slice(0, 2);\n\n\tasync function loadFairs() {\n\t\tconsole.log(locale);\n\t\tconst response = await fetch('\/wp-json\/wp\/v2\/fair?lang=' + locale + '&per_page=100');\n\t\tconst fairs = await response.json();\n\t\treturn fairs;\n\t}\n\n\t\/**\n\t * Initializes the calendar\n\t * \n\t * Get all fairs via API call\n\t * Process the dates;\n\t * - start date is used to find the first fair next fair\n\t * - end date is incremented of one day, to be included as a day of the event in the calendar\n\t *\/\n\tasync function initCalendar() {\n\t\t\n\t\tconst fairs = await loadFairs();\n\t\t\n\t\tlet calendarData = [];\n\t\tlet today = new Date();\n\n\t\t\/\/ Set initial first date to far future to make accurate comparison\n\t\tlet firstFairDate = new Date().setFullYear(today.getFullYear() + 2);\n\n\t\tfor (const fair of fairs) {\n\t\t\t\n\t\t\tconst startDate = convertToDate(fair.acf.dates.start_date);\n\t\t\tconst endDate = convertToDate(fair.acf.dates.end_date);\n\t\t\tendDate.setDate(endDate.getDate() + 1)\n\n\t\t\tlet fairURL = fair.link;\n\n\t\t\tif (locale == 'en' && fairURL.includes('\/expositions')) {\n\t\t\t\tfairURL = fairURL.replace('\/expositions', '\/en\/fairs');\n\t\t\t}\n\n\t\t\tif (locale == 'fr' && fairURL.includes('\/en\/fairs')) {\n\t\t\t\tfairURL = fairURL.replace('\/en\/fairs', '\/expositions');\n\t\t\t}\n\n\t\t\tcalendarData.push({\n\t\t\t\ttitle: decodeHtmlEntities(fair.title.rendered),\n\t\t\t\tstart: startDate.toISOString().split('T')[0],\n\t\t\t\tend: endDate.toISOString().split('T')[0],\n\t\t\t\turl: fairURL\n\t\t\t});\n\n\t\t\tif (startDate >= today && startDate < firstFairDate) {\n\t\t\t\tfirstFairDate = startDate;\n\t\t\t}\n\t\t}\n\n\t\tvar calendarEl = document.getElementById('calendar');\n\n\t\tvar calendar = new FullCalendar.Calendar(calendarEl, {\n\t\t\tinitialView: 'dayGridMonth',\n\t\t\tinitialDate: firstFairDate.toISOString().split('T')[0],\n\t\t\tfixedWeekCount: false,\n\t\t\tshowNonCurrentDates: false,\n\t\t\theight: 'auto',\n\t\t\tlocale: locale,\n\t\t\teventContent: function(arg, createElement) {\n\t\t\t\treturn createElement('div', {'class': 'fc-event-title', 'title': arg.event.title}, arg.event.title)\n\t\t\t},\n\t\t\theaderToolbar: {\n\t\t\t\tleft: 'prev today',\n\t\t\t\tcenter: 'title',\n\t\t\t\tright: 'listView next'\n\t\t\t},\n\t\t\tcustomButtons: {\n\t\t\t\tlistView: {\n\t\t\t\t\ttext: locale == 'en' ? 'List View' : 'Vue liste',\n\t\t\t\t\tclick: function() {\n\t\t\t\t\t\twindow.location.href = locale == 'en' ? '\/en\/fairs' : '\/expositions';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tevents: calendarData\n\t\t});\n\n\t\tcalendar.render();\n\n\t}\n\n\t\/\/ Convert from \"YYYYMMDD\" to \"YYYY-MM-DD\"\n\tfunction convertToDate(rawDate) {\n\t\tconst formattedDate = rawDate.replace(\/(\\d{4})(\\d{2})(\\d{2})\/, '$1-$2-$3');\n\t\treturn new Date(formattedDate);\n\t}\n\n\t\/\/ Decode HTML entities (used for fairs titles)\n\tfunction decodeHtmlEntities(str) {\n\t\tconst textarea = document.createElement('textarea');\n\t\ttextarea.innerHTML = str;\n\t\treturn textarea.value;\n\t}\n\n\tinitCalendar();\n\n<\/script>\n\n\n<div class=\"fairs-calendar\">\n\t<div class=\"container\">\n\t\t<div id=\"calendar\"><\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":5,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-1558","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/expoduquebec.com\/en\/wp-json\/wp\/v2\/pages\/1558","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expoduquebec.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/expoduquebec.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/expoduquebec.com\/en\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/expoduquebec.com\/en\/wp-json\/wp\/v2\/comments?post=1558"}],"version-history":[{"count":3,"href":"https:\/\/expoduquebec.com\/en\/wp-json\/wp\/v2\/pages\/1558\/revisions"}],"predecessor-version":[{"id":1572,"href":"https:\/\/expoduquebec.com\/en\/wp-json\/wp\/v2\/pages\/1558\/revisions\/1572"}],"wp:attachment":[{"href":"https:\/\/expoduquebec.com\/en\/wp-json\/wp\/v2\/media?parent=1558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}