Skip to content

Commit

Permalink
songs done
Browse files Browse the repository at this point in the history
  • Loading branch information
Hendrixer committed Dec 14, 2021
1 parent 7ceb274 commit a9a13db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/songsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Box } from '@chakra-ui/layout'
import { Table, Thead, Td, Tr, Tbody, Th, IconButton } from '@chakra-ui/react'
import { BsFillPlayFill } from 'react-icons/bs'
import { AiOutlineClockCircle } from 'react-icons/ai'
import { formatDate, formatTime } from '../lib/formatters'

const SongTable = ({ songs }) => {
return (
Expand Down Expand Up @@ -41,8 +42,8 @@ const SongTable = ({ songs }) => {
>
<Td>{i + 1}</Td>
<Td>{song.name}</Td>
<Td>{song.createdAt.toString()}</Td>
<Td>{song.duration}</Td>
<Td>{formatDate(song.createdAt)}</Td>
<Td>{formatTime(song.duration)}</Td>
</Tr>
))}
</Tbody>
Expand Down
13 changes: 13 additions & 0 deletions lib/formatters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import formatDuration from 'format-duration'

export const formatTime = (timeInSeconds = 0) => {
return formatDuration(timeInSeconds * 1000)
}

export const formatDate = (date: Date) => {
return date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
})
}

0 comments on commit a9a13db

Please sign in to comment.