diff --git a/src/components/projects/ListProjects.jsx b/src/components/projects/ListProjects.jsx index 05b6ac9..c60f53f 100644 --- a/src/components/projects/ListProjects.jsx +++ b/src/components/projects/ListProjects.jsx @@ -9,6 +9,7 @@ import Loading from '../base/Loading' import { convertTokenAmountUsd, percentToGoal } from '../../utils/prices' import { getTokenLabel } from '../../utils/currencies' import { getAmountFromWei } from '../../utils/pledges' +import { getDateFromTimestamp } from '../../utils/dates' import { FundingContext } from '../../context' function FundingDetail({ classes, pledgesInfos, goal, goalToken }) { @@ -54,14 +55,16 @@ function ListProjects({ classes }) { Contact person Date created {profiles.map((profile, i) => { - const { id, projectInfo: { title, subtitle, goal, goalToken, creator }, pledgesInfos } = profile + const { id, projectInfo: { title, subtitle, goal, goalToken, creator, creationTime }, pledgesInfos } = profile console.log({i, profile}) + const creationDate = getDateFromTimestamp(creationTime) return ( {title} {subtitle} {creator} + {creationDate} ) })} diff --git a/src/components/projects/queries.js b/src/components/projects/queries.js index 8fdfc0a..ae6cd17 100644 --- a/src/components/projects/queries.js +++ b/src/components/projects/queries.js @@ -45,6 +45,7 @@ query Projects($type: String! = "PROJECT"){ type url profileId + creationTime projectInfo { id title diff --git a/src/utils/dates.js b/src/utils/dates.js index 12a6e5e..a1714eb 100644 --- a/src/utils/dates.js +++ b/src/utils/dates.js @@ -22,7 +22,12 @@ export function timeSinceBlock(date=false, interval) { export function getDateCreated(daysSince) { const d = new Date(); d.setDate(d.getDate() - daysSince); - return `${d.getMonth()}/${d.getDate()}/${d.getFullYear()}` + return `${d.getMonth()+1}/${d.getDate()}/${d.getFullYear()}` +} + +export function getDateFromTimestamp(ts) { + const daysSince = timeSinceBlock(ts, 'days') + return getDateCreated(daysSince) } export const convertToHours = seconds => Number(seconds) / 60 / 60