Archived
1
0

Added correctly formatted date

This commit is contained in:
2020-01-09 22:31:46 +01:00
parent ad4c8d4999
commit bbcf642e89
3 changed files with 13 additions and 2 deletions

5
package-lock.json generated
View File

@@ -3624,6 +3624,11 @@
"resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.5.tgz",
"integrity": "sha512-CBCRqFnpu715iPmw1KrdOrzRqbdFwQTwAWyyyYS42+iAgHCuXZ+/TdMgQkUENPomxEz9z1BEzuQU2Xw0kUuAgA=="
},
"dateformat": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz",
"integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q=="
},
"debug": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",

View File

@@ -14,6 +14,7 @@
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
},
"dependencies": {
"dateformat": "^3.0.3",
"gatsby": "^2.18.12",
"react": "^16.12.0",
"react-dom": "^16.12.0"

View File

@@ -1,5 +1,6 @@
import React from "react"
import Header from "../components/header"
var dateFormat = require("dateformat")
const GIT_NAME = "creyD"
const GIT_REPO = "urban_website"
@@ -8,6 +9,10 @@ const GIT_URL =
const GIT_COMMIT_URL =
"https://github.com/" + GIT_NAME + "/" + GIT_REPO + "/commit/"
// Format the date provided by the GitHub API
function getDateFormatted(unformated_date) {
return dateFormat(unformated_date, "dd.mm.yyyy")
}
// Adds Git History to the site
function addGitHistory(data) {
@@ -17,8 +22,8 @@ function addGitHistory(data) {
var url = GIT_COMMIT_URL + data[push]["payload"]["commits"][commit].sha
new_li.innerHTML =
data[push]["payload"]["commits"][commit].author.name +
" committed " +
getDate(data[push].created_at) +
" committed on " +
getDateFormatted(data[push].created_at) +
": " +
data[push]["payload"]["commits"][commit].message +
" <a href=" +