From 0adcb77c1224f58a3701ae0e9726b2b0e70fd7b8 Mon Sep 17 00:00:00 2001 From: paoda Date: Thu, 5 Mar 2020 11:30:20 -0400 Subject: [PATCH] Basic Utility Functions Written. --- .gitignore | 1 + .vscode/launch.json | 17 +++++++++++++++++ index.js | 0 index.ts | 35 +++++++++++++++++++++++++++++++++++ tsconfig.json | 9 +++++++++ 5 files changed, 62 insertions(+) create mode 100644 .vscode/launch.json delete mode 100644 index.js create mode 100644 index.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index 144585f..bf21eaf 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,4 @@ typings/ # FuseBox cache .fusebox/ +out/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..7211190 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Launch Program", + "program": "${workspaceFolder}/out/index.js", + "skipFiles": [ + "/**" + ] + } + ] +} \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index e69de29..0000000 diff --git a/index.ts b/index.ts new file mode 100644 index 0000000..9a1e2dd --- /dev/null +++ b/index.ts @@ -0,0 +1,35 @@ +"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 = []; + +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}`; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..7f3508a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "target": "ES5", + "module": "CommonJS", + "outDir": "out", + "sourceMap": true + }, + "compileOnSave": true +} \ No newline at end of file