rust-search-extension/extension/rust-version.js

57 lines
1.5 KiB
JavaScript
Raw Normal View History

// 6 week release gap.
const RUST_RELEASE_GAP = 6 * 7;
2021-01-28 14:58:24 +00:00
function getScheduledVersions(limit = 10) {
2021-01-25 15:58:58 +00:00
let versions = [];
let startMinor = 42;
let date = new Date("2020-03-12");
let today = new Date();
// Set to the start seconds of today
today.setHours(0, 0, 0);
2021-01-25 15:58:58 +00:00
for (let i = 1, j = 1; j <= limit; i++) {
date.setDate(date.getDate() + RUST_RELEASE_GAP);
if (date >= today) {
2021-01-25 15:58:58 +00:00
let minor = startMinor + i;
versions.push({
number: "1." + minor + ".0",
major: 1,
minor,
fix: 0,
date: new Date(date),
});
j += 1;
}
}
return versions;
}
2021-01-28 14:58:24 +00:00
function getReleasedVersions() {
let versions = [];
2021-01-28 14:58:24 +00:00
let nextVersion = getScheduledVersions(1)[0];
let startMinor = nextVersion.minor;
let date = nextVersion.date;
let now = new Date();
2021-02-12 12:25:45 +00:00
for (let i = startMinor, j = 1; i > 1; i--) {
date.setDate(date.getDate() - RUST_RELEASE_GAP);
if (date <= now) {
let minor = startMinor - j;
versions.push({
number: "1." + minor + ".0",
major: 1,
minor,
fix: 0,
date: new Date(date),
});
j += 1;
}
}
2021-02-12 12:25:45 +00:00
// Version 1.0.0 is a special release date.
versions.push({
number: "1.0.0",
major: 1,
minor: 0,
fix: 0,
date: new Date("2015-05-15"),
});
return versions;
2021-01-25 15:58:58 +00:00
}