Skip to content

Commit

Permalink
Update holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
aolde committed May 27, 2023
1 parent 6919e91 commit bfc3277
Show file tree
Hide file tree
Showing 4 changed files with 235 additions and 244 deletions.
4 changes: 4 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
font-family: "Fjalla One", sans-serif;
}
</style>
<script>
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('phc_gxbPlt0M7yjWUxZoJpwCvnhsQfhhD7kZTNzNFRItWcs',{api_host:'https://eu.posthog.com'})
</script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
80 changes: 40 additions & 40 deletions scripts/holidays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,54 @@ import path from "path";
*/

async function init() {
const response = await axios.get<Response>(
"https://sholiday.faboul.se/dagar/v2.1/2022"
);
const holidays = response.data.dagar
.filter(
(day) =>
(day["dag i vecka"] !== "6" &&
day["dag i vecka"] !== "7" &&
day["röd dag"] === "Ja") ||
day.helgdag === "Midsommarafton" ||
day.helgdag === "Nyårsafton" ||
day.helgdag === "Julafton"
)
.map((day) => ({
date: day.datum,
holiday: day.helgdag,
}));
const response = await axios.get<Response>(
"https://sholiday.faboul.se/dagar/v2.1/2023"
);
const holidays = response.data.dagar
.filter(
(day) =>
(day["dag i vecka"] !== "6" &&
day["dag i vecka"] !== "7" &&
day["röd dag"] === "Ja") ||
day.helgdag === "Midsommarafton" ||
day.helgdag === "Nyårsafton" ||
day.helgdag === "Julafton"
)
.map((day) => ({
date: day.datum,
holiday: day.helgdag,
}));

const holidaysPath = path.resolve(__dirname, "../src/services/holidays.ts");
const holidaysContent = `const holidays = ${JSON.stringify(holidays)};
const holidaysPath = path.resolve(__dirname, "../src/services/holidays.ts");
const holidaysContent = `const holidays = ${JSON.stringify(holidays)};
export default holidays;`;
fs.writeFileSync(holidaysPath, holidaysContent);
fs.writeFileSync(holidaysPath, holidaysContent);
}

init()
.then(() => console.log("done"))
.catch((err) => console.error("failed.", err));
.then(() => console.log("done"))
.catch((err) => console.error("failed.", err));

export interface Dagar {
datum: string;
veckodag: string;
"arbetsfri dag": string;
"röd dag": string;
vecka: string;
"dag i vecka": string;
helgdag: string;
namnsdag: string[];
flaggdag: string;
helgdagsafton: string;
"dag före arbetsfri helgdag": string;
klämdag: string;
datum: string;
veckodag: string;
"arbetsfri dag": string;
"röd dag": string;
vecka: string;
"dag i vecka": string;
helgdag: string;
namnsdag: string[];
flaggdag: string;
helgdagsafton: string;
"dag före arbetsfri helgdag": string;
klämdag: string;
}

export interface Response {
cachetid: string;
version: string;
uri: string;
startdatum: string;
slutdatum: string;
dagar: Dagar[];
cachetid: string;
version: string;
uri: string;
startdatum: string;
slutdatum: string;
dagar: Dagar[];
}
Loading

0 comments on commit bfc3277

Please sign in to comment.