import * as React from "react"
import * as styles from "./index.module.scss"

interface IProps {
  name: string
  date: string
}

const formatDate = (date: string) => {
  const newDate = new Date(date)
  return `${newDate.getFullYear()}年${
    newDate.getMonth() + 1
  }月${newDate.getDate()}日`
}

const AuthorAndDate: React.FC<IProps> = ({ name, date }) => (
  <div className={styles.authorAndDate}>
    <div className="is-flex is-justify-content-space-between">
      <span>作者：{name}</span>
      <span>时间：{formatDate(date)}</span>
    </div>
    <div className={styles.line} />
  </div>
)

export default AuthorAndDate
