From ba2cec1c3736cf0fc43db23eb7baa9848f6fb513 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 29 Apr 2021 21:39:32 +0200 Subject: sort by date --- index.ts | 9 +++++++++ makefile | 3 +++ 2 files changed, 12 insertions(+) diff --git a/index.ts b/index.ts index 07013ce..8048c6a 100644 --- a/index.ts +++ b/index.ts @@ -43,6 +43,15 @@ downloads.each(async (i, el) => { } versions.push(version); if( i == downloadCount - 1 ) { + versions = versions.sort((a, b) => { + var dateFormat = /(\d{2})\.(\d{2})\.(\d{4})/; + var aR = a.date.match(dateFormat); + var bR = b.date.match(dateFormat); + return ( new Date(Number(bR[3]), Number(bR[2]) - 1, Number(bR[1])).getTime() ) - + ( new Date(Number(aR[3]), Number(aR[2]) - 1, Number(aR[1])).getTime() ); + }); + console.log(versions) + var minecraftVersions = {}; var latest: types.OptifineVersion; var latestPre: types.OptifineVersion; diff --git a/makefile b/makefile index ccfe6bd..3446912 100644 --- a/makefile +++ b/makefile @@ -2,3 +2,6 @@ all: mkdir out node . +clean: + rm -r out + -- cgit v1.2.3