From cb2bd2c868832c3c9412df113ccfc3d355701fb2 Mon Sep 17 00:00:00 2001 From: elPandaFriki Date: Sat, 25 Feb 2023 23:11:47 +0100 Subject: [PATCH] 3.0.6 --- package.json | 7 +++-- scripts/update_version.ts | 59 +++++++++++++++++++++++++++++++++++---- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 561596b1..593b9900 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "portfolio", - "version": "3.0.5", - "date": "2023-02-25 21:59", + "version": "3.0.6", + "date": "25 Feb 2023 22:08", "homepage": "https://elPandaFriki.github.io/portfolio", "private": true, "dependencies": { @@ -28,9 +28,10 @@ "typescript": "^4.9.5" }, "scripts": { + "fix_version": "npm run exec_update_version && prettier --loglevel silent --write -c package.json", "exec_update_version": "ts-node --project ./scripts/tsconfig.json scripts/update_version.ts", "exec_commit_version": "ts-node --project ./scripts/tsconfig.json scripts/commit_version.ts", - "update-version": "npm run exec_update_version && prettier --loglevel silent --write -c package.json && npm run exec_commit_version", + "update-version": "npm run fix_version && npm run exec_commit_version", "analyze": "source-map-explorer 'build/static/js/*.js'", "start": "react-scripts start", "build": "react-scripts build", diff --git a/scripts/update_version.ts b/scripts/update_version.ts index da589dac..cd93b009 100644 --- a/scripts/update_version.ts +++ b/scripts/update_version.ts @@ -13,14 +13,61 @@ function padStart(text: number | string, length: number, chars: string): string function getUniversalString(): string { const date = new Date(); const getDate = () => { - const yearString = `${date.getUTCFullYear()}`; - const monthString = `${padStart(date.getUTCMonth() + 1, 2, '0')}`; - const dayString = `${padStart(date.getUTCDate(), 2, '0')}`; - return `${yearString}-${monthString}-${dayString}`; + const year = date.getUTCFullYear(); + const month = date.getUTCMonth(); + const day = date.getUTCDate(); + const yearString = padStart(year, 4, '0'); + // const monthString = `${padStart(month + 1, 2, '0')}`; + const getMonthName = () => { + switch (month) { + case 0: { + return 'January'; + } + case 1: { + return 'February'; + } + case 2: { + return 'March'; + } + case 3: { + return 'April'; + } + case 4: { + return 'May'; + } + case 5: { + return 'June'; + } + case 6: { + return 'July'; + } + case 7: { + return 'August'; + } + case 8: { + return 'September'; + } + case 9: { + return 'October'; + } + case 10: { + return 'November'; + } + case 11: { + return 'December'; + } + } + return ''; + }; + const monthString = getMonthName().substring(0, 3); + const dayString = padStart(day, 2, '0'); + return `${dayString} ${monthString} ${yearString}`; }; const getTime = () => { - const hourString = `${padStart(date.getUTCHours(), 2, '0')}`; - const minutesString = `${padStart(date.getUTCMinutes(), 2, '0')}`; + const hours = date.getUTCHours(); + const minutes = date.getUTCMinutes(); + const hourString = padStart(hours, 2, '0'); + const minutesString = padStart(minutes, 2, '0'); return `${hourString}:${minutesString}`; }; return `${getDate()} ${getTime()}`;