35 lines
915 B
TypeScript
35 lines
915 B
TypeScript
|
"use strict";
|
||
|
const SITE_URL = "https://trendogate.com/";
|
||
|
const NUMBER_OF_DAYS = 100;
|
||
|
const USA_ID = 23424977;
|
||
|
// https://trendogate.com/placebydate/23424977/2015-04-01
|
||
|
|
||
|
// Topic | Date | Position
|
||
|
|
||
|
// SO: https://stackoverflow.com/questions/4345045/javascript-loop-between-date-ranges/14655646
|
||
|
const now: Date = new Date();
|
||
|
let tmp : Date = now;
|
||
|
let days: Array<Date> = [];
|
||
|
|
||
|
for (let i = 0; i < 100; i++) {
|
||
|
tmp = new Date(tmp.getDate() - 1);
|
||
|
days.push(tmp);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
function getNewDateURL(date: Date): String {
|
||
|
let year: Number = date.getFullYear();
|
||
|
let month: Number = date.getMonth();
|
||
|
let day: Number = date.getDay();
|
||
|
let monthFmt: String;
|
||
|
let dayFmt: String;
|
||
|
|
||
|
if (month < 10) monthFmt = `0${month}`;
|
||
|
else monthFmt = `${month}`;
|
||
|
|
||
|
if (day < 10) dayFmt = `0${day}`;
|
||
|
else dayFmt = `${day}`;
|
||
|
|
||
|
return `${SITE_URL}/placebydate/${USA_ID}/${year}-${monthFmt}-${dayFmt}`;
|
||
|
}
|