Skip to content

Commit

Permalink
Merge pull request #109 from awest25/dateFormat
Browse files Browse the repository at this point in the history
Date format
  • Loading branch information
Fredenck authored Apr 6, 2024
2 parents 5957b3f + cd9c293 commit ba985fb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/components/FilterList.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const FilterList = ({ pointsData, filterList, setFilterList, showPercent, showCo
return pointsData.filter(point => point[key] === value).length;
};

const countFilteredPointsTotal = (key, value) => {
const countFilteredPointsTotal = (key) => {
return pointsData.reduce((total, point) => {
// Check if the value attribute is not an empty string
if (point[key] !== '') {
Expand Down
13 changes: 9 additions & 4 deletions app/components/MatchTiles.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from "react";
import React, { useState } from "react";
import styles from "../styles/MatchTiles.module.css";

const extractSetScore = (setObject) => {
Expand Down Expand Up @@ -46,27 +46,32 @@ const isWomensTeam = (match) => {

//Retrieve Match Date
const extractDateFromString = (inputString) => {
const regex = /\b(\d{1,2}\/\d{1,2}\/\d{2,4})\b/g;
const regexSlash = /\b(\d{1,2}\/\d{1,2}\/\d{2,4})\b/g;
const regexDash = /\b(\d{1,2}-\d{1,2}-?\d{0,4})\b/g;
const regex = new RegExp(`${regexSlash.source}|${regexDash.source}`, "g");
const matches = inputString.match(regex);
if (matches) {
// Assuming there might be multiple date patterns in the string, return an array of matches
const firstMatch = matches[0]; // Assuming you want to pick the first matched date
const dateParts = firstMatch.split("/");
const dateParts = firstMatch.includes('/') ? firstMatch.split('/') : firstMatch.split('-');
const month = parseInt(dateParts[0]);
const day = parseInt(dateParts[1]);
const year = parseInt(dateParts[2]);
console.log(month, day, year)

// Create a new Date object with the extracted components
const dateObject = new Date(year + 2000, month - 1, day);

const formattedDate = dateObject.toLocaleDateString("en-US", {
month: "long",
day: "numeric",
year: "numeric",
});
console.log(formattedDate)

return formattedDate;
} else {
console.log(inputString.match(regexDash))
console.log('unmatched')
return null;
}
};
Expand Down
2 changes: 1 addition & 1 deletion app/services/getLogos.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { db, storage } from '../services/initializeFirebase.js'; // Ensure storage is exported from initializeFirebase.js
import { storage } from '../services/initializeFirebase.js'; // Ensure storage is exported from initializeFirebase.js
import { ref, listAll, getDownloadURL } from "firebase/storage"; // Import storage functions

const logosRef = ref(storage, 'logos');
Expand Down

0 comments on commit ba985fb

Please sign in to comment.