2021-02-10 01:01:50 +04:00
|
|
|
const moment = require("moment-timezone");
|
|
|
|
|
|
|
|
const formats = Object.freeze({
|
|
|
|
post_date: "Do MMMM YYYY HH:mm:ss z",
|
|
|
|
file_date: "YYYY-MM-DD HH:mm:ss z",
|
|
|
|
id_date: "YYYYMMDD-HHmm" });
|
|
|
|
|
2021-02-10 03:24:14 +04:00
|
|
|
function getTimezone(ctx) {
|
|
|
|
if (ctx.header['x-client-timezone'] !== undefined)
|
|
|
|
return ctx.header['x-client-timezone'];
|
|
|
|
}
|
|
|
|
|
2021-02-10 01:01:50 +04:00
|
|
|
function datetime(date, format=formats.post_date, timezone="UTC") {
|
|
|
|
return moment.utc(date).tz(timezone).format(format);
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.getBaseHost = (host) => {
|
|
|
|
switch (host) {
|
|
|
|
case host.endsWith("onion"):
|
|
|
|
return `http://moq7aejnf4xk5k2bkaltli3ftkhusy2mbrd3pj23nrca343ku2mgk4yd.onion`;
|
|
|
|
case host.endsWith("b32.i2p"):
|
|
|
|
return `http://t42fkp6zp5dfqywantq3zp427ig3q2onrmfv246tyaztpg4ckb5a.b32.i2p`;
|
|
|
|
default:
|
|
|
|
return "https://arav.top";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-10 03:24:14 +04:00
|
|
|
exports.getTimezone = getTimezone;
|
2021-02-10 01:01:50 +04:00
|
|
|
exports.formats = formats;
|
|
|
|
exports.datetime = datetime;
|
|
|
|
|
|
|
|
exports.rssLink = (proto, host, date, category, timezone="UTC") =>
|
|
|
|
`${proto}://${host}/mindflow#${category}-${datetime(date, formats.id_date, timezone)}`;
|
|
|
|
|