{% for fallacy in site.data.fallacies %}
{% assign id = "" %}
{% if fallacy.id.size > 0 %}
{% assign id = fallacy.id %}
{% else %}
{% assign id = fallacy.name | slugify %}
{% endif %}
<script>
const timestamps = document.getElementsByTagName("timestamp");
var requests = [];
for (var i = 0; i < timestamps.length; i++) {
var tag = timestamps[i];
tag.id = "timestamp-"+i;
var request = { 'id': tag.id };
request.locale = 'en_US';
if (tag.hasAttribute('calendar')) {
request.calendar = tag.getAttribute('calendar');
}
if (tag.hasAttribute('template')) {
request.format = { 'template': tag.getAttribute('template') };
}
requests.push(request);
}
/*
This updates the localized timestamps on the page by using the API for nsdateformatter.com
*/
const formatEndpoint = "https://api.nsdateformatter.com/api/format";
fetch(formatEndpoint, {
method: "POST",
body: JSON.stringify(requests),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
.then((response) => response.json())
.then(function (json) {
for (var i = 0; i < json.length; i++) {
var tag = document.getElementById(json[i].id);
var text = document.createTextNode(json[i].value);
tag.appendChild(text);
}
});
/*
This creates the information about how many tzdb changes have happened recently.
It works by counting the number of tags on the eggert/tz git repo, which correlate to
the tzdb releases. It then buckets them by year and picks the two most recent years of
changes in order to build a summary to show on the page.
*/
fetch("https://api.github.com/repos/eggert/tz/git/refs/tags")
.then((response) => response.json())
.then(function (json) {
var yearBuckets = {};
for (var i = 0; i < json.length; i++) {
var ref = json[i].ref;
var releaseName = ref.replace(/^refs\/tags\//, '');
var year = releaseName.substr(0, 4);
if (yearBuckets[year] === undefined) {
yearBuckets[year] = [];
}
yearBuckets[year].push(releaseName);
}
var tzSummary = document.getElementById("tzchanges");
var currentYear = new Date().getFullYear();
var tzchanges = "";
var summaryCounts = 0;
for (var year = currentYear; year >= 2012 && summaryCounts < 2; year--) {
var isCurrentYear = (year == currentYear);
if (yearBuckets[year] !== undefined && yearBuckets[year].length > 0) {
var prefix = "In ";
var count = yearBuckets[year].length;
var verb = (count == 1) ? "was" : "were";
if (isCurrentYear) {
verb = (count == 1) ? "has been" : "have been";
prefix = "So far in ";
}
var changes = (count == 1) ? "change" : "changes"
var suffix = " to the time zone database"
if (summaryCounts > 0) {
tzchanges += " ";
suffix = "";
}
tzchanges += prefix + year + " there " + verb + " " + count + " " + changes + suffix + ".";
summaryCounts += 1;
}
}
var tzChangeNode = document.createTextNode(tzchanges);
tzSummary.appendChild(tzChangeNode);
});
</script>
{% assign title = fallacy.name | markdownify | remove_first: "
" %} {% assign reversedTitle = title | split: "" | reverse | join: "" | remove_first: ">p/<" %} {% assign title = reversedTitle | split: "" | reverse | join: "" %}
{% endfor %}