text: import "./comment.css";
  
  export default function Comment({comment}) {
  	return (
  		<div className="comment">
  			<div className="avatar">
  				<svg
  					version="1.1"
  					xmlns="http://www.w3.org/2000/svg"
  					width="45.532px"
  					height="45.532px"
  					viewBox="0 0 45.532 45.532"
  				>
  					<g>
  						<path
  							d="M22.766,0.001C10.194,0.001,0,10.193,0,22.766s10.193,22.765,22.766,22.765c12.574,0,22.766-10.192,22.766-22.765
  		S35.34,0.001,22.766,0.001z M22.766,6.808c4.16,0,7.531,3.372,7.531,7.53c0,4.159-3.371,7.53-7.531,7.53
  		c-4.158,0-7.529-3.371-7.529-7.53C15.237,10.18,18.608,6.808,22.766,6.808z M22.761,39.579c-4.149,0-7.949-1.511-10.88-4.012
  		c-0.714-0.609-1.126-1.502-1.126-2.439c0-4.217,3.413-7.592,7.631-7.592h8.762c4.219,0,7.619,3.375,7.619,7.592
  		c0,0.938-0.41,1.829-1.125,2.438C30.712,38.068,26.911,39.579,22.761,39.579z"
  						/>
  					</g>
  				</svg>
  			</div>
  			<div className="content">
  				<div className="name">{comment.createdBy.name}</div>
  				<div className="meta">{giveTimePassed(comment.createdAt)}</div>
  				<div className="text">{comment.content}</div>
  			</div>
  		</div>
  	);
  }
  
  function giveTimePassed(t){
    // time difference in millisec
    var timeDiff = new Date() - new Date(t);
  
    // seconds
    timeDiff /= 1000;
    timeDiff = Math.floor(timeDiff)
    if(timeDiff < 5){
      return "just now"
    }
    if(timeDiff < 60){
      return `${timeDiff} second${timeDiff===1?"":"s"} ago`;
    }
  
    // minutes
    timeDiff /= 60;
    timeDiff = Math.floor(timeDiff)
    if(timeDiff < 60){
      return `${timeDiff} minute${timeDiff===1?"":"s"} ago`;
    }
  
    // hours
    timeDiff /= 60;
    timeDiff = Math.floor(timeDiff)
    if(timeDiff < 24){
      return `${timeDiff} hour${timeDiff===1?"":"s"} ago`;
    }
  
    // days
    timeDiff /= 24;
    timeDiff = Math.floor(timeDiff)
    if(timeDiff < 30){
      return `${timeDiff} day${timeDiff===1?"":"s"} ago`;
    }
  
    // months
    timeDiff /= 30;
    timeDiff = Math.floor(timeDiff)
    if(timeDiff < 12){
      return `${timeDiff} month${timeDiff===1?"":"s"} ago`;
    }
  
    // years
    timeDiff /= 12;
    timeDiff = Math.floor(timeDiff)
    return `${timeDiff} year${timeDiff===1?"":"s"} ago`;
  }